@unifold/connect-react-native 0.1.34 → 0.1.35-beta-001

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import*as Dn from'react';import {createContext,useContext,useRef,useEffect,useState,useMemo,useCallback,useId,Fragment as Fragment$1}from'react';import {StyleSheet,Platform,useWindowDimensions,Animated,Modal,StatusBar,TouchableWithoutFeedback,View,TouchableOpacity,Text,ActivityIndicator,ScrollView,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Easing,Dimensions,FlatList,Image,Linking,Clipboard}from'react-native';import Bt,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Polyline,Line,SvgXml,SvgUri}from'react-native-svg';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Sc from'@react-native-async-storage/async-storage';import Ch from'expo-constants';import eg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Ad=e=>{throw TypeError(e)};var Mm=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var zl=(e,t,r)=>t.has(e)||Ad("Cannot "+r);var p=(e,t,r)=>(zl(e,t,"read from private field"),r?r.call(e):t.get(e)),Y=(e,t,r)=>t.has(e)?Ad("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),B=(e,t,r,o)=>(zl(e,t,"write to private field"),t.set(e,r),r),Fe=(e,t,r)=>(zl(e,t,"access private method"),r);var ys=(e,t,r,o)=>({set _(n){B(e,t,n);},get _(){return p(e,t,o)}});var Ul={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},dark:{background:"#2D2C2F",card:"#3A393C",cardHover:"#48474A",foreground:"#F8FAFC",foregroundMuted:"#94A3B8",foregroundSubtle:"#64748B",border:"#38383A",borderSecondary:"#48484A",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"rgba(34, 197, 94, 0.1)",warning:"#F59E0B",warningBackground:"rgba(245, 158, 11, 0.1)",error:"#EF4444",errorBackground:"rgba(239, 68, 68, 0.1)",overlay:"rgba(0, 0, 0, 0.7)"}},Hl=Ul;function da(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function bs(e,t,r){let o=r?t?.[r]:void 0,n=(l,h,S)=>{let g=o?.[l]?.[h];if(g!==void 0)return g;let y=t?.[l]?.[h];return y!==void 0?y:S},s={backgroundColor:n("card","backgroundColor",e.card),titleColor:n("card","titleColor",e.foreground),subtitleColor:n("card","subtitleColor",e.foregroundMuted),labelColor:n("card","labelColor",e.foregroundMuted),headerColor:n("card","headerColor",e.foregroundMuted),labelRightColor:n("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:n("card","labelHighlightRightColor",e.warning),textRightColor:n("card","textRightColor",e.foreground),subtextRightColor:n("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:n("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:n("card","rowRightLabel",e.foreground),iconColor:n("card","iconColor",e.primary),iconBackgroundColor:n("card","iconBackgroundColor",e.primary+"26"),actionColor:n("card","actionColor",e.foregroundMuted),actionIcon:n("card","actionIcon",e.foregroundMuted),descriptionColor:n("card","descriptionColor",e.foregroundMuted),borderRadius:n("card","borderRadius",12),borderWidth:n("card","borderWidth",0),borderColor:n("card","borderColor",e.border),shadowColor:n("card","shadowColor","#000"),shadowOffset:n("card","shadowOffset",{width:0,height:-4}),shadowOpacity:n("card","shadowOpacity",0),shadowRadius:n("card","shadowRadius",12),elevation:n("card","elevation",0),iconContainerBorderRadius:n("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},i=(o?.depositMenu??t?.depositMenu)?.card,a=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,c=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,u=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:s,input:{backgroundColor:n("input","backgroundColor",n("search","backgroundColor",e.card)),textColor:n("input","textColor",n("search","inputColor",e.foreground)),placeholderColor:n("input","placeholderColor",n("search","placeholderColor",e.foregroundMuted)),borderColor:n("input","borderColor",e.border),borderRadius:n("input","borderRadius",n("search","borderRadius",8)),borderWidth:n("input","borderWidth",1)},button:{primaryBackground:n("button","primaryBackground",e.primary),primaryText:n("button","primaryText",e.primaryForeground),secondaryBackground:n("button","secondaryBackground",e.card),secondaryText:n("button","secondaryText",e.foreground),borderRadius:n("button","borderRadius",12),borderWidth:n("button","borderWidth",0),borderColor:n("button","borderColor",e.border)},container:{titleColor:n("container","titleColor",e.foreground),subtitleColor:n("container","subtitleColor",e.foregroundMuted),actionColor:n("container","actionColor",e.foregroundMuted),actionTitle:n("container","actionTitle",e.foregroundMuted),buttonColor:n("container","buttonColor",e.primary),buttonTitleColor:n("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:n("container","iconBackgroundColor",e.success),iconColor:n("container","iconColor",e.foreground)},search:{backgroundColor:n("search","backgroundColor",e.card),inputColor:n("search","inputColor",e.foreground),placeholderColor:n("search","placeholderColor",e.foregroundMuted),borderRadius:n("search","borderRadius",8)},list:{titleSectionColor:n("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:n("list","rowBorderRadius",12)},badge:{borderRadius:n("badge","borderRadius",8)},sheet:{shadowColor:n("sheet","shadowColor","#000"),shadowOffset:n("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:n("sheet","shadowOpacity",.1),shadowRadius:n("sheet","shadowRadius",12),elevation:n("sheet","elevation",16)},depositMenu:{card:da(s,i)},transferCrypto:{depositAddress:{card:da(s,a)}},depositCard:{quoteProvider:{card:da(s,c)}},depositTracker:{executionRow:{card:da(s,u)}}}}function Nl(e,t,r){let n={...Ul[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var jl=createContext(null);function V(){let e=useContext(jl);if(!e){let t=Hl.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:bs(t,void 0,"dark"),isDark:true}}return e}function yt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:s,gradientTo:i}){let{colors:a}=V(),c=s??a.warning,u=i??"#FBBF24",l=useRef(new Animated.Value(0)).current,h=useId(),S=useMemo(()=>`circularProgressGrad_${h.replace(/[^a-zA-Z0-9_-]/g,"")}`,[h]),g=(e-t)/2,y=2*Math.PI*g,C=e/2,d=o??Math.max(0,Math.round(e-t*2-8)),w=(e-d)/2;useEffect(()=>{let m=Animated.loop(Animated.timing(l,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return m.start(),()=>m.stop()},[l]);let b=l.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},n],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:b}]},children:jsxs(Bt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:S,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:c}),jsx(Stop,{offset:"100%",stopColor:u})]})}),jsx(Circle,{cx:C,cy:C,r:g,stroke:`url(#${S})`,strokeWidth:t,fill:"none",strokeDasharray:`${y*.75} ${y*.25}`,strokeLinecap:"round",rotation:-90,origin:`${C}, ${C}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:w+1.5,left:w,width:d,height:d},children:r}):null]})}function Ql({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function vi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function yo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Cs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function nt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Vr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Pi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"15 18 9 12 15 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ot({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function jn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function $e({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function ws({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12.01",y2:"16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Kl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"2",x2:"12",y2:"6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"18",x2:"12",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"12",x2:"6",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"18",y1:"12",x2:"22",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function bo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function mn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,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:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function pa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Co({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function ma({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:r,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:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function fn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function fa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ks({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ud({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M11 14h10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 10l4 4-4 4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Fi({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:s,components:i}){let a=useColorScheme(),c=useMemo(()=>t==="auto"?a==="dark"?"dark":"light":t,[t,a]),u=useMemo(()=>{let g=o?.[c];return Nl(c,g,r)},[c,o,r]),l=useMemo(()=>bs(u,i,c),[u,i,c]),h=useMemo(()=>s?{regular:s.regular||n,medium:s.medium||n,semibold:s.semibold||n,bold:s.bold||n}:n?{regular:n,medium:n,semibold:n,bold:n}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[n,s]),S=useMemo(()=>({mode:c,colors:u,fonts:h,components:l,isDark:c==="dark"}),[c,u,h,l]);return jsx(jl.Provider,{value:S,children:e})}function Ze({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,showHandle:n=true,heightPercent:s,noPadding:i=false,borderTopLeftRadius:a=24,borderTopRightRadius:c=24}){let{colors:u,components:l}=V(),{height:h}=useWindowDimensions(),S=useRef(h);S.current=h;let g=useRef(new Animated.Value(h)).current,y=useRef(new Animated.Value(0)).current,C=s!=null&&s>=1;useEffect(()=>{let w=S.current;e?(g.setValue(w),y.setValue(0),Animated.parallel([Animated.spring(g,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(y,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(g,{toValue:w,useNativeDriver:true,tension:65,friction:11}),Animated.timing(y,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,g,y]);let d=()=>{o&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(GestureHandlerRootView,{style:[hn.container,Platform.OS==="android"&&{paddingTop:StatusBar.currentHeight}],children:[jsx(Animated.View,{style:[hn.backdrop,{backgroundColor:"#000000",opacity:y}],pointerEvents:"none"}),!C&&jsx(TouchableWithoutFeedback,{onPress:d,children:jsx(View,{style:hn.backdropTouchArea})}),jsxs(Animated.View,{style:[hn.sheet,{maxHeight:h*.9,backgroundColor:u.background,borderTopLeftRadius:a,borderTopRightRadius:c,overflow:"hidden",transform:[{translateY:g}],shadowColor:l.sheet.shadowColor,shadowOffset:l.sheet.shadowOffset,shadowOpacity:l.sheet.shadowOpacity,shadowRadius:l.sheet.shadowRadius,elevation:l.sheet.elevation,...s&&{height:h*s,maxHeight:h*s},...C&&{paddingBottom:0},...i&&{paddingBottom:0}}],children:[n&&jsx(View,{style:hn.handleContainer,children:jsx(View,{style:[hn.handle,{backgroundColor:u.border}]})}),jsx(View,{style:[hn.content,s&&hn.contentFlex],children:r})]})]})})}var hn=StyleSheet.create({container:{flex:1},backdrop:{...StyleSheet.absoluteFillObject},backdropTouchArea:{flex:1},sheet:{paddingBottom:Platform.OS==="ios"?34:24},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});var sf="https://api.unifold.io",Yl="__UnifoldDevApiBaseUrl__",wr="pk_test_123",ga={};function af(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[Yl];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Qt(){return af()??sf}function ya(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.'),wr=e.publishableKey;}e.defaultConfig&&(ga=e.defaultConfig);}function $d(e){if(typeof __DEV__>"u"||!__DEV__){console.warn("[Unifold] setDevApiUrl() is only available in development mode");return}if(typeof globalThis>"u")return;let t=e.trim();t.length>0?globalThis[Yl]=t:delete globalThis[Yl];}function Ts(){return Qt()}function ba(){return wr}function Lr(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 Nt(e){let t=e.startsWith("/")?e:`/${e}`;return `${Qt()}/api/public${t}`}function J(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,Qt()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${Qt()}${e}`:`${Qt()}/api/public${e}`:""}async function Uo(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||ga.recipientAddress;if(!r)throw new Error("[Unifold] recipient_address is required for createDepositAddress. Pass recipientAddress in your beginDeposit() config.");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||ga.destinationChainId||"8453",destination_token_address:e?.destination_token_address||ga.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||wr;Lr(n);let s=await fetch(`${Qt()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!s.ok)throw new Error(`Failed to create deposit address: ${s.statusText}`);return await s.json()}function Ho(e,t){return e.find(r=>r.chain_type===t)}async function No(e,t,r){let o=t||wr;Lr(o);let n=await fetch(`${Qt()}/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,...r&&{action_type:r}})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}async function Ca(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/direct_executions/poll`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify({deposit_wallet_id:e})});if(!o.ok)throw new Error(`Failed to poll executions: ${o.statusText}`);return o.json()}function ge(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let r=e.icon_urls.find(o=>o.format===t);return r?r.url:e.icon_url}async function qn(e,t){let r=e||wr;Lr(r);let o=`${Qt()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let s=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});o=`${o}?${s.toString()}`;}let n=await fetch(o,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch supported deposit tokens: ${n.statusText}`);return n.json()}async function Jl(e,t){let r=t||wr;Lr(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${Qt()}/v1/public/tokens/token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch token metadata: ${n.statusText}`);return n.json()}function wa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function Zl(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to fetch onramp quotes: ${o.statusText}`);return o.json()}async function Xl(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to create onramp session: ${o.statusText}`);return o.json()}async function ec(e,t){let r=t||wr;Lr(r);let o=new URLSearchParams;e.country_code&&o.append("country_code",e.country_code),e.subdivision_code&&o.append("subdivision_code",e.subdivision_code),o.append("token_address",e.token_address),o.append("chain_id",e.chain_id),o.append("chain_type",e.chain_type);let n=await fetch(`${Qt()}/v1/public/onramps/default_token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch default onramp token: ${n.statusText}`);return n.json()}async function tc(e){let t=e||wr;Lr(t);let r=await fetch(`${Qt()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch fiat currencies: ${r.statusText}`);return r.json()}function Di(e,t="png"){if(!e||e.length===0)return;let r=e.find(o=>o.format===t);return r?r.url:e[0]?.url}async function xs(e){let t=e||wr;Lr(t);let r=await fetch(`${Qt()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch project config: ${r.statusText}`);return r.json()}async function rc(){let e=await fetch(`${Qt()}/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 ka(e,t,r){let o=e.find(s=>s.chain_id===r);if(o)return o.chain_name;let n=e.find(s=>s.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function _s(){let e=await fetch(`${Qt()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}async function Sa(e){let t=e||wr;Lr(t);let r=await fetch(`${Qt()}/v1/public/tokens/supported_destination_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch supported destination tokens: ${r.statusText}`);return r.json()}async function oc(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/addresses/verify`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":r},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to verify address: ${o.statusText}`);return o.json()}async function nc(e,t){return Ca(e.deposit_wallet_id,t)}async function Ta(e,t,r,o,n){let s=n||wr;Lr(s);let i=await fetch(`${Qt()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":s},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!i.ok)throw new Error(`Failed to fetch address balance: ${i.statusText}`);return i.json()}function Qd({size:e=28}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxs(G,{fillRule:"evenodd",children:[jsx(Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsx(Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function Gd({size:e=28}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#eth_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsx(Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsx(Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsx(Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsx(Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsx(Defs,{children:jsx(ClipPath,{id:"eth_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function Zd({size:e=28}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#btc_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsx(Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsx(Defs,{children:jsx(ClipPath,{id:"btc_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function Xd({size:e=28}){return jsxs(Bt,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxs(Defs,{children:[jsxs(LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsx(Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxs(G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsx(Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsx(Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsx(Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function eu({size:e=28}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxs(G,{children:[jsx(Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsx(Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var xa=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:Qd},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:Gd},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:Zd},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:Xd},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:eu}];function tu(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function _a(e,t){let r=parseFloat(e);if(isNaN(r))return e;let o=t.toLowerCase(),n=["eth","btc"].includes(o)?4:2;return r.toFixed(n)}function Ra(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=xa.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=xa.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Jt({onPress:e,title:t,variant:r="close"}){let{components:o,fonts:n}=V(),s=r==="back",i=s?jsx(Pi,{size:22,color:o.header.buttonColor,strokeWidth:2.5}):jsx(nt,{size:20,color:o.header.buttonColor,strokeWidth:2}),a=jsx(TouchableOpacity,{style:gn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:s?"Back":"Close",children:i});return t?jsxs(View,{style:gn.headerWithTitle,children:[s?a:jsx(View,{style:gn.headerSide}),jsx(Text,{style:[gn.headerTitleText,{color:o.header.titleColor},...n.bold?[{fontFamily:n.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),s?jsx(View,{style:gn.headerSide}):a]}):jsxs(View,{style:s?gn.headerWithTitle:gn.header,children:[s?a:jsx(View,{style:gn.headerSpacer}),!s&&a]})}var Ia={paddingTop:60,paddingBottom:16},gn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ia},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ia},headerSpacer:{flex:1},headerSide:{width:28},headerTitleText:{flex:1,textAlign:"center",fontSize:17},closeBtn:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"}});function kr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=V();return e?jsx(Text,{style:[ru.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[ru.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var ru=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function lo({quote:e,label:t,value:r,last:o,hideDivider:n}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsx(Text,{style:[e.rowValue],children:r})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}function dc({quote:e,label:t,address:r,last:o,hideDivider:n}){let[s,i]=useState(false),{colors:a,components:c}=V(),u=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},l=tu(r);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:l}),jsx(TouchableOpacity,{onPress:u,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:s?jsx($e,{size:14,color:a.success,strokeWidth:2.5}):jsx(jn,{size:14,color:c.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var va={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function iu({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=V(),s=e.toLowerCase(),i=va[s]??n.primary,a=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:i,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:a,height:a,borderRadius:a/2,borderWidth:2,borderColor:n.background}}):null]})}function Pa({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:s}){let{colors:i,components:a,fonts:c}=V(),u=Nt(`/icons/currencies/png/${e.toLowerCase()}.png`),l=Ra(r);return jsxs(View,{style:[Gr.diagram,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor},s],children:[jsxs(View,{style:Gr.step,children:[jsx(Image,{source:{uri:u},style:Gr.iconImage}),jsx(Text,{style:[Gr.label,{color:a.card.subtitleColor,fontFamily:c.regular}],children:"You bought"}),jsx(Text,{style:[Gr.value,{color:a.card.titleColor,fontFamily:c.medium}],children:e.toUpperCase()})]}),jsx(Vr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:Gr.step,children:[jsxs(View,{style:Gr.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:Gr.tokenIcon}):jsx(View,{style:[Gr.tokenIcon,{backgroundColor:va[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[Gr.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[Gr.label,{color:a.card.subtitleColor,fontFamily:c.regular}],children:"You receive"}),jsxs(Text,{style:[Gr.value,{color:a.card.titleColor,fontFamily:c.medium}],children:[t.toUpperCase()," ",l]})]})]})}var Gr=StyleSheet.create({diagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",paddingVertical:20,paddingHorizontal:24,width:"100%"},step:{alignItems:"center"},iconImage:{width:24,height:24,borderRadius:12,marginBottom:4},iconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},tokenIcon:{width:24,height:24,borderRadius:12},networkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},label:{fontSize:10},value:{fontSize:14,fontWeight:"500",paddingTop:4}});function Bi(){let{colors:e,fonts:t,components:r}=V(),o=r.input,n=r.button,s=r.container,i=r.card,a=r.header;return useMemo(()=>{let c=i.borderRadius,u={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:48},content:{flex:1,paddingTop:16},title:{fontSize:28,color:a.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:e.foregroundSubtle,marginBottom:8,textTransform:"uppercase",letterSpacing:.5,...t.semibold?{fontFamily:t.semibold}:{}},input:{backgroundColor:o.backgroundColor,borderRadius:o.borderRadius,padding:16,fontSize:17,color:o.textColor,borderWidth:o.borderWidth,borderColor:o.borderColor,...t.regular?{fontFamily:t.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...t.regular?{fontFamily:t.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(c,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:s.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:s.buttonTitleColor,fontSize:17,...t.bold?{fontFamily:t.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...t.medium?{fontFamily:t.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},l={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...t.medium?{fontFamily:t.medium}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor},quickPillText:{fontSize:14,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},numpad:{gap:4,marginBottom:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...t.regular?{fontFamily:t.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...t.regular?{fontFamily:t.regular}:{}},paymentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,borderRadius:999,backgroundColor:"transparent",alignSelf:"flex-start",marginBottom:12},paymentRowHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:16,borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor,alignSelf:"center"},paymentLeft:{flexDirection:"row",alignItems:"center",gap:6},applePayIcon:{fontSize:20,color:e.foreground},paymentLabel:{fontSize:15,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},paymentHint:{fontSize:13,color:e.foregroundMuted,marginLeft:12,...t.regular?{fontFamily:t.regular}:{}},inlineError:{fontSize:13,color:e.error,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},inlineStatus:{fontSize:13,color:e.foregroundMuted,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},sheetContent:{flex:1,paddingHorizontal:24,paddingTop:20,paddingBottom:32,gap:12},sheetHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:4},sheetBackBtn:{width:32,height:32,borderRadius:16,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},sheetCloseBtn:{width:28,height:28,borderRadius:14,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitle:{fontSize:18,color:e.foreground,...t.bold?{fontFamily:t.bold}:{}},sheetOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(c,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border},sheetOptionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:12},sheetOptionIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},sheetOptionLabel:{fontSize:16,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},sheetOptionHint:{fontSize:13,color:e.foregroundMuted,marginTop:2,...t.regular?{fontFamily:t.regular}:{}},sheetLoading:{alignItems:"center",paddingVertical:32,gap:12},sheetStatusText:{fontSize:15,color:e.foregroundMuted,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},sheetError:{flex:1,justifyContent:"center",paddingVertical:20},sheetErrorText:{fontSize:14,color:e.error,textAlign:"center",lineHeight:20,...t.regular?{fontFamily:t.regular}:{}},addPaymentBtn:{marginTop:12,paddingVertical:14,borderRadius:Math.min(c,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},h={heroBox:{backgroundColor:i.backgroundColor,borderRadius:c,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:i.borderWidth,borderColor:i.borderColor,gap:4},heroLabel:{fontSize:12,color:e.foregroundSubtle,letterSpacing:.5,textTransform:"uppercase",...t.semibold?{fontFamily:t.semibold}:{}},heroAmount:{fontSize:48,color:e.foreground,letterSpacing:-1,...t.bold?{fontFamily:t.bold}:{}},heroCurrency:{fontSize:22,color:e.primary,...t.medium?{fontFamily:t.medium}:{}},heroNetwork:{fontSize:15,color:e.foregroundSubtle,marginTop:2,...t.medium?{fontFamily:t.medium}:{}},card:{backgroundColor:i.backgroundColor,borderRadius:c,borderWidth:i.borderWidth,borderColor:i.borderColor,overflow:"hidden",marginBottom:12,marginTop:16},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},rowRight:{flex:1,minWidth:0,flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:8},rowDivider:{height:1,marginHorizontal:16,backgroundColor:e.border},rowLabel:{fontSize:14,color:i.rowLeftLabel,...t.regular?{fontFamily:t.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:i.rowRightLabel,...t.medium?{fontFamily:t.medium}:{}}},S=Math.max(16,Math.min(c,22)),g={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:S,borderTopRightRadius:S,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:S,borderBottomRightRadius:S,borderTopLeftRadius:10,borderTopRightRadius:10,marginTop:16},swapConnectorWrap:{alignSelf:"center",zIndex:3,marginTop:-24,marginBottom:-32},swapConnectorCircle:{width:48,height:48,borderRadius:24,backgroundColor:e.primary,alignItems:"center",justifyContent:"center",borderWidth:4,borderColor:e.background},swapRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginTop:8,gap:12},swapLeftCol:{flex:1,minWidth:0},swapSpendAmount:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceivePrimary:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceiveSub:{fontSize:13,color:e.foregroundMuted,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},swapPill:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:10,paddingHorizontal:14,borderRadius:999,backgroundColor:e.cardHover,borderWidth:i.borderWidth,borderColor:e.border},swapPillText:{fontSize:16,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},payHint:{fontSize:15,color:e.foregroundMuted,textAlign:"center",marginBottom:18,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},summaryLabel:{fontSize:12,color:e.foregroundSubtle,textTransform:"uppercase",letterSpacing:.3,...t.semibold?{fontFamily:t.semibold}:{}},applePayBtn:{backgroundColor:n.secondaryBackground,borderRadius:n.borderRadius,borderWidth:n.borderWidth>0?n.borderWidth:1,borderColor:n.borderWidth>0?n.borderColor:e.border,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:n.secondaryText,fontSize:17,...t.bold?{fontFamily:t.bold}:{}}},y={input:{fontSize:14,...t.regular?{fontFamily:t.regular}:{}},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(c,14),borderWidth:i.borderWidth,borderColor:e.border,backgroundColor:e.card},rowSelected:{borderColor:e.primary,backgroundColor:e.successBackground},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:e.foregroundMuted,...t.medium?{fontFamily:t.medium}:{}},rowTextSelected:{color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:e.primary,alignItems:"center",justifyContent:"center"}},C={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:e.successBackground,borderWidth:2,borderColor:e.success,alignItems:"center",justifyContent:"center",marginBottom:28},heading:{fontSize:28,color:a.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:u,quote:h,pm:g,wallet:y,flow:C,amount:l}},[e,t,o,n,s,i,a])}function Lf({size:e=24}){let t=e,r=e*(471/750);return jsxs(Bt,{width:t,height:r,viewBox:"0 0 750 471",children:[jsx(Rect,{width:"750",height:"471",rx:"40",fill:"#1A1F71"}),jsx(Path,{fill:"#FFFFFF",d:"M278.198,334.228l33.36-195.763h53.358l-33.384,195.763H278.198z"}),jsx(Path,{fill:"#FFFFFF",d:"M524.307,142.687c-10.57-3.966-27.135-8.222-47.822-8.222c-52.725,0-89.863,26.551-90.18,64.604c-0.297,28.129,26.514,43.821,46.754,53.185c20.77,9.597,27.752,15.716,27.652,24.283c-0.133,13.123-16.586,19.116-31.924,19.116c-21.355,0-32.701-2.967-50.225-10.274l-6.877-3.112l-7.488,43.823c12.463,5.466,35.508,10.199,59.438,10.445c56.09,0,92.502-26.248,92.916-66.884c0.199-22.27-14.016-39.216-44.801-53.188c-18.65-9.056-30.072-15.099-29.951-24.269c0-8.137,9.668-16.838,30.559-16.838c17.447-0.271,30.088,3.534,39.936,7.5l4.781,2.259L524.307,142.687"}),jsx(Path,{fill:"#FFFFFF",d:"M661.615,138.464h-41.23c-12.773,0-22.332,3.486-27.941,16.234l-79.244,179.402h56.031c0,0,9.16-24.121,11.232-29.418c6.123,0,60.555,0.084,68.336,0.084c1.596,6.854,6.492,29.334,6.492,29.334h49.512L661.615,138.464z M596.198,264.872c4.414-11.279,21.26-54.724,21.26-54.724c-0.314,0.521,4.381-11.334,7.074-18.684l3.607,16.878c0,0,10.217,46.729,12.352,56.527h-44.293V264.872z"}),jsx(Path,{fill:"#FFFFFF",d:"M45.879,138.465l-0.682,4.073c21.093,5.106,39.932,12.496,56.426,21.689l47.346,169.688h56.455l83.004-195.45h-56.526l-52.238,133.496l-5.564-27.131c-0.261-0.838-0.544-1.678-0.834-2.52L156.106,154.992c-3.229-12.396-12.597-16.095-24.186-16.528H45.879z"})]})}function Bf({size:e=24}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 24 24",children:jsxs(G,{fill:"none",fillRule:"evenodd",children:[jsx(Circle,{cx:"7",cy:"12",r:"7",fill:"#EA001B"}),jsx(Circle,{cx:"17",cy:"12",r:"7",fill:"#FFA200",fillOpacity:.8})]})})}function Wf({size:e=24}){return jsx(Bt,{width:e,height:e,viewBox:"0 0 1152 1152",children:jsxs(G,{transform:"matrix(1.3333333,0,0,-1.3333333,0,1152)",children:[jsx(Path,{fill:"#006FCF",d:"M 0,0 H 863.998 V 864 H 0 Z"}),jsx(G,{transform:"translate(312.9867,136.7145)",children:jsx(Path,{fill:"#FFFFFF",d:"m 0,0 341.634,-0.725 53.654,59.858 54.038,-59.632 h 101.685 v 87.332 l -63.687,68.682 63.687,68.059 V 309.09 L 0,309.585 Z"})}),jsx(G,{transform:"translate(349.7917,170.655)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"m 0,0 v 241.575 h 204.832 v -55.65 H 66.318 V 148.15 H 201.529 V 93.423 H 66.318 V 56.319 H 204.832 V 10e-4 Z"})}),jsx(G,{transform:"translate(780.0408,412.227)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 -69.456,-76.568 -138.713,0 h -87.729 l 113.343,-120.647 -113.341,-120.925 h 85.343 l 69.764,77.335 70.487,-77.335 h 84.803 v 3.43 L -26.971,-120.647 83.957,-1.903 V 0 Z"})}),jsx(G,{transform:"translate(738.7857,721.0845)",children:jsx(Path,{fill:"#FFFFFF",d:"M 0,0 -28.373,-79.366 -56.65,0 H -220.625 V -105.93 L -267.278,0 H -400.1 l -136.414,-309.586 h 661.726 l 0,309.586 z"})}),jsx(G,{transform:"translate(373.0462,548.583)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"M 0,0 32.145,76.837 64.268,0 Z m -9.212,138.867 -107.187,-241.37 h 73.518 l 20.22,48.332 H 86.914 l 20.207,-48.332 h 75.345 L 75.723,138.867 Z"})}),jsx(G,{transform:"translate(554.5071,446.121)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 64.997,-0.001 V 165.796 L 126.661,-0.001 h 58.418 L 245.49,165.233 V -0.564 l 64,0.563 V 241.368 H 210.032 L 156.513,92.624 103.342,241.012 0,241.369 Z"})})]})})}function pc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(vi,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(Lf,{size:t}):o.includes("mastercard")?jsx(Bf,{size:t}):o.includes("amex")||o.includes("american express")?jsx(Wf,{size:t}):jsx(vi,{size:t*.75,color:r,strokeWidth:1.75})}var Ef=[50,100,500],Mf=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function du(e){return e.charAt(0).toUpperCase()+e.slice(1)}function zf(e){return e.card?`${du(e.card.brand)} ${du(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Oa({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:s="inline",onCollectPayment:i,paymentLoading:a=false,paymentStatus:c,paymentError:u,paymentTokens:l=[],onAddPaymentMethod:h,onConfirm:S,onCancel:g,sheetBorderTopLeftRadius:y,sheetBorderTopRightRadius:C}){let d=Bi(),{colors:w,components:b}=V(),m=y??b.card.borderRadius,f=C??b.card.borderRadius,[x,_]=useState(e),[F,k]=useState(r?"apple_pay":l.length>0?l[0].id:null),T=useRef(false),A=W=>{T.current=true,k(W);};useEffect(()=>{T.current||r||l.length>0&&k(l[0].id);},[l,r]);let[M,O]=useState(false),[v,z]=useState("select"),[E,de]=useState(null),Qe=useRef(false);useEffect(()=>{a&&c&&/saving/i.test(c)&&z("card");},[a,c]);let We=F==="apple_pay",oe=1e3,ae=We?oe:n,be=ae!=null&&ae>0,Ie=useMemo(()=>{if(o)return [];let W=Ef.map(L=>({label:`$${L}`,amount:String(L),disabled:false}));return We?W.push({label:`$${oe}`,amount:String(oe),disabled:false}):W.push({label:"MAX",amount:be?String(ae):"0",disabled:!be}),W},[o,be,ae,We]),rt=W=>{if(W==="\u232B"){_(L=>L.slice(0,-1));return}if(W==="."){if(x.includes("."))return;_(L=>L===""?"0.":L+".");return}_(L=>{let ee=L.indexOf(".");return ee!==-1&&L.length-ee>2?L:L==="0"&&W!=="."?W:L+W});},Ne=x===""?"0":x,Se=parseFloat(x),ue=x!==""&&!isNaN(Se)&&Se>0,Te=r||l.length>0,Ke=s==="header",lt=useMemo(()=>{let W=[];r&&W.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let L of l)W.push({id:L.id,label:zf(L),hint:L.card?`Expires ${L.card.exp_month}/${L.card.exp_year}`:L.type,brand:L.card?.brand,isApplePay:false});return W},[r,l]),ve=lt.find(W=>W.id===F),Be=F!=null&&F!=="apple_pay",X=ve?ve.label:Be&&E?E:Be?"Card":"Pay With",q=ve?!ve.isApplePay:Be,Ce=ve?.brand??E??void 0,dt=Te?jsx(TouchableOpacity,{style:[Ke?d.amount.paymentRowHeader:d.amount.paymentRow,a&&{opacity:.5}],onPress:()=>{a||(z("select"),O(true));},activeOpacity:.7,disabled:a,children:jsxs(View,{style:d.amount.paymentLeft,children:[ve?.isApplePay?jsx(Text,{style:d.amount.applePayIcon,children:"\uF8FF"}):q?jsx(pc,{sublabel:Ce,size:20}):null,jsx(Text,{style:d.amount.paymentLabel,children:X}),jsx(Ot,{size:12,color:d.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:d.form.screen,children:[jsx(Jt,{onPress:g,title:"Enter amount"}),Ke&&dt,jsxs(View,{style:d.form.content,children:[jsxs(View,{style:d.amount.amountContainer,children:[jsxs(Text,{style:[d.amount.amountText,Ne==="0"&&d.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",Ne]}),jsx(Text,{style:d.amount.currencyLabel,children:t.toUpperCase()})]}),!Ke&&dt,Ie.length>0&&jsx(View,{style:d.amount.quickRow,children:Ie.map(W=>{let L=!W.disabled&&x===W.amount&&x!=="";return jsx(TouchableOpacity,{style:[d.amount.quickPill,L&&{backgroundColor:w.primary},W.disabled&&{opacity:.4}],activeOpacity:.7,disabled:W.disabled||a,onPress:()=>_(W.amount),children:jsx(Text,{style:[d.amount.quickPillText,L&&{color:w.primaryForeground}],children:W.label})},W.label)})}),jsx(View,{style:d.amount.numpad,children:Mf.map((W,L)=>jsx(View,{style:d.amount.numpadRow,children:W.map(ee=>jsx(TouchableOpacity,{style:[d.amount.numpadKey,a&&{opacity:.3}],onPress:()=>rt(ee),activeOpacity:.6,disabled:a,children:jsx(Text,{style:ee==="\u232B"?d.amount.backspaceText:d.amount.numpadKeyText,children:ee})},ee))},L))}),jsx(TouchableOpacity,{style:[d.form.continueBtn,(!ue||a)&&d.form.continueBtnDisabled],onPress:()=>ue&&!a&&S(x,F),disabled:!ue||a,children:a?jsx(ActivityIndicator,{size:"small",color:w.primaryForeground}):jsx(Text,{style:[d.form.continueBtnText,!ue&&d.form.continueBtnTextDisabled],children:"Continue"})}),!M&&u?jsx(Text,{style:d.amount.inlineError,children:u}):!M&&a&&c&&__DEV__?jsx(Text,{style:d.amount.inlineStatus,children:c}):null]}),jsx(Ze,{visible:M,onClose:()=>{a||(O(false),z("select"));},closeOnBackdropPress:!a,showHandle:false,heightPercent:.5,borderTopLeftRadius:m,borderTopRightRadius:f,children:jsx(View,{style:d.amount.sheetContent,children:v==="select"?jsxs(Fragment,{children:[jsxs(View,{style:d.amount.sheetTitleRow,children:[jsx(Text,{style:d.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity,{onPress:()=>O(false),activeOpacity:.7,style:d.amount.sheetCloseBtn,children:jsx(nt,{size:16,color:w.foregroundMuted,strokeWidth:2.5})})]}),jsxs(ScrollView,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[lt.map(W=>{let L=F===W.id;return jsxs(TouchableOpacity,{style:[d.amount.sheetOption,L&&{borderColor:w.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{A(W.id),de(W.isApplePay?null:W.label),O(false);},children:[jsxs(View,{style:d.amount.sheetOptionLeft,children:[jsx(View,{style:d.amount.sheetOptionIcon,children:W.isApplePay?jsx(Text,{style:d.amount.applePayIcon,children:"\uF8FF"}):jsx(pc,{sublabel:W.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:d.amount.sheetOptionLabel,children:W.label}),jsx(Text,{style:d.amount.sheetOptionHint,children:W.hint})]})]}),L&&jsx($e,{size:18,color:w.primary,strokeWidth:2.5})]},W.id)}),jsx(TouchableOpacity,{style:d.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!Qe.current){Qe.current=true;try{let W=await h?.();W&&(A(W.token),de(W.sublabel),O(!1));}finally{Qe.current=false;}}},children:jsx(Text,{style:d.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:d.amount.sheetHeader,children:[jsx(TouchableOpacity,{onPress:()=>{a||z("select");},activeOpacity:.7,style:d.amount.sheetBackBtn,children:jsx(Pi,{size:20,color:w.foreground,strokeWidth:2})}),jsx(Text,{style:d.amount.sheetTitle,children:"Pay With"})]}),a?jsxs(View,{style:d.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:w.primary}),__DEV__?jsx(Text,{style:d.amount.sheetStatusText,children:c||"Loading Stripe Link..."}):null]}):u?jsxs(Fragment,{children:[jsx(View,{style:d.amount.sheetError,children:jsx(Text,{style:d.amount.sheetErrorText,children:u})}),jsx(TouchableOpacity,{style:d.form.continueBtn,onPress:()=>{i&&ue&&i(false,x);},children:jsx(Text,{style:d.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:d.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:w.primary}),__DEV__?jsx(Text,{style:d.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})})]})}var Os=4;function Fa({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Bi(),{colors:s,fonts:i,components:a}=V(),c=a.input.placeholderColor,[u,l]=useState(1),[h,S]=useState(e.firstName??""),[g,y]=useState(e.lastName??""),[C,d]=useState(e.dobMonth??""),[w,b]=useState(e.dobDay??""),[m,f]=useState(e.dobYear??""),[x,_]=useState(e.addressLine1??""),[F,k]=useState(e.addressLine2??""),[T,A]=useState(e.city??""),[M,O]=useState(e.state??""),[v,z]=useState(e.postalCode??""),[E,de]=useState(e.country??"US"),[Qe,We]=useState(e.idNumber??""),oe=useRef(null),ae=useRef(null),be=useRef(null),Ie=useRef(null),rt=useRef(null),Ne=useRef(null),Se=useRef(null),ue=useRef(null),Te=()=>{switch(u){case 1:return h.trim().length>0&&g.trim().length>0;case 2:return C.length===2&&w.length===2&&m.length===4;case 3:return x.trim().length>0&&T.trim().length>0&&M.trim().length>0&&v.trim().length>0;case 4:return Qe.trim().length>0;default:return false}},Ke=()=>{Te()&&(u<Os?l(X=>X+1):r({firstName:h,lastName:g,idNumber:Qe,dobMonth:C,dobDay:w,dobYear:m,addressLine1:x,addressLine2:F,city:T,state:M,postalCode:v,country:E}));},lt=()=>{u>1?l(X=>X-1):o();},ve=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Ve=["Use your full legal name as it appears on your ID.","We use this to verify your identity.","Enter the address associated with your ID.","Your SSN is encrypted and used only for identity verification."],Be=[Wt.stepCounter,{color:s.foregroundMuted},...i.semibold?[{fontFamily:i.semibold}]:[]];return jsx(KeyboardAvoidingView,{style:n.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:n.form.screen,children:[jsxs(View,{style:Wt.header,children:[jsx(View,{style:Wt.headerSide,children:jsx(TouchableOpacity,{style:Wt.iconButton,onPress:lt,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:u>1?"Back":"Cancel",children:jsx(Cs,{size:20,color:a.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Wt.headerCenter,children:jsxs(Text,{style:Be,children:[u," of ",Os]})}),jsx(View,{style:Wt.headerSide,children:jsx(TouchableOpacity,{style:Wt.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(nt,{size:20,color:a.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Wt.progressTrack,children:Array.from({length:Os}).map((X,q)=>jsx(View,{style:[Wt.progressSegment,{backgroundColor:q<u||q+1===u?s.primary:s.border}]},q))}),jsxs(ScrollView,{style:n.form.flex,contentContainerStyle:Wt.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:ve[u-1]}),jsx(Text,{style:n.form.subtitle,children:Ve[u-1]}),u===1&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:c,value:h,onChangeText:S,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>oe.current?.focus()})}),jsx($o,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:oe,style:n.form.input,placeholder:"Doe",placeholderTextColor:c,value:g,onChangeText:y,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:Ke})})]}),u===2&&jsxs(View,{style:Wt.dobRow,children:[jsxs(View,{style:Wt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Wt.dobInput],placeholder:"MM",placeholderTextColor:c,value:C,onChangeText:X=>{let q=X.replace(/\D/g,"").slice(0,2);d(q),q.length===2&&ae.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Wt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Day"}),jsx(TextInput,{ref:ae,style:[n.form.input,Wt.dobInput],placeholder:"DD",placeholderTextColor:c,value:w,onChangeText:X=>{let q=X.replace(/\D/g,"").slice(0,2);b(q),q.length===2&&be.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Wt.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Year"}),jsx(TextInput,{ref:be,style:[n.form.input,Wt.dobInput],placeholder:"YYYY",placeholderTextColor:c,value:m,onChangeText:X=>{let q=X.replace(/\D/g,"").slice(0,4);f(q);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:Ke})]})]}),u===3&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:c,value:x,onChangeText:_,returnKeyType:"next",onSubmitEditing:()=>Ie.current?.focus()})}),jsx($o,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:Ie,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:c,value:F,onChangeText:k,returnKeyType:"next",onSubmitEditing:()=>rt.current?.focus()})}),jsx($o,{form:n.form,label:"City",children:jsx(TextInput,{ref:rt,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:c,value:T,onChangeText:A,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Ne.current?.focus()})}),jsxs(View,{style:Wt.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx($o,{form:n.form,label:"State",children:jsx(TextInput,{ref:Ne,style:n.form.input,placeholder:"NY",placeholderTextColor:c,value:M,onChangeText:X=>O(X.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>Se.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx($o,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:Se,style:n.form.input,placeholder:"11201",placeholderTextColor:c,value:v,onChangeText:z,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>ue.current?.focus()})})})]}),jsx($o,{form:n.form,label:"Country",children:jsx(TextInput,{ref:ue,style:n.form.input,placeholder:"US",placeholderTextColor:c,value:E,onChangeText:X=>de(X.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:Ke})})]}),u===4&&jsxs($o,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:c,value:Qe,onChangeText:We,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:Ke}),jsx(Text,{style:[n.form.hint,Wt.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&u===Os?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(yt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!Te()&&n.form.continueBtnDisabled],onPress:Ke,disabled:!Te(),children:jsx(Text,{style:[n.form.continueBtnText,!Te()&&n.form.continueBtnTextDisabled],children:u===Os?"Submit":"Continue"})})})]})})}function $o({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Wt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:16},headerSide:{width:40,alignItems:"center"},headerCenter:{flex:1,alignItems:"center",justifyContent:"center"},iconButton:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"},stepCounter:{fontSize:15},progressTrack:{flexDirection:"row",gap:4,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{marginTop:10,lineHeight:18}});var pu="",mu;function Da(e){pu=e;}function Va(e){mu=e;}function Er(){let e=pu||ba();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Mr(){return mu??Ts()}async function La(){let e=`${Mr()}/v1/public/onramps/headless/stripe/config`,t=Er(),r=await fetch(e,{method:"GET",headers:{"x-publishable-key":t,"Content-Type":"application/json"}});if(!r.ok)throw new Error(`Failed to load Stripe config: ${r.status}`);let o=await r.json();if(!o?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return o.publishable_key}async function yc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw new Error(`Failed to create auth intent: ${t.status}`);let r=await t.json();return r.auth_intent_id??r.id}async function fu(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!t.ok)throw new Error(`Failed to exchange auth intent for tokens: ${t.status}`);return t.json()}async function bc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})}),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r?.message??`Failed to refresh OAuth token: ${t.status}`);return r}async function hu(e,t){let r={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},o=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t,"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await o.text();if(!o.ok)throw new Error(`Failed to create onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function gu(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}}),o=await r.text();if(!r.ok)throw new Error(`Failed to confirm onramp session: ${r.status} ${o}`);return JSON.parse(o)}async function Ba(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp customer: ${o.status} ${n}`);return JSON.parse(n)}async function yu(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Cc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}});if(!r.ok){let o=await r.text();throw new Error(`Failed to refresh quote: ${r.status} ${o}`)}return r.json()}async function bu(e){let t=new URLSearchParams({destinationNetwork:e.destinationNetwork,walletAddress:e.walletAddress});e.destinationTag&&t.set("destinationTag",e.destinationTag),e.cryptoCustomerId&&t.set("crypto_customer_id",e.cryptoCustomerId);let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":e.accessToken}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch transaction limits: ${r.status} ${o}`)}return r.json()}async function wc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch payment tokens: ${r.status} ${o}`)}return r.json()}async function Cu(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let t={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},r=await fetch(`${Mr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.status}`);return r.json()}function kc(e,t){if(e?.length){let r=e.find(n=>n.format==="png");if(r)return r.url;let o=e.find(n=>n.format==="svg");if(o)return o.url}return t}async function wu(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Er()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}var Tc="@unifold/stripe_oauth";async function ku(){try{let e=await Sc.getItem(Tc);return e?JSON.parse(e):null}catch{return null}}async function xc(e){try{await Sc.setItem(Tc,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function Cn(){try{await Sc.removeItem(Tc);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Gf=5,kn=null,Su={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Wa(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:s,authorize:i,attachKycInfo:a,presentKycInfoVerification:c,verifyIdentity:u,registerWalletAddress:l,collectPaymentMethod:h,createCryptoPaymentToken:S}=useOnramp(),[g,y]=useState(r),[C,d]=useState(!!e?.externalUserId),[w,b]=useState(false),[m,f]=useState(""),[x,_]=useState(null),[F,k]=useState(e?.email??""),[T,A]=useState(e?.phone??""),[M,O]=useState(""),[v,z]=useState("US"),[E,de]=useState(""),[Qe,We]=useState(""),oe=useRef(""),ae=useRef(""),be=useRef(""),[Ie,rt]=useState(false),[Ne,Se]=useState(false),ue=useRef(0),Te=useRef(false),Ke=useRef(false),lt=useRef(false),ve=useRef(""),Ve=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),Be=useRef(null),[X,q]=useState(Su),[Ce,dt]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[W,L]=useState(""),[ee,le]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[pe,wt]=useState(e?.defaultSourceAmount??"100"),[ut,Ye]=useState(e?.defaultSourceCurrency??"usd"),[je,Pt]=useState(e?.defaultDestinationCurrency??"usdc"),[_t,ir]=useState(null),[Ae,ot]=useState(),[pt,Or]=useState(),[Cr,ce]=useState(false),tt=useRef(null),fe=useRef(false),Je=useRef(0),$=useRef(e?.onComplete),re=useRef(e?.onError),xe=useRef(e?.onStepChange),me=useRef(r);useEffect(()=>{$.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{re.current=e?.onError;},[e?.onError]),useEffect(()=>{xe.current=e?.onStepChange;},[e?.onStepChange]);let ne=useRef(r);useEffect(()=>{g!==ne.current&&(xe.current?.(g,ne.current),ne.current=g),me.current=g;},[g]),useEffect(()=>{C&&g!==r&&d(false);},[C,g,r]);let P=useCallback((R,I,N)=>{let Z={code:R,message:I,step:me.current,stripeErrorCode:N};_(Z),f(""),re.current?.(Z);},[]),gt=useCallback(R=>{let I={sessionId:R.id,status:R.status,sourceAmount:R.transaction_details.source_amount,sourceCurrency:R.transaction_details.source_currency,destinationAmount:R.transaction_details.destination_amount,destinationCurrency:R.transaction_details.destination_currency,destinationNetwork:R.transaction_details.destination_network,walletAddress:R.transaction_details.wallet_address,fees:{networkFee:R.transaction_details.fees.network_fee_amount,transactionFee:R.transaction_details.fees.transaction_fee_amount}};return $.current?.(I),I},[]),Pe=useCallback(()=>_(null),[]),un=R=>R.refresh_token??R.refresh?.refresh_token??"",xi=useCallback((R,I,N,Z,he)=>{ae.current=I,oe.current=N,e?.externalUserId&&xc({accessToken:I,refreshToken:N,customerId:R,externalUserId:e.externalUserId,email:he||F,expiresAt:Date.now()+Z*1e3});},[e?.externalUserId,F]),_i=useCallback(async()=>{let R=oe.current;if(!R)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let I=await bc(R),N=I.access_token,Z=un(I)||R;return We(N),xi(be.current,N,Z,I.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),N}catch(I){return console.error("[tryRefreshAccessToken] refresh failed:",I?.message),await Cn(),kn=null,ae.current="",oe.current="",be.current="",We(""),de(""),null}},[xi]),go=useCallback(async R=>{try{return await R(ae.current)}catch(I){let N=I?.message??"";if(N.includes("stripe_onramp_forbidden")||N.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let Z=await _i();if(!Z)throw P("authorization_error","Session expired. Please sign in again."),y("email"),I;return await R(Z)}throw I}},[_i,P]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){ce(false);return}let I=false;return isPlatformPaySupported().then(N=>{I||ce(N);}),()=>{I=true;}},[e?.merchantIdentifier]),useEffect(()=>(fe.current=false,()=>{fe.current=true,tt.current&&clearTimeout(tt.current);}),[]);let Ri=useRef(false);useEffect(()=>{if(Ri.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),Cn(),kn=null,d(false);return}let R=false;return (async()=>{try{let I=await ku();if(R||!I){R||d(!1);return}if(I.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",I.externalUserId,"current:",e.externalUserId),await Cn(),kn=null,R||d(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",I.customerId);let N=Date.now()>=I.expiresAt,Z=I.accessToken,he=I.refreshToken;if(N){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Ee=await bc(I.refreshToken);if(R)return;Z=Ee.access_token,he=Ee.refresh_token??Ee.refresh?.refresh_token??I.refreshToken,await xc({accessToken:Z,refreshToken:he,customerId:I.customerId,externalUserId:e.externalUserId,email:I.email,expiresAt:Date.now()+(Ee.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Ee){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Ee?.message),await Cn(),kn=null,R||d(!1);return}}if(R)return;if(Ri.current=!0,de(I.customerId),be.current=I.customerId,We(Z),ae.current=Z,oe.current=he,I.email&&k(I.email),kn===I.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",I.customerId,"\u2014 skipping configure()"),Be.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",I.customerId);let Ee=await o({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}},cryptoCustomerId:I.customerId});Ee.error?console.error("[useStripeOnramp] restore configureSDK error:",Ee.error.message):kn=I.customerId,Be.current=Promise.resolve(Ee);}if(R)return;let mt=()=>new Promise(Ee=>{let ur=()=>{lt.current&&ve.current?Ee():setTimeout(ur,200);};ur();});try{if(await Promise.race([mt(),new Promise((ur,Vt)=>setTimeout(()=>Vt(new Error("timeout")),1e4))]),R)return;let Ee=ve.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Ee,"network:",Ve.current),await l(Ee,Ve.current);}catch(Ee){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Ee?.message);}if(R)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),y("session_params");}finally{R||d(false);}})(),()=>{R=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||Ie||Ne)return;let R=false;Se(true);async function I(){try{let[N,Z]=await Promise.all([Cu({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?wu({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Lt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Lt?.message),null)):Promise.resolve(null)]);if(R)return;let he=e?.destinationChainType??"ethereum",mt=N.data.find(Lt=>Lt.chain_type===he);if(mt?.address){let Lt=mt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Lt,"recipient:",mt.recipient_address),dt(Lt),ve.current=Lt,mt.recipient_address&&L(mt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",he,"in",N.data?.length,"wallets");let Ee={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},ur={8453:"base",1:"ethereum",137:"polygon"},Vt=Z?.destination_network,sr="none";if(Vt&&Ee[Vt])le(Ee[Vt]),Ve.current=Ee[Vt],sr=Vt+" (from default_token API)";else if(e?.destinationChainId&&ur[e.destinationChainId]){let Lt=ur[e.destinationChainId];Ee[Lt]&&(le(Ee[Lt]),Ve.current=Ee[Lt]),sr=Lt+" (from chain_id "+e.destinationChainId+")";}else Ee[he]&&(le(Ee[he]),Ve.current=Ee[he],sr=he+" (from chain_type fallback)");Z?.destination_currency&&Pt(Z.destination_currency.toLowerCase());let er=Z?.destination_token_metadata,qr=kc(er?.icon_urls,er?.icon_url),Qr=kc(er?.chain?.icon_urls,er?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",qr,"network:",Qr),qr&&ot(qr),Qr&&Or(Qr),rt(!0),lt.current=!0;}catch(N){console.error("[useStripeOnramp] Failed to resolve wallet:",N?.message),rt(true),lt.current=true;}finally{R||Se(false);}}return I(),()=>{R=true;}},[e?.publishableKey,e?.externalUserId]);let io=useCallback(async()=>{if(Be.current)return Be.current;let R=o({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(I=>(I.error&&(console.error("[useStripeOnramp] configureSDK error:",I.error.message,I.error.code),Be.current=null),I)).catch(I=>{throw console.error("[useStripeOnramp] configureSDK threw:",I?.message??I),Be.current=null,I});return Be.current=R,R},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||io();},[]);let Mo=useCallback(async R=>{if(!Te.current){Te.current=true,b(true),Pe(),f("Creating auth intent...");try{let I=await yc(R);f("Waiting for authorization...");let N=await i(I);if(N?.error){console.log("[proceedToAuthorize] authorize error:",N.error.message),P("authorization_error","Something went wrong during authorization. Please try again."),y("email");return}if(N?.status==="Denied"){P("authorization_error","Authorization denied by user."),y("email");return}if(N?.status!=="Consented"||!N.customerId){P("authorization_error","Authorization was canceled."),y("email");return}f("Exchanging tokens...");let Z=await fu(I),he=N.customerId,mt=Z.access_token,Ee=un(Z);console.log("[useStripeOnramp] customerId:",he),console.log("[useStripeOnramp] accessToken acquired, length:",mt.length),de(he),be.current=he,kn=he,We(mt),xi(he,mt,Ee,Z.expires_in??3600),f("Checking verification status...");try{let ur=await Ba(he,mt),Vt=ur.verifications.find(pn=>pn.name==="kyc_verified"),sr=ur.verifications.find(pn=>pn.name==="id_document_verified"),er=Vt?.status==="verified",qr=Vt?.status==="rejected",Qr=sr?.status==="verified",Lt=ur.provided_fields.includes("first_name");if(f(""),qr&&!Lt)P("kyc_error","KYC was previously rejected. Please submit with correct info."),y("kyc");else if(qr&&Lt)y(Qr?"wallet":"identity");else if(!er&&!Lt)y("kyc");else if(!Qr)y("identity");else if(lt.current&&ve.current)try{let pn=ve.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",pn,"network:",ee);let ca=await l(pn,ee);ca?.error?(console.warn("[proceedToAuthorize] wallet registration error:",ca.error.message),P("wallet_error",ca.error.message,ca.error.code),y("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),y("session_params"));}catch(pn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",pn?.message),y("wallet");}else y("wallet");}catch(ur){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",ur?.message),f(""),y("kyc");}}catch(I){P("authorization_error",I?.message??String(I)),y("email");}finally{Te.current=false,b(false);}}},[i,Pe,P,xi,l,ee]),Q=useCallback(async()=>{if(Keyboard.dismiss(),!F){P("validation_error","Please enter an email address.");return}b(true),Pe(),f("");try{f("Configuring...");let R=await io();if(R.error){P("configuration_error",R.error.message,R.error.code);return}f("Checking Link account...");let I=await n(F);if(I.error){P("authorization_error",I.error.message,I.error.code);return}I.hasLinkAccount?await Mo(F):(f(""),y("register"));}catch(R){P("unknown_error",R?.message??String(R));}finally{b(false);}},[Pe,io,F,P,n,Mo]),ie=useCallback(async()=>{if(!T){P("validation_error","Please enter your phone number.");return}b(true),Pe(),f("");try{f("Creating Link account...");let R=await s({email:F,phone:T,fullName:M||F,country:v||"US"});if(R.error){P("registration_error",R.error.message,R.error.code);return}await Mo(F);}catch(R){P("registration_error",R?.message??String(R));}finally{b(false);}},[Pe,v,F,P,M,T,s,Mo]);useEffect(()=>{if(g!=="email"||!e?.email)return;let R=++ue.current,I=false,N=()=>I||ue.current!==R;return e?.phone?(async()=>{b(true),Pe();try{f("Configuring...");let Z=await io();if(N())return;if(Z.error){P("configuration_error",Z.error.message,Z.error.code);return}f("Checking Link account...");let he=await n(e.email);if(N())return;if(he.error){P("authorization_error",he.error.message,he.error.code);return}if(he.hasLinkAccount){if(N())return;await Mo(e.email);}else {f("Creating Link account...");let mt=await s({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(N())return;if(mt.error){P("registration_error",mt.error.message,mt.error.code);return}if(N())return;await Mo(e.email);}}catch(Z){N()||P("unknown_error",Z?.message??String(Z));}finally{b(false);}})():(async()=>{b(true),Pe();try{f("Configuring...");let Z=await io();if(N())return;if(Z.error){P("configuration_error",Z.error.message,Z.error.code);return}f("Checking Link account...");let he=await n(e.email);if(N())return;if(he.error){P("authorization_error",he.error.message,he.error.code);return}if(he.hasLinkAccount){if(N())return;await Mo(e.email);}else {if(N())return;f(""),y("register");}}catch(Z){N()||P("unknown_error",Z?.message??String(Z));}finally{b(false);}})(),()=>{I=true;}},[g,e?.email,e?.phone]);let St=useCallback(async R=>{b(true),Pe(),f(""),q(R);try{let I={firstName:R.firstName,lastName:R.lastName,idNumber:R.idNumber||void 0,dateOfBirth:{day:parseInt(R.dobDay,10),month:parseInt(R.dobMonth,10),year:parseInt(R.dobYear,10)},address:{line1:R.addressLine1,line2:R.addressLine2||void 0,city:R.city,state:R.state,postalCode:R.postalCode,country:R.country}},N=await a(I);if(N?.error){if(N.error.stripeErrorCode==="consumer_person_already_verified"){f(""),y("identity");return}P("kyc_error",N.error.message,N.error.stripeErrorCode??N.error.code),y("kyc");return}f("Please review your KYC information...");let Z=await c(null);if(Z?.error){P("kyc_error",Z.error.message,Z.error.stripeErrorCode??Z.error.code),y("kyc");return}if(Z?.status==="UpdateAddress"){P("kyc_error","Please update your address and resubmit."),y("kyc");return}f(""),y("identity");}catch(I){P("kyc_error",I?.message??String(I)),y("kyc");}finally{b(false);}},[a,Pe,P,c]),Fr=useCallback(async()=>{if(!Ke.current){Ke.current=true,b(true),Pe(),f("Launching identity verification...");try{let R=await u();if(R?.error){P("identity_error",R.error.message,R.error.code);return}f(""),y("wallet");}catch(R){P("identity_error",R?.message??String(R));}finally{Ke.current=false,b(false);}}},[Pe,P,u]);useEffect(()=>{g==="identity"&&!w&&Fr();},[g]);let gs=useCallback(async()=>{if(!Ce){P("validation_error","Please enter a wallet address.");return}b(true),Pe(),f("");try{let R=Ce.toLowerCase();console.log("[registerWallet] registering wallet:",R,"network:",ee);let I=await l(R,ee);if(I?.error){console.warn("[registerWallet] error:",I.error.message),P("wallet_error",I.error.message,I.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),y("session_params");}catch(R){P("wallet_error",R?.message??String(R));}finally{b(false);}},[Pe,P,Ce,ee,l]);useEffect(()=>{g==="wallet"&&Ie&&Ce&&gs();},[g,Ie,Ce]);let so=useCallback(R=>{fe.current=false,Je.current=0;let I=0,N=async()=>{I+=1;let Z=ae.current;try{let he=await yu(R,Z);if(console.log(`[pollSessionStatus] poll #${I} session=${R} status="${he.status}"`),fe.current)return;Je.current=0,he.status==="fulfillment_complete"?(ir(he),y("success")):tt.current=setTimeout(N,3e3);}catch(he){if(fe.current)return;let mt=he?.message??"";if((mt.includes("stripe_onramp_forbidden")||mt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await _i()&&!fe.current)){tt.current=setTimeout(N,1e3);return}if(Je.current+=1,console.error(`[pollSessionStatus] poll #${I} error:`,mt),Je.current>=Gf){P("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}tt.current=setTimeout(N,5e3);}};tt.current=setTimeout(N,3e3);},[P,_i]),ao=useCallback(()=>{if(me.current==="processing"&&_t?.id){if(!ae.current){P("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}Pe(),Je.current=0,tt.current&&(clearTimeout(tt.current),tt.current=null),so(_t.id);}},[Pe,P,so,_t?.id]),Dr=useCallback(async R=>{b(true),Pe(),f("");try{f("Confirming purchase...");let I=await go(N=>gu(R,N));console.log("[finalizeOnrampSession] confirmed session:",I.id,"status:",I.status),ir(I),y("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",I.id),so(I.id);}finally{b(false);}},[Pe,so,go]),zo=useRef(false),Lm=useCallback(async()=>{if(!(!_t||zo.current)){zo.current=true;try{b(!0),Pe(),f("Refreshing quote...");let R=await go(I=>Cc(_t.id,I));ir(R),await Dr(R.id);}catch(R){console.log("[confirmCheckout] error:",R?.message),P("session_error","Something went wrong. Please try again."),y("quote");}finally{b(false),zo.current=false;}}},[Pe,P,Dr,_t,go]),Wd=useCallback(async()=>{let R=F;if(!R)return console.warn("[reauthorizeLink] no email available for re-authorization"),false;try{console.log("[reauthorizeLink] re-establishing Link session for:",R),f("Verifying identity...");let I=await yc(R),N=await i(I);return N?.status==="Consented"&&N.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",N.customerId),be.current=N.customerId,de(N.customerId),kn=N.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",N?.status),!1)}catch(I){return console.warn("[reauthorizeLink] failed:",I?.message),false}},[i,F]),Bm=useCallback(async(R=false,I,N)=>{let Z=I??pe;if(console.log("[collectPaymentMethod] called:",{useApplePay:R,amt:Z,amountOverride:I,sourceAmount:pe,hasSavedToken:!!N}),!Z||isNaN(Number(Z))||Number(Z)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),P("validation_error","Please enter a valid amount.");return}I&&wt(I),b(true),Pe(),f("");try{let he=await io();if(he.error){P("configuration_error",he.error.message,he.error.code);return}let mt;if(N)console.log("[collectPaymentMethod] using saved payment token"),mt=N;else if(R){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),P("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),y("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Vt={applePay:{merchantCountryCode:"US",currencyCode:ut.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${je.toUpperCase()} purchase + fees`,amount:Z}]}},sr=await h("PlatformPay",Vt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!sr?.error),sr?.error){let qr=sr.error.message??"",Qr=sr.error.code??"",Lt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",sr.error,"isCancellation:",Lt),Lt||(P("payment_error",qr,Qr),y("session_params"));return}if(!sr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let er=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){P("payment_error",er.error.message,er.error.code),y("session_params");return}mt=er.cryptoPaymentToken;}else {f("Select a payment method...");let Vt=await h("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Vt?.error),Vt?.error){let qr=Vt.error.message??"",Qr=Vt.error.code??"",Lt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",Vt.error,"isCancellation:",Lt),Lt||(P("payment_error",qr,Qr),y("session_params"));return}if(!Vt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let sr=Vt.displayData;console.log("[collectPaymentMethod] displayData:",{type:sr.type,label:sr.label,sublabel:sr.sublabel,hasIcon:!!sr.icon}),f("Creating payment token...");let er=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){P("payment_error",er.error.message,er.error.code),y("session_params");return}mt=er.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",Ce,"walletAddressRef:",ve.current);let Ee=ve.current||Ce.toLowerCase(),ur=await go(Vt=>hu({cryptoCustomerId:be.current,paymentToken:mt,sourceAmount:Number(Z),sourceCurrency:ut,destinationCurrency:je,walletAddress:Ee,destinationNetwork:ee},Vt));console.log("[collectPaymentMethod] session created:",ur?.id,"useApplePay:",R),ir(ur),f(""),R?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await Dr(ur.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):y("quote");}catch(he){console.log("[collectPaymentMethod] error caught:",he?.message),P("session_error","Something went wrong. Please try again."),y("session_params");}finally{b(false),f("");}},[Pe,io,h,S,je,P,Dr,wt,pe,ut,Ce,ee,go,e?.merchantIdentifier]),Wm=useCallback(async()=>{b(true),Pe(),f("Select a payment method...");try{let R=await io();if(R.error)return P("configuration_error",R.error.message,R.error.code),null;let I=await h("Card");if(console.log("[addPaymentMethod] Card result ok:",!I?.error),I?.error?.message&&/no active link consumer/i.test(I.error.message)){if(console.log("[addPaymentMethod] no active Link consumer \u2014 attempting re-authorization"),!await Wd())return P("authorization_error","Please verify your identity to add a payment method."),null;I=await h("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!I?.error);}if(I?.error){let he=I.error.message??"",mt=I.error.code??"",Ee=/cancel/i.test(he)||/cancel/i.test(mt);return console.log("[addPaymentMethod] pmResult error:",I.error,"isCancellation:",Ee),Ee||P("payment_error",he,mt),null}if(!I?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let N=I.displayData;console.log("[addPaymentMethod] displayData:",{type:N.type,label:N.label,sublabel:N.sublabel,hasIcon:!!N.icon}),f("Saving payment method...");let Z=await S();return console.log("[addPaymentMethod] tokenResult ok:",!Z?.error),Z?.error?(P("payment_error",Z.error.message,Z.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:Z.cryptoPaymentToken,sublabel:N.sublabel??""})}catch(R){return console.log("[addPaymentMethod] error:",R?.message),P("session_error",R?.message??String(R)),null}finally{b(false),f("");}},[Pe,io,h,S,P,Wd]),Am=useCallback(async()=>{if(_t){b(true),Pe(),f("");try{let R=await go(I=>Cc(_t.id,I));ir(R);}catch(R){console.log("[refreshQuote] error:",R?.message),P("session_error","Something went wrong. Please try again.");}finally{b(false);}}},[Pe,P,_t,go]),Em=useCallback(()=>{fe.current=true,Je.current=0,tt.current&&(clearTimeout(tt.current),tt.current=null),y(r),b(false),f(""),_(null),k(e?.email??""),A(e?.phone??""),O(""),z("US"),de(""),be.current="",We(""),ae.current="",oe.current="",rt(false),Se(false),q(Su),dt(e?.recipientAddress??""),ve.current="",lt.current=false,le(Onramp.CryptoNetwork.ethereum),wt(e?.defaultSourceAmount??"100"),Ye(e?.defaultSourceCurrency??"usd"),Pt(e?.defaultDestinationCurrency??"usdc"),L(""),ot(void 0),Or(void 0),ir(null),ue.current+=1,Te.current=false,Ke.current=false;},[e,r]);return {step:g,restoring:C,loading:w,status:m,error:x,email:F,phone:T,fullName:M,country:v,customerId:E,accessToken:Qe,session:_t,kycData:X,walletAddress:Ce,resolvedRecipientAddress:W,walletNetwork:ee,sourceAmount:pe,sourceCurrency:ut,destinationCurrency:je,tokenIconUrl:Ae,networkIconUrl:pt,applePaySupported:Cr,walletReady:Ie,walletLoading:Ne,setStep:y,setStatus:f,setEmail:k,setPhone:A,setFullName:O,setCountry:z,setWalletAddress:dt,setWalletNetwork:le,setSourceAmount:wt,setSourceCurrency:Ye,setDestinationCurrency:Pt,checkEmail:Q,register:ie,attachKyc:St,verifyIdentity:Fr,registerWallet:gs,collectPaymentMethod:Bm,addPaymentMethod:Wm,refreshQuote:Am,confirmCheckout:Lm,reset:Em,clearError:Pe,emitComplete:gt,resumeFulfillmentPolling:ao,amountFirst:t}}function Tu({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:s,email:i,setEmail:a,checkEmail:c,onClose:u}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:u}),jsxs(View,{style:e.flow.centered,children:[jsx(yt,{size:56,strokeWidth:3}),jsx(kr,{error:n,progress:s,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:u}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your email"}),jsx(Text,{style:e.form.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Email address"}),jsx(TextInput,{style:e.form.input,placeholder:"jane@example.com",placeholderTextColor:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:a,autoFocus:true,returnKeyType:"done",onSubmitEditing:c})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(yt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:c,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(kr,{error:n,progress:s,loading:o})]})]})})}function _u({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:s}){return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:s}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(yt,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:r||"Preparing identity verification..."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Text,{style:e.flow.idIcon,children:"\u{1FAAA}"})}),jsx(Text,{style:e.flow.heading,children:"Identity verification"}),jsx(Text,{style:e.flow.sub,children:r||"Tap below to continue verification."})]}),jsx(kr,{error:o,progress:r,loading:false})]}),!t&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:n,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function Iu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:s,destinationNetwork:i,tokenIconUrl:a,networkIconUrl:c,onClose:u,onRetryStatusCheck:l}){let h=!!t;return jsxs(View,{style:e.form.screen,children:[h?jsx(Jt,{onPress:u}):jsx(View,{style:Ia}),jsx(View,{style:e.flow.centered,children:t?jsxs(Fragment,{children:[jsx(Text,{style:e.flow.heading,children:"Could not confirm status"}),jsx(Text,{style:e.flow.sub,children:"Your payment may still be completing. Try checking again, or close this screen and verify your wallet balance."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(yt,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Processing your purchase"}),jsxs(Text,{style:e.flow.sub,children:["Your payment has been confirmed.",`
2
- `,"We're sending your crypto \u2014 this usually takes less than a minute."]}),n&&s&&i&&jsx(Pa,{sourceCurrency:n,destinationCurrency:s,destinationNetwork:i,tokenIconUrl:a,networkIconUrl:c,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(kr,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:l,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function vu({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:s,tokenIconUrl:i,networkIconUrl:a,onClose:c,onBack:u}){let l=t.transaction_details,h=_a(l.destination_amount,l.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:u??c,title:"Review your purchase",variant:u?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(iu,{currency:l.destination_currency,tokenIconUrl:i,networkIconUrl:a,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(lo,{quote:e.quote,label:"You pay",value:`${l.source_amount} ${l.source_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"You receive",value:`${h} ${l.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Network fee",value:`$${l.fees.network_fee_amount}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Transaction fee",value:`$${l.fees.transaction_fee_amount}`,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(yt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:s,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(kr,{error:o,progress:n,loading:r})]})]})}function Pu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:s,phone:i,setPhone:a,register:c,onClose:u}){let l=V();return t?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:u}),jsxs(View,{style:e.flow.centered,children:[jsx(yt,{size:56,strokeWidth:3}),jsx(kr,{error:o,progress:n,loading:r})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:u}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your phone"}),jsx(Text,{style:e.form.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Phone number"}),jsx(TextInput,{style:e.form.input,placeholder:"+12125551234",placeholderTextColor:l.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:h=>a(h.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:c}),jsx(Text,{style:e.form.hint,children:"Include country code, e.g. +12125551234"})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:s})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(yt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:c,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(kr,{error:o,progress:n,loading:r})]})]})})}function ph({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=V(),n=e.toLowerCase(),s=va[n]??o.primary,i=Math.round(r*.36);return jsxs(View,{style:{width:r,height:r,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:r,height:r,borderRadius:r/2}}):jsx(View,{style:[xo.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:s}],children:jsx(Text,{style:[xo.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[xo.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx($e,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Ou({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:s,onDone:i}){let {colors:a,components:c,fonts:u}=V(),l=t.transaction_details,h=_a(l.destination_amount,l.destination_currency),S=r||o||"";Ra(l.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(ScrollView,{style:e.form.flex,contentContainerStyle:xo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:xo.iconSection,children:[jsx(ph,{currency:l.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:xo.statusRow,children:[jsx(View,{style:[xo.statusDot,{backgroundColor:a.success}]}),jsx(Text,{style:[xo.statusText,{color:a.foreground,fontFamily:u.semibold}],children:"Completed"})]}),jsx(Text,{style:[xo.subtitle,{color:a.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(Pa,{sourceCurrency:l.source_currency,destinationCurrency:l.destination_currency,destinationNetwork:l.destination_network,tokenIconUrl:n,networkIconUrl:s,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor},xo.detailCard],children:[jsx(lo,{quote:e.quote,label:"You Bought",value:`${l.source_amount} ${l.source_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"You Received",value:`${h} ${l.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Network Fee",value:`$${l.fees.network_fee_amount}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Transaction Fee",value:`$${l.fees.transaction_fee_amount}`,hideDivider:true}),jsx(dc,{quote:e.quote,label:"Intent Address",address:l.wallet_address,hideDivider:true}),S?jsx(dc,{quote:e.quote,label:"Recipient Address",address:S,last:true}):jsx(lo,{quote:e.quote,label:"Session",value:t.id.slice(0,8)+"..."+t.id.slice(-6),last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var xo=StyleSheet.create({scrollContent:{paddingBottom:24,alignItems:"center"},iconSection:{alignItems:"center",marginTop:24,marginBottom:24},tokenCircle:{alignItems:"center",justifyContent:"center"},tokenLetter:{color:"#FFFFFF",fontWeight:"700",letterSpacing:.5},checkBadge:{position:"absolute",bottom:0,right:0,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",marginTop:16,gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16},subtitle:{fontSize:14,marginTop:4},detailCard:{width:"100%"}});function Fu({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:s,walletNetwork:i,setWalletAddress:a,setWalletNetwork:c,setDestinationCurrency:u,registerWallet:l,onClose:h}){let{components:S}=V();if(t){let g=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:h}),jsxs(View,{style:e.flow.centered,children:[!g&&jsx(yt,{size:56,strokeWidth:3}),jsx(kr,{error:o,progress:n,loading:r})]}),g&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:l,children:jsx(Text,{style:e.form.continueBtnText,children:"Retry"})})})]})}return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:h}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Your crypto wallet"}),jsx(Text,{style:e.form.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[e.form.input,e.wallet.input],placeholder:"0x...",placeholderTextColor:S.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:s,onChangeText:a})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:xa.map(g=>{let y=i===g.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,y&&e.wallet.rowSelected],onPress:()=>{c(g.value),u(g.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(g.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,y&&e.wallet.rowTextSelected],children:g.label}),y&&jsx(View,{style:e.wallet.checkCircle,children:jsx($e,{size:14,color:S.container.buttonTitleColor,strokeWidth:2.5})})]},g.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(yt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!s&&e.form.continueBtnDisabled],onPress:l,disabled:!s,children:jsx(Text,{style:[e.form.continueBtnText,!s&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(kr,{error:o,progress:n,loading:r})]})]})})}function Ua({config:e,onClose:t}){let r=V(),o=Bi(),{step:n,restoring:s,loading:i,status:a,error:c,email:u,phone:l,session:h,kycData:S,walletAddress:g,resolvedRecipientAddress:y,walletNetwork:C,sourceAmount:d,sourceCurrency:w,destinationCurrency:b,tokenIconUrl:m,networkIconUrl:f,applePaySupported:x,setStep:_,setEmail:F,setPhone:k,setWalletAddress:T,setWalletNetwork:A,setSourceAmount:M,setDestinationCurrency:O,checkEmail:v,register:z,attachKyc:E,verifyIdentity:de,registerWallet:Qe,collectPaymentMethod:We,addPaymentMethod:oe,confirmCheckout:ae,reset:be,emitComplete:Ie,resumeFulfillmentPolling:rt,amountFirst:Ne,customerId:Se,accessToken:ue}=Wa(e),Te=!!e?.email,Ke=!!e?.phone,lt=!!e?.publishableKey&&!!e?.externalUserId,[ve,Ve]=useState(void 0),[Be,X]=useState([]);useEffect(()=>{if(n!=="session_params"||!Se||!ue)return;console.log("[OnrampScreen] customerId:",Se);let L=le=>{let pe=le?.message??"";return pe.includes("stripe_onramp_forbidden")||pe.includes("403")},ee=le=>{L(le)&&(Cn(),be());};Ba(Se,ue).then(le=>{console.log("[OnrampScreen] customer fetched, id:",le?.id);}).catch(le=>{console.warn("[OnrampScreen] customer fetch error:",le?.message),ee(le);}),wc(Se,ue).then(le=>{console.log("[OnrampScreen] payment_tokens fetched, count:",le.data?.length??0),X(le.data??[]);}).catch(le=>{console.warn("[OnrampScreen] payment_tokens error:",le?.message),ee(le);}),console.log("[OnrampScreen] walletAddress:",g,"walletNetwork:",C),g&&(console.log("[OnrampScreen] calling getTransactionLimits..."),bu({destinationNetwork:C||"ethereum",walletAddress:g,accessToken:ue,cryptoCustomerId:Se}).then(le=>{console.log("[OnrampScreen] transaction_limits fetched");let pe=le.limits?.usd;if(pe?.card?.length){let wt=Math.max(...pe.card.map(ut=>ut.limit));Ve(wt),console.log("[OnrampScreen] card max amount:",wt);}}).catch(le=>{console.warn("[OnrampScreen] transaction_limits error:",le?.message),ee(le);}));},[n,Se,ue,g,C,be]);let q=async()=>{if(!(!Se||!ue))try{let L=await wc(Se,ue);console.log("[OnrampScreen] payment_tokens refreshed, count:",L.data?.length??0),X(L.data??[]);}catch(L){console.warn("[OnrampScreen] payment_tokens refresh error:",L?.message);let ee=L?.message??"";(ee.includes("stripe_onramp_forbidden")||ee.includes("403"))&&(Cn(),be());}},Ce=async()=>{let L=await oe();return L&&await q(),L},dt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&dt&&h&&(Ie(h),be(),t?.());},[n,dt,h,Ie,be,t]);let W=()=>{be(),t?.();};return s?jsx(View,{style:bh.container,children:jsx(yt,{size:56,strokeWidth:3})}):n==="email"?jsx(Tu,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:Te,loading:i,error:c,status:a,email:u,setEmail:F,checkEmail:v,onClose:W}):n==="register"?jsx(Pu,{styles:o,hasPrefilledPhone:Ke,loading:i,error:c,status:a,email:u,phone:l,setPhone:k,register:z,onClose:W}):n==="kyc"?jsx(Fa,{initialData:S,loading:i,onComplete:E,onCancel:()=>_("email")}):n==="identity"?jsx(_u,{styles:o,loading:i,status:a,error:c,verifyIdentity:de,onClose:W}):n==="wallet"?jsx(Fu,{styles:o,hasAutoWallet:lt,loading:i,error:c,status:a,walletAddress:g,walletNetwork:C,setWalletAddress:T,setWalletNetwork:A,setDestinationCurrency:O,registerWallet:Qe,onClose:W}):n==="session_params"?jsx(Oa,{initialAmount:d,currency:w,applePaySupported:x,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:ve,paymentTokens:Be,onAddPaymentMethod:Ce,onCollectPayment:(L,ee)=>{We(L,ee);},paymentLoading:i,paymentStatus:a,paymentError:c?.message??null,onConfirm:(L,ee)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:L,selectedMethod:ee,amountFirst:Ne}),Ne&&!Se)M(L),_("email");else {let le=ee==="apple_pay",pe=!le&&ee?ee:void 0;console.log("[OnrampScreen] isApplePay:",le,"hasSavedToken:",!!pe),We(le,L,pe);}},onCancel:W}):n==="quote"&&h?jsx(vu,{styles:o,session:h,loading:i,error:c,status:a,confirmCheckout:ae,tokenIconUrl:m,networkIconUrl:f,onClose:W,onBack:()=>_("session_params")}):n==="processing"?jsx(Iu,{styles:o,error:c,status:a,loading:i,sourceCurrency:h?.transaction_details.source_currency,destinationCurrency:h?.transaction_details.destination_currency??b,destinationNetwork:h?.transaction_details.destination_network??"base",tokenIconUrl:m,networkIconUrl:f,onClose:W,onRetryStatusCheck:rt}):n==="success"&&h&&!dt?jsx(Ou,{styles:o,session:h,resolvedRecipientAddress:y,recipientFromConfig:e?.recipientAddress,tokenIconUrl:m,networkIconUrl:f,onDone:()=>{Ie(h),be(),t?.();}}):null}var bh=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000"}});function Lu(){try{let e=Ch.expoConfig?.plugins;if(!Array.isArray(e))return;for(let t of e){if(!Array.isArray(t))continue;let[r,o]=t;if(r!=="@stripe/stripe-react-native"||!o||typeof o!="object")continue;let n=o.merchantIdentifier;if(typeof n=="string"){let s=n.trim();if(s.length>0)return s}}}catch{}}function Ha({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:s="ethereum",destinationChainId:i="8453",destinationTokenAddress:a,recipientAddress:c,onComplete:u,onError:l,onStepChange:h,onClose:S,merchantIdentifier:g="",urlScheme:y="unifoldOnramp",paymentSelectorPosition:C,skipSuccessConfirmation:d=false}){let w=e||ba(),b=useMemo(()=>{let k=g.trim();return k.length>0?k:Lu()??""},[g]),[m,f]=useState("loading"),[x,_]=useState(null);useEffect(()=>{let k=false;async function T(){try{w&&(Da(w),Va(Ts()));let A=await La();if(k)return;let M=b.trim();if(await initStripe({publishableKey:A,urlScheme:y,...M?{merchantIdentifier:M}:{}}),k)return;f("ready");}catch(A){if(k)return;console.error("[StripeOnramp] Init failed:",A),_(A?.message??"Failed to load Stripe configuration"),f("error");}}return T(),()=>{k=true;}},[w,b,y]);let F=useMemo(()=>{let k={publishableKey:w,externalUserId:o,destinationChainType:s,destinationChainId:i,onComplete:u,onError:l,onStepChange:h};return a&&(k.destinationTokenAddress=a),c&&(k.recipientAddress=c),t&&(k.email=t),r&&(k.phone=r),n&&(k.flowOrder=n),C&&(k.paymentSelectorPosition=C),k.skipSuccessConfirmation=d,k.merchantIdentifier=b,k},[w,o,s,i,a,c,t,r,n,C,d,b,u,l,h]);return m==="error"?jsxs(View,{style:zi.centered,children:[jsx(Text,{style:zi.errorText,children:"Unable to initialize"}),jsx(Text,{style:zi.errorDetail,children:x}),S&&jsx(TouchableOpacity,{style:zi.retryBtn,onPress:S,children:jsx(Text,{style:zi.retryBtnText,children:"Go Back"})})]}):m==="loading"?jsx(View,{style:zi.centered,children:jsx(yt,{size:56,strokeWidth:3})}):jsx(Ua,{config:F,onClose:S})}var zi=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function Eu(){let{configure:e}=useOnramp(),t=useRef(false);return useEffect(()=>{t.current||(t.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(r=>{r.error&&console.error("[StripeOnrampPreconfigure] error:",r.error.message);}).catch(r=>{console.error("[StripeOnrampPreconfigure] threw:",r?.message);}));},[e]),null}var Mu="__unifold_stripe_onramp__";function Na(e){globalThis[Mu]=e;}function zu(){return globalThis[Mu]}Na(Ha);var _o=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this);}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe();}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var Xn,xn,Ui,Uu,vh=(Uu=class extends _o{constructor(){super();Y(this,Xn);Y(this,xn);Y(this,Ui);B(this,Ui,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){p(this,xn)||this.setEventListener(p(this,Ui));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,xn))==null||t.call(this),B(this,xn,void 0));}setEventListener(t){var r;B(this,Ui,t),(r=p(this,xn))==null||r.call(this),B(this,xn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){p(this,Xn)!==t&&(B(this,Xn,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof p(this,Xn)=="boolean"?p(this,Xn):globalThis.document?.visibilityState!=="hidden"}},Xn=new WeakMap,xn=new WeakMap,Ui=new WeakMap,Uu),Hi=new vh;var Ph={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ro,ei,Hu,Oh=(Hu=class{constructor(){Y(this,Ro,Ph);Y(this,ei,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&p(this,ei)&&e!==p(this,Ro)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:p(this,Ro),provider:e}),B(this,Ro,e),process.env.NODE_ENV!=="production"&&B(this,ei,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&B(this,ei,true),p(this,Ro).setTimeout(e,t)}clearTimeout(e){p(this,Ro).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&B(this,ei,true),p(this,Ro).setInterval(e,t)}clearInterval(e){p(this,Ro).clearInterval(e);}},Ro=new WeakMap,ei=new WeakMap,Hu),Io=new Oh;function Nu(e){setTimeout(e,0);}var vc=typeof window>"u"||"Deno"in globalThis;function Gt(){}function qu(e,t){return typeof e=="function"?e(t):e}function Bs(e){return typeof e=="number"&&e>=0&&e!==1/0}function $a(e,t){return Math.max(e+(t||0)-Date.now(),0)}function po(e,t){return typeof e=="function"?e(t):e}function Rr(e,t){return typeof e=="function"?e(t):e}function qa(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:s,queryKey:i,stale:a}=e;if(i){if(o){if(t.queryHash!==Ws(i,t.options))return false}else if(!oi(t.queryKey,i))return false}if(r!=="all"){let c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return false}return !(typeof a=="boolean"&&t.isStale()!==a||n&&n!==t.state.fetchStatus||s&&!s(t))}function Qa(e,t){let{exact:r,status:o,predicate:n,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return false;if(r){if(ti(t.options.mutationKey)!==ti(s))return false}else if(!oi(t.options.mutationKey,s))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Ws(e,t){return (t?.queryKeyHashFn||ti)(e)}function ti(e){return JSON.stringify(e,(t,r)=>Ic(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function oi(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>oi(e[r],t[r])):false}var Fh=Object.prototype.hasOwnProperty;function ja(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=ju(e)&&ju(t);if(!o&&!(Ic(e)&&Ic(t)))return t;let s=(o?e:Object.keys(e)).length,i=o?t:Object.keys(t),a=i.length,c=o?new Array(a):{},u=0;for(let l=0;l<a;l++){let h=o?l:i[l],S=e[h],g=t[h];if(S===g){c[h]=S,(o?l<s:Fh.call(e,h))&&u++;continue}if(S===null||g===null||typeof S!="object"||typeof g!="object"){c[h]=g;continue}let y=ja(S,g,r+1);c[h]=y,y===S&&u++;}return s===a&&u===s?e:c}function Ka(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return false;for(let r in e)if(e[r]!==t[r])return false;return true}function ju(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ic(e){if(!$u(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!$u(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function $u(e){return Object.prototype.toString.call(e)==="[object Object]"}function Qu(e){return new Promise(t=>{Io.setTimeout(t,e);})}function As(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==false){if(process.env.NODE_ENV!=="production")try{return ja(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return ja(e,t)}return t}function Ku(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function Gu(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var ri=Symbol();function Ga(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===ri&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ri?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ya(e,t){return typeof e=="function"?e(...t):!!e}function Yu(e,t,r){let o=false,n;return Object.defineProperty(e,"signal",{enumerable:true,get:()=>(n??(n=t()),o||(o=true,n.aborted?r():n.addEventListener("abort",r,{once:true})),n)}),e}var vo=(()=>{let e=()=>vc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function Es(){let e,t,r=new Promise((n,s)=>{e=n,t=s;});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject;}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n);},r.reject=n=>{o({status:"rejected",reason:n}),t(n);},r}var Ju=Nu;function Dh(){let e=[],t=0,r=a=>{a();},o=a=>{a();},n=Ju,s=a=>{t?e.push(a):n(()=>{r(a);});},i=()=>{let a=e;e=[],a.length&&n(()=>{o(()=>{a.forEach(c=>{r(c);});});});};return {batch:a=>{let c;t++;try{c=a();}finally{t--,t||i();}return c},batchCalls:a=>(...c)=>{s(()=>{a(...c);});},schedule:s,setNotifyFunction:a=>{r=a;},setBatchNotifyFunction:a=>{o=a;},setScheduler:a=>{n=a;}}}var Tt=Dh();var Ni,_n,ji,Zu,Vh=(Zu=class extends _o{constructor(){super();Y(this,Ni,true);Y(this,_n);Y(this,ji);B(this,ji,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t(true),o=()=>t(false);return window.addEventListener("online",r,false),window.addEventListener("offline",o,false),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o);}}});}onSubscribe(){p(this,_n)||this.setEventListener(p(this,ji));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,_n))==null||t.call(this),B(this,_n,void 0));}setEventListener(t){var r;B(this,ji,t),(r=p(this,_n))==null||r.call(this),B(this,_n,t(this.setOnline.bind(this)));}setOnline(t){p(this,Ni)!==t&&(B(this,Ni,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return p(this,Ni)}},Ni=new WeakMap,_n=new WeakMap,ji=new WeakMap,Zu),$i=new Vh;function Lh(e){return Math.min(1e3*2**e,3e4)}function Pc(e){return (e??"online")==="online"?$i.isOnline():true}var Ja=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function Za(e){let t=false,r=0,o,n=Es(),s=()=>n.status!=="pending",i=C=>{if(!s()){let d=new Ja(C);S(d),e.onCancel?.(d);}},a=()=>{t=true;},c=()=>{t=false;},u=()=>Hi.isFocused()&&(e.networkMode==="always"||$i.isOnline())&&e.canRun(),l=()=>Pc(e.networkMode)&&e.canRun(),h=C=>{s()||(o?.(),n.resolve(C));},S=C=>{s()||(o?.(),n.reject(C));},g=()=>new Promise(C=>{o=d=>{(s()||u())&&C(d);},e.onPause?.();}).then(()=>{o=void 0,s()||e.onContinue?.();}),y=()=>{if(s())return;let C,d=r===0?e.initialPromise:void 0;try{C=d??e.fn();}catch(w){C=Promise.reject(w);}Promise.resolve(C).then(h).catch(w=>{if(s())return;let b=e.retry??(vo.isServer()?0:3),m=e.retryDelay??Lh,f=typeof m=="function"?m(r,w):m,x=b===true||typeof b=="number"&&r<b||typeof b=="function"&&b(r,w);if(t||!x){S(w);return}r++,e.onFail?.(r,w),Qu(f).then(()=>u()?void 0:g()).then(()=>{t?S(w):y();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:a,continueRetry:c,canStart:l,start:()=>(l()?y():g().then(y),n)}}var ni,Xu,Xa=(Xu=class{constructor(){Y(this,ni);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),Bs(this.gcTime)&&B(this,ni,Io.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(vo.isServer()?1/0:300*1e3));}clearGcTimeout(){p(this,ni)!==void 0&&(Io.clearTimeout(p(this,ni)),B(this,ni,void 0));}},ni=new WeakMap,Xu);var ii,qi,to,si,rr,Ms,ai,Hr,np,Qo,rp,op=(rp=class extends Xa{constructor(t){super();Y(this,Hr);Y(this,ii);Y(this,qi);Y(this,to);Y(this,si);Y(this,rr);Y(this,Ms);Y(this,ai);B(this,ai,false),B(this,Ms,t.defaultOptions),this.setOptions(t.options),this.observers=[],B(this,si,t.client),B(this,to,p(this,si).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,B(this,ii,tp(this.options)),this.state=t.state??p(this,ii),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return p(this,rr)?.promise}setOptions(t){if(this.options={...p(this,Ms),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=tp(this.options);r.data!==void 0&&(this.setState(ep(r.data,r.dataUpdatedAt)),B(this,ii,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&p(this,to).remove(this);}setData(t,r){let o=As(this.state.data,t,this.options);return Fe(this,Hr,Qo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Fe(this,Hr,Qo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=p(this,rr)?.promise;return p(this,rr)?.cancel(t),r?r.then(Gt).catch(Gt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return p(this,ii)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Rr(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ri||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>po(t.options.staleTime,this)==="static"):false}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?true:t==="static"?false:this.state.isInvalidated?true:!$a(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),p(this,rr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),p(this,rr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),p(this,to).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(p(this,rr)&&(p(this,ai)||Fe(this,Hr,np).call(this)?p(this,rr).cancel({revert:true}):p(this,rr).cancelRetry()),this.scheduleGc()),p(this,to).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Fe(this,Hr,Qo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&p(this,rr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(p(this,rr))return p(this,rr).continueRetry(),p(this,rr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let c=this.observers.find(u=>u.options.queryFn);c&&this.setOptions(c.options);}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));let o=new AbortController,n=c=>{Object.defineProperty(c,"signal",{enumerable:true,get:()=>(B(this,ai,true),o.signal)});},s=()=>{let c=Ga(this.options,r),l=(()=>{let h={client:p(this,si),queryKey:this.queryKey,meta:this.meta};return n(h),h})();return B(this,ai,false),this.options.persister?this.options.persister(c,l,this):c(l)},a=(()=>{let c={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:p(this,si),state:this.state,fetchFn:s};return n(c),c})();this.options.behavior?.onFetch(a,this),B(this,qi,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&Fe(this,Hr,Qo).call(this,{type:"fetch",meta:a.fetchOptions?.meta}),B(this,rr,Za({initialPromise:r?.initialPromise,fn:a.fetchFn,onCancel:c=>{c instanceof Ja&&c.revert&&this.setState({...p(this,qi),fetchStatus:"idle"}),o.abort();},onFail:(c,u)=>{Fe(this,Hr,Qo).call(this,{type:"failed",failureCount:c,error:u});},onPause:()=>{Fe(this,Hr,Qo).call(this,{type:"pause"});},onContinue:()=>{Fe(this,Hr,Qo).call(this,{type:"continue"});},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>true}));try{let c=await p(this,rr).start();if(c===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(c),p(this,to).config.onSuccess?.(c,this),p(this,to).config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Ja){if(c.silent)return p(this,rr).promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw Fe(this,Hr,Qo).call(this,{type:"error",error:c}),p(this,to).config.onError?.(c,this),p(this,to).config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc();}}},ii=new WeakMap,qi=new WeakMap,to=new WeakMap,si=new WeakMap,rr=new WeakMap,Ms=new WeakMap,ai=new WeakMap,Hr=new WeakSet,np=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Qo=function(t){let r=o=>{switch(t.type){case "failed":return {...o,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case "pause":return {...o,fetchStatus:"paused"};case "continue":return {...o,fetchStatus:"fetching"};case "fetch":return {...o,...Oc(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...ep(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return B(this,qi,t.manual?n:void 0),n;case "error":let s=t.error;return {...o,error:s,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:true};case "invalidate":return {...o,isInvalidated:true};case "setState":return {...o,...t.state}}};this.state=r(this.state),Tt.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),p(this,to).notify({query:this,type:"updated",action:t});});},rp);function Oc(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Pc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ep(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function tp(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return {data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:false,status:r?"success":"pending",fetchStatus:"idle"}}var Ir,Me,Us,Sr,li,Qi,Ko,Rn,Hs,Ki,Gi,ci,di,In,Yi,st,zs,Fc,Dc,Vc,Lc,Bc,Wc,Ac,lp,ap,Mc=(ap=class extends _o{constructor(t,r){super();Y(this,st);Y(this,Ir);Y(this,Me);Y(this,Us);Y(this,Sr);Y(this,li);Y(this,Qi);Y(this,Ko);Y(this,Rn);Y(this,Hs);Y(this,Ki);Y(this,Gi);Y(this,ci);Y(this,di);Y(this,In);Y(this,Yi,new Set);this.options=r,B(this,Ir,t),B(this,Rn,null),B(this,Ko,Es()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(p(this,Me).addObserver(this),ip(p(this,Me),this.options)?Fe(this,st,zs).call(this):this.updateResult(),Fe(this,st,Lc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Ec(p(this,Me),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ec(p(this,Me),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Fe(this,st,Bc).call(this),Fe(this,st,Wc).call(this),p(this,Me).removeObserver(this);}setOptions(t){let r=this.options,o=p(this,Me);if(this.options=p(this,Ir).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Rr(this.options.enabled,p(this,Me))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Fe(this,st,Ac).call(this),p(this,Me).setOptions(this.options),r._defaulted&&!Ka(this.options,r)&&p(this,Ir).getQueryCache().notify({type:"observerOptionsUpdated",query:p(this,Me),observer:this});let n=this.hasListeners();n&&sp(p(this,Me),o,this.options,r)&&Fe(this,st,zs).call(this),this.updateResult(),n&&(p(this,Me)!==o||Rr(this.options.enabled,p(this,Me))!==Rr(r.enabled,p(this,Me))||po(this.options.staleTime,p(this,Me))!==po(r.staleTime,p(this,Me)))&&Fe(this,st,Fc).call(this);let s=Fe(this,st,Dc).call(this);n&&(p(this,Me)!==o||Rr(this.options.enabled,p(this,Me))!==Rr(r.enabled,p(this,Me))||s!==p(this,In))&&Fe(this,st,Vc).call(this,s);}getOptimisticResult(t){let r=p(this,Ir).getQueryCache().build(p(this,Ir),t),o=this.createResult(r,t);return Wh(this,o)&&(B(this,Sr,o),B(this,Qi,this.options),B(this,li,p(this,Me).state)),o}getCurrentResult(){return p(this,Sr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&p(this,Ko).status==="pending"&&p(this,Ko).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){p(this,Yi).add(t);}getCurrentQuery(){return p(this,Me)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=p(this,Ir).defaultQueryOptions(t),o=p(this,Ir).getQueryCache().build(p(this,Ir),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Fe(this,st,zs).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),p(this,Sr)))}createResult(t,r){let o=p(this,Me),n=this.options,s=p(this,Sr),i=p(this,li),a=p(this,Qi),u=t!==o?t.state:p(this,Us),{state:l}=t,h={...l},S=false,g;if(r._optimisticResults){let T=this.hasListeners(),A=!T&&ip(t,r),M=T&&sp(t,o,r,n);(A||M)&&(h={...h,...Oc(l.data,t.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle");}let{error:y,errorUpdatedAt:C,status:d}=h;g=h.data;let w=false;if(r.placeholderData!==void 0&&g===void 0&&d==="pending"){let T;s?.isPlaceholderData&&r.placeholderData===a?.placeholderData?(T=s.data,w=true):T=typeof r.placeholderData=="function"?r.placeholderData(p(this,Gi)?.state.data,p(this,Gi)):r.placeholderData,T!==void 0&&(d="success",g=As(s?.data,T,r),S=true);}if(r.select&&g!==void 0&&!w)if(s&&g===i?.data&&r.select===p(this,Hs))g=p(this,Ki);else try{B(this,Hs,r.select),g=r.select(g),g=As(s?.data,g,r),B(this,Ki,g),B(this,Rn,null);}catch(T){B(this,Rn,T);}p(this,Rn)&&(y=p(this,Rn),g=p(this,Ki),C=Date.now(),d="error");let b=h.fetchStatus==="fetching",m=d==="pending",f=d==="error",x=m&&b,_=g!==void 0,k={status:d,fetchStatus:h.fetchStatus,isPending:m,isSuccess:d==="success",isError:f,isInitialLoading:x,isLoading:x,data:g,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:C,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:b,isRefetching:b&&!m,isLoadingError:f&&!_,isPaused:h.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:f&&_,isStale:zc(t,r),refetch:this.refetch,promise:p(this,Ko),isEnabled:Rr(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let T=k.data!==void 0,A=k.status==="error"&&!T,M=z=>{A?z.reject(k.error):T&&z.resolve(k.data);},O=()=>{let z=B(this,Ko,k.promise=Es());M(z);},v=p(this,Ko);switch(v.status){case "pending":t.queryHash===o.queryHash&&M(v);break;case "fulfilled":(A||k.data!==v.value)&&O();break;case "rejected":(!A||k.error!==v.reason)&&O();break}}return k}updateResult(){let t=p(this,Sr),r=this.createResult(p(this,Me),this.options);if(B(this,li,p(this,Me).state),B(this,Qi,this.options),p(this,li).data!==void 0&&B(this,Gi,p(this,Me)),Ka(r,t))return;B(this,Sr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,s=typeof n=="function"?n():n;if(s==="all"||!s&&!p(this,Yi).size)return true;let i=new Set(s??p(this,Yi));return this.options.throwOnError&&i.add("error"),Object.keys(p(this,Sr)).some(a=>{let c=a;return p(this,Sr)[c]!==t[c]&&i.has(c)})};Fe(this,st,lp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Fe(this,st,Lc).call(this);}},Ir=new WeakMap,Me=new WeakMap,Us=new WeakMap,Sr=new WeakMap,li=new WeakMap,Qi=new WeakMap,Ko=new WeakMap,Rn=new WeakMap,Hs=new WeakMap,Ki=new WeakMap,Gi=new WeakMap,ci=new WeakMap,di=new WeakMap,In=new WeakMap,Yi=new WeakMap,st=new WeakSet,zs=function(t){Fe(this,st,Ac).call(this);let r=p(this,Me).fetch(this.options,t);return t?.throwOnError||(r=r.catch(Gt)),r},Fc=function(){Fe(this,st,Bc).call(this);let t=po(this.options.staleTime,p(this,Me));if(vo.isServer()||p(this,Sr).isStale||!Bs(t))return;let o=$a(p(this,Sr).dataUpdatedAt,t)+1;B(this,ci,Io.setTimeout(()=>{p(this,Sr).isStale||this.updateResult();},o));},Dc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(p(this,Me)):this.options.refetchInterval)??false},Vc=function(t){Fe(this,st,Wc).call(this),B(this,In,t),!(vo.isServer()||Rr(this.options.enabled,p(this,Me))===false||!Bs(p(this,In))||p(this,In)===0)&&B(this,di,Io.setInterval(()=>{(this.options.refetchIntervalInBackground||Hi.isFocused())&&Fe(this,st,zs).call(this);},p(this,In)));},Lc=function(){Fe(this,st,Fc).call(this),Fe(this,st,Vc).call(this,Fe(this,st,Dc).call(this));},Bc=function(){p(this,ci)!==void 0&&(Io.clearTimeout(p(this,ci)),B(this,ci,void 0));},Wc=function(){p(this,di)!==void 0&&(Io.clearInterval(p(this,di)),B(this,di,void 0));},Ac=function(){let t=p(this,Ir).getQueryCache().build(p(this,Ir),this.options);if(t===p(this,Me))return;let r=p(this,Me);B(this,Me,t),B(this,Us,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},lp=function(t){Tt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(p(this,Sr));}),p(this,Ir).getQueryCache().notify({query:p(this,Me),type:"observerResultsUpdated"});});},ap);function Bh(e,t){return Rr(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function ip(e,t){return Bh(e,t)||e.state.data!==void 0&&Ec(e,t,t.refetchOnMount)}function Ec(e,t,r){if(Rr(t.enabled,e)!==false&&po(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&zc(e,t)}return false}function sp(e,t,r,o){return (e!==t||Rr(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&zc(e,r)}function zc(e,t){return Rr(t.enabled,e)!==false&&e.isStaleByTime(po(t.staleTime,e))}function Wh(e,t){return !Ka(e.getCurrentResult(),t)}function Uc(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],i=t.state.data?.pageParams||[],a={pages:[],pageParams:[]},c=0,u=async()=>{let l=false,h=y=>{Yu(y,()=>t.signal,()=>l=true);},S=Ga(t.options,t.fetchOptions),g=async(y,C,d)=>{if(l)return Promise.reject();if(C==null&&y.pages.length)return Promise.resolve(y);let b=(()=>{let _={client:t.client,queryKey:t.queryKey,pageParam:C,direction:d?"backward":"forward",meta:t.options.meta};return h(_),_})(),m=await S(b),{maxPages:f}=t.options,x=d?Gu:Ku;return {pages:x(y.pages,m,f),pageParams:x(y.pageParams,C,f)}};if(n&&s.length){let y=n==="backward",C=y?Ah:cp,d={pages:s,pageParams:i},w=C(o,d);a=await g(d,w,y);}else {let y=e??s.length;do{let C=c===0?i[0]??o.initialPageParam:cp(o,a);if(c>0&&C==null)break;a=await g(a,C),c++;}while(c<y)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u;}}}function cp(e,{pages:t,pageParams:r}){let o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function Ah(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var Ns,Po,hr,ui,Oo,vn,dp,up=(dp=class extends Xa{constructor(t){super();Y(this,Oo);Y(this,Ns);Y(this,Po);Y(this,hr);Y(this,ui);B(this,Ns,t.client),this.mutationId=t.mutationId,B(this,hr,t.mutationCache),B(this,Po,[]),this.state=t.state||Eh(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){p(this,Po).includes(t)||(p(this,Po).push(t),this.clearGcTimeout(),p(this,hr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){B(this,Po,p(this,Po).filter(r=>r!==t)),this.scheduleGc(),p(this,hr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){p(this,Po).length||(this.state.status==="pending"?this.scheduleGc():p(this,hr).remove(this));}continue(){return p(this,ui)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Fe(this,Oo,vn).call(this,{type:"continue"});},o={client:p(this,Ns),meta:this.options.meta,mutationKey:this.options.mutationKey};B(this,ui,Za({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{Fe(this,Oo,vn).call(this,{type:"failed",failureCount:i,error:a});},onPause:()=>{Fe(this,Oo,vn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(this,hr).canRun(this)}));let n=this.state.status==="pending",s=!p(this,ui).canStart();try{if(n)r();else {Fe(this,Oo,vn).call(this,{type:"pending",variables:t,isPaused:s}),p(this,hr).config.onMutate&&await p(this,hr).config.onMutate(t,this,o);let a=await this.options.onMutate?.(t,o);a!==this.state.context&&Fe(this,Oo,vn).call(this,{type:"pending",context:a,variables:t,isPaused:s});}let i=await p(this,ui).start();return await p(this,hr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await p(this,hr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Fe(this,Oo,vn).call(this,{type:"success",data:i}),i}catch(i){try{await p(this,hr).config.onError?.(i,t,this.state.context,this,o);}catch(a){Promise.reject(a);}try{await this.options.onError?.(i,t,this.state.context,o);}catch(a){Promise.reject(a);}try{await p(this,hr).config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,o);}catch(a){Promise.reject(a);}try{await this.options.onSettled?.(void 0,i,t,this.state.context,o);}catch(a){Promise.reject(a);}throw Fe(this,Oo,vn).call(this,{type:"error",error:i}),i}finally{p(this,hr).runNext(this);}}},Ns=new WeakMap,Po=new WeakMap,hr=new WeakMap,ui=new WeakMap,Oo=new WeakSet,vn=function(t){let r=o=>{switch(t.type){case "failed":return {...o,failureCount:t.failureCount,failureReason:t.error};case "pause":return {...o,isPaused:true};case "continue":return {...o,isPaused:false};case "pending":return {...o,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case "success":return {...o,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:false};case "error":return {...o,data:void 0,error:t.error,failureCount:o.failureCount+1,failureReason:t.error,isPaused:false,status:"error"}}};this.state=r(this.state),Tt.batch(()=>{p(this,Po).forEach(o=>{o.onMutationUpdate(t);}),p(this,hr).notify({mutation:this,type:"updated",action:t});});},dp);function Eh(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Go,mo,js,pp,mp=(pp=class extends _o{constructor(t={}){super();Y(this,Go);Y(this,mo);Y(this,js);this.config=t,B(this,Go,new Set),B(this,mo,new Map),B(this,js,0);}build(t,r,o){let n=new up({client:t,mutationCache:this,mutationId:++ys(this,js)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){p(this,Go).add(t);let r=el(t);if(typeof r=="string"){let o=p(this,mo).get(r);o?o.push(t):p(this,mo).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(p(this,Go).delete(t)){let r=el(t);if(typeof r=="string"){let o=p(this,mo).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&p(this,mo).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=el(t);if(typeof r=="string"){let n=p(this,mo).get(r)?.find(s=>s.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=el(t);return typeof r=="string"?p(this,mo).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Tt.batch(()=>{p(this,Go).forEach(t=>{this.notify({type:"removed",mutation:t});}),p(this,Go).clear(),p(this,mo).clear();});}getAll(){return Array.from(p(this,Go))}find(t){let r={exact:true,...t};return this.getAll().find(o=>Qa(r,o))}findAll(t={}){return this.getAll().filter(r=>Qa(t,r))}notify(t){Tt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return Tt.batch(()=>Promise.all(t.map(r=>r.continue().catch(Gt))))}},Go=new WeakMap,mo=new WeakMap,js=new WeakMap,pp);function el(e){return e.options.scope?.id}var Fo,fp,hp=(fp=class extends _o{constructor(t={}){super();Y(this,Fo);this.config=t,B(this,Fo,new Map);}build(t,r,o){let n=r.queryKey,s=r.queryHash??Ws(n,r),i=this.get(s);return i||(i=new op({client:t,queryKey:n,queryHash:s,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){p(this,Fo).has(t.queryHash)||(p(this,Fo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=p(this,Fo).get(t.queryHash);r&&(t.destroy(),r===t&&p(this,Fo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){Tt.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return p(this,Fo).get(t)}getAll(){return [...p(this,Fo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>qa(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>qa(t,o)):r}notify(t){Tt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){Tt.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){Tt.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Fo=new WeakMap,fp);var Mt,Pn,On,Ji,Zi,Fn,Xi,es,gp,Hc=(gp=class{constructor(e={}){Y(this,Mt);Y(this,Pn);Y(this,On);Y(this,Ji);Y(this,Zi);Y(this,Fn);Y(this,Xi);Y(this,es);B(this,Mt,e.queryCache||new hp),B(this,Pn,e.mutationCache||new mp),B(this,On,e.defaultOptions||{}),B(this,Ji,new Map),B(this,Zi,new Map),B(this,Fn,0);}mount(){ys(this,Fn)._++,p(this,Fn)===1&&(B(this,Xi,Hi.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,Mt).onFocus());})),B(this,es,$i.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,Mt).onOnline());})));}unmount(){var e,t;ys(this,Fn)._--,p(this,Fn)===0&&((e=p(this,Xi))==null||e.call(this),B(this,Xi,void 0),(t=p(this,es))==null||t.call(this),B(this,es,void 0));}isFetching(e){return p(this,Mt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return p(this,Pn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,Mt).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=p(this,Mt).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(po(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return p(this,Mt).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),s=p(this,Mt).get(o.queryHash)?.state.data,i=qu(t,s);if(i!==void 0)return p(this,Mt).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return Tt.batch(()=>p(this,Mt).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,Mt).get(t.queryHash)?.state}removeQueries(e){let t=p(this,Mt);Tt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=p(this,Mt);return Tt.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=Tt.batch(()=>p(this,Mt).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Gt).catch(Gt)}invalidateQueries(e,t={}){return Tt.batch(()=>(p(this,Mt).findAll(e).forEach(r=>{r.invalidate();}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??true},o=Tt.batch(()=>p(this,Mt).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let s=n.fetch(void 0,r);return r.throwOnError||(s=s.catch(Gt)),n.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(o).then(Gt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=p(this,Mt).build(this,t);return r.isStaleByTime(po(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Gt).catch(Gt)}fetchInfiniteQuery(e){return e.behavior=Uc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Gt).catch(Gt)}ensureInfiniteQueryData(e){return e.behavior=Uc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return $i.isOnline()?p(this,Pn).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(this,Mt)}getMutationCache(){return p(this,Pn)}getDefaultOptions(){return p(this,On)}setDefaultOptions(e){B(this,On,e);}setQueryDefaults(e,t){p(this,Ji).set(ti(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...p(this,Ji).values()],r={};return t.forEach(o=>{oi(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){p(this,Zi).set(ti(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...p(this,Zi).values()],r={};return t.forEach(o=>{oi(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...p(this,On).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Ws(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ri&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...p(this,On).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){p(this,Mt).clear(),p(this,Pn).clear();}},Mt=new WeakMap,Pn=new WeakMap,On=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,Fn=new WeakMap,Xi=new WeakMap,es=new WeakMap,gp);var Nc=Dn.createContext(void 0),jc=e=>{let t=Dn.useContext(Nc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},$c=({client:e,children:t})=>(Dn.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(Nc.Provider,{value:e,children:t}));var yp=Dn.createContext(false),bp=()=>Dn.useContext(yp);yp.Provider;function zh(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var Uh=Dn.createContext(zh()),Cp=()=>Dn.useContext(Uh);var kp=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?Ya(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Sp=e=>{Dn.useEffect(()=>{e.clearReset();},[e]);},Tp=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||Ya(r,[e.error,o]));var xp=e=>{if(e.suspense){let r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3));}},_p=(e,t)=>e.isLoading&&e.isFetching&&!t,Rp=(e,t)=>e?.suspense&&t.isPending,qc=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Ip(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let o=bp(),n=Cp(),s=jc(),i=s.defaultQueryOptions(e);s.getDefaultOptions().queries?._experimental_beforeQuery?.(i);let a=s.getQueryCache().get(i.queryHash);process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=o?"isRestoring":"optimistic",xp(i),kp(i,n,a),Sp(n);let c=!s.getQueryCache().get(i.queryHash),[u]=Dn.useState(()=>new t(s,i)),l=u.getOptimisticResult(i),h=!o&&e.subscribed!==false;if(Dn.useSyncExternalStore(Dn.useCallback(S=>{let g=h?u.subscribe(Tt.batchCalls(S)):Gt;return u.updateResult(),g},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Dn.useEffect(()=>{u.setOptions(i);},[i,u]),Rp(i,l))throw qc(i,u,n);if(Tp({result:l,errorResetBoundary:n,throwOnError:i.throwOnError,query:a,suspense:i.suspense}))throw l.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(i,l),i.experimental_prefetchInRender&&!vo.isServer()&&_p(l,o)&&(c?qc(i,u,n):a?.promise)?.catch(Gt).finally(()=>{u.updateResult();}),i.notifyOnChangeProps?l:u.trackResult(l)}function Yo(e,t){return Ip(e,Mc)}var os=new Map;function vp({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function Ln({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:s="transparent",backgroundColor:i="transparent",style:a}){let{colors:c}=V(),[u,l]=useState(false),[h,S]=useState(false),[g,y]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let x=os.get(e);return x?{uri:e,xml:x}:null}),C=e?.toLowerCase().endsWith(".svg"),d=C&&e&&g?.uri===e?g.xml:null;useEffect(()=>{l(false),S(false);},[e]),useEffect(()=>{if(!C||!e)return;if(os.has(e)){y({uri:e,xml:os.get(e)});return}let x=false;return fetch(e).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.text()}).then(_=>{x||(os.set(e,_),y({uri:e,xml:_}));}).catch(()=>{x||l(true);}),()=>{x=true;}},[e,C]);let w=c.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:w},a]});let b={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:s,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...a},m=t-n*2,f=r-n*2;return u?jsx(View,{style:[b,{backgroundColor:i||w}]}):C?jsxs(View,{style:b,children:[!!!d&&jsx(vp,{width:m,height:f,borderRadius:o,color:w}),d?jsx(SvgXml,{xml:d,width:m,height:f,onError:()=>l(true)}):jsx(SvgUri,{uri:e,width:m,height:f,onError:()=>l(true)})]}):jsxs(View,{style:b,children:[!h&&jsx(vp,{width:m,height:f,borderRadius:o,color:w}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:m,height:f},resizeMode:"contain",onLoad:()=>S(true),onError:()=>l(true)})]})}function Gc(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(os.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{os.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Tr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:s,badge:i,showBalance:a=false,balanceAddress:c,balanceChainType:u,balanceChainId:l,balanceTokenAddress:h,publishableKey:S,projectName:g,leftIcon:y,onLeftAction:C}){let{colors:d,fonts:w,components:b}=V(),[m,f]=useState(null),[x,_]=useState(false),F=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!x)return;let T=Animated.loop(Animated.sequence([Animated.timing(F,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(F,{toValue:0,duration:700,useNativeDriver:true})]));return T.start(),()=>T.stop()},[x,F]),useEffect(()=>{if(!a||!c||!u||!l||!h||!S){f(null),_(false);return}let T=false;return _(true),Ta(c,u,l,h,S).then(A=>{if(T)return;let M=A.balance,O=null;M&&(M.amount_usd!=null&&M.amount_usd!==""?O=`$${M.amount_usd}`:O="$0.00"),f(O);}).catch(()=>{T||f(null);}).finally(()=>{T||_(false);}),()=>{T=true;}},[a,c,u,l,h,S]);let k=F.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:gr.header,children:[jsx(View,{style:gr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Cs,{size:20,color:b.header.buttonColor,strokeWidth:2})}):y&&C?jsx(TouchableOpacity,{onPress:C,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:y}):jsx(View,{style:gr.spacer})}),jsxs(View,{style:gr.titleContainer,children:[jsxs(View,{style:gr.titleRow,children:[jsx(Text,{style:[gr.title,{color:b.header.titleColor,fontFamily:w.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[gr.titleBadge,{backgroundColor:d.card}],children:jsx(Text,{style:[gr.titleBadgeText,{color:d.foregroundMuted,fontFamily:w.regular}],children:i.count})})]}),t?jsx(Text,{style:[gr.balanceText,{color:d.foregroundMuted,fontFamily:w.regular}],children:t}):null,a&&(x?jsx(Animated.View,{style:[gr.balanceSkeleton,{backgroundColor:d.cardHover,opacity:k}]}):m!=null?jsxs(Text,{style:[gr.balanceText,{color:d.foregroundMuted,fontFamily:w.regular}],children:[g?`${g} `:"","Balance: ",m]}):null)]}),jsx(View,{style:gr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:s,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(nt,{size:20,color:b.header.buttonColor,strokeWidth:2})}):jsx(View,{style:gr.spacer})})]})}var gr=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,alignItems:"center"},titleRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},balanceSkeleton:{height:10,width:120,borderRadius:5,marginTop:4},balanceText:{fontSize:14,marginTop:3,textAlign:"center"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function Yt({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:s}){let{components:i}=V(),a=s??i.card,c=a.backShadowColor!=="transparent",u={backgroundColor:a.backgroundColor,borderRadius:a.borderRadius,borderWidth:a.borderWidth,borderColor:a.borderColor},l=[Dp.wrapper,t,c&&{marginBottom:a.backShadowSpacing}],h=[u,r];return jsxs(View,{style:l,children:[c&&jsx(View,{style:[Dp.backShadow,{top:a.backShadowOffset.top,left:a.backShadowOffset.left,right:a.backShadowOffset.right,bottom:a.backShadowOffset.bottom,backgroundColor:a.backShadowColor,borderRadius:a.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:h,children:e}):jsx(View,{style:h,children:e})]})}var Dp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function qs({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:s}=V(),i=s.depositMenu.card,a=o?[...o].sort((c,u)=>c.position-u.position):[];return jsxs(Yt,{cardTokens:i,onPress:e,style:Do.wrapper,contentStyle:Do.container,children:[jsxs(View,{style:Do.leftContent,children:[jsx(View,{style:[Do.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Ql,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Do.textContainer,children:[jsx(Text,{style:[Do.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Do.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Do.rightContent,children:jsx(View,{style:Do.networkIcons,children:a.map((c,u)=>{let l=c.icon_urls.find(h=>h.format==="png")?.url||c.icon_urls.find(h=>h.format==="svg")?.url;return jsx(View,{style:[Do.networkIconWrapper,{marginLeft:u===0?0:-6,zIndex:a.length-u}],children:jsx(Ln,{uri:J(l),width:20,height:20})},c.name)})})})]})}var Do=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,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 Ks({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:s}=V(),i=s.depositMenu.card;return jsxs(Yt,{cardTokens:i,onPress:e,style:Jo.wrapper,contentStyle:Jo.container,children:[jsxs(View,{style:Jo.leftContent,children:[jsx(View,{style:[Jo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(vi,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Jo.textContainer,children:[jsx(Text,{style:[Jo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Jo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Jo.rightContent,children:jsx(View,{style:Jo.paymentIcons,children:o?.map(a=>{let c=a.icon_urls.find(u=>u.format==="png")?.url||a.icon_urls.find(u=>u.format==="svg")?.url;return jsx(Ln,{uri:J(c),width:32,height:20,borderRadius:4},a.name)})})})]})}var Jo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,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 Gs({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:s}=V(),i=s.depositMenu.card;return jsx(Yt,{cardTokens:i,onPress:e,style:Zo.wrapper,contentStyle:Zo.container,children:jsxs(View,{style:Zo.leftContent,children:[jsxs(View,{style:[Zo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(yo,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[Zo.badge,{backgroundColor:i.iconColor,borderRadius:s.badge.borderRadius}],children:jsx(Text,{style:[Zo.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:Zo.textContainer,children:[jsx(Text,{style:[Zo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Zo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var Zo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,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 Js({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=V(),s=n.depositMenu.card;return jsxs(Yt,{cardTokens:s,onPress:e,style:Vo.wrapper,contentStyle:Vo.container,children:[jsxs(View,{style:Vo.leftContent,children:[jsx(View,{style:[Vo.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:jsx(fa,{size:20,color:s.iconColor,strokeWidth:2})}),jsxs(View,{style:Vo.textContainer,children:[jsx(Text,{style:[Vo.title,{color:s.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Vo.subtitle,{color:s.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Vo.rightContent,children:jsx(View,{style:Vo.badge,children:jsx(Text,{style:[Vo.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Vo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,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},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var Wp=1e4,Ap=2500,Ep=3e3,Mp=6e4;function Zs(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:s,modalOpenedAt:i,depositWalletId:a,depositExecutions:c,trackedExecutions:u,setDepositExecutions:l,setTrackedExecutions:h,setLatestExecution:S,setShowStatusSheet:g,onDepositSuccess:y,onExecutionsChange:C,onDepositError:d}=e,[w,b]=useState(false),[m,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;b(false),t==="auto_ui"&&f(false);let _=setTimeout(()=>{b(true),t==="auto_ui"&&f(true);},Wp);return ()=>clearTimeout(_)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let _=new Date(i.getTime()-Mp),F=setInterval(async()=>{try{let A=[...(await No(n,s)).data??[]].sort((O,v)=>{let z=O.created_at?new Date(O.created_at).getTime():0;return (v.created_at?new Date(v.created_at).getTime():0)-z}),M=null;for(let O of A){let v=O.created_at?new Date(O.created_at):null;if(!v||v<=_)continue;let z=u.get(O.id);if(!z){M=O;break}if(["pending","waiting","delayed"].includes(z)&&O.status==="succeeded"){M=O;break}}if(M){let O=M;l(v=>{let z=v.findIndex(E=>E.id===O.id);if(z>=0){let E=[...v];return E[z]=O,E}return [...v,O]}),h(v=>{let z=new Map(v);return z.set(O.id,O.status),z}),S(O),g(!0),O.status==="succeeded"&&y?.({message:"Deposit completed successfully",executionId:O.id}),C?.([...c,O]);}}catch(k){d?.({message:"Failed to check deposit status",error:k});}},Ap);return ()=>clearInterval(F)},[n,s,i,u,c,C,y,d]),useEffect(()=>{if(!w||!a)return;let _=async()=>{try{await Ca(a,s);}catch{}};_();let F=setInterval(_,Ep);return ()=>clearInterval(F)},[w,a,s]),{pollingEnabled:w,showWaitingUi:m,handleIveDeposited:()=>{b(true),f(true);}}}function as({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:s,isDark:i}=V(),a=i?"#1a1a1a":"#ffffff",c=i?"#ffffff":"#000000",u=n||a;return jsxs(View,{style:[Up.container,{width:t,height:t}],children:[jsx(eg,{value:e||"placeholder",size:t,backgroundColor:a,color:c,ecl:"H",quietZone:4}),r&&jsx(View,{style:[Up.logoContainer,{width:o+12,height:o+12,backgroundColor:u,borderRadius:(o+12)/2}],children:jsx(Ln,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var Up=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function jp(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function ng(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),s=e.getHours(),i=e.getMinutes(),a=s>=12?"pm":"am";s=s%12,s=s||12;let c=i<10?`0${i}`:i;return `${r} ${o}, ${n} at ${s}:${c}${a}`}function ls({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:s,amountUsd:i,onClose:a,borderTopLeftRadius:c,borderTopRightRadius:u}){let{colors:l,fonts:h,components:S}=V(),[g,y]=useState(false),C=t==="pending"||t==="waiting"||t==="delayed",d=t==="succeeded",w=()=>{o&&Linking.openURL(o);},b=()=>{n&&Linking.openURL(n);};return jsx(Ze,{visible:e,onClose:a,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:c,borderTopRightRadius:u,children:jsxs(View,{style:Ft.container,children:[jsx(TouchableOpacity,{style:Ft.closeButton,onPress:a,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(nt,{size:20,color:S.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Ft.iconContainer,children:C?jsx(yt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:J(r)},style:Ft.tokenIconFill}):jsx(View,{style:[Ft.tokenIconFill,{backgroundColor:l.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:J(r)},style:Ft.tokenIconLarge}):jsx(View,{style:[Ft.tokenIconLarge,{backgroundColor:l.cardHover}]}),jsx(View,{style:[Ft.statusBadge,{backgroundColor:S.container.iconBackgroundColor}],children:jsx($e,{size:16,color:S.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Ft.title,{color:S.container.titleColor,fontFamily:h.semibold}],children:C?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Ft.amount,{color:S.container.titleColor,fontFamily:h.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),s&&jsx(Text,{style:[Ft.date,{color:S.container.subtitleColor,fontFamily:h.regular}],children:ng(s)}),jsx(Text,{style:[Ft.subtitle,{color:S.container.subtitleColor,fontFamily:h.regular}],children:C?"This usually takes less than a minute.":"Your account has been credited successfully!"}),d&&(o||n)&&jsxs(View,{style:Ft.detailsSection,children:[jsx(View,{style:[Ft.divider,{backgroundColor:l.border}]}),jsxs(TouchableOpacity,{style:Ft.detailsToggle,onPress:()=>y(!g),children:[jsx(Text,{style:[Ft.detailsToggleText,{color:S.container.actionTitle,fontFamily:h.medium}],children:g?"See less":"See more details"}),g?jsx(Co,{size:18,color:S.container.actionColor,strokeWidth:2}):jsx(Ot,{size:18,color:S.container.actionColor,strokeWidth:2})]}),g&&jsxs(View,{style:Ft.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Ft.txButton,{backgroundColor:S.card.backgroundColor,borderColor:l.border}],onPress:w,children:[jsx(Text,{style:[Ft.txLabel,{color:S.card.titleColor,fontFamily:h.medium}],children:"Deposit tx"}),jsx(Text,{style:[Ft.txHash,{color:S.card.subtitleColor,fontFamily:h.regular}],children:jp(o)}),jsx(bo,{size:16,color:S.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Ft.txButton,{backgroundColor:S.card.backgroundColor,borderColor:l.border}],onPress:b,children:[jsx(Text,{style:[Ft.txLabel,{color:S.card.titleColor,fontFamily:h.medium}],children:"Completion tx"}),jsx(Text,{style:[Ft.txHash,{color:S.card.subtitleColor,fontFamily:h.regular}],children:jp(n)}),jsx(bo,{size:16,color:S.card.actionColor,strokeWidth:2})]})]})]})]})})}var Ft=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});function al({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:s,fonts:i,components:a}=V();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[fi.iveDepositedButton,{backgroundColor:s.primary,borderRadius:a.button.borderRadius,borderWidth:a.button.borderWidth,borderColor:a.button.borderColor}],children:jsx(Text,{style:[fi.iveDepositedButtonText,{color:s.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[fi.processingCard,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor,shadowColor:a.card.shadowOpacity>0?a.card.shadowColor:void 0,shadowOffset:a.card.shadowOpacity>0?a.card.shadowOffset:void 0,shadowOpacity:a.card.shadowOpacity,shadowRadius:a.card.shadowRadius,elevation:a.card.elevation}],children:[jsx(View,{style:[fi.detailIcon,{backgroundColor:a.card.iconBackgroundColor,borderRadius:a.card.iconContainerBorderRadius}],children:jsx(Kl,{size:14,color:a.card.iconColor,strokeWidth:2})}),jsxs(View,{style:fi.processingCardText,children:[jsx(Text,{style:[fi.processingCardTitle,{color:a.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[fi.processingCardSubtitle,{color:a.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var fi=StyleSheet.create({iveDepositedButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginBottom:12},iveDepositedButtonText:{fontSize:16},processingCard:{flexDirection:"row",alignItems:"center",padding:12,marginBottom:12,gap:12},processingCardText:{flex:1,gap:4},processingCardTitle:{fontSize:14},processingCardSubtitle:{fontSize:12,lineHeight:18},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"}});var Xs=(e,t)=>`${t}:${e}`,mg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function cl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:s,destinationTokenSymbol:i,defaultChainType:a,defaultChainId:c,defaultTokenAddress:u,depositConfirmationMode:l="auto_ui",onExecutionsChange:h,onDepositSuccess:S,onDepositError:g,borderTopLeftRadius:y,borderTopRightRadius:C,sheetBorderRadius:d}){let{colors:w,fonts:b,components:m}=V(),f=a&&c?`${a}:${c}`:"solana:mainnet",[x,_]=useState("USDC"),[F,k]=useState(f),[T,A]=useState([]),[M,O]=useState(true),[v,z]=useState([]),[E,de]=useState(true),[Qe,We]=useState(false),[oe,ae]=useState(false),[be,Ie]=useState(false),[rt,Ne]=useState(false),[Se,ue]=useState([]),[Te,Ke]=useState(new Map),[lt]=useState(()=>new Date),[ve,Ve]=useState(null),[Be,X]=useState(false),[q,Ce]=useState(null),[dt,W]=useState(false),L=new Map;v.forEach($=>{$.chains.forEach(re=>{let xe=`${re.chain_type}:${re.chain_id}`;L.has(xe)||L.set(xe,re);});});let ee=Array.from(L.values()),le=mg(F),wt=ee.find($=>$.chain_type===le.chainType&&$.chain_id===le.chainId)?.chain_type||"ethereum",ut=Ho(T,wt),Ye=ut?.address||"",je=useRef(false);useEffect(()=>{async function $(){try{de(!0),Ve(null);let xe=await qn(t,s&&n&&o?{destination_token_address:s,destination_chain_id:n,destination_chain_type:o}:void 0);if(z(xe.data),xe.data.length>0&&!je.current){je.current=!0;let me,ne;if(a&&c)if(u)for(let P of xe.data){let gt=P.chains.find(Pe=>Pe.chain_type===a&&Pe.chain_id===c&&Pe.token_address.toLowerCase()===u.toLowerCase());if(gt){me=P,ne=gt;break}}else for(let P of xe.data){let gt=P.chains.find(Pe=>Pe.chain_type===a&&Pe.chain_id===c);if(gt){me=P,ne=gt;break}}if(!me&&s)for(let P of xe.data){let gt=P.chains.find(Pe=>Pe.token_address.toLowerCase()===s.toLowerCase());if(gt){me=P,ne=gt;break}}me||(me=xe.data.find(P=>P.symbol==="USDC"),me&&me.chains.length>0&&(ne=me.chains[0])),me||(me=xe.data.find(P=>P.symbol==="USDT"),me&&me.chains.length>0&&(ne=me.chains[0])),me||(me=xe.data[0],me.chains.length>0&&(ne=me.chains[0])),me&&_(me.symbol),ne&&k(Xs(ne.chain_id,ne.chain_type));}}catch(re){console.error("Error fetching supported tokens:",re),Ve("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:re});}finally{de(false);}}$();},[t,g,a,c,u,s,n,o]),useEffect(()=>{async function $(){try{O(!0),Ve(null);let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:s},t);A(re.data);}catch(re){console.error("Error fetching wallets:",re),Ve("Failed to load wallets"),g?.({message:"Failed to load wallets",error:re});}finally{O(false);}}$();},[e,r,o,n,s,t,g]);let Pt=ut?.id??"",{showWaitingUi:_t,handleIveDeposited:ir}=Zs({depositConfirmationMode:l,depositAddress:Ye,chain:F,externalUserId:e,publishableKey:t,modalOpenedAt:lt,depositWalletId:Pt,depositExecutions:Se,trackedExecutions:Te,setDepositExecutions:ue,setTrackedExecutions:Ke,setLatestExecution:Ce,setShowStatusSheet:X,onDepositSuccess:S,onExecutionsChange:h,onDepositError:g});useEffect(()=>{if(!v.length)return;let $=v.find(xe=>xe.symbol===x);if(!$||$.chains.length===0)return;if(!$.chains.some(xe=>Xs(xe.chain_id,xe.chain_type)===F)){let xe=$.chains[0];k(Xs(xe.chain_id,xe.chain_type));}},[x,v,F]);let Ae=v.find($=>$.symbol===x),ot=Ae?.chains||[],pt=ot.find($=>Xs($.chain_id,$.chain_type)===F),Or=async()=>{if(Ye)try{Clipboard.setString(Ye),We(!0),setTimeout(()=>We(!1),2e3);}catch($){console.error("Failed to copy:",$);}},Cr=pt?.estimated_price_impact_percent??0,ce=pt?.max_slippage_percent??.25,tt=pt?.minimum_deposit_amount_usd??3;if(E)return jsxs(View,{style:D.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:w.primary}),jsx(Text,{style:[D.loadingText,{color:w.foregroundMuted,fontFamily:b.regular}],children:"Loading currencies..."})]});if(ve&&v.length===0)return jsxs(View,{style:D.errorContainer,children:[jsx(Text,{style:[D.errorText,{color:w.error,fontFamily:b.regular}],children:ve}),jsx(Text,{style:[D.errorHint,{color:w.foregroundMuted,fontFamily:b.regular}],children:"Please check your network connection and try again."})]});let fe=()=>jsxs(Ze,{visible:be,onClose:()=>Ie(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:d?.tokenSelector?.borderTopLeftRadius??y,borderTopRightRadius:d?.tokenSelector?.borderTopRightRadius??C,children:[jsxs(View,{style:[D.sheetHeader,{borderBottomColor:w.border}],children:[jsx(View,{style:D.sheetHeaderSpacer}),jsx(Text,{style:[D.sheetTitle,{color:m.header.titleColor,fontFamily:b.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Ie(false),style:D.sheetCloseButton,children:jsx(nt,{size:20,color:m.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:D.sheetList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:v.map($=>jsxs(TouchableOpacity$1,{onPress:()=>{_($.symbol),Ie(false);},activeOpacity:.7,style:[D.sheetItem,{backgroundColor:x===$.symbol?m.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:J(ge($,"png"))},style:D.sheetItemIcon}),jsxs(View,{style:D.sheetItemText,children:[jsx(Text,{style:[D.sheetItemTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:$.symbol}),jsxs(Text,{style:[D.sheetItemSubtitle,{color:m.card.subtitleColor,fontFamily:b.regular}],children:[$.chains.length," network",$.chains.length!==1?"s":""," available"]})]}),x===$.symbol&&jsx($e,{size:20,color:w.primary,strokeWidth:2})]},$.symbol))})]}),Je=()=>jsxs(Ze,{visible:rt,onClose:()=>Ne(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:d?.chainSelector?.borderTopLeftRadius??y,borderTopRightRadius:d?.chainSelector?.borderTopRightRadius??C,children:[jsxs(View,{style:[D.sheetHeader,{borderBottomColor:w.border}],children:[jsx(View,{style:D.sheetHeaderSpacer}),jsx(Text,{style:[D.sheetTitle,{color:m.header.titleColor,fontFamily:b.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>Ne(false),style:D.sheetCloseButton,children:jsx(nt,{size:20,color:m.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:D.sheetList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:ot.map($=>{let re=Xs($.chain_id,$.chain_type),xe=F===re;return jsxs(TouchableOpacity$1,{onPress:()=>{k(re),Ne(false);},activeOpacity:.7,style:[D.sheetItem,{backgroundColor:xe?m.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:J(ge($,"png"))},style:D.sheetItemIcon}),jsxs(View,{style:D.sheetItemText,children:[jsx(Text,{style:[D.sheetItemTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:$.chain_name}),jsxs(Text,{style:[D.sheetItemSubtitle,{color:m.card.subtitleColor,fontFamily:b.regular}],children:["Min deposit: $",$.minimum_deposit_amount_usd]})]}),xe&&jsx($e,{size:20,color:w.primary,strokeWidth:2})]},re)})})]});return jsxs(View,{style:D.container,children:[jsxs(View,{style:D.selectorSection,children:[jsx(Text,{style:[D.selectorLabel,{color:m.card.labelColor,fontFamily:b.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Ie(true),style:[D.selector,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[Ae&&jsx(Image,{source:{uri:J(ge(Ae,"png"))},style:D.selectorIcon}),jsx(Text,{style:[D.selectorText,{color:m.card.titleColor,fontFamily:b.medium}],children:x}),jsx(Ot,{size:16,color:m.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:D.selectorSection,children:[jsxs(Text,{style:[D.selectorLabel,{color:m.card.labelColor,fontFamily:b.regular}],children:["Network"," ",jsxs(Text,{style:[D.minDeposit,{fontFamily:b.regular}],children:["($",tt," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>Ne(true),style:[D.selector,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[pt&&jsx(Image,{source:{uri:J(ge(pt,"png"))},style:D.selectorIcon}),jsx(Text,{style:[D.selectorText,{color:m.card.titleColor,fontFamily:b.medium}],numberOfLines:1,children:pt?.chain_name||"Select network"}),jsx(Ot,{size:16,color:m.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:D.qrContainer,children:jsx(View,{style:[D.qrWrapper,{backgroundColor:w.background,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth>0?m.card.borderWidth:1,borderColor:m.card.borderColor}],children:M?jsxs(View,{style:D.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:w.primary}),jsx(Text,{style:[D.loadingText,{color:w.foregroundMuted,fontFamily:b.regular}],children:"Loading..."})]}):Ye?jsx(as,{value:Ye,size:160,logoUri:J(ge(pt,"png")||Nt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:D.qrLoading,children:jsx(Text,{style:[D.errorText,{color:w.error,fontFamily:b.regular}],children:"No address available"})})})}),jsxs(View,{style:D.addressSection,children:[jsxs(View,{style:D.addressHeader,children:[jsx(Text,{style:[D.addressLabel,{color:m.card.labelColor,fontFamily:b.medium}],children:"Deposit Address"}),Qe&&jsxs(View,{style:D.copiedIndicator,children:[jsx($e,{size:14,color:w.success,strokeWidth:2}),jsx(Text,{style:[D.copiedText,{color:w.success,fontFamily:b.regular}],children:"Copied"})]})]}),jsxs(Yt,{cardTokens:m.transferCrypto.depositAddress.card,onPress:!M&&Ye?Or:void 0,contentStyle:D.addressBox,children:[jsx(Text,{style:[D.addressText,{color:m.card.titleColor,fontFamily:b.regular}],numberOfLines:2,children:M?"Loading...":Ye||"No address available"}),jsx(View,{style:D.addressCopyIcon,children:jsx(jn,{size:16,color:m.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[D.detailsCard,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>ae(!oe),style:D.detailsHeader,children:[jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(yo,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:D.chevronContainer,children:oe?jsx(Co,{size:16,color:m.card.actionColor,strokeWidth:2}):jsx(Ot,{size:16,color:m.card.actionColor,strokeWidth:2})})]}),oe&&jsxs(View,{style:D.detailsContent,children:[jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:["Price impact: ",Cr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>W(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:m.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:["Slippage: Auto \u2022 ",ce.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>W(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:m.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(pa,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(al,{depositConfirmationMode:l,depositAddress:Ye,showWaitingUi:_t,latestExecution:q,onIveDeposited:ir}),jsx(TouchableOpacity$1,{style:D.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[D.termsText,{color:w.primary,fontFamily:b.regular}],children:"Terms apply"})}),fe(),Je(),jsxs(Ze,{visible:dt,onClose:()=>W(false),closeOnBackdropPress:true,showHandle:true,borderTopLeftRadius:d?.infoSheet?.borderTopLeftRadius??y,borderTopRightRadius:d?.infoSheet?.borderTopRightRadius??C,children:[jsxs(View,{style:[D.sheetHeader,{borderBottomColor:w.border}],children:[jsx(View,{style:D.sheetHeaderSpacer}),jsx(Text,{style:[D.sheetTitle,{color:m.header.titleColor,fontFamily:b.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>W(false),style:D.sheetCloseButton,children:jsx(nt,{size:20,color:m.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:D.infoSheetContent,children:[jsxs(View,{style:[D.infoCard,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[jsxs(View,{style:D.infoCardHeader,children:[jsx(View,{style:[D.infoCardIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:m.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[D.infoCardTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:"Price Impact"}),jsxs(Text,{style:[D.infoCardValue,{color:m.card.titleColor,fontFamily:b.medium}],children:[Cr.toFixed(2),"%"]})]}),jsx(Text,{style:[D.infoCardDescription,{color:m.card.descriptionColor,fontFamily:b.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[D.infoCard,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[jsxs(View,{style:D.infoCardHeader,children:[jsx(View,{style:[D.infoCardIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:m.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[D.infoCardTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:"Max Slippage"}),jsxs(Text,{style:[D.infoCardValue,{color:m.card.titleColor,fontFamily:b.medium}],children:[ce.toFixed(2),"%"]})]}),jsx(Text,{style:[D.infoCardDescription,{color:m.card.descriptionColor,fontFamily:b.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),q&&jsx(ls,{visible:Be,status:q.status,tokenIconUrl:q.destination_token_metadata?.icon_urls?.find($=>$.format==="png")?.url||q.destination_token_metadata?.icon_url||ge(Ae,"png"),explorerUrl:q.explorer_url,completionExplorerUrl:q.destination_explorer_url,date:q.created_at?new Date(q.created_at):void 0,amountUsd:q.source_amount_usd?parseFloat(q.source_amount_usd):void 0,onClose:()=>X(false),borderTopLeftRadius:d?.depositStatus?.borderTopLeftRadius??y,borderTopRightRadius:d?.depositStatus?.borderTopRightRadius??C})]})}var D=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{maxHeight:400,paddingTop:8},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function dl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:s}=V();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[hi.container,{backgroundColor:s.card.backgroundColor,borderRadius:s.list.rowBorderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:hi.leftContent,children:[jsx(View,{style:[hi.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:J(ge(e,"png"))},style:hi.icon})}),jsxs(View,{style:hi.textContainer,children:[jsx(Text,{style:[hi.name,{color:s.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[hi.code,{color:s.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx($e,{size:16,color:o.primary,strokeWidth:2})]})}var hi=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding: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 ta({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:s}=V();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:Gp.headerContainer,children:jsx(Text,{style:[Gp.title,{color:s.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(dl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var Gp=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function pl({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:s,borderTopLeftRadius:i,borderTopRightRadius:a}){let{colors:c,fonts:u,components:l}=V(),[h,S]=useState(""),g=o.map(f=>r.find(x=>x.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),y=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),C=f=>{if(!h)return f;let x=h.toLowerCase();return f.filter(_=>_.name.toLowerCase().includes(x)||_.currency_code.toLowerCase().includes(x))},d=C(g),w=C(y),b=f=>{s(f),t(false),S("");},m=()=>{t(false),S("");};return jsxs(Ze,{visible:e,onClose:m,closeOnBackdropPress:true,showHandle:false,heightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:a,children:[jsx(Tr,{title:"Currency",showBack:false,onClose:m}),jsx(View,{style:gi.searchContainer,children:jsx(TextInput,{style:[gi.searchInput,{backgroundColor:l.search.backgroundColor,color:l.search.inputColor,fontFamily:u.regular,borderRadius:l.input.borderRadius,borderWidth:l.input.borderWidth,borderColor:l.input.borderColor}],value:h,onChangeText:S,placeholder:"Search",placeholderTextColor:l.search.placeholderColor})}),jsx(ScrollView,{style:gi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:gi.listContent,children:[jsx(ta,{title:"Popular currencies",currencies:d,selectedCurrency:n,onSelect:b}),d.length>0&&w.length>0&&jsx(View,{style:gi.sectionSpacer}),jsx(ta,{title:"All currencies",currencies:w,selectedCurrency:n,onSelect:b}),d.length===0&&w.length===0&&jsx(View,{style:gi.noResultsContainer,children:jsx(Text,{style:[gi.noResultsText,{color:l.container.subtitleColor,fontFamily:u.regular}],children:"No currencies found"})})]})})]})}var gi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:24},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function gd(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 hl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:s,destinationChainType:i,destinationChainId:a,destinationTokenAddress:c,onDepositSuccess:u,onDepositError:l,borderTopLeftRadius:h,borderTopRightRadius:S,sheetBorderRadius:g}){let{colors:y,fonts:C,components:d}=V(),[w,b]=useState(""),[m,f]=useState("usd"),[x,_]=useState(false),[F,k]=useState(false),[T,A]=useState([]),[M,O]=useState(false),[v,z]=useState(null),[E,de]=useState(null),[Qe,We]=useState("amount"),[oe,ae]=useState(null),[be,Ie]=useState(true),[rt,Ne]=useState(null),[Se,ue]=useState(false),Te=useRef(null),Ke=useRef(false);useEffect(()=>{Te.current=oe;},[oe]),useEffect(()=>{Ke.current=Se;},[Se]);let[lt,ve]=useState([]),[Ve,Be]=useState(true),[X,q]=useState(60),[Ce,dt]=useState([]),[W,L]=useState([]),[ee,le]=useState(null),[pe,wt]=useState(null),[ut,Ye]=useState(true),[je,Pt]=useState(null),[_t,ir]=useState(false),[Ae,ot]=useState(null),[pt,Or]=useState(false),[Cr,ce]=useState(false),[tt,fe]=useState(false),[Je,$]=useState(null),re=r??Qe,xe=useRef(null),me=Ce.find(Q=>Q.currency_code.toLowerCase()===m.toLowerCase()),ne=useCallback(Q=>{We(Q),Q==="quotes"?o?.(Q,T.length):o?.(Q);},[T.length,o]);useEffect(()=>{async function Q(){try{let ie=await _s();wt(ie);}catch(ie){console.error("Error fetching user IP:",ie);}finally{Ye(false);}}Q();},[]),useEffect(()=>{async function Q(){try{let ie=await Uo({external_user_id:e,recipient_address:s,destination_chain_type:i,destination_chain_id:a,destination_token_address:c},t);ve(ie.data);}catch(ie){console.error("Error fetching wallets:",ie),z("Failed to load wallet addresses");}finally{Be(false);}}Q();},[e,s,i,a,c,t]);let P=n||ee?.symbol.toUpperCase()||"USDC",gt=Di(ee?.icon_urls,"png")||ee?.icon_url,Pe=Di(ee?.chain_icon_urls,"png")||ee?.chain_icon_url;useEffect(()=>{async function Q(){try{let ie=await tc(t);dt(ie.data),L(ie.preferred||[]);}catch(ie){console.error("Error fetching fiat currencies:",ie);}}Q();},[t]),useEffect(()=>{if(x||Ce.length===0||!pe?.alpha2)return;let Q=pe.alpha2.toUpperCase(),ie=Ce.find(St=>St.country_codes.includes(Q));if(ie)f(ie.currency_code.toLowerCase()),!w&&!F&&b(String(ie.default_amount??100));else if(!w&&!F){let St=Ce.find(Fr=>Fr.currency_code.toLowerCase()==="usd");St&&b(String(St.default_amount??100));}},[Ce,pe,x,w,F]),useEffect(()=>{if(Ce.length!==0){if(xe.current!==null&&xe.current!==m){let Q=Ce.find(ie=>ie.currency_code.toLowerCase()===m.toLowerCase());Q&&b(String(Q.default_amount??100));}xe.current=m;}},[m,Ce]),useEffect(()=>{async function Q(){try{let ie=await Jl({chain_type:i||"",chain_id:a||"",token_address:c||""},t);le(ie);}catch(ie){console.error("Error fetching supported tokens:",ie);}}Q();},[i,a,c,t]),useEffect(()=>{async function Q(){if(!(!c||!a||!i)&&!ut){ir(true);try{let ie=await ec({country_code:pe?.alpha2?.toUpperCase()||"US",subdivision_code:pe?.state||void 0,token_address:c,chain_id:a,chain_type:i},t);Pt(ie);}catch(ie){console.error("Error fetching default onramp token:",ie);}finally{ir(false);}}}Q();},[c,a,i,pe,ut,t]),useEffect(()=>{let Q=parseFloat(w);if(isNaN(Q)||Q<=0){A([]),de(null);return}if(!je||_t){A([]),ae(null);return}let ie=Ce.find(Fr=>Fr.currency_code.toLowerCase()===m.toLowerCase());if(ie){if(Q<ie.minimum_amount){A([]),ae(null),de(`Minimum amount is ${gd(m)}${ie.minimum_amount.toLocaleString()}`);return}if(Q>ie.maximum_amount){A([]),ae(null),de(`Maximum amount is ${gd(m)}${ie.maximum_amount.toLocaleString()}`);return}}de(null);let St=setTimeout(()=>{un(Q);},500);return ()=>clearTimeout(St)},[w,m,t,je,_t,Ce]);let un=async Q=>{if(!je){z("Loading token information...");return}O(true),z(null);try{let ie={country_code:pe?.alpha2?.toUpperCase()||"US",source_amount:Q.toString(),source_currency:m.toLowerCase(),destination_currency:je.destination_currency,destination_network:je.destination_network,subdivision_code:pe?.state||void 0},St=await Zl(ie,t);A(St.data);let Fr=Ke.current,gs=Te.current;if(Fr&&gs){let so=St.data.find(ao=>ao.service_provider===gs.service_provider);if(so){if(ae(so),St.data.length>0){let ao=St.data.reduce((Dr,zo)=>zo.destination_amount>Dr.destination_amount?zo:Dr);rt||Ne(ao.service_provider),Ie(so.service_provider===rt);}}else if(St.data.length>0){let ao=St.data.reduce((Dr,zo)=>zo.destination_amount>Dr.destination_amount?zo:Dr);ae(ao),Ne(ao.service_provider),Ie(!0),ue(!1);}}else if(St.data.length>0){let so=St.data.reduce((ao,Dr)=>Dr.destination_amount>ao.destination_amount?Dr:ao);ae(so),Ne(so.service_provider),Ie(!0);}q(60);}catch(ie){console.error("Failed to fetch quotes:",ie),z("Failed to fetch quotes. Please try again."),A([]);}finally{O(false);}};useEffect(()=>{if(T.length===0)return;let Q=setInterval(()=>{q(ie=>{if(ie<=1){let St=parseFloat(w);return !isNaN(St)&&St>0&&un(St),60}return ie-1});},1e3);return ()=>clearInterval(Q)},[T.length,w]);let xi=Q=>{(/^\d*\.?\d{0,2}$/.test(Q)||Q==="")&&(b(Q),k(true));},_i=Q=>{b(Q.toString()),k(true);},go=async()=>{if(oe&&je)try{let Q=je.destination_token_metadata.chain_type,ie=Ho(lt,Q);if(!ie?.address){z("Wallet address not available");return}let St={service_provider:oe.service_provider,country_code:oe.country_code?.toUpperCase()||pe?.alpha2?.toUpperCase()||"US",source_currency:oe.source_currency,source_amount:w,destination_currency:oe.destination_currency,destination_network:oe.destination_network,wallet_address:ie.address,subdivision_code:pe?.state||void 0},Fr=await Xl(St,t);ot({provider:oe,sourceCurrency:m,sourceAmount:w,sessionUrl:Fr.url}),$(Fr.url),fe(!0);}catch(Q){console.error("Failed to create session:",Q),z("Failed to start payment flow"),l?.({message:"Failed to start payment flow",error:Q});}},Ri=gd(m),io=()=>{fe(false),ne("onramp"),u?.({message:"Payment flow completed"});},Mo=()=>jsx(vg,{visible:tt,onClose:io,url:Je,providerName:oe?.service_provider_display_name||"Complete Payment",colors:y,fonts:C,borderTopLeftRadius:g?.webView?.borderTopLeftRadius??h,borderTopRightRadius:g?.webView?.borderTopRightRadius??S});return re==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:j.amountViewContainer,children:[jsxs(ScrollView,{style:j.scrollContainer,contentContainerStyle:j.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:j.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Or(true),style:[j.currencyButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.input.borderRadius,borderWidth:d.input.borderWidth,borderColor:d.input.borderColor}],children:[me&&jsx(Image,{source:{uri:J(ge(me,"png"))},style:j.currencyIcon}),jsx(Text,{style:[j.currencyText,{color:d.card.titleColor,fontFamily:C.medium}],children:m.toUpperCase()}),jsx(Ot,{size:16,color:d.card.actionColor,strokeWidth:2})]})}),jsx(pl,{open:pt,onOpenChange:Or,currencies:Ce,preferredCurrencyCodes:W,selectedCurrency:m,onSelectCurrency:Q=>{f(Q.toLowerCase()),_(true);},borderTopLeftRadius:g?.currencyModal?.borderTopLeftRadius??h,borderTopRightRadius:g?.currencyModal?.borderTopRightRadius??S}),jsx(View,{style:j.amountContainer,children:jsxs(View,{style:j.amountInputRow,children:[jsx(Text,{style:[j.currencySymbol,{color:d.container.titleColor,fontFamily:C.medium}],children:Ri}),jsx(TextInput,{style:[j.amountInput,{color:d.container.titleColor,fontFamily:C.medium}],value:w,onChangeText:xi,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:y.foregroundMuted})]})}),me?.suggested_amounts&&me.suggested_amounts.length>0&&jsx(View,{style:j.quickAmounts,children:me.suggested_amounts.map(Q=>jsx(TouchableOpacity$1,{onPress:()=>_i(Q),style:[j.quickAmountButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.button.borderRadius,borderWidth:parseFloat(w)===Q?2:d.button.borderWidth,borderColor:parseFloat(w)===Q?y.primary:d.button.borderColor}],children:jsxs(Text,{style:[j.quickAmountText,{color:d.card.titleColor,fontFamily:C.medium}],children:[Ri,Q.toLocaleString()]})},Q))}),E&&jsx(Text,{style:[j.validationError,{color:y.error,fontFamily:C.regular}],children:E}),jsxs(View,{style:j.providerSection,children:[jsxs(View,{style:j.providerHeader,children:[jsx(Text,{style:[j.providerLabel,{color:d.card.labelColor,fontFamily:C.medium}],children:"Provider"}),T.length>0&&!M&&jsxs(Text,{style:[j.refreshText,{color:d.card.labelRightColor,fontFamily:C.regular}],children:["Refreshing in ",X,"s"]})]}),jsx(Yt,{cardTokens:d.depositCard.quoteProvider.card,onPress:M||T.length===0?void 0:()=>ce(true),contentStyle:StyleSheet.flatten([j.providerButton,(M||T.length===0)&&j.disabled]),children:M?jsxs(View,{style:j.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:d.container.subtitleColor}),jsx(Text,{style:[j.loadingText,{color:d.container.subtitleColor,fontFamily:C.regular}],children:"Finding best rates..."})]}):oe?jsxs(View,{style:j.providerContent,children:[jsxs(View,{style:j.providerInfo,children:[be&&jsx(Text,{style:[j.autoPickedText,{color:d.container.subtitleColor,fontFamily:C.regular}],children:"Auto-picked for you"}),jsxs(View,{style:j.providerRow,children:[jsx(Image,{source:{uri:J(wa(oe.icon_urls,"png",oe.icon_url))},style:j.providerIconImage},`provider-${oe.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[j.providerName,{color:d.card.titleColor,fontFamily:C.medium}],children:oe.service_provider_display_name}),jsxs(Text,{style:[j.bestPriceText,{color:y.success,fontFamily:C.regular}],children:["Best price \u2022 ",oe.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(Vr,{size:20,color:d.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[j.noProviderText,{color:d.container.subtitleColor,fontFamily:C.regular}],children:parseFloat(w)>0?"No providers available":"Enter an amount to see providers"})}),v&&jsx(Text,{style:[j.errorText,{color:y.error,fontFamily:C.regular}],children:v})]}),jsxs(Ze,{visible:Cr,onClose:()=>ce(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:g?.providerModal?.borderTopLeftRadius??h,borderTopRightRadius:g?.providerModal?.borderTopRightRadius??S,children:[jsx(Tr,{title:"Select Provider",showBack:false,onClose:()=>ce(false)}),jsx(ScrollView,{style:j.providerModalList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsx(View,{style:j.quotesList,children:[...T].sort((Q,ie)=>ie.destination_amount-Q.destination_amount).map((Q,ie)=>{let St=oe?.service_provider===Q.service_provider,Fr=ie===0;return jsxs(Yt,{cardTokens:d.depositCard.quoteProvider.card,onPress:()=>{ae(Q),ue(true),Ie(Q.service_provider===rt),ce(false);},contentStyle:StyleSheet.flatten([j.quoteItem,St&&{borderWidth:2,borderColor:y.primary}]),children:[jsxs(View,{style:j.quoteLeft,children:[jsx(Image,{source:{uri:J(wa(Q.icon_urls,"png",Q.icon_url))},style:j.providerIconImage}),jsxs(View,{children:[jsx(Text,{style:[j.quoteName,{color:d.card.titleColor,fontFamily:C.medium}],children:Q.service_provider_display_name}),Fr&&jsx(Text,{style:[j.bestPriceLabel,{color:y.success,fontFamily:C.regular}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:j.quoteRight,children:[jsxs(Text,{style:[j.quoteAmount,{color:d.card.textRightColor,fontFamily:C.medium}],children:[Q.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[j.quoteSource,{color:d.card.subtextRightColor,fontFamily:C.regular}],children:["Fee: ",Ri,Q.total_fee.toFixed(2)]})]})]},Q.service_provider)})})})]})]}),jsx(View,{style:[j.continueButtonContainer,{backgroundColor:y.background}],children:jsx(TouchableOpacity$1,{onPress:go,disabled:M||Ve||!oe||parseFloat(w)<=0,style:[j.continueButton,{backgroundColor:d.container.buttonColor,borderRadius:d.button.borderRadius,borderWidth:d.button.borderWidth,borderColor:d.button.borderColor},(M||Ve||!oe)&&j.disabledButton],children:jsx(Text,{style:[j.continueButtonText,{color:d.container.buttonTitleColor,fontFamily:C.medium}],children:Ve?"Loading...":"Continue"})})})]}),Mo()]}):re==="onramp"&&Ae?jsxs(View,{style:j.onrampContainer,children:[jsx(Image,{source:{uri:J(wa(Ae.provider.icon_urls,"png",Ae.provider.icon_url))},style:j.onrampProviderIcon}),jsxs(Text,{style:[j.onrampTitle,{color:d.container.titleColor,fontFamily:C.medium}],children:["Complete transaction with ",Ae.provider.service_provider_display_name]}),jsx(Text,{style:[j.onrampSubtitle,{color:d.container.subtitleColor,fontFamily:C.regular}],children:"You can close this modal."}),jsxs(View,{style:[j.flowDiagram,{backgroundColor:d.card.backgroundColor}],children:[jsxs(View,{style:j.flowStep,children:[jsx(Image,{source:{uri:Nt(`/icons/currencies/png/${Ae.sourceCurrency.toLowerCase()}.png`)},style:j.flowIconImage}),jsx(Text,{style:[j.flowLabel,{color:d.card.subtitleColor,fontFamily:C.regular}],children:"You use"}),jsx(Text,{style:[j.flowValue,{color:d.card.titleColor,fontFamily:C.medium}],children:Ae.sourceCurrency.toUpperCase()})]}),jsx(Vr,{size:16,color:d.card.actionColor,strokeWidth:2}),jsxs(View,{style:j.flowStep,children:[jsxs(View,{style:j.flowIconWithBadge,children:[jsx(Image,{source:{uri:Di(je?.destination_token_metadata?.icon_urls,"png")||je?.destination_token_metadata?.icon_url||Nt("/icons/tokens/png/usdc.png")},style:j.flowIconImageNoBadge}),jsx(Image,{source:{uri:Di(je?.destination_token_metadata?.chain?.icon_urls,"png")||je?.destination_token_metadata?.chain?.icon_url||Nt("/icons/networks/png/polygon.png")},style:[j.flowNetworkBadge,{borderColor:y.background,borderRadius:d.badge.borderRadius}]})]}),jsx(Text,{style:[j.flowLabel,{color:d.card.subtitleColor,fontFamily:C.regular}],children:"You buy"}),jsx(Text,{style:[j.flowValue,{color:d.card.titleColor,fontFamily:C.medium}],children:"USDC"})]}),jsx(Vr,{size:16,color:d.card.actionColor,strokeWidth:2}),jsxs(View,{style:j.flowStep,children:[jsxs(View,{style:j.flowIconWithBadge,children:[jsx(Image,{source:{uri:gt||Nt("/icons/tokens/png/usdc.png")},style:j.flowIconImageNoBadge}),jsx(Image,{source:{uri:Pe||Nt("/icons/networks/png/polygon.png")},style:[j.flowNetworkBadge,{borderColor:y.background,borderRadius:d.badge.borderRadius}]})]}),jsx(Text,{style:[j.flowLabel,{color:d.card.subtitleColor,fontFamily:C.regular}],children:"You receive"}),jsx(Text,{style:[j.flowValue,{color:d.card.titleColor,fontFamily:C.medium}],children:P})]})]}),jsx(View,{style:[j.onrampInfoBox,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:jsx(Text,{style:[j.onrampInfoText,{color:d.card.descriptionColor,fontFamily:C.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function vg({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:s,borderTopLeftRadius:i,borderTopRightRadius:a}){return jsxs(Ze,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:a,children:[jsxs(View,{style:yi.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:yi.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx($e,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[yi.headerTitle,{color:n.foreground,fontFamily:s.medium}],children:o}),jsx(View,{style:yi.headerSpacer})]}),r&&jsx(View,{style:yi.container,children:jsx(WebView,{source:{uri:r},style:yi.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:yi.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var yi=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),j=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8},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},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},bestPriceLabel:{fontSize:11,marginTop:2},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function Dg(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 Vg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function bl({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=V(),s=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let c=J(ge(e.destination_token_metadata,"png")||Nt("/icons/tokens/png/usdc.png")),u=i?"Deposit Processing":"Deposit Completed",l=Dg(e.created_at||new Date().toISOString()),h=Vg(e.source_amount_usd);return jsxs(Yt,{cardTokens:s,onPress:t,contentStyle:rn.container,children:[jsxs(View,{style:rn.iconContainer,children:[jsx(Image,{source:{uri:c},style:rn.tokenIcon}),jsx(View,{style:[rn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:s.backgroundColor}],children:i?jsx(ma,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:rn.textContainer,children:[jsx(Text,{style:[rn.title,{color:s.titleColor,fontFamily:o.medium}],children:u}),jsx(Text,{style:[rn.dateTime,{color:s.subtitleColor,fontFamily:o.regular}],children:l})]}),jsxs(View,{style:rn.rightContainer,children:[jsx(Text,{style:[rn.amount,{color:s.textRightColor,fontFamily:o.medium}],children:h}),jsx(Vr,{size:20,color:s.actionColor,strokeWidth:2})]})]})}var rn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});function tm(e,t){let r={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||r[e]||e:r[e]||e}function rm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function Eg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var om=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function nm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Mg(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 wl({visible:e,onClose:t,executions:r,externalUserId:o,publishableKey:n,borderTopLeftRadius:s,borderTopRightRadius:i}){let{height:a}=useWindowDimensions(),{colors:c,fonts:u,components:l}=V(),[h,S]=useState(r),[g,y]=useState(false),[C,d]=useState(null),[w,b]=useState(false),m=useRef(null);useEffect(()=>{if(!e||!o)return;let T=async()=>{y(true);try{let O=[...(await No(o,n)).data].sort((v,z)=>{let E=v.created_at?new Date(v.created_at).getTime():0;return (z.created_at?new Date(z.created_at).getTime():0)-E});S(O);}catch(M){console.error("Failed to fetch executions:",M),S(r);}finally{y(false);}};T();let A=setInterval(T,1e4);return ()=>clearInterval(A)},[e,o,n,r]),useEffect(()=>{r.length>0&&S(T=>{let A=new Set(T.map(O=>O.id)),M=r.filter(O=>!A.has(O.id));return M.length>0?[...M,...T]:T});},[r]),useEffect(()=>{e||d(null);},[e]);let f=T=>{d(T);},x=()=>{d(null),b(false);},_=()=>{d(null),t();};return jsxs(Ze,{visible:e,onClose:_,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,borderTopLeftRadius:s,borderTopRightRadius:i,children:[jsx(Tr,{title:C?"Deposit Details":"Deposit Tracker",onClose:_,showClose:!C,showBack:!!C,onBack:x}),C?(()=>{if(!C)return null;let T=C,A=T.status==="pending"||T.status==="waiting"||T.status==="delayed",M=T.status==="succeeded",O=J(ge(T.destination_token_metadata,"png")||Nt("/icons/tokens/png/usdc.png")),v=T.provider_metadata?.details,z=v?.currencyIn,E=v?.currencyOut;z?.currency?.symbol||"USDC";E?.currency?.symbol||"USDC";let We=rm(T.source_amount_base_unit,T.source_token_metadata?.decimals),oe=rm(T.destination_amount_base_unit,T.destination_token_metadata?.decimals),ae=Eg(T.source_amount_usd),be=tm(T.source_chain_type,T.source_chain_id),Ie=tm(T.destination_chain_type,T.destination_chain_id),rt=()=>{T.explorer_url&&Linking.openURL(T.explorer_url);},Ne=()=>{T.destination_explorer_url&&Linking.openURL(T.destination_explorer_url);};return jsxs(ScrollView,{ref:m,style:[se.scrollContainer,{maxHeight:a*.7}],contentContainerStyle:se.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:se.iconSection,children:[jsxs(View,{style:se.iconWrapper,children:[jsx(Image,{source:{uri:O},style:se.tokenIcon}),jsx(View,{style:[se.statusBadge,{backgroundColor:A?c.warning:c.success,borderColor:c.background}],children:A?jsx(Ot,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx($e,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:se.statusRow,children:[jsx(View,{style:[se.statusDot,{backgroundColor:A?c.warning:c.success}]}),jsx(Text,{style:[se.statusText,{color:l.container.titleColor,fontFamily:u.semibold}],children:A?"Processing":"Completed"})]}),jsx(Text,{style:[se.dateText,{color:l.container.subtitleColor,fontFamily:u.regular}],children:Mg(T.created_at||new Date().toISOString())})]}),jsxs(View,{style:[se.card,{backgroundColor:l.card.backgroundColor,borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor}],children:[jsxs(View,{style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"Amount Sent"}),jsxs(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:[We," ",nm(T.source_currency)]})]}),jsx(View,{style:[se.cardDivider,{backgroundColor:c.border}]}),jsxs(View,{style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"Amount Received"}),jsxs(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:[oe," ",nm(T.destination_currency)]})]}),jsx(View,{style:[se.cardDivider,{backgroundColor:c.border}]}),jsxs(View,{style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"USD Value"}),jsx(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:ae})]}),jsx(View,{style:[se.cardDivider,{backgroundColor:c.border}]}),jsxs(View,{style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"Source Network"}),jsx(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:be})]}),jsx(View,{style:[se.cardDivider,{backgroundColor:c.border}]}),jsxs(View,{style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"Destination Network"}),jsx(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:Ie})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Se=!w;b(Se),Se?setTimeout(()=>{m.current?.scrollToEnd({animated:true});},100):m.current?.scrollTo({y:0,animated:true});},style:se.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[se.toggleText,{color:l.container.actionTitle,fontFamily:u.regular}],children:w?"See less":"See more details"}),w?jsx(Co,{size:14,color:l.container.actionColor,strokeWidth:2}):jsx(Ot,{size:14,color:l.container.actionColor,strokeWidth:2})]}),w&&jsxs(View,{style:[se.card,{backgroundColor:l.card.backgroundColor,borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor}],children:[T.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:rt,style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"Deposit Tx"}),jsxs(View,{style:se.cardRowRight,children:[jsx(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:om(T.transaction_hash)}),jsx(bo,{size:14,color:l.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[se.cardDivider,{backgroundColor:c.border}]})]}),T.destination_explorer_url&&M&&jsxs(TouchableOpacity,{onPress:Ne,style:se.cardRow,children:[jsx(Text,{style:[se.cardLabel,{color:l.card.rowLeftLabel,fontFamily:u.regular}],children:"Completion Tx"}),jsxs(View,{style:se.cardRowRight,children:[jsx(Text,{style:[se.cardValue,{color:l.card.rowRightLabel,fontFamily:u.medium}],children:om(T.destination_transaction_hashes[0])}),jsx(bo,{size:14,color:l.card.actionIcon,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:[se.scrollContainer,{maxHeight:a*.7}],contentContainerStyle:se.scrollContent,showsVerticalScrollIndicator:false,children:h.length===0?jsxs(View,{style:se.emptyContainer,children:[jsx(Text,{style:[se.emptyText,{color:l.container.titleColor,fontFamily:u.medium}],children:"No deposits yet"}),jsx(Text,{style:[se.emptySubtext,{color:l.container.subtitleColor,fontFamily:u.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:se.executionsList,children:h.map(T=>jsx(bl,{execution:T,onPress:()=>f(T)},T.id))})})]})}var se=StyleSheet.create({scrollContainer:{paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function ra(e,t=true){let[r,o]=useState(null),[n,s]=useState(null),[i,a]=useState(false),[c,u]=useState(false),[l,h]=useState(null),[S,g]=useState(null);useEffect(()=>{!t||r||(a(true),_s().then(w=>{o(w),h(null);}).catch(w=>{h(w instanceof Error?w:new Error(String(w)));}).finally(()=>{a(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(u(true),xs(e).then(w=>{s(w),g(null);}).catch(w=>{g(w instanceof Error?w:new Error(String(w)));}).finally(()=>{u(false);}));},[t,e,n]);let y=i||c,C=l||S||null,d=null;if(r&&n){let w=n.blocked_country_codes||[],b=r.alpha2.toUpperCase();d=!w.some(m=>m.toUpperCase()===b);}return {isAllowed:d,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:y,error:C}}var Sd="unifold_recent_tokens",Hg=5,cm=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function Tl(){try{let e=await Sc.getItem(Sd);return e?JSON.parse(e):[]}catch{return []}}async function Ng(e){try{let r=(await Tl()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,Hg);await Sc.setItem(Sd,JSON.stringify(o));}catch{}}async function jg(e){try{let r=(await Tl()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Sc.setItem(Sd,JSON.stringify(r)),r}catch{return []}}function Td({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:s,borderTopLeftRadius:i,borderTopRightRadius:a}){let{colors:c,fonts:u,components:l}=V(),[h,S]=useState(""),[g,y]=useState([]);useEffect(()=>{e&&Tl().then(y);},[e]),useEffect(()=>{e||S("");},[e]);let C=useMemo(()=>{let x=[];return r.forEach(_=>{_.chains.forEach(F=>{x.push({token:_,chain:F});});}),x},[r]),d=useMemo(()=>{let x=[],_=new Set,F=(k,T,A,M)=>{let O=`${k}-${T}:${A}`;if(_.has(O))return;let v=r.find(E=>E.symbol===k);if(!v)return;let z=v.chains.find(E=>E.chain_type===T&&E.chain_id===A);z&&(_.add(O),x.push({token:v,chain:z,isRecent:M}));};return g.forEach(k=>{F(k.symbol,k.chainType,k.chainId,true);}),cm.forEach(k=>{F(k.symbol,k.chainType,k.chainId,false);}),x},[r,g]),w=useMemo(()=>{if(!h.trim())return C;let x=h.toLowerCase();return C.filter(({token:_,chain:F})=>_.symbol.toLowerCase().includes(x)||_.name.toLowerCase().includes(x)||F.chain_name.toLowerCase().includes(x))},[C,h]),b=(x,_,F)=>cm.some(k=>k.symbol===x&&k.chainType===_&&k.chainId===F),m=async(x,_)=>{let F=`${_.chain_type}:${_.chain_id}`;if(!b(x.symbol,_.chain_type,_.chain_id)){await Ng({symbol:x.symbol,chainType:_.chain_type,chainId:_.chain_id});let k=await Tl();y(k);}S(""),s(x.symbol,F),t();},f=async(x,_)=>{let F=await jg({symbol:x.symbol,chainType:_.chain_type,chainId:_.chain_id});y(F);};return jsxs(Ze,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:false,heightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:a,children:[jsxs(View,{style:at.header,children:[jsx(View,{style:at.headerSpacer}),jsx(Text,{style:[at.headerTitle,{color:l.header.titleColor,fontFamily:u.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:at.closeButton,children:jsx(nt,{size:20,color:l.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:at.searchContainer,children:jsx(TextInput,{style:[at.searchInput,{backgroundColor:l.search.backgroundColor,color:l.search.inputColor,fontFamily:u.regular,borderRadius:l.input.borderRadius,borderWidth:l.input.borderWidth,borderColor:l.input.borderColor}],placeholder:"Search",placeholderTextColor:l.search.placeholderColor,value:h,onChangeText:S,autoCapitalize:"none",autoCorrect:false})}),d.length>0&&!h&&jsxs(View,{style:at.quickSelectSection,children:[jsx(Text,{style:[at.sectionLabel,{color:l.list.titleSectionColor,fontFamily:u.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:at.quickSelectScroll,children:d.map(({token:x,chain:_,isRecent:F})=>{let k=`${_.chain_type}:${_.chain_id}`;x.symbol===o&&k===n;return jsxs(View,{children:[F&&jsx(TouchableOpacity$1,{onPress:()=>f(x,_),style:at.removeButton,children:jsx(nt,{size:12,color:c.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>m(x,_),activeOpacity:.7,style:[at.quickSelectItem,{backgroundColor:l.card.backgroundColor,borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor}],children:[jsxs(View,{style:at.tokenIconContainer,children:[jsx(Image,{source:{uri:J(ge(x,"png"))},style:at.quickSelectIcon}),jsx(Image,{source:{uri:J(ge(_,"png"))},style:[at.quickSelectChainBadge,{borderColor:l.card.backgroundColor,borderRadius:l.badge.borderRadius}]})]}),jsxs(View,{style:at.quickSelectText,children:[jsx(Text,{style:[at.quickSelectSymbol,{color:l.card.titleColor,fontFamily:u.medium}],children:x.symbol}),jsx(Text,{style:[at.quickSelectChain,{color:l.card.subtitleColor,fontFamily:u.regular}],children:_.chain_name})]})]})]},`quick-${x.symbol}-${k}`)})})]}),jsx(Text,{style:[at.sectionLabel,{color:l.list.titleSectionColor,fontFamily:u.regular}],children:"All supported tokens"}),jsx(ScrollView,{style:at.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:at.tokenListContent,children:w.length===0?jsx(View,{style:at.emptyState,children:jsx(Text,{style:[at.emptyText,{color:c.foregroundMuted,fontFamily:u.regular}],children:"No tokens found"})}):w.map(({token:x,chain:_})=>{let F=`${_.chain_type}:${_.chain_id}`,k=x.symbol===o&&F===n;return jsxs(TouchableOpacity$1,{onPress:()=>m(x,_),activeOpacity:.7,style:[at.tokenItem,{backgroundColor:k?l.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:at.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:J(ge(x,"png"))},style:at.tokenIcon}),jsx(Image,{source:{uri:J(ge(_,"png"))},style:[at.tokenChainBadge,{borderColor:l.card.backgroundColor,borderRadius:l.badge.borderRadius}]})]}),jsxs(View,{style:at.tokenInfo,children:[jsx(Text,{style:[at.tokenSymbol,{color:l.card.titleColor,fontFamily:u.medium}],children:x.symbol}),jsx(Text,{style:[at.tokenChainName,{color:l.card.subtitleColor,fontFamily:u.regular}],children:_.chain_name})]}),jsxs(Text,{style:[at.minDeposit,{color:l.card.labelColor,fontFamily:u.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:l.card.labelHighlightRightColor,fontFamily:u.regular},children:["$",_.minimum_deposit_amount_usd]})]})]},`${x.symbol}-${F}`)})})]})}var at=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:24,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var _l=(e,t)=>`${t}:${e}`,Gg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function xd({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:s,destinationTokenSymbol:i,defaultChainType:a,defaultChainId:c,defaultTokenAddress:u,depositConfirmationMode:l="auto_ui",onExecutionsChange:h,onDepositSuccess:S,onDepositError:g,wallets:y,borderTopLeftRadius:C,borderTopRightRadius:d,sheetBorderRadius:w}){let{colors:b,fonts:m,components:f}=V(),x=a&&c?`${a}:${c}`:"solana:mainnet",[_,F]=useState("USDC"),[k,T]=useState(x),[A,M]=useState([]),[O,v]=useState(!y?.length),z=y?.length?y:A,[E,de]=useState([]),[Qe,We]=useState(true),[oe,ae]=useState(false),[be,Ie]=useState(false),[rt,Ne]=useState(false),[Se,ue]=useState([]),[Te,Ke]=useState(new Map),[lt]=useState(()=>new Date),[ve,Ve]=useState(null),[Be,X]=useState(false),[q,Ce]=useState(null),[dt,W]=useState(false),L=new Map;E.forEach(fe=>{fe.chains.forEach(Je=>{let $=`${Je.chain_type}:${Je.chain_id}`;L.has($)||L.set($,Je);});});let ee=Array.from(L.values()),le=Gg(k),pe=ee.find(fe=>fe.chain_type===le.chainType&&fe.chain_id===le.chainId),wt=pe?.chain_type||"ethereum",ut=Ho(z,wt),Ye=ut?.address||"",je=useRef(false);useEffect(()=>{async function fe(){try{We(!0),Ve(null);let $=await qn(t,s&&n&&o?{destination_token_address:s,destination_chain_id:n,destination_chain_type:o}:void 0);if(de($.data),$.data.length>0&&!je.current){je.current=!0;let re,xe;if(a&&c)if(u)for(let me of $.data){let ne=me.chains.find(P=>P.chain_type===a&&P.chain_id===c&&P.token_address.toLowerCase()===u.toLowerCase());if(ne){re=me,xe=ne;break}}else for(let me of $.data){let ne=me.chains.find(P=>P.chain_type===a&&P.chain_id===c);if(ne){re=me,xe=ne;break}}if(!re&&s)for(let me of $.data){let ne=me.chains.find(P=>P.token_address.toLowerCase()===s.toLowerCase());if(ne){re=me,xe=ne;break}}re||(re=$.data.find(me=>me.symbol==="USDC"),re&&re.chains.length>0&&(xe=re.chains[0])),re||(re=$.data.find(me=>me.symbol==="USDT"),re&&re.chains.length>0&&(xe=re.chains[0])),re||(re=$.data[0],re.chains.length>0&&(xe=re.chains[0])),re&&F(re.symbol),xe&&T(_l(xe.chain_id,xe.chain_type));}}catch(Je){console.error("Error fetching supported tokens:",Je),Ve("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:Je});}finally{We(false);}}fe();},[t,s,n,o,a,c,u,g]),useEffect(()=>{h&&h(Se);},[Se,h]),useEffect(()=>{if(y?.length){v(false);return}if(A.length>0){v(false);return}let fe=null,Je=false,$=async()=>{if(!Je){v(true);try{let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:s},t);Je||(M(re.data),Ve(null),v(!1));}catch(re){console.error("Error fetching wallets, retrying in 5s:",re),Je||(Ve(re instanceof Error?re.message:"Failed to load wallets"),v(false),fe=setTimeout($,5e3));}}};return $(),()=>{Je=true,fe&&clearTimeout(fe);}},[e,r,o,n,s,t,y,A.length]);let Pt=ut?.id??"",{showWaitingUi:_t,handleIveDeposited:ir}=Zs({depositConfirmationMode:l,depositAddress:Ye,chain:k,externalUserId:e,publishableKey:t,modalOpenedAt:lt,depositWalletId:Pt,depositExecutions:Se,trackedExecutions:Te,setDepositExecutions:ue,setTrackedExecutions:Ke,setLatestExecution:Ce,setShowStatusSheet:X,onDepositSuccess:S,onExecutionsChange:h,onDepositError:g});useEffect(()=>{if(!E.length)return;let fe=E.find($=>$.symbol===_);if(!fe||fe.chains.length===0)return;if(!fe.chains.some($=>_l($.chain_id,$.chain_type)===k)){let $=fe.chains[0];T(_l($.chain_id,$.chain_type));}},[_,E,k]);let Ae=E.find(fe=>fe.symbol===_),pt=(Ae?.chains||[]).find(fe=>_l(fe.chain_id,fe.chain_type)===k),Or=async()=>{if(Ye)try{Clipboard.setString(Ye),ae(!0),setTimeout(()=>ae(!1),2e3);}catch(fe){console.error("Failed to copy:",fe);}},Cr=pt?.estimated_price_impact_percent??0,ce=pt?.max_slippage_percent??.25,tt=pt?.minimum_deposit_amount_usd??3;return Qe?jsxs(View,{style:H.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:b.primary}),jsx(Text,{style:[H.loadingText,{color:b.foregroundMuted,fontFamily:m.regular}],children:"Loading currencies..."})]}):ve&&E.length===0?jsxs(View,{style:H.errorContainer,children:[jsx(Text,{style:[H.errorText,{color:b.error,fontFamily:m.regular}],children:ve}),jsx(Text,{style:[H.errorHint,{color:b.foregroundMuted,fontFamily:m.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:H.container,children:[jsxs(View,{style:H.selectorSection,children:[jsx(Text,{style:[H.selectorLabel,{color:f.card.labelColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>Ne(true),disabled:Qe||E.length===0,style:[H.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:Qe?jsxs(View,{style:H.tokenSelectorLoading,children:[jsx(View,{style:[H.loadingIcon,{backgroundColor:b.cardHover}]}),jsxs(View,{style:H.loadingTextContainer,children:[jsx(View,{style:[H.loadingLine,{backgroundColor:b.cardHover,width:60}]}),jsx(View,{style:[H.loadingLine,{backgroundColor:b.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:H.tokenIconWrapper,children:[Ae&&jsx(Image,{source:{uri:J(ge(Ae,"png"))},style:H.tokenMainIcon}),(pt||pe)&&jsx(Image,{source:{uri:J(ge(pt||pe,"png"))},style:[H.tokenChainBadge,{borderColor:f.card.backgroundColor,borderRadius:f.badge.borderRadius}]})]}),jsxs(View,{style:H.tokenSelectorInfo,children:[jsx(Text,{style:[H.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:m.semibold}],children:Ae?.symbol||_}),jsx(Text,{style:[H.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:m.regular}],numberOfLines:1,children:pt?.chain_name||pe?.chain_name||"Select network"})]}),jsxs(View,{style:H.tokenSelectorRight,children:[jsxs(Text,{style:[H.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:m.medium}],children:["$",tt," min"]}),jsx(Vr,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Td,{visible:rt,onClose:()=>Ne(false),tokens:E,selectedToken:_,selectedChainKey:k,onSelect:(fe,Je)=>{F(fe),T(Je);},borderTopLeftRadius:w?.tokenSelector?.borderTopLeftRadius??C,borderTopRightRadius:w?.tokenSelector?.borderTopRightRadius??d}),jsx(View,{style:H.qrContainer,children:jsx(View,{style:[H.qrWrapper,{backgroundColor:b.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:O?jsxs(View,{style:H.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[H.loadingText,{color:b.foregroundMuted,fontFamily:m.regular}],children:"Loading..."})]}):Ye?jsx(as,{value:Ye,size:180,logoUri:J(ge(pt,"png")||Nt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:H.qrLoading,children:jsx(Text,{style:[H.errorText,{color:b.error,fontFamily:m.regular}],children:"No address available"})})})}),jsxs(View,{style:H.addressSection,children:[jsxs(View,{style:H.addressHeader,children:[jsx(Text,{style:[H.addressLabel,{color:f.card.labelColor,fontFamily:m.medium}],children:"Deposit Address"}),oe&&jsxs(View,{style:H.copiedIndicator,children:[jsx($e,{size:14,color:b.success,strokeWidth:2}),jsx(Text,{style:[H.copiedText,{color:b.success,fontFamily:m.regular}],children:"Copied"})]})]}),jsxs(Yt,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!O&&Ye?Or:void 0,contentStyle:H.addressBox,children:[jsx(Text,{style:[H.addressText,{color:f.card.titleColor,fontFamily:m.regular}],numberOfLines:2,children:O?"Loading...":Ye||"No address available"}),jsx(View,{style:H.addressCopyIcon,children:jsx(jn,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[H.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Ie(!be),style:H.detailsHeader,children:[jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yo,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:H.chevronContainer,children:be?jsx(Co,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Ot,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),be&&jsxs(View,{style:H.detailsContent,children:[jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:["Price impact: ",Cr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>W(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:["Slippage: Auto \u2022 ",ce.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>W(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(pa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(al,{depositConfirmationMode:l,depositAddress:Ye,showWaitingUi:_t,latestExecution:q,onIveDeposited:ir}),jsx(TouchableOpacity$1,{style:H.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[H.termsText,{color:b.primary,fontFamily:m.regular}],children:"Terms apply"})}),jsxs(Ze,{visible:dt,onClose:()=>W(false),closeOnBackdropPress:true,showHandle:true,borderTopLeftRadius:w?.infoSheet?.borderTopLeftRadius??C,borderTopRightRadius:w?.infoSheet?.borderTopRightRadius??d,children:[jsxs(View,{style:[H.sheetHeader,{borderBottomColor:b.border}],children:[jsx(View,{style:H.sheetHeaderSpacer}),jsx(Text,{style:[H.sheetTitle,{color:f.header.titleColor,fontFamily:m.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>W(false),style:H.sheetCloseButton,children:jsx(nt,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:H.infoSheetContent,children:[jsxs(View,{style:[H.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:H.infoCardHeader,children:[jsx(View,{style:[H.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:m.medium}],children:"Price Impact"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:m.medium}],children:[Cr.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:m.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[H.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:H.infoCardHeader,children:[jsx(View,{style:[H.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:m.medium}],children:"Max Slippage"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:m.medium}],children:[ce.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:m.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),q&&jsx(ls,{visible:Be,status:q.status,tokenIconUrl:q.destination_token_metadata?.icon_urls?.find(fe=>fe.format==="png")?.url||q.destination_token_metadata?.icon_url||ge(Ae,"png"),explorerUrl:q.explorer_url,completionExplorerUrl:q.destination_explorer_url,date:q.created_at?new Date(q.created_at):void 0,amountUsd:q.source_amount_usd?parseFloat(q.source_amount_usd):void 0,onClose:()=>X(false),borderTopLeftRadius:w?.depositStatus?.borderTopLeftRadius??C,borderTopRightRadius:w?.depositStatus?.borderTopRightRadius??d})]})}var H=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var nn={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},stripeLinkPay:{title:"Pay with Stripe Link",subtitle:"Apple Pay or Card"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function ey(){let{colors:e,components:t}=V(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[r]);let s=({rightIcons:i=2})=>jsxs(View,{style:[Un.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[Un.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:Un.textBlock,children:[jsx(Animated.View,{style:[Un.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[Un.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:Un.rightIcons,children:Array.from({length:i}).map((a,c)=>jsx(Animated.View,{style:[Un.rightIcon,{backgroundColor:n,opacity:r}]},c))})]});return jsxs(View,{style:Un.container,children:[jsx(s,{rightIcons:3}),jsx(s,{rightIcons:2}),jsx(s,{rightIcons:0})]})}var Un=StyleSheet.create({container:{paddingTop:8,paddingBottom:24,gap:8},card:{marginHorizontal:16,flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:12,gap:12},leftIcon:{width:36,height:36},textBlock:{flex:1,gap:6},titleBar:{height:12,width:"70%",borderRadius:6},subtitleBar:{height:10,width:"50%",borderRadius:5},rightIcons:{flexDirection:"row",alignItems:"center",gap:4},rightIcon:{width:20,height:20,borderRadius:10}});function ty({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:s,recipientAddress:i,destinationChainType:a,destinationChainId:c,destinationTokenAddress:u,defaultChainType:l,defaultChainId:h,defaultTokenAddress:S,showBalance:g=false,hideDepositTracker:y=false,enableStripeLinkPay:C=false,StripeOnrampComponent:d,stripeOnrampEmail:w,stripeOnrampPhone:b,stripeMerchantIdentifier:m,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:x,stripeTheme:_,depositConfirmationMode:F="auto_ui",transferInputVariant:k="double_input",initialScreen:T="main",onDepositSuccess:A,onDepositError:M,sheetBorderRadius:O}){let v=O?.globalBorderTopLeftRadius,z=O?.globalBorderTopRightRadius,{colors:E,fonts:de}=V(),[Qe,We]=useState([]),[oe,ae]=useState(()=>T==="tracker"&&!y),[be,Ie]=useState(()=>T==="transfer"),[rt,Ne]=useState(()=>T==="card"),[Se,ue]=useState(false),[Te,Ke]=useState(null),[lt,ve]=useState("amount"),{isAllowed:Ve,isLoading:Be}=ra(o,e);useEffect(()=>{if(!e||Te)return;let pe=false;return xs(o).then(async wt=>{if(pe)return;let ut=[];for(let Ye of wt?.transfer_crypto?.networks??[]){let je=Ye.icon_urls.find(Pt=>Pt.format==="png")?.url||Ye.icon_urls.find(Pt=>Pt.format==="svg")?.url;je&&ut.push(J(je));}for(let Ye of wt?.payment_networks?.networks??[]){let je=Ye.icon_urls.find(Pt=>Pt.format==="png")?.url||Ye.icon_urls.find(Pt=>Pt.format==="svg")?.url;je&&ut.push(J(je));}ut.length>0&&await Gc(ut),pe||Ke(wt);}).catch(console.error),()=>{pe=true;}},[e,Te,o]);let X=()=>{t();},q=T==="main"||T==="tracker"&&y,Ce=Qe.filter(pe=>pe.status==="pending"||pe.status==="waiting").length,W=!!(i&&a&&c&&u&&o)&&g!==false&&!!Te,L=Be||e&&!Te,ee=Ve===false,le=null;if(Se&&d){let pe=jsx(d,{publishableKey:o,email:w,phone:b,externalUserId:r,recipientAddress:i??"",destinationChainType:a,destinationChainId:c,destinationTokenAddress:u,merchantIdentifier:m,paymentSelectorPosition:f,skipSuccessConfirmation:x,onClose:()=>ue(false)});le=_?jsx(Fi,{..._,children:pe}):pe;}return jsxs(Fragment,{children:[jsxs(Ze,{visible:e&&q,onClose:X,closeOnBackdropPress:false,showHandle:false,borderTopLeftRadius:O?.main?.borderTopLeftRadius??v,borderTopRightRadius:O?.main?.borderTopRightRadius??z,children:[jsx(Tr,{title:n,showBack:false,onClose:X,showBalance:W,balanceAddress:i,balanceChainType:a,balanceChainId:c,balanceTokenAddress:u,publishableKey:o,projectName:Te?.project_name}),L&&jsx(ey,{}),!L&&ee&&jsxs(View,{style:br.centeredContainer,children:[jsx(View,{style:[br.iconContainer,{backgroundColor:E.cardHover}],children:jsx(ks,{size:32,color:E.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:E.foreground,fontFamily:de.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:E.foreground,opacity:.7,fontFamily:de.regular}],children:"There are no supported tokens available from your current location."})]}),!L&&!ee&&jsxs(View,{style:br.optionsContainer,children:[jsx(qs,{onPress:()=>Ie(true),title:nn.transferCrypto.title,subtitle:nn.transferCrypto.subtitle,featuredTokens:Te?.transfer_crypto?.networks}),jsx(Ks,{onPress:()=>Ne(true),title:nn.depositWithCard.title,subtitle:nn.depositWithCard.subtitle,paymentNetworks:Te?.payment_networks?.networks}),C&&d&&jsx(Js,{onPress:()=>ue(true),title:nn.stripeLinkPay.title,subtitle:nn.stripeLinkPay.subtitle}),!y&&jsx(Gs,{onPress:()=>ae(true),title:nn.depositTracker.title,subtitle:nn.depositTracker.subtitle,badge:Ce>0?Ce:void 0})]})]}),jsx(wl,{visible:e&&oe,onClose:()=>{ae(false),q||X();},executions:Qe,externalUserId:r,publishableKey:o,borderTopLeftRadius:O?.depositsTracker?.borderTopLeftRadius??v,borderTopRightRadius:O?.depositsTracker?.borderTopRightRadius??z}),jsxs(Ze,{visible:e&&be,onClose:()=>{Ie(false),q||X();},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,borderTopLeftRadius:O?.transferCrypto?.borderTopLeftRadius??v,borderTopRightRadius:O?.transferCrypto?.borderTopRightRadius??z,children:[jsx(Tr,{title:nn.transferCrypto.title,showBack:false,onClose:()=>{Ie(false),q||X();},showBalance:W,balanceAddress:i,balanceChainType:a,balanceChainId:c,balanceTokenAddress:u,publishableKey:o,projectName:Te?.project_name}),Be&&jsx(View,{style:[br.centeredContainer,br.centeredFlex],children:jsx(ActivityIndicator,{color:E.foreground})}),!Be&&ee&&jsxs(View,{style:[br.centeredContainer,br.centeredFlex],children:[jsx(View,{style:[br.iconContainer,{backgroundColor:E.cardHover}],children:jsx(ks,{size:32,color:E.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:E.foreground,fontFamily:de.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:E.foreground,opacity:.7,fontFamily:de.regular}],children:"There are no supported tokens available from your current location."})]}),!Be&&!ee&&jsx(ScrollView,{style:br.transferScrollContainer,contentContainerStyle:br.scrollContent,showsVerticalScrollIndicator:false,children:k==="single_input"?jsx(xd,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:a,destinationChainId:c,destinationTokenAddress:u,destinationTokenSymbol:s,defaultChainType:l,defaultChainId:h,defaultTokenAddress:S,depositConfirmationMode:F,onExecutionsChange:We,onDepositSuccess:A,onDepositError:M,borderTopLeftRadius:v,borderTopRightRadius:z,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(cl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:a,destinationChainId:c,destinationTokenAddress:u,destinationTokenSymbol:s,defaultChainType:l,defaultChainId:h,defaultTokenAddress:S,depositConfirmationMode:F,onExecutionsChange:We,onDepositSuccess:A,onDepositError:M,borderTopLeftRadius:v,borderTopRightRadius:z,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),jsxs(Ze,{visible:e&&rt,onClose:()=>{Ne(false),ve("amount"),q||X();},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,borderTopLeftRadius:O?.buyWithCard?.borderTopLeftRadius??v,borderTopRightRadius:O?.buyWithCard?.borderTopRightRadius??z,children:[jsx(Tr,{title:`Deposit ${s||"USDC"}`,showBack:lt==="onramp",onBack:()=>ve("amount"),onClose:()=>{Ne(false),ve("amount"),q||X();},showBalance:W,balanceAddress:i,balanceChainType:a,balanceChainId:c,balanceTokenAddress:u,publishableKey:o,projectName:Te?.project_name}),jsx(View,{style:br.buyWithCardContainer,children:jsx(hl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:s,recipientAddress:i,destinationChainType:a,destinationChainId:c,destinationTokenAddress:u,onDepositSuccess:A,onDepositError:M,view:lt,onViewChange:pe=>ve(pe),borderTopLeftRadius:v,borderTopRightRadius:z,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),C&&d&&jsx(Ze,{visible:e&&Se,onClose:()=>ue(false),closeOnBackdropPress:false,showHandle:false,heightPercent:1,borderTopLeftRadius:0,borderTopRightRadius:0,children:jsx(View,{style:br.stripeLinkPayContainer,children:le})})]})}function Il({theme:e="auto",...t}){return jsx(ty,{...t})}var br=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},stripeLinkPayContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},centeredFlex:{flex:1},iconContainer:{width:64,height:64,borderRadius:32,alignItems:"center",justifyContent:"center",marginBottom:16},blockedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},blockedDescription:{fontSize:14,textAlign:"center",maxWidth:280,lineHeight:20}});function vl(e,t=true){return Yo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Sa(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function _d(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:s,enabled:i=true}=e;return Yo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,s],queryFn:async()=>{let c=await qn(s),u=null,l=null,h=null,S=null,g,y,C,d=c.data.some(w=>w.chains.some(b=>{let m=b.chain_type===t&&b.chain_id===r&&b.token_address.toLowerCase()===o.toLowerCase();return m&&(u=b.minimum_deposit_amount_usd,l=b.estimated_processing_time,h=b.max_slippage_percent,S=b.estimated_price_impact_percent,C=b.chain_name,y=w),m}));if(y){let w=ge(y,"png");w&&(g=J(w));}return {isSupported:d,minimumAmountUsd:u,estimatedProcessingTime:l,maxSlippagePercent:h,priceImpactPercent:S,errorMessage:d?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:g,chainName:C}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Rd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:s,enabled:i=true}=e;return Yo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,s],queryFn:async()=>{let c=await Ta(t,r,o,n,s);if(c.balance){let u=c.balance.token?.decimals??6,l=c.balance.token?.symbol??"",h=c.balance.amount,S=BigInt(h),g=BigInt(10**u),y=S/g,d=(S%g).toString().padStart(u,"0").replace(/0+$/,""),w=d?`${y}.${d}`:y.toString();return {balanceBaseUnit:h,balanceHuman:w,balanceUsd:c.balance.amount_usd,exchangeRate:c.balance.exchange_rate,decimals:u,symbol:l}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:i&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var oy=2500,ny=3e3,iy=6e4;function Id({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:s}){let[i,a]=useState([]),[c,u]=useState(false),l=useRef(new Date),h=useRef(new Map),S=useRef(false),g=useRef(n),y=useRef(s);return useEffect(()=>{g.current=n;},[n]),useEffect(()=>{y.current=s;},[s]),useEffect(()=>{o&&!S.current&&(l.current=new Date,h.current.clear()),o||h.current.clear(),S.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let C=l.current,d=async()=>{try{let b=await No(e,t,"withdraw"),m=new Date(C.getTime()-iy),f=[...b.data].sort((k,T)=>{let A=k.created_at?new Date(k.created_at).getTime():0;return (T.created_at?new Date(T.created_at).getTime():0)-A}),x=["pending","waiting","delayed"],_=["succeeded","failed"],F=null;for(let k of f){let T=k.created_at?new Date(k.created_at):null;if(!T||T<m)continue;let A=h.current.get(k.id);if(!A){F=k;break}if(x.includes(A)&&_.includes(k.status)){F=k;break}}if(F){let k=F,T=k.created_at?new Date(k.created_at):null;if(!T||T<l.current)return;let A=h.current.get(k.id);h.current.set(k.id,k.status),a(M=>{let O=M.findIndex(v=>v.id===k.id);if(O>=0){let v=[...M];return v[O]=k,v}return [...M,k]}),k.status==="succeeded"&&(!A||x.includes(A))?g.current?.({message:"Withdrawal completed successfully",transaction:k}):k.status==="failed"&&A!=="failed"&&y.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:k});}}catch(b){console.error("Failed to fetch withdraw executions:",b),y.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:b});}};d();let w=setInterval(d,oy);return u(true),()=>{clearInterval(w),u(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let C=async()=>{try{await nc({deposit_wallet_id:r},t);}catch{}};C();let d=setInterval(C,ny);return ()=>clearInterval(d)},[o,r,t]),{executions:i,isPolling:c}}var vd=(e,t)=>`${t}:${e}`;function ia({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:s=false,tokenLabel:i="Receive token",chainLabel:a="Receive chain",tokenPickerBorderTopLeftRadius:c,tokenPickerBorderTopRightRadius:u,chainPickerBorderTopLeftRadius:l,chainPickerBorderTopRightRadius:h}){let{colors:S,fonts:g,components:y}=V(),[C,d]=useState(false),[w,b]=useState(false),m=y.card,f=t?e.find(k=>k.symbol===t):void 0,x=f?.chains||[],_=r?x.find(k=>vd(k.chain_id,k.chain_type)===r):void 0,F={backgroundColor:m.backgroundColor,borderRadius:m.borderRadius,borderWidth:m.borderWidth||1,borderColor:m.borderColor};return jsxs(View,{style:qe.row,children:[jsxs(View,{style:qe.col,children:[jsx(Text,{style:[qe.label,{color:m.labelColor,fontFamily:g.medium}],children:i}),jsxs(TouchableOpacity,{style:[qe.selectButton,F],onPress:()=>!s&&e.length>0&&d(true),activeOpacity:.7,disabled:s||e.length===0,children:[s?jsx(Text,{style:[qe.placeholder,{color:m.subtitleColor,fontFamily:g.regular}],children:"Loading..."}):f?jsxs(View,{style:qe.selectedItem,children:[jsx(Image,{source:{uri:J(ge(f,"png"))},style:qe.icon}),jsx(Text,{style:[qe.selectedText,{color:m.titleColor,fontFamily:g.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[qe.placeholder,{color:m.subtitleColor,fontFamily:g.regular}],children:"Select receive token"}),jsx(Ot,{size:16,color:m.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:qe.col,children:[jsx(Text,{style:[qe.label,{color:m.labelColor,fontFamily:g.medium}],children:a}),jsxs(TouchableOpacity,{style:[qe.selectButton,F,(!f||x.length===0)&&qe.disabled],onPress:()=>!s&&f&&x.length>0&&b(true),activeOpacity:.7,disabled:s||!f||x.length===0,children:[_?jsxs(View,{style:qe.selectedItem,children:[jsx(Image,{source:{uri:J(ge(_,"png"))},style:qe.icon}),jsx(Text,{style:[qe.selectedText,{color:m.titleColor,fontFamily:g.medium}],numberOfLines:1,children:_.chain_name})]}):jsx(Text,{style:[qe.placeholder,{color:m.subtitleColor,fontFamily:g.regular}],children:"Chain"}),jsx(Ot,{size:16,color:m.actionColor,strokeWidth:2})]})]}),jsxs(Ze,{visible:C,onClose:()=>d(false),closeOnBackdropPress:true,showHandle:false,heightPercent:.6,borderTopLeftRadius:c,borderTopRightRadius:u,children:[jsxs(View,{style:qe.pickerHeader,children:[jsx(View,{style:qe.pickerHeaderSpacer}),jsx(Text,{style:[qe.pickerTitle,{color:S.foreground,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:qe.pickerHeaderClose,onPress:()=>d(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(nt,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(FlatList,{data:e,keyExtractor:k=>k.symbol,contentContainerStyle:qe.listContent,renderItem:({item:k})=>jsxs(TouchableOpacity,{style:[qe.pickerItem,{backgroundColor:k.symbol===t?S.cardHover:"transparent"}],onPress:()=>{o(k.symbol),d(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:J(ge(k,"png"))},style:qe.pickerIcon}),jsx(Text,{style:[qe.pickerItemText,{color:S.foreground,fontFamily:g.medium}],children:k.symbol}),jsx(Text,{style:[qe.pickerItemSub,{color:S.foregroundMuted,fontFamily:g.regular}],children:k.name}),k.symbol===t&&jsx($e,{size:18,color:S.primary,strokeWidth:2.5})]})})]}),jsxs(Ze,{visible:w,onClose:()=>b(false),closeOnBackdropPress:true,showHandle:false,heightPercent:.6,borderTopLeftRadius:l,borderTopRightRadius:h,children:[jsxs(View,{style:qe.pickerHeader,children:[jsx(View,{style:qe.pickerHeaderSpacer}),jsx(Text,{style:[qe.pickerTitle,{color:S.foreground,fontFamily:g.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:qe.pickerHeaderClose,onPress:()=>b(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(nt,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(FlatList,{data:x,keyExtractor:k=>vd(k.chain_id,k.chain_type),contentContainerStyle:qe.listContent,renderItem:({item:k})=>{let T=vd(k.chain_id,k.chain_type);return jsxs(TouchableOpacity,{style:[qe.pickerItem,{backgroundColor:T===r?S.cardHover:"transparent"}],onPress:()=>{n(T),b(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:J(ge(k,"png"))},style:qe.pickerIcon}),jsx(Text,{style:[qe.pickerItemText,{color:S.foreground,fontFamily:g.medium}],children:k.chain_name}),T===r&&jsx($e,{size:18,color:S.primary,strokeWidth:2.5})]})}})]})]})}var qe=StyleSheet.create({row:{flexDirection:"column",gap:10},col:{},label:{fontSize:12,marginBottom:6},selectButton:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:12,gap:6,minHeight:48},selectedItem:{flex:1,flexDirection:"row",alignItems:"center",gap:6},icon:{width:20,height:20,borderRadius:10},selectedText:{fontSize:13,flexShrink:1},placeholder:{flex:1,fontSize:13},disabled:{opacity:.4},pickerHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:16,paddingBottom:12},pickerHeaderSpacer:{width:28},pickerHeaderClose:{width:28,alignItems:"flex-end"},pickerTitle:{flex:1,fontSize:16,textAlign:"center"},listContent:{paddingHorizontal:16,paddingVertical:8},pickerItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:12,borderRadius:10,gap:10},pickerIcon:{width:32,height:32,borderRadius:16},pickerItemText:{fontSize:15,flex:1},pickerItemSub:{fontSize:13}});function Pd(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:s,enabled:i=true}=e,a=n?.trim()||"",c=!!t&&!!r&&!!o&&a.length>0;return Yo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,a,s],queryFn:()=>oc({chain_type:t,chain_id:r,token_address:o,recipient_address:a},s),enabled:i&&c,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function cy(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function dy(e,t){if(e<=0)return "0";if(t===0)return BigInt(Math.round(e)).toString();let r=e.toFixed(t),[o,n=""]=r.split("."),s=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(s)).toString()}function uy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Fl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:s,sourceTokenIconUrl:i,recipientAddressProp:a,selectedToken:c,selectedChain:u,balanceData:l,isLoadingBalance:h,minimumWithdrawAmountUsd:S,estimatedProcessingTime:g,maxSlippagePercent:y,priceImpactPercent:C,canWithdraw:d,onDepositWalletCreation:w,onWithdraw:b,onWithdrawError:m,onWithdrawSubmitted:f,onViewTracker:x}){let _="https://unifold.io/terms",F="https://unifold.io/support",{colors:k,fonts:T,components:A}=V(),[M,O]=useState(a||""),[v,z]=useState(""),[E,de]=useState("crypto"),[Qe,We]=useState(false),[oe,ae]=useState(null),[be,Ie]=useState(false),[rt,Ne]=useState(""),Se=useRef(null);useEffect(()=>{O(a||""),z(""),de("crypto"),ae(null);},[a]);let ue=M.trim();useEffect(()=>{let ce=setTimeout(()=>Ne(ue),500);return ()=>clearTimeout(ce)},[ue]);let {data:Te,isLoading:Ke,error:lt}=Pd({chainType:u?.chain_type,chainId:u?.chain_id,tokenAddress:u?.token_address,recipientAddress:rt,publishableKey:e,enabled:rt.length>5&&!!u}),ve=ue!==rt,Ve=useMemo(()=>!ue||ue.length<=5||ve||Ke?null:lt?"Invalid address":Te&&!Te.valid?Te.failure_code==="account_not_found"?`Account not found on ${u?.chain_name}`:Te.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${c?.symbol} on ${u?.chain_name}`:"Invalid address":null,[ue,ve,Ke,lt,Te,u,c]),Be=!ve&&!!Te?.valid&&!Ve,X=useMemo(()=>l?.exchangeRate?parseFloat(l.exchangeRate):0,[l]),q=useMemo(()=>l?.balanceHuman?parseFloat(l.balanceHuman):0,[l]),Ce=useMemo(()=>l?.balanceUsd?parseFloat(l.balanceUsd):0,[l]),dt=n||l?.symbol||"TOKEN",W=l?.decimals??6,L=useMemo(()=>{let ce=parseFloat(v);return !ce||ce<=0?0:E==="crypto"?ce:X>0?ce/X:0},[v,E,X]),ee=useMemo(()=>{let ce=parseFloat(v);return !ce||ce<=0?0:E==="fiat"?ce:ce*X},[v,E,X]);useMemo(()=>!v||parseFloat(v)<=0?null:E==="crypto"?`$${ee.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`:`${L.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})} ${dt}`,[v,E,ee,L,dt]);useMemo(()=>h||!l?null:E==="crypto"?`${q.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})} ${dt}`:`$${Ce.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`,[h,l,E,q,Ce,dt]);let wt=useCallback(async()=>{try{let tt=await Mm("expo-clipboard").getStringAsync();tt&&(O(tt.trim()),ae(null));}catch{}},[]),ut=useCallback(()=>{let ce=parseFloat(v);if(!ce||ce<=0||X<=0){de(tt=>tt==="crypto"?"fiat":"crypto"),z("");return}E==="crypto"?(z((ce*X).toFixed(2)),de("fiat")):(z((ce/X).toFixed(W>6?6:W)),de("crypto"));},[v,E,X,W]),Ye=useCallback(()=>{if(E==="crypto"){if(q<=0)return;z(l?.balanceHuman??"0");}else {if(Ce<=0)return;z((Math.floor(Ce*100)/100).toFixed(2));}},[E,q,Ce,l]),je=S!==null&&ee>0&&ee<S,Pt=E==="crypto"?L>0&&q>0&&L>q:ee>0&&Ce>0&&ee>Ce,_t=ue.length>0&&v.trim().length>0&&L>0&&Be&&!je&&!Pt&&!!l,ir=useCallback(async()=>{if(!(!c||!u||!_t||!d)){We(true),ae(null);try{let ce=await w({destinationChainType:u.chain_type,destinationChainId:u.chain_id,destinationTokenAddress:u.token_address,recipientAddress:ue}),tt=dy(L,W),fe=uy(L,W),Je={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:dt,sourceTokenIconUrl:i,destinationChainType:u.chain_type,destinationChainId:u.chain_id,destinationTokenAddress:u.token_address,destinationTokenSymbol:c.symbol,destinationChainName:u.chain_name,destinationTokenIconUrl:c?J(ge(c,"png")):void 0,amount:fe,amountBaseUnit:tt,submittedAt:new Date,withdrawIntentAddress:ce.address,recipientAddress:ue};await b(Je),f(Je);}catch(ce){let tt=ce instanceof Error?ce.message:"Withdrawal failed. Please try again.",fe=tt.length>120?"Withdrawal failed. Please try again.":tt;ae(fe),m?.({message:tt,error:ce,code:"WITHDRAW_FAILED"});}finally{We(false);}}},[c,u,_t,d,ue,t,r,o,dt,i,v,E,q,Ce,l,L,W,ee,w,b,m,f]),Ae=A.input,ot=A.card,pt=A.button,Or=Ve?k.error:Ae.borderColor,Cr=useMemo(()=>Qe?"Processing...":Pt?"Insufficient balance":je?`Minimum $${S?.toFixed(2)}`:oe?"Withdrawal failed \u2014 try again":"Withdraw",[Qe,Pt,je,S,oe]);return jsxs(View,{style:He.container,children:[jsxs(View,{children:[jsxs(View,{style:He.labelRow,children:[jsx(Text,{style:[He.label,{color:ot.labelColor,fontFamily:T.medium}],children:"Recipient address"}),(ve||Ke)&&ue.length>5?jsx(ActivityIndicator,{size:"small",color:k.foregroundMuted}):jsx(TouchableOpacity,{onPress:wt,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(Ud,{size:16,color:k.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[He.inputRow,{backgroundColor:Ae.backgroundColor,borderRadius:Ae.borderRadius,borderWidth:Ae.borderWidth,borderColor:Or}],children:jsx(TextInput,{style:[He.textInput,{color:Ae.textColor,fontFamily:T.regular}],placeholder:"Enter wallet address",placeholderTextColor:Ae.placeholderColor,value:M,onChangeText:ce=>{O(ce),ae(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Se.current?.focus()})}),Ve?jsx(Text,{style:[He.errorText,{color:k.error,fontFamily:T.regular}],children:Ve}):null]}),jsxs(View,{children:[jsxs(Text,{style:[He.label,{color:ot.labelColor,fontFamily:T.medium,paddingBottom:8}],children:["Amount",S!=null&&S>0&&jsx(Text,{style:{color:k.warning,fontFamily:T.regular},children:` ($${S.toFixed(2)} min)`})]}),jsxs(View,{style:[He.amountRow,{backgroundColor:Ae.backgroundColor,borderRadius:Ae.borderRadius,borderWidth:Ae.borderWidth,borderColor:Ae.borderColor}],children:[jsx(TextInput,{ref:Se,style:[He.amountInput,{color:Ae.textColor,fontFamily:T.regular}],placeholder:"0.00",placeholderTextColor:Ae.placeholderColor,value:v,onChangeText:ce=>{(ce===""||/^\d*\.?\d*$/.test(ce))&&(z(ce),ae(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(TouchableOpacity,{onPress:X>0?ut:void 0,activeOpacity:.7,children:jsx(Text,{style:[He.unitLabel,{color:k.foregroundMuted,fontFamily:T.medium}],children:E==="crypto"?dt:"USD"})}),jsx(TouchableOpacity,{style:[He.maxButton,{backgroundColor:`${k.primary}20`}],onPress:Ye,activeOpacity:.7,children:jsx(Text,{style:[He.maxText,{color:k.primary,fontFamily:T.medium}],children:"Max"})})]})]}),jsxs(View,{style:[He.detailsCard,{marginTop:24,backgroundColor:ot.backgroundColor,borderRadius:ot.borderRadius,borderWidth:ot.borderWidth||1,borderColor:ot.borderColor}],children:[jsx(TouchableOpacity,{style:He.detailsToggle,onPress:()=>Ie(!be),activeOpacity:.7,children:jsxs(View,{style:He.detailsRow,children:[jsx(View,{style:[He.detailIcon,{backgroundColor:ot.iconBackgroundColor,borderRadius:ot.iconContainerBorderRadius}],children:jsx(yo,{size:12,color:ot.iconColor,strokeWidth:2})}),jsxs(Text,{style:[He.detailsLabel,{color:ot.titleColor,fontFamily:T.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:T.medium},children:cy(g)})]}),jsx(View,{style:{transform:[{rotate:be?"180deg":"0deg"}]},children:jsx(Ot,{size:16,color:ot.actionColor,strokeWidth:2})})]})}),be&&jsxs(View,{style:He.detailsExpanded,children:[jsxs(View,{style:He.detailsRow,children:[jsx(View,{style:[He.detailIcon,{backgroundColor:ot.iconBackgroundColor,borderRadius:ot.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:ot.iconColor,strokeWidth:2})}),jsxs(Text,{style:[He.detailsLabel,{color:ot.titleColor,fontFamily:T.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:T.medium},children:["Auto \u2022 ",(y??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:He.detailsRow,children:[jsx(View,{style:[He.detailIcon,{backgroundColor:ot.iconBackgroundColor,borderRadius:ot.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:ot.iconColor,strokeWidth:2})}),jsxs(Text,{style:[He.detailsLabel,{color:ot.titleColor,fontFamily:T.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:T.medium},children:[(C??0).toFixed(2),"%"]})]})]})]})]}),oe&&jsx(Text,{style:[He.errorText,{color:k.error,fontFamily:T.regular,textAlign:"center"}],children:oe}),jsxs(View,{style:He.withdrawRow,children:[jsxs(TouchableOpacity,{style:[He.withdrawButton,{backgroundColor:pt.primaryBackground,borderRadius:pt.borderRadius,borderWidth:pt.borderWidth,borderColor:pt.borderColor,opacity:!_t||!d||Qe?.5:1}],onPress:ir,disabled:!_t||!d||Qe,activeOpacity:.8,children:[Qe&&jsx(ActivityIndicator,{size:"small",color:pt.primaryText}),jsx(Text,{style:[He.withdrawButtonText,{color:pt.primaryText,fontFamily:T.medium}],children:Cr})]}),jsxs(View,{style:He.footerRow,children:[jsxs(TouchableOpacity,{style:He.historyLink,onPress:x,activeOpacity:.7,children:[jsx(yo,{size:14,color:k.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[He.historyText,{color:k.foregroundMuted,fontFamily:T.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:He.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[He.legalText,{color:k.foregroundMuted,fontFamily:T.regular}],children:"Terms"})}),jsx(Text,{style:[He.legalSeparator,{color:k.foregroundMuted,fontFamily:T.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(F),activeOpacity:.7,children:jsx(Text,{style:[He.legalText,{color:k.foregroundMuted,fontFamily:T.regular}],children:"Help"})})]})]})]})]})}var He=StyleSheet.create({container:{gap:12,paddingHorizontal:16,paddingBottom:16},label:{fontSize:12},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:6},inputRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:4,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:4,minHeight:48,gap:8},amountInput:{flex:1,fontSize:14,paddingVertical:8},unitLabel:{fontSize:14,flexShrink:0},maxButton:{paddingHorizontal:8,paddingVertical:4,borderRadius:6},maxText:{fontSize:12,fontWeight:"600"},balanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginTop:6,paddingHorizontal:4},convertedText:{fontSize:12},balanceText:{fontSize:12},withdrawRow:{gap:12},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},historyLink:{flexDirection:"row",alignItems:"center",gap:6},historyText:{fontSize:13},legalLinks:{flexDirection:"row",alignItems:"center",gap:6},legalText:{fontSize:13},legalSeparator:{fontSize:13},detailsCard:{paddingHorizontal:12,overflow:"hidden"},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13,flex:1},detailsExpanded:{gap:10,paddingBottom:12},withdrawButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:15,gap:8},withdrawButtonText:{fontSize:16,fontWeight:"600"}});function fy(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 hy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ll({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=V(),s=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed",a=e.status==="failed"||e.status==="refunded",c=a?r.error:i?r.warning:r.success,u=J(ge(e.destination_token_metadata,"png")||Nt("/icons/tokens/png/usdc.png")),l=a?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",h=fy(e.created_at||new Date().toISOString()),S=hy(e.source_amount_usd);return jsxs(Yt,{cardTokens:s,onPress:t,contentStyle:ln.container,children:[jsxs(View,{style:ln.iconContainer,children:[jsx(Image,{source:{uri:u},style:ln.tokenIcon}),jsx(View,{style:[ln.statusBadge,{backgroundColor:c,borderColor:s.backgroundColor}],children:a?jsx(ws,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(ma,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:ln.textContainer,children:[jsx(Text,{style:[ln.title,{color:s.titleColor,fontFamily:o.medium}],children:l}),jsx(Text,{style:[ln.dateTime,{color:s.subtitleColor,fontFamily:o.regular}],children:h})]}),jsxs(View,{style:ln.rightContainer,children:[jsx(Text,{style:[ln.amount,{color:s.textRightColor,fontFamily:o.medium}],children:S}),jsx(Vr,{size:20,color:s.actionColor,strokeWidth:2})]})]})}var ln=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function Fd(e){try{let t=new Date(e),o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=t.getDate(),s=t.getFullYear(),i=t.getHours(),a=t.getMinutes(),c=i>=12?"PM":"AM";i=i%12||12;let u=a<10?`0${a}`:`${a}`;return `${o} ${n}, ${s} at ${i}:${u} ${c}`}catch{return e}}function Rm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function by(e,t){if(e)try{return `$${Number(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}if(t)try{return `$${(Number(t)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}return "$0.00"}function Im(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function vm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function sa({label:e,value:t,isLast:r}){let{fonts:o,components:n}=V(),s=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:De.detailRow,children:[jsx(Text,{style:[De.detailLabel,{color:s.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[De.detailValue,{color:s.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[De.divider,{backgroundColor:s.borderColor}]})]})}function Vd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:s}){let{colors:i,fonts:a,components:c}=V(),[u,l]=useState([]),[h,S]=useState(!!n),g=c.card,y=c.button,C=c.header,d=c.container;useEffect(()=>{rc().then(de=>l(de.data)).catch(()=>{});},[]),useEffect(()=>{S(!!n);},[e?.id]);let w=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,b=e?e.status==="failed"||e.status==="refunded":false,m=b?i.error:w?i.warning:i.success,f=b?"Failed":w?"Processing":"Completed",x=e?.destination_token_metadata?J(ge(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?J(t.destinationTokenIconUrl):J(Nt("/icons/tokens/png/usdc.png")),_=e?.created_at?Fd(e.created_at):t.submittedAt?Fd(t.submittedAt.toISOString()):Fd(new Date().toISOString()),F=e?`${Rm(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Im(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,k=e?`${Rm(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Im(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,T=e?by(e.source_amount_usd,e.source_amount_base_unit):"$0.00",A=e?ka(u,e.source_chain_type,e.source_chain_id):t.sourceChainId,M=e?ka(u,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,v=e?.explorer_url,z=e?.destination_transaction_hashes?.[0],E=e?.destination_explorer_url;return jsxs(ScrollView,{style:De.scroll,contentContainerStyle:De.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:De.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Pi,{size:22,color:C.buttonColor,strokeWidth:2})}):jsx(View,{style:De.headerSpacer}),jsx(Text,{style:[De.headerTitle,{color:C.titleColor,fontFamily:a.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:De.headerSpacer}):jsx(TouchableOpacity,{onPress:s??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(nt,{size:20,color:C.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:De.iconContainer,children:[jsx(Image,{source:{uri:x},style:De.tokenIcon}),jsx(View,{style:[De.statusBadge,{backgroundColor:m}],children:b?jsx(ws,{size:10,color:"#FFFFFF",strokeWidth:3}):w?jsx(View,{style:De.spinnerDot}):jsx($e,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:De.statusRow,children:[jsx(View,{style:[De.statusDot,{backgroundColor:m}]}),jsx(Text,{style:[De.statusText,{color:m,fontFamily:a.medium}],children:f})]}),jsx(Text,{style:[De.dateText,{color:d.subtitleColor,fontFamily:a.regular}],children:_}),jsxs(View,{style:[De.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:[jsx(sa,{label:"Amount Sent",value:F}),jsx(sa,{label:"Amount Received",value:k}),jsx(sa,{label:"USD Value",value:T}),jsx(sa,{label:"Source Network",value:A}),jsx(sa,{label:"Destination Network",value:M,isLast:true})]}),jsxs(TouchableOpacity,{style:De.moreDetailsRow,onPress:()=>S(de=>!de),activeOpacity:.7,children:[jsx(Text,{style:[De.moreDetailsText,{color:d.actionTitle,fontFamily:a.regular}],children:h?"See less":n?"See more":"See more details"}),h?jsx(Co,{size:16,color:d.actionColor,strokeWidth:2}):jsx(Ot,{size:16,color:d.actionColor,strokeWidth:2})]}),h&&jsx(View,{style:[De.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:O&&v?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:De.txRow,onPress:()=>Linking.openURL(v),activeOpacity:.7,children:[jsx(Text,{style:[De.txLabel,{color:g.subtitleColor,fontFamily:a.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[De.txHash,{color:g.titleColor,fontFamily:a.regular}],children:vm(O)}),jsx(bo,{size:14,color:g.actionColor,strokeWidth:2})]}),!w&&z&&E&&jsxs(Fragment,{children:[jsx(View,{style:[De.divider,{backgroundColor:g.borderColor}]}),jsxs(TouchableOpacity,{style:De.txRow,onPress:()=>Linking.openURL(E),activeOpacity:.7,children:[jsx(Text,{style:[De.txLabel,{color:g.subtitleColor,fontFamily:a.regular}],children:"Completion Tx"}),jsx(Text,{style:[De.txHash,{color:g.titleColor,fontFamily:a.regular}],children:vm(z)}),jsx(bo,{size:14,color:g.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:De.detailRow,children:jsx(Text,{style:[De.detailLabel,{color:g.subtitleColor,fontFamily:a.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:De.buttonRow,children:[jsx(TouchableOpacity,{style:[De.button,De.halfButton,{backgroundColor:y.secondaryBackground,borderRadius:y.borderRadius,borderWidth:y.borderWidth,borderColor:y.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[De.buttonText,{color:y.secondaryText,fontFamily:a.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[De.button,De.halfButton,{backgroundColor:y.primaryBackground,borderRadius:y.borderRadius,borderWidth:y.borderWidth,borderColor:y.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[De.buttonText,{color:y.primaryText,fontFamily:a.medium}],children:"Close"})})]})]})}var De=StyleSheet.create({scroll:{flex:1},container:{alignItems:"center",paddingHorizontal:20,paddingTop:8,paddingBottom:32,gap:12},headerRow:{flexDirection:"row",alignItems:"center",width:"100%",paddingTop:16,marginBottom:4},headerSpacer:{width:28},headerTitle:{flex:1,fontSize:16,textAlign:"center"},iconContainer:{position:"relative",marginTop:8},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center"},spinnerDot:{width:10,height:10,borderRadius:5,borderWidth:2,borderColor:"#FFFFFF",borderTopColor:"transparent"},statusRow:{flexDirection:"row",alignItems:"center",gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:15},dateText:{fontSize:13,marginTop:-4},detailsCard:{width:"100%",paddingHorizontal:16,overflow:"hidden"},detailRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailLabel:{fontSize:13,flex:1},detailValue:{fontSize:13,flexShrink:0,maxWidth:"55%",textAlign:"right"},divider:{height:StyleSheet.hairlineWidth,opacity:.5},moreDetailsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingHorizontal:4},moreDetailsText:{fontSize:14},txRow:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:12},txLabel:{fontSize:13},txHash:{fontSize:13,flex:1,textAlign:"right"},buttonRow:{flexDirection:"row",gap:10,width:"100%",marginTop:4},button:{paddingVertical:14,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:14}});function Pm(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Bl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:s,components:i}=V(),a=t.length>0?t[t.length-1]:null,c=a?.status==="succeeded",u=a?.status==="failed",l={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return c?jsxs(View,{style:kt.container,children:[jsx(TouchableOpacity,{style:kt.closeButton,onPress:r,children:jsx(nt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[kt.iconRing,{backgroundColor:n.successBackground}],children:jsx($e,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[kt.title,{color:n.foreground,fontFamily:s.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[kt.subtitle,{color:n.foregroundMuted,fontFamily:s.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",Pm(e.recipientAddress)]}),jsxs(View,{style:kt.buttonRow,children:[jsx(TouchableOpacity,{style:[kt.button,kt.halfButton,l,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[kt.buttonText,{color:i.button.secondaryText,fontFamily:s.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[kt.button,kt.halfButton,l,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[kt.buttonText,{color:i.button.primaryText,fontFamily:s.medium}],children:"Close"})})]})]}):u?jsxs(View,{style:kt.container,children:[jsx(TouchableOpacity,{style:kt.closeButton,onPress:r,children:jsx(nt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[kt.iconRing,{backgroundColor:n.errorBackground}],children:jsx(nt,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[kt.title,{color:n.foreground,fontFamily:s.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[kt.subtitle,{color:n.foregroundMuted,fontFamily:s.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[kt.button,kt.fullButton,l,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[kt.buttonText,{color:i.button.primaryText,fontFamily:s.medium}],children:"Close"})})]}):jsxs(View,{style:kt.container,children:[jsx(TouchableOpacity,{style:kt.closeButton,onPress:r,children:jsx(nt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(yt,{size:80,strokeWidth:4,iconSize:68,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:J(e.sourceTokenIconUrl)},style:kt.tokenIconFill}):jsx(View,{style:[kt.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[kt.title,{color:n.foreground,fontFamily:s.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[kt.subtitle,{color:n.foregroundMuted,fontFamily:s.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",Pm(e.recipientAddress)]})]})}var kt=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:48,paddingBottom:24},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconRing:{width:80,height:80,borderRadius:40,alignItems:"center",justifyContent:"center",marginBottom:20},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},title:{fontSize:20,marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,marginBottom:24},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,alignItems:"center",justifyContent:"center",borderRadius:12},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:15}});function Ry(e){let t=e.source_token_metadata?.decimals??6,r=e.source_amount_base_unit??"0",o=Number(r)/Math.pow(10,t),n=o>=1?o.toFixed(2):o.toPrecision(4).replace(/\.?0+$/,"");return {sourceChainType:e.source_chain_type,sourceChainId:e.source_chain_id,sourceTokenAddress:e.source_token_address,sourceTokenSymbol:e.source_currency?.toUpperCase()??"",sourceTokenIconUrl:J(ge(e.source_token_metadata,"png")),destinationChainType:e.destination_chain_type,destinationChainId:e.destination_chain_id,destinationTokenAddress:e.destination_token_address,destinationTokenSymbol:e.destination_currency?.toUpperCase()??"",destinationTokenIconUrl:J(ge(e.destination_token_metadata,"png")),amount:n,amountBaseUnit:r,submittedAt:e.created_at?new Date(e.created_at):void 0,withdrawIntentAddress:e.deposit_wallet?.address??"",recipientAddress:e.recipient_address??""}}var Om=(e,t)=>`${t}:${e}`;function Iy(){let{colors:e}=V(),t=useRef(new Animated.Value(.5)).current,r=e.cardHover;return useEffect(()=>{let o=Animated.loop(Animated.sequence([Animated.timing(t,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(t,{toValue:.5,duration:800,useNativeDriver:true})]));return o.start(),()=>o.stop()},[t]),jsx(View,{style:{gap:12,paddingHorizontal:16},children:[1,2,3].map(o=>jsx(Animated.View,{style:{height:48,borderRadius:12,backgroundColor:r,opacity:t}},o))})}function El({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:s,modalTitle:i="Withdraw Crypto",onWithdraw:a,onWithdrawSuccess:c,onWithdrawError:u,heightPercent:l=.92,sheetBorderRadius:h,sourceChainType:S,sourceChainId:g,sourceTokenAddress:y,sourceTokenSymbol:C,sourceChainName:d,sourceTokenIconUrl:w}){let{colors:b,fonts:m}=V(),[f,x]=useState("form"),[_,F]=useState(S),[k,T]=useState(g),[A,M]=useState(y),[O,v]=useState(C),[z,E]=useState(d),[de,Qe]=useState(w),[We,oe]=useState(null),[ae,be]=useState(null),[Ie,rt]=useState(null),[Ne,Se]=useState(),[ue,Te]=useState([]),[Ke,lt]=useState(null),[ve,Ve]=useState("form"),Be=useRef(new Animated.Value(Dimensions.get("window").width)).current,X=useRef(null),q=!!_&&!!k&&!!A,{data:Ce,isLoading:dt}=vl(r,e&&f==="form"),W=Ce?.data??[],{data:L,isLoading:ee}=_d({sourceChainType:_,sourceChainId:k,sourceTokenAddress:A,sourceTokenSymbol:O,publishableKey:r,enabled:e&&q&&f==="form"}),{data:le,isLoading:pe}=Rd({address:n,chainType:_,chainId:k,tokenAddress:A,publishableKey:r,enabled:e&&q}),{executions:wt}=Id({userId:o,publishableKey:r,depositWalletId:Ne,enabled:!!Ne&&e,onWithdrawSuccess:c,onWithdrawError:u});useEffect(()=>{if(!e||f!=="tracker")return;let ne=false;return No(o,r,"withdraw").then(P=>{ne||Te(P.data);}).catch(console.error),()=>{ne=true;}},[e,f,o,r]),useEffect(()=>{e&&(X.current&&(clearTimeout(X.current),X.current=null),x("form"),F(S),T(g),M(y),v(C),E(d),Qe(w),oe(null),be(null),rt(null),Se(void 0),Te([]),lt(null),Ve("form"),Be.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{X.current&&clearTimeout(X.current);},[]),useEffect(()=>{de||L?.iconUrl&&Qe(L.iconUrl);},[L?.iconUrl,de]),useEffect(()=>{z||L?.chainName&&E(L.chainName);},[L?.chainName,z]),useEffect(()=>{f==="confirming"&&wt.length>0&&x("details");},[f,wt]);let ut=useCallback(()=>{t(),X.current=setTimeout(()=>{x("form"),F(S),T(g),M(y),v(C),E(d),Qe(w),oe(null),be(null),rt(null),Se(void 0),Te([]),lt(null),Ve("form"),X.current=null;},300);},[t,S,g,y,C,d,w]),Ye=useCallback(ne=>{let P=W.find(gt=>gt.symbol===ne);P&&(oe(P),P.chains.length>0&&be(P.chains[0]));},[W]),je=useCallback(ne=>{if(!We)return;let P=We.chains.find(gt=>Om(gt.chain_id,gt.chain_type)===ne);P&&be(P);},[We]),Pt=useCallback(async ne=>{let P=await Uo({external_user_id:o,destination_chain_type:ne.destinationChainType,destination_chain_id:ne.destinationChainId,destination_token_address:ne.destinationTokenAddress,recipient_address:ne.recipientAddress,action_type:"withdraw"},r),gt=Ho(P.data,_??"");if(!gt)throw new Error(`No deposit wallet found for chain type: ${_}`);return Se(gt.id),{id:gt.id,address:gt.address}},[o,r,_]),_t=useCallback(ne=>{rt(ne),x("confirming");},[]),ir=useCallback(ne=>{lt(ne),Be.setValue(Dimensions.get("window").width),Animated.timing(Be,{toValue:0,duration:280,useNativeDriver:true}).start();},[Be]),Ae=useCallback(()=>{Animated.timing(Be,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>lt(null));},[Be]),ot=dt||ee,pt=L?.isSupported??null,Or=f==="confirming"?"Withdrawal Status":i,Cr=h?.globalBorderTopLeftRadius,ce=h?.globalBorderTopRightRadius,tt=h?.main?.borderTopLeftRadius??Cr,fe=h?.main?.borderTopRightRadius??ce,Je=h?.tokenSelector?.borderTopLeftRadius??Cr,$=h?.tokenSelector?.borderTopRightRadius??ce,re=h?.chainSelector?.borderTopLeftRadius??Cr,xe=h?.chainSelector?.borderTopRightRadius??ce,me=(()=>{if(f!=="form"||!q||pe||!le)return;let ne=O||le.symbol,P=le.balanceUsd;if(P!=null){let un=`$${parseFloat(P).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return ne?`Balance: ${un} ${ne}`:`Balance: ${un}`}let gt=le.balanceHuman;if(!(!gt||gt==="0"))return ne?`Balance: ${gt} ${ne}`:`Balance: ${gt}`})();return jsx(Ze,{visible:e,onClose:ut,closeOnBackdropPress:false,showHandle:false,heightPercent:f==="confirming"?.3:f==="details"?.7:l,borderTopLeftRadius:tt,borderTopRightRadius:fe,children:f==="confirming"&&Ie?jsx(Bl,{txInfo:Ie,executions:wt,onClose:ut,onViewTracker:()=>{Ve("confirming"),x("tracker");}}):f==="details"&&Ie?jsx(Vd,{execution:wt.length>0?wt[wt.length-1]:null,txInfo:Ie,onClose:ut,onViewHistory:()=>{Ve("details"),x("tracker");},onHeaderClose:()=>x("form")}):f==="tracker"?jsxs(View,{style:Ao.trackerContainer,children:[jsx(Tr,{title:"Withdrawal History",onClose:()=>x(ve)}),ue.length===0?jsx(View,{style:Ao.emptyState,children:jsx(Text,{style:[Ao.emptyText,{color:b.foregroundMuted,fontFamily:m.regular}],children:"No withdrawals to track yet"})}):jsx(FlatList,{data:ue,keyExtractor:ne=>ne.id,contentContainerStyle:Ao.listContent,renderItem:({item:ne})=>jsx(Ll,{execution:ne,onPress:()=>ir(ne)})}),Ke&&jsx(Animated.View,{style:[Ao.historyDetailOverlay,{backgroundColor:b.background,transform:[{translateX:Be}]}],children:jsx(Vd,{execution:Ke,txInfo:Ry(Ke),onClose:ut,onBack:Ae,onViewHistory:Ae})})]}):jsxs(Fragment,{children:[jsx(Tr,{title:Or,subtitle:me,onClose:ut}),ot?jsx(Iy,{}):pt===false?jsxs(View,{style:Ao.unsupportedContainer,children:[jsx(Text,{style:[Ao.unsupportedTitle,{color:b.foreground,fontFamily:m.medium}],children:"Unsupported Token"}),jsx(Text,{style:[Ao.unsupportedMessage,{color:b.foregroundMuted,fontFamily:m.regular}],children:L?.errorMessage})]}):jsx(vy,{publishableKey:r,sourceChainType:_??"",sourceChainId:k??"",sourceTokenAddress:A??"",sourceTokenSymbol:O,sourceChainName:z,sourceTokenIconUrl:de,recipientAddressProp:s,destinationTokens:W,selectedToken:We,selectedChain:ae,selectedChainKey:ae?Om(ae.chain_id,ae.chain_type):null,onTokenChange:Ye,onChainChange:je,tokensLoading:dt,balanceData:le??null,isLoadingBalance:pe,sourceValidation:L??null,onDepositWalletCreation:Pt,onWithdraw:a,onWithdrawError:u,onWithdrawSubmitted:_t,onViewTracker:()=>{Ve("form"),x("tracker");},tokenSelectorLeft:Je,tokenSelectorRight:$,chainSelectorLeft:re,chainSelectorRight:xe})]})})}function vy({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:s,sourceTokenIconUrl:i,recipientAddressProp:a,destinationTokens:c,selectedToken:u,selectedChain:l,selectedChainKey:h,onTokenChange:S,onChainChange:g,tokensLoading:y,balanceData:C,isLoadingBalance:d,sourceValidation:w,onDepositWalletCreation:b,onWithdraw:m,onWithdrawError:f,onWithdrawSubmitted:x,onViewTracker:_,tokenSelectorLeft:F,tokenSelectorRight:k,chainSelectorLeft:T,chainSelectorRight:A}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(ScrollView,{style:{flex:1,paddingTop:16},contentContainerStyle:Ao.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:Ao.doubleInputWrapper,children:jsx(ia,{tokens:c,selectedTokenSymbol:u?.symbol??null,selectedChainKey:h,onTokenChange:S,onChainChange:g,isLoading:y,tokenPickerBorderTopLeftRadius:F,tokenPickerBorderTopRightRadius:k,chainPickerBorderTopLeftRadius:T,chainPickerBorderTopRightRadius:A})}),jsx(Fl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:s,sourceTokenIconUrl:i,recipientAddressProp:a,selectedToken:u,selectedChain:l,balanceData:C,isLoadingBalance:d,minimumWithdrawAmountUsd:w?.minimumAmountUsd??null,estimatedProcessingTime:w?.estimatedProcessingTime??null,maxSlippagePercent:w?.maxSlippagePercent??null,priceImpactPercent:w?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:b,onWithdraw:m,onWithdrawError:f,onWithdrawSubmitted:x,onViewTracker:_})]})})}var Ao=StyleSheet.create({scrollContent:{paddingBottom:32},doubleInputWrapper:{paddingHorizontal:16,paddingBottom:12,paddingTop:4},listContent:{paddingHorizontal:16,paddingBottom:32,gap:8},trackerContainer:{flex:1,overflow:"hidden"},historyDetailOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},emptyState:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:48},emptyText:{fontSize:14},unsupportedContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24,paddingVertical:48},unsupportedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},unsupportedMessage:{fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280}});StyleSheet.create({container:{paddingHorizontal:16,paddingTop:16,paddingBottom:24,gap:16},fieldGroup:{gap:8},fieldLabel:{fontSize:12},walletCard:{paddingHorizontal:12,paddingVertical:12,minHeight:48,justifyContent:"center"},walletAddress:{fontSize:13},primaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginTop:4},primaryButtonText:{fontSize:16},secondaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center"},secondaryButtonText:{fontSize:16}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Vm=createContext(null);function Ey({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new Hc({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,s]=useState(false),[i,a]=useState(null),[c,u]=useState(false),[l,h]=useState(null),S=useColorScheme(),g=useRef(false);g.current||(ya({publishableKey:t}),g.current=true);let y=useMemo(()=>{let v=r?.appearance||"dark";return v==="auto"?S==="dark"?"dark":"light":v},[r?.appearance,S]);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.'),ya({publishableKey:t});},[t]),useEffect(()=>()=>{d.current&&clearTimeout(d.current),_.current&&clearTimeout(_.current);},[]);let C=useRef(null),d=useRef(null),w=useCallback(v=>{d.current&&(clearTimeout(d.current),d.current=null),C.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),C.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),C.current=null);let z=new Promise((E,de)=>{C.current={resolve:E,reject:de};});return a(v),s(true),z},[]),b=useCallback(()=>{C.current&&(C.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),C.current=null),s(false),d.current=setTimeout(()=>{a(null),d.current=null;},200);},[]),m=useCallback(v=>{i?.onSuccess&&i.onSuccess(v),C.current&&(C.current.resolve(v),C.current=null);},[i]),f=useCallback(v=>{console.error("[UnifoldProvider] Deposit error:",v),i?.onError&&i.onError(v),C.current&&(C.current.reject(v),C.current=null);},[i]),x=useRef(null),_=useRef(null),F=useRef(void 0),k=useCallback(v=>{_.current&&(clearTimeout(_.current),_.current=null),x.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),x.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),x.current=null);let z=new Promise((E,de)=>{x.current={resolve:E,reject:de};});return F.current=v.onClose,h(v),u(true),z},[]),T=useCallback(()=>{x.current&&(x.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),x.current=null),F.current?.(),F.current=void 0,u(false),_.current=setTimeout(()=>{h(null),_.current=null;},200);},[]),A=useCallback(v=>{l?.onSuccess&&l.onSuccess(v),x.current&&(x.current.resolve(v),x.current=null);},[l]),M=useCallback(v=>{console.error("[UnifoldProvider] Withdraw error:",v),l?.onError&&l.onError(v),x.current&&(x.current.reject(v),x.current=null);},[l]),O=useMemo(()=>({publishableKey:t,beginDeposit:w,closeDeposit:b,beginWithdraw:k,closeWithdraw:T}),[t,w,b,k,T]);return jsx($c,{client:o,children:jsx(Vm.Provider,{value:O,children:jsxs(Fi,{mode:y,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Il,{visible:n,onClose:b,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:i.externalUserId,destinationChainType:i.destinationChainType,destinationChainId:i.destinationChainId,destinationTokenSymbol:i.destinationTokenSymbol,recipientAddress:i.recipientAddress,destinationTokenAddress:i.destinationTokenAddress,defaultChainType:i.defaultChainType,defaultChainId:i.defaultChainId,defaultTokenAddress:i.defaultTokenAddress,showBalance:i.showBalance,stripeOnrampEmail:i.stripeOnrampEmail,stripeOnrampPhone:i.stripeOnrampPhone,stripeTheme:{mode:y,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:i.depositConfirmationMode??"auto_ui",initialScreen:i.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?zu():void 0,onDepositSuccess:m,onDepositError:f,theme:y,sheetBorderRadius:r?.sheetBorderRadius}),l&&jsx(El,{visible:c,onClose:T,publishableKey:t,externalUserId:l.externalUserId,senderAddress:l.senderAddress,recipientAddress:l.recipientAddress,sourceChainType:l.sourceChainType,sourceChainId:l.sourceChainId,sourceTokenAddress:l.sourceTokenAddress,sourceTokenSymbol:l.sourceTokenSymbol,onWithdraw:l.withdraw,onWithdrawSuccess:A,onWithdrawError:M,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function My(){let e=useContext(Vm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
- export{Oa as AmountScreen,Ze as BottomSheet,Fa as KYCWizardScreen,Ua as OnrampScreen,Ha as StripeOnramp,Eu as StripeOnrampPreconfigure,Ey as UnifoldProvider,ge as getPreferredIcon,La as getStripePublishableKey,Sa as getSupportedDestinationTokens,J as normalizeIconUrl,Na as registerStripeOnramp,$d as setDevApiUrl,Va as setStripeOnrampApiUrl,Da as setStripeOnrampPublishableKey,ra as useAllowedCountry,Wa as useStripeOnramp,V as useTheme,My as useUnifold};
1
+ import*as Dn from'react';import {createContext,useContext,useRef,useEffect,useState,useMemo,useCallback,useId,Fragment as Fragment$1}from'react';import {StyleSheet,Platform,useWindowDimensions,Animated,Modal,StatusBar,TouchableWithoutFeedback,View,TouchableOpacity,Text,ActivityIndicator,ScrollView,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Easing,Dimensions,FlatList,Image,Linking,Clipboard}from'react-native';import Lt,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Polyline,Line,SvgXml,SvgUri}from'react-native-svg';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import kc from'@react-native-async-storage/async-storage';import wh from'expo-constants';import tg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Md=e=>{throw TypeError(e)};var zm=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ml=(e,t,r)=>t.has(e)||Md("Cannot "+r);var u=(e,t,r)=>(Ml(e,t,"read from private field"),r?r.call(e):t.get(e)),J=(e,t,r)=>t.has(e)?Md("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),L=(e,t,r,o)=>(Ml(e,t,"write to private field"),t.set(e,r),r),Oe=(e,t,r)=>(Ml(e,t,"access private method"),r);var gs=(e,t,r,o)=>({set _(n){L(e,t,n);},get _(){return u(e,t,o)}});var zl={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},dark:{background:"#2D2C2F",card:"#3A393C",cardHover:"#48474A",foreground:"#F8FAFC",foregroundMuted:"#94A3B8",foregroundSubtle:"#64748B",border:"#38383A",borderSecondary:"#48484A",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"rgba(34, 197, 94, 0.1)",warning:"#F59E0B",warningBackground:"rgba(245, 158, 11, 0.1)",error:"#EF4444",errorBackground:"rgba(239, 68, 68, 0.1)",overlay:"rgba(0, 0, 0, 0.7)"}},Ul=zl;function ca(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function ys(e,t,r){let o=r?t?.[r]:void 0,n=(c,g,S)=>{let h=o?.[c]?.[g];if(h!==void 0)return h;let y=t?.[c]?.[g];return y!==void 0?y:S},a={backgroundColor:n("card","backgroundColor",e.card),titleColor:n("card","titleColor",e.foreground),subtitleColor:n("card","subtitleColor",e.foregroundMuted),labelColor:n("card","labelColor",e.foregroundMuted),headerColor:n("card","headerColor",e.foregroundMuted),labelRightColor:n("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:n("card","labelHighlightRightColor",e.warning),textRightColor:n("card","textRightColor",e.foreground),subtextRightColor:n("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:n("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:n("card","rowRightLabel",e.foreground),iconColor:n("card","iconColor",e.primary),iconBackgroundColor:n("card","iconBackgroundColor",e.primary+"26"),actionColor:n("card","actionColor",e.foregroundMuted),actionIcon:n("card","actionIcon",e.foregroundMuted),descriptionColor:n("card","descriptionColor",e.foregroundMuted),borderRadius:n("card","borderRadius",12),borderWidth:n("card","borderWidth",0),borderColor:n("card","borderColor",e.border),shadowColor:n("card","shadowColor","#000"),shadowOffset:n("card","shadowOffset",{width:0,height:-4}),shadowOpacity:n("card","shadowOpacity",0),shadowRadius:n("card","shadowRadius",12),elevation:n("card","elevation",0),iconContainerBorderRadius:n("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},i=(o?.depositMenu??t?.depositMenu)?.card,s=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,l=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,p=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:a,input:{backgroundColor:n("input","backgroundColor",n("search","backgroundColor",e.card)),textColor:n("input","textColor",n("search","inputColor",e.foreground)),placeholderColor:n("input","placeholderColor",n("search","placeholderColor",e.foregroundMuted)),borderColor:n("input","borderColor",e.border),borderRadius:n("input","borderRadius",n("search","borderRadius",8)),borderWidth:n("input","borderWidth",1)},button:{primaryBackground:n("button","primaryBackground",e.primary),primaryText:n("button","primaryText",e.primaryForeground),secondaryBackground:n("button","secondaryBackground",e.card),secondaryText:n("button","secondaryText",e.foreground),borderRadius:n("button","borderRadius",12),borderWidth:n("button","borderWidth",0),borderColor:n("button","borderColor",e.border)},container:{titleColor:n("container","titleColor",e.foreground),subtitleColor:n("container","subtitleColor",e.foregroundMuted),actionColor:n("container","actionColor",e.foregroundMuted),actionTitle:n("container","actionTitle",e.foregroundMuted),buttonColor:n("container","buttonColor",e.primary),buttonTitleColor:n("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:n("container","iconBackgroundColor",e.success),iconColor:n("container","iconColor",e.foreground)},search:{backgroundColor:n("search","backgroundColor",e.card),inputColor:n("search","inputColor",e.foreground),placeholderColor:n("search","placeholderColor",e.foregroundMuted),borderRadius:n("search","borderRadius",8)},list:{titleSectionColor:n("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:n("list","rowBorderRadius",12)},badge:{borderRadius:n("badge","borderRadius",8)},sheet:{shadowColor:n("sheet","shadowColor","#000"),shadowOffset:n("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:n("sheet","shadowOpacity",.1),shadowRadius:n("sheet","shadowRadius",12),elevation:n("sheet","elevation",16)},depositMenu:{card:ca(a,i)},transferCrypto:{depositAddress:{card:ca(a,s)}},depositCard:{quoteProvider:{card:ca(a,l)}},depositTracker:{executionRow:{card:ca(a,p)}}}}function Hl(e,t,r){let n={...zl[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var Nl=createContext(null);function V(){let e=useContext(Nl);if(!e){let t=Ul.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:ys(t,void 0,"dark"),isDark:true}}return e}function Ct({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=V(),l=a??s.warning,p=i??"#FBBF24",c=useRef(new Animated.Value(0)).current,g=useId(),S=useMemo(()=>`circularProgressGrad_${g.replace(/[^a-zA-Z0-9_-]/g,"")}`,[g]),h=(e-t)/2,y=2*Math.PI*h,w=e/2,d=o??Math.max(0,Math.round(e-t*2-8)),k=(e-d)/2;useEffect(()=>{let m=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return m.start(),()=>m.stop()},[c]);let b=c.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},n],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:b}]},children:jsxs(Lt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:S,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:p})]})}),jsx(Circle,{cx:w,cy:w,r:h,stroke:`url(#${S})`,strokeWidth:t,fill:"none",strokeDasharray:`${y*.75} ${y*.25}`,strokeLinecap:"round",rotation:-90,origin:`${w}, ${w}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:k+1.5,left:k,width:d,height:d},children:r}):null]})}function ql({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ii({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function yo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function bs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function at({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Vr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function vi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"15 18 9 12 15 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Pt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function jn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function qe({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Cs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12.01",y2:"16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ql({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"2",x2:"12",y2:"6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"18",x2:"12",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"12",x2:"6",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"18",y1:"12",x2:"22",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function bo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function mn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,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:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ua({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Co({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function pa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:r,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:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Pi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function fn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{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:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ma({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ws({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Nd({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M11 14h10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 10l4 4-4 4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oi({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:a,components:i}){let s=useColorScheme(),l=useMemo(()=>t==="auto"?s==="dark"?"dark":"light":t,[t,s]),p=useMemo(()=>{let h=o?.[l];return Hl(l,h,r)},[l,o,r]),c=useMemo(()=>ys(p,i,l),[p,i,l]),g=useMemo(()=>a?{regular:a.regular||n,medium:a.medium||n,semibold:a.semibold||n,bold:a.bold||n}:n?{regular:n,medium:n,semibold:n,bold:n}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[n,a]),S=useMemo(()=>({mode:l,colors:p,fonts:g,components:c,isDark:l==="dark"}),[l,p,g,c]);return jsx(Nl.Provider,{value:S,children:e})}function ft({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,showHandle:n=true,heightPercent:a,noPadding:i=false,borderTopLeftRadius:s=24,borderTopRightRadius:l=24}){let{colors:p,components:c}=V(),{height:g}=useWindowDimensions(),S=useRef(g);S.current=g;let h=useRef(new Animated.Value(g)).current,y=useRef(new Animated.Value(0)).current,w=a!=null&&a>=1;useEffect(()=>{let k=S.current;e?(h.setValue(k),y.setValue(0),Animated.parallel([Animated.spring(h,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(y,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(h,{toValue:k,useNativeDriver:true,tension:65,friction:11}),Animated.timing(y,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,h,y]);let d=()=>{o&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(GestureHandlerRootView,{style:[hn.container,Platform.OS==="android"&&{paddingTop:StatusBar.currentHeight}],children:[jsx(Animated.View,{style:[hn.backdrop,{backgroundColor:"#000000",opacity:y}],pointerEvents:"none"}),!w&&jsx(TouchableWithoutFeedback,{onPress:d,children:jsx(View,{style:hn.backdropTouchArea})}),jsxs(Animated.View,{style:[hn.sheet,{maxHeight:g*.9,backgroundColor:p.background,borderTopLeftRadius:s,borderTopRightRadius:l,overflow:"hidden",transform:[{translateY:h}],shadowColor:c.sheet.shadowColor,shadowOffset:c.sheet.shadowOffset,shadowOpacity:c.sheet.shadowOpacity,shadowRadius:c.sheet.shadowRadius,elevation:c.sheet.elevation,...a&&{height:g*a,maxHeight:g*a},...w&&{paddingBottom:0},...i&&{paddingBottom:0}}],children:[n&&jsx(View,{style:hn.handleContainer,children:jsx(View,{style:[hn.handle,{backgroundColor:p.border}]})}),jsx(View,{style:[hn.content,a&&hn.contentFlex],children:r})]})]})})}var hn=StyleSheet.create({container:{flex:1},backdrop:{...StyleSheet.absoluteFillObject},backdropTouchArea:{flex:1},sheet:{paddingBottom:Platform.OS==="ios"?34:24},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});var af="https://api.unifold.io",Gl="__UnifoldDevApiBaseUrl__",wr="pk_test_123",ha={};function lf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[Gl];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Qt(){return lf()??af}function ga(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.'),wr=e.publishableKey;}e.defaultConfig&&(ha=e.defaultConfig);}function Qd(e){if(typeof __DEV__>"u"||!__DEV__){console.warn("[Unifold] setDevApiUrl() is only available in development mode");return}if(typeof globalThis>"u")return;let t=e.trim();t.length>0?globalThis[Gl]=t:delete globalThis[Gl];}function Ss(){return Qt()}function ya(){return wr}function Lr(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 Nt(e){let t=e.startsWith("/")?e:`/${e}`;return `${Qt()}/api/public${t}`}function Z(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,Qt()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${Qt()}${e}`:`${Qt()}/api/public${e}`:""}async function Uo(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||ha.recipientAddress;if(!r)throw new Error("[Unifold] recipient_address is required for createDepositAddress. Pass recipientAddress in your beginDeposit() config.");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||ha.destinationChainId||"8453",destination_token_address:e?.destination_token_address||ha.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||wr;Lr(n);let a=await fetch(`${Qt()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create deposit address: ${a.statusText}`);return await a.json()}function Ho(e,t){return e.find(r=>r.chain_type===t)}async function No(e,t,r){let o=t||wr;Lr(o);let n=await fetch(`${Qt()}/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,...r&&{action_type:r}})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}async function ba(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/direct_executions/poll`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify({deposit_wallet_id:e})});if(!o.ok)throw new Error(`Failed to poll executions: ${o.statusText}`);return o.json()}function be(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let r=e.icon_urls.find(o=>o.format===t);return r?r.url:e.icon_url}async function qn(e,t){let r=e||wr;Lr(r);let o=`${Qt()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let a=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});o=`${o}?${a.toString()}`;}let n=await fetch(o,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch supported deposit tokens: ${n.statusText}`);return n.json()}async function Yl(e,t){let r=t||wr;Lr(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${Qt()}/v1/public/tokens/token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch token metadata: ${n.statusText}`);return n.json()}function Ca(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function Jl(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to fetch onramp quotes: ${o.statusText}`);return o.json()}async function Zl(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to create onramp session: ${o.statusText}`);return o.json()}async function Xl(e,t){let r=t||wr;Lr(r);let o=new URLSearchParams;e.country_code&&o.append("country_code",e.country_code),e.subdivision_code&&o.append("subdivision_code",e.subdivision_code),o.append("token_address",e.token_address),o.append("chain_id",e.chain_id),o.append("chain_type",e.chain_type);let n=await fetch(`${Qt()}/v1/public/onramps/default_token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch default onramp token: ${n.statusText}`);return n.json()}async function ec(e){let t=e||wr;Lr(t);let r=await fetch(`${Qt()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch fiat currencies: ${r.statusText}`);return r.json()}function Fi(e,t="png"){if(!e||e.length===0)return;let r=e.find(o=>o.format===t);return r?r.url:e[0]?.url}async function Ts(e){let t=e||wr;Lr(t);let r=await fetch(`${Qt()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch project config: ${r.statusText}`);return r.json()}async function tc(){let e=await fetch(`${Qt()}/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 wa(e,t,r){let o=e.find(a=>a.chain_id===r);if(o)return o.chain_name;let n=e.find(a=>a.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function xs(){let e=await fetch(`${Qt()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}async function ka(e){let t=e||wr;Lr(t);let r=await fetch(`${Qt()}/v1/public/tokens/supported_destination_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch supported destination tokens: ${r.statusText}`);return r.json()}async function rc(e,t){let r=t||wr;Lr(r);let o=await fetch(`${Qt()}/v1/public/addresses/verify`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":r},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to verify address: ${o.statusText}`);return o.json()}async function oc(e,t){return ba(e.deposit_wallet_id,t)}async function Sa(e,t,r,o,n){let a=n||wr;Lr(a);let i=await fetch(`${Qt()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":a},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!i.ok)throw new Error(`Failed to fetch address balance: ${i.statusText}`);return i.json()}function Gd({size:e=28}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxs(G,{fillRule:"evenodd",children:[jsx(Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsx(Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function Jd({size:e=28}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#eth_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsx(Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsx(Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsx(Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsx(Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsx(Defs,{children:jsx(ClipPath,{id:"eth_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function eu({size:e=28}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#btc_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsx(Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsx(Defs,{children:jsx(ClipPath,{id:"btc_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function tu({size:e=28}){return jsxs(Lt,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxs(Defs,{children:[jsxs(LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsx(Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxs(G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsx(Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsx(Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsx(Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function ru({size:e=28}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxs(G,{children:[jsx(Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsx(Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var Ta=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:Gd},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:Jd},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:eu},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:tu},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:ru}];function ou(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function xa(e,t){let r=parseFloat(e);if(isNaN(r))return e;let o=t.toLowerCase(),n=["eth","btc"].includes(o)?4:2;return r.toFixed(n)}function _a(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=Ta.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=Ta.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Jt({onPress:e,title:t,variant:r="close"}){let{components:o,fonts:n}=V(),a=r==="back",i=a?jsx(vi,{size:22,color:o.header.buttonColor,strokeWidth:2.5}):jsx(at,{size:20,color:o.header.buttonColor,strokeWidth:2}),s=jsx(TouchableOpacity,{style:gn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:a?"Back":"Close",children:i});return t?jsxs(View,{style:gn.headerWithTitle,children:[a?s:jsx(View,{style:gn.headerSide}),jsx(Text,{style:[gn.headerTitleText,{color:o.header.titleColor},...n.bold?[{fontFamily:n.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),a?jsx(View,{style:gn.headerSide}):s]}):jsxs(View,{style:a?gn.headerWithTitle:gn.header,children:[a?s:jsx(View,{style:gn.headerSpacer}),!a&&s]})}var Ra={paddingTop:60,paddingBottom:16},gn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ra},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ra},headerSpacer:{flex:1},headerSide:{width:28},headerTitleText:{flex:1,textAlign:"center",fontSize:17},closeBtn:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"}});function kr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=V();return e?jsx(Text,{style:[nu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[nu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var nu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function lo({quote:e,label:t,value:r,last:o,hideDivider:n}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsx(Text,{style:[e.rowValue],children:r})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}function cc({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=V(),p=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},c=ou(r);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:c}),jsx(TouchableOpacity,{onPress:p,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx(qe,{size:14,color:s.success,strokeWidth:2.5}):jsx(jn,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Ia={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function au({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=V(),a=e.toLowerCase(),i=Ia[a]??n.primary,s=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:i,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:s,height:s,borderRadius:s/2,borderWidth:2,borderColor:n.background}}):null]})}function va({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=V(),p=Nt(`/icons/currencies/png/${e.toLowerCase()}.png`),c=_a(r);return jsxs(View,{style:[Gr.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:Gr.step,children:[jsx(Image,{source:{uri:p},style:Gr.iconImage}),jsx(Text,{style:[Gr.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You bought"}),jsx(Text,{style:[Gr.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(Vr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:Gr.step,children:[jsxs(View,{style:Gr.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:Gr.tokenIcon}):jsx(View,{style:[Gr.tokenIcon,{backgroundColor:Ia[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[Gr.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[Gr.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[Gr.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var Gr=StyleSheet.create({diagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",paddingVertical:20,paddingHorizontal:24,width:"100%"},step:{alignItems:"center"},iconImage:{width:24,height:24,borderRadius:12,marginBottom:4},iconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},tokenIcon:{width:24,height:24,borderRadius:12},networkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},label:{fontSize:10},value:{fontSize:14,fontWeight:"500",paddingTop:4}});function Li(){let{colors:e,fonts:t,components:r}=V(),o=r.input,n=r.button,a=r.container,i=r.card,s=r.header;return useMemo(()=>{let l=i.borderRadius,p={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:48},content:{flex:1,paddingTop:16},title:{fontSize:28,color:s.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:e.foregroundSubtle,marginBottom:8,textTransform:"uppercase",letterSpacing:.5,...t.semibold?{fontFamily:t.semibold}:{}},input:{backgroundColor:o.backgroundColor,borderRadius:o.borderRadius,padding:16,fontSize:17,color:o.textColor,borderWidth:o.borderWidth,borderColor:o.borderColor,...t.regular?{fontFamily:t.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...t.regular?{fontFamily:t.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(l,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:a.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:a.buttonTitleColor,fontSize:17,...t.bold?{fontFamily:t.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...t.medium?{fontFamily:t.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},c={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...t.medium?{fontFamily:t.medium}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor},quickPillText:{fontSize:14,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},numpad:{gap:4,marginBottom:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...t.regular?{fontFamily:t.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...t.regular?{fontFamily:t.regular}:{}},paymentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,borderRadius:999,backgroundColor:"transparent",alignSelf:"flex-start",marginBottom:12},paymentRowHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:16,borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor,alignSelf:"center"},paymentLeft:{flexDirection:"row",alignItems:"center",gap:6},applePayIcon:{fontSize:20,color:e.foreground},paymentLabel:{fontSize:15,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},paymentHint:{fontSize:13,color:e.foregroundMuted,marginLeft:12,...t.regular?{fontFamily:t.regular}:{}},inlineError:{fontSize:13,color:e.error,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},inlineStatus:{fontSize:13,color:e.foregroundMuted,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},sheetContent:{flex:1,paddingHorizontal:24,paddingTop:20,paddingBottom:32,gap:12},sheetHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:4},sheetBackBtn:{width:32,height:32,borderRadius:16,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},sheetCloseBtn:{width:28,height:28,borderRadius:14,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitle:{fontSize:18,color:e.foreground,...t.bold?{fontFamily:t.bold}:{}},sheetOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border},sheetOptionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:12},sheetOptionIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},sheetOptionLabel:{fontSize:16,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},sheetOptionHint:{fontSize:13,color:e.foregroundMuted,marginTop:2,...t.regular?{fontFamily:t.regular}:{}},sheetLoading:{alignItems:"center",paddingVertical:32,gap:12},sheetStatusText:{fontSize:15,color:e.foregroundMuted,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},sheetError:{flex:1,justifyContent:"center",paddingVertical:20},sheetErrorText:{fontSize:14,color:e.error,textAlign:"center",lineHeight:20,...t.regular?{fontFamily:t.regular}:{}},addPaymentBtn:{marginTop:12,paddingVertical:14,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},g={heroBox:{backgroundColor:i.backgroundColor,borderRadius:l,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:i.borderWidth,borderColor:i.borderColor,gap:4},heroLabel:{fontSize:12,color:e.foregroundSubtle,letterSpacing:.5,textTransform:"uppercase",...t.semibold?{fontFamily:t.semibold}:{}},heroAmount:{fontSize:48,color:e.foreground,letterSpacing:-1,...t.bold?{fontFamily:t.bold}:{}},heroCurrency:{fontSize:22,color:e.primary,...t.medium?{fontFamily:t.medium}:{}},heroNetwork:{fontSize:15,color:e.foregroundSubtle,marginTop:2,...t.medium?{fontFamily:t.medium}:{}},card:{backgroundColor:i.backgroundColor,borderRadius:l,borderWidth:i.borderWidth,borderColor:i.borderColor,overflow:"hidden",marginBottom:12,marginTop:16},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},rowRight:{flex:1,minWidth:0,flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:8},rowDivider:{height:1,marginHorizontal:16,backgroundColor:e.border},rowLabel:{fontSize:14,color:i.rowLeftLabel,...t.regular?{fontFamily:t.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:i.rowRightLabel,...t.medium?{fontFamily:t.medium}:{}}},S=Math.max(16,Math.min(l,22)),h={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:S,borderTopRightRadius:S,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:S,borderBottomRightRadius:S,borderTopLeftRadius:10,borderTopRightRadius:10,marginTop:16},swapConnectorWrap:{alignSelf:"center",zIndex:3,marginTop:-24,marginBottom:-32},swapConnectorCircle:{width:48,height:48,borderRadius:24,backgroundColor:e.primary,alignItems:"center",justifyContent:"center",borderWidth:4,borderColor:e.background},swapRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginTop:8,gap:12},swapLeftCol:{flex:1,minWidth:0},swapSpendAmount:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceivePrimary:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceiveSub:{fontSize:13,color:e.foregroundMuted,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},swapPill:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:10,paddingHorizontal:14,borderRadius:999,backgroundColor:e.cardHover,borderWidth:i.borderWidth,borderColor:e.border},swapPillText:{fontSize:16,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},payHint:{fontSize:15,color:e.foregroundMuted,textAlign:"center",marginBottom:18,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},summaryLabel:{fontSize:12,color:e.foregroundSubtle,textTransform:"uppercase",letterSpacing:.3,...t.semibold?{fontFamily:t.semibold}:{}},applePayBtn:{backgroundColor:n.secondaryBackground,borderRadius:n.borderRadius,borderWidth:n.borderWidth>0?n.borderWidth:1,borderColor:n.borderWidth>0?n.borderColor:e.border,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:n.secondaryText,fontSize:17,...t.bold?{fontFamily:t.bold}:{}}},y={input:{fontSize:14,...t.regular?{fontFamily:t.regular}:{}},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),borderWidth:i.borderWidth,borderColor:e.border,backgroundColor:e.card},rowSelected:{borderColor:e.primary,backgroundColor:e.successBackground},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:e.foregroundMuted,...t.medium?{fontFamily:t.medium}:{}},rowTextSelected:{color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:e.primary,alignItems:"center",justifyContent:"center"}},w={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:e.successBackground,borderWidth:2,borderColor:e.success,alignItems:"center",justifyContent:"center",marginBottom:28},heading:{fontSize:28,color:s.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:p,quote:g,pm:h,wallet:y,flow:w,amount:c}},[e,t,o,n,a,i,s])}function Bf({size:e=24}){let t=e,r=e*(471/750);return jsxs(Lt,{width:t,height:r,viewBox:"0 0 750 471",children:[jsx(Rect,{width:"750",height:"471",rx:"40",fill:"#1A1F71"}),jsx(Path,{fill:"#FFFFFF",d:"M278.198,334.228l33.36-195.763h53.358l-33.384,195.763H278.198z"}),jsx(Path,{fill:"#FFFFFF",d:"M524.307,142.687c-10.57-3.966-27.135-8.222-47.822-8.222c-52.725,0-89.863,26.551-90.18,64.604c-0.297,28.129,26.514,43.821,46.754,53.185c20.77,9.597,27.752,15.716,27.652,24.283c-0.133,13.123-16.586,19.116-31.924,19.116c-21.355,0-32.701-2.967-50.225-10.274l-6.877-3.112l-7.488,43.823c12.463,5.466,35.508,10.199,59.438,10.445c56.09,0,92.502-26.248,92.916-66.884c0.199-22.27-14.016-39.216-44.801-53.188c-18.65-9.056-30.072-15.099-29.951-24.269c0-8.137,9.668-16.838,30.559-16.838c17.447-0.271,30.088,3.534,39.936,7.5l4.781,2.259L524.307,142.687"}),jsx(Path,{fill:"#FFFFFF",d:"M661.615,138.464h-41.23c-12.773,0-22.332,3.486-27.941,16.234l-79.244,179.402h56.031c0,0,9.16-24.121,11.232-29.418c6.123,0,60.555,0.084,68.336,0.084c1.596,6.854,6.492,29.334,6.492,29.334h49.512L661.615,138.464z M596.198,264.872c4.414-11.279,21.26-54.724,21.26-54.724c-0.314,0.521,4.381-11.334,7.074-18.684l3.607,16.878c0,0,10.217,46.729,12.352,56.527h-44.293V264.872z"}),jsx(Path,{fill:"#FFFFFF",d:"M45.879,138.465l-0.682,4.073c21.093,5.106,39.932,12.496,56.426,21.689l47.346,169.688h56.455l83.004-195.45h-56.526l-52.238,133.496l-5.564-27.131c-0.261-0.838-0.544-1.678-0.834-2.52L156.106,154.992c-3.229-12.396-12.597-16.095-24.186-16.528H45.879z"})]})}function Wf({size:e=24}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 24 24",children:jsxs(G,{fill:"none",fillRule:"evenodd",children:[jsx(Circle,{cx:"7",cy:"12",r:"7",fill:"#EA001B"}),jsx(Circle,{cx:"17",cy:"12",r:"7",fill:"#FFA200",fillOpacity:.8})]})})}function Af({size:e=24}){return jsx(Lt,{width:e,height:e,viewBox:"0 0 1152 1152",children:jsxs(G,{transform:"matrix(1.3333333,0,0,-1.3333333,0,1152)",children:[jsx(Path,{fill:"#006FCF",d:"M 0,0 H 863.998 V 864 H 0 Z"}),jsx(G,{transform:"translate(312.9867,136.7145)",children:jsx(Path,{fill:"#FFFFFF",d:"m 0,0 341.634,-0.725 53.654,59.858 54.038,-59.632 h 101.685 v 87.332 l -63.687,68.682 63.687,68.059 V 309.09 L 0,309.585 Z"})}),jsx(G,{transform:"translate(349.7917,170.655)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"m 0,0 v 241.575 h 204.832 v -55.65 H 66.318 V 148.15 H 201.529 V 93.423 H 66.318 V 56.319 H 204.832 V 10e-4 Z"})}),jsx(G,{transform:"translate(780.0408,412.227)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 -69.456,-76.568 -138.713,0 h -87.729 l 113.343,-120.647 -113.341,-120.925 h 85.343 l 69.764,77.335 70.487,-77.335 h 84.803 v 3.43 L -26.971,-120.647 83.957,-1.903 V 0 Z"})}),jsx(G,{transform:"translate(738.7857,721.0845)",children:jsx(Path,{fill:"#FFFFFF",d:"M 0,0 -28.373,-79.366 -56.65,0 H -220.625 V -105.93 L -267.278,0 H -400.1 l -136.414,-309.586 h 661.726 l 0,309.586 z"})}),jsx(G,{transform:"translate(373.0462,548.583)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"M 0,0 32.145,76.837 64.268,0 Z m -9.212,138.867 -107.187,-241.37 h 73.518 l 20.22,48.332 H 86.914 l 20.207,-48.332 h 75.345 L 75.723,138.867 Z"})}),jsx(G,{transform:"translate(554.5071,446.121)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 64.997,-0.001 V 165.796 L 126.661,-0.001 h 58.418 L 245.49,165.233 V -0.564 l 64,0.563 V 241.368 H 210.032 L 156.513,92.624 103.342,241.012 0,241.369 Z"})})]})})}function uc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Ii,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(Bf,{size:t}):o.includes("mastercard")?jsx(Wf,{size:t}):o.includes("amex")||o.includes("american express")?jsx(Af,{size:t}):jsx(Ii,{size:t*.75,color:r,strokeWidth:1.75})}var Mf=[50,100,500],zf=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function pu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Uf(e){return e.card?`${pu(e.card.brand)} ${pu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Pa({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:a="inline",onCollectPayment:i,paymentLoading:s=false,paymentStatus:l,paymentError:p,paymentTokens:c=[],onAddPaymentMethod:g,onConfirm:S,onCancel:h,sheetBorderTopLeftRadius:y,sheetBorderTopRightRadius:w}){let d=Li(),{colors:k,components:b}=V(),m=y??b.card.borderRadius,f=w??b.card.borderRadius,[x,_]=useState(e),[T,C]=useState(r?"apple_pay":c.length>0?c[0].id:null),I=useRef(false),W=A=>{I.current=true,C(A);};useEffect(()=>{I.current||r||c.length>0&&C(c[0].id);},[c,r]);let[z,F]=useState(false),[P,j]=useState("select"),[E,de]=useState(null),He=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&j("card");},[s,l]);let Be=T==="apple_pay",K=1e3,ue=Be?K:n,ye=ue!=null&&ue>0,Te=useMemo(()=>{if(o)return [];let A=Mf.map(B=>({label:`$${B}`,amount:String(B),disabled:false}));return Be?A.push({label:`$${K}`,amount:String(K),disabled:false}):A.push({label:"MAX",amount:ye?String(ue):"0",disabled:!ye}),A},[o,ye,ue,Be]),Ne=A=>{if(A==="\u232B"){_(B=>B.slice(0,-1));return}if(A==="."){if(x.includes("."))return;_(B=>B===""?"0.":B+".");return}_(B=>{let te=B.indexOf(".");return te!==-1&&B.length-te>2?B:B==="0"&&A!=="."?A:B+A});},tt=x===""?"0":x,ie=parseFloat(x),se=x!==""&&!isNaN(ie)&&ie>0,Ke=r||c.length>0,De=a==="header",rt=useMemo(()=>{let A=[];r&&A.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let B of c)A.push({id:B.id,label:Uf(B),hint:B.card?`Expires ${B.card.exp_month}/${B.card.exp_year}`:B.type,brand:B.card?.brand,isApplePay:false});return A},[r,c]),xe=rt.find(A=>A.id===T),Ye=T!=null&&T!=="apple_pay",oe=xe?xe.label:Ye&&E?E:Ye?"Card":"Pay With",G=xe?!xe.isApplePay:Ye,fe=xe?.brand??E??void 0,ot=Ke?jsx(TouchableOpacity,{style:[De?d.amount.paymentRowHeader:d.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(j("select"),F(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:d.amount.paymentLeft,children:[xe?.isApplePay?jsx(Text,{style:d.amount.applePayIcon,children:"\uF8FF"}):G?jsx(uc,{sublabel:fe,size:20}):null,jsx(Text,{style:d.amount.paymentLabel,children:oe}),jsx(Pt,{size:12,color:d.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:d.form.screen,children:[jsx(Jt,{onPress:h,title:"Enter amount"}),De&&ot,jsxs(View,{style:d.form.content,children:[jsxs(View,{style:d.amount.amountContainer,children:[jsxs(Text,{style:[d.amount.amountText,tt==="0"&&d.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",tt]}),jsx(Text,{style:d.amount.currencyLabel,children:t.toUpperCase()})]}),!De&&ot,Te.length>0&&jsx(View,{style:d.amount.quickRow,children:Te.map(A=>{let B=!A.disabled&&x===A.amount&&x!=="";return jsx(TouchableOpacity,{style:[d.amount.quickPill,B&&{backgroundColor:k.primary},A.disabled&&{opacity:.4}],activeOpacity:.7,disabled:A.disabled||s,onPress:()=>_(A.amount),children:jsx(Text,{style:[d.amount.quickPillText,B&&{color:k.primaryForeground}],children:A.label})},A.label)})}),jsx(View,{style:d.amount.numpad,children:zf.map((A,B)=>jsx(View,{style:d.amount.numpadRow,children:A.map(te=>jsx(TouchableOpacity,{style:[d.amount.numpadKey,s&&{opacity:.3}],onPress:()=>Ne(te),activeOpacity:.6,disabled:s,children:jsx(Text,{style:te==="\u232B"?d.amount.backspaceText:d.amount.numpadKeyText,children:te})},te))},B))}),jsx(TouchableOpacity,{style:[d.form.continueBtn,(!se||s)&&d.form.continueBtnDisabled],onPress:()=>se&&!s&&S(x,T),disabled:!se||s,children:s?jsx(ActivityIndicator,{size:"small",color:k.primaryForeground}):jsx(Text,{style:[d.form.continueBtnText,!se&&d.form.continueBtnTextDisabled],children:"Continue"})}),!z&&p?jsx(Text,{style:d.amount.inlineError,children:p}):!z&&s&&l&&__DEV__?jsx(Text,{style:d.amount.inlineStatus,children:l}):null]}),jsx(ft,{visible:z,onClose:()=>{s||(F(false),j("select"));},closeOnBackdropPress:!s,showHandle:false,heightPercent:.5,borderTopLeftRadius:m,borderTopRightRadius:f,children:jsx(View,{style:d.amount.sheetContent,children:P==="select"?jsxs(Fragment,{children:[jsxs(View,{style:d.amount.sheetTitleRow,children:[jsx(Text,{style:d.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity,{onPress:()=>F(false),activeOpacity:.7,style:d.amount.sheetCloseBtn,children:jsx(at,{size:16,color:k.foregroundMuted,strokeWidth:2.5})})]}),jsxs(ScrollView,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[rt.map(A=>{let B=T===A.id;return jsxs(TouchableOpacity,{style:[d.amount.sheetOption,B&&{borderColor:k.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{W(A.id),de(A.isApplePay?null:A.label),F(false);},children:[jsxs(View,{style:d.amount.sheetOptionLeft,children:[jsx(View,{style:d.amount.sheetOptionIcon,children:A.isApplePay?jsx(Text,{style:d.amount.applePayIcon,children:"\uF8FF"}):jsx(uc,{sublabel:A.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:d.amount.sheetOptionLabel,children:A.label}),jsx(Text,{style:d.amount.sheetOptionHint,children:A.hint})]})]}),B&&jsx(qe,{size:18,color:k.primary,strokeWidth:2.5})]},A.id)}),jsx(TouchableOpacity,{style:d.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!He.current){He.current=true;try{let A=await g?.();A&&(W(A.token),de(A.sublabel),F(!1));}finally{He.current=false;}}},children:jsx(Text,{style:d.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:d.amount.sheetHeader,children:[jsx(TouchableOpacity,{onPress:()=>{s||j("select");},activeOpacity:.7,style:d.amount.sheetBackBtn,children:jsx(vi,{size:20,color:k.foreground,strokeWidth:2})}),jsx(Text,{style:d.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:d.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:k.primary}),__DEV__?jsx(Text,{style:d.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):p?jsxs(Fragment,{children:[jsx(View,{style:d.amount.sheetError,children:jsx(Text,{style:d.amount.sheetErrorText,children:p})}),jsx(TouchableOpacity,{style:d.form.continueBtn,onPress:()=>{i&&se&&i(false,x);},children:jsx(Text,{style:d.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:d.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:k.primary}),__DEV__?jsx(Text,{style:d.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})})]})}var Ps=4;function Oa({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Li(),{colors:a,fonts:i,components:s}=V(),l=s.input.placeholderColor,[p,c]=useState(1),[g,S]=useState(e.firstName??""),[h,y]=useState(e.lastName??""),[w,d]=useState(e.dobMonth??""),[k,b]=useState(e.dobDay??""),[m,f]=useState(e.dobYear??""),[x,_]=useState(e.addressLine1??""),[T,C]=useState(e.addressLine2??""),[I,W]=useState(e.city??""),[z,F]=useState(e.state??""),[P,j]=useState(e.postalCode??""),[E,de]=useState(e.country??"US"),[He,Be]=useState(e.idNumber??""),K=useRef(null),ue=useRef(null),ye=useRef(null),Te=useRef(null),Ne=useRef(null),tt=useRef(null),ie=useRef(null),se=useRef(null),Ke=()=>{switch(p){case 1:return g.trim().length>0&&h.trim().length>0;case 2:return w.length===2&&k.length===2&&m.length===4;case 3:return x.trim().length>0&&I.trim().length>0&&z.trim().length>0&&P.trim().length>0;case 4:return He.trim().length>0;default:return false}},De=()=>{Ke()&&(p<Ps?c(oe=>oe+1):r({firstName:g,lastName:h,idNumber:He,dobMonth:w,dobDay:k,dobYear:m,addressLine1:x,addressLine2:T,city:I,state:z,postalCode:P,country:E}));},rt=()=>{p>1?c(oe=>oe-1):o();},xe=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Pe=["Use your full legal name as it appears on your ID.","We use this to verify your identity.","Enter the address associated with your ID.","Your SSN is encrypted and used only for identity verification."],Ye=[Bt.stepCounter,{color:a.foregroundMuted},...i.semibold?[{fontFamily:i.semibold}]:[]];return jsx(KeyboardAvoidingView,{style:n.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:n.form.screen,children:[jsxs(View,{style:Bt.header,children:[jsx(View,{style:Bt.headerSide,children:jsx(TouchableOpacity,{style:Bt.iconButton,onPress:rt,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:p>1?"Back":"Cancel",children:jsx(bs,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Bt.headerCenter,children:jsxs(Text,{style:Ye,children:[p," of ",Ps]})}),jsx(View,{style:Bt.headerSide,children:jsx(TouchableOpacity,{style:Bt.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(at,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Bt.progressTrack,children:Array.from({length:Ps}).map((oe,G)=>jsx(View,{style:[Bt.progressSegment,{backgroundColor:G<p||G+1===p?a.primary:a.border}]},G))}),jsxs(ScrollView,{style:n.form.flex,contentContainerStyle:Bt.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:xe[p-1]}),jsx(Text,{style:n.form.subtitle,children:Pe[p-1]}),p===1&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:g,onChangeText:S,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>K.current?.focus()})}),jsx($o,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:K,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:h,onChangeText:y,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:De})})]}),p===2&&jsxs(View,{style:Bt.dobRow,children:[jsxs(View,{style:Bt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Bt.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Bt.dobInput],placeholder:"MM",placeholderTextColor:l,value:w,onChangeText:oe=>{let G=oe.replace(/\D/g,"").slice(0,2);d(G),G.length===2&&ue.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Bt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Bt.dobLabel],children:"Day"}),jsx(TextInput,{ref:ue,style:[n.form.input,Bt.dobInput],placeholder:"DD",placeholderTextColor:l,value:k,onChangeText:oe=>{let G=oe.replace(/\D/g,"").slice(0,2);b(G),G.length===2&&ye.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Bt.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Bt.dobLabel],children:"Year"}),jsx(TextInput,{ref:ye,style:[n.form.input,Bt.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:m,onChangeText:oe=>{let G=oe.replace(/\D/g,"").slice(0,4);f(G);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:De})]})]}),p===3&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:x,onChangeText:_,returnKeyType:"next",onSubmitEditing:()=>Te.current?.focus()})}),jsx($o,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:Te,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:T,onChangeText:C,returnKeyType:"next",onSubmitEditing:()=>Ne.current?.focus()})}),jsx($o,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ne,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:I,onChangeText:W,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>tt.current?.focus()})}),jsxs(View,{style:Bt.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx($o,{form:n.form,label:"State",children:jsx(TextInput,{ref:tt,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:z,onChangeText:oe=>F(oe.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>ie.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx($o,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:ie,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:P,onChangeText:j,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>se.current?.focus()})})})]}),jsx($o,{form:n.form,label:"Country",children:jsx(TextInput,{ref:se,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:E,onChangeText:oe=>de(oe.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:De})})]}),p===4&&jsxs($o,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:He,onChangeText:Be,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:De}),jsx(Text,{style:[n.form.hint,Bt.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&p===Ps?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!Ke()&&n.form.continueBtnDisabled],onPress:De,disabled:!Ke(),children:jsx(Text,{style:[n.form.continueBtnText,!Ke()&&n.form.continueBtnTextDisabled],children:p===Ps?"Submit":"Continue"})})})]})})}function $o({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Bt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:16},headerSide:{width:40,alignItems:"center"},headerCenter:{flex:1,alignItems:"center",justifyContent:"center"},iconButton:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"},stepCounter:{fontSize:15},progressTrack:{flexDirection:"row",gap:4,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{marginTop:10,lineHeight:18}});var fu="",hu;function Fa(e){fu=e;}function Da(e){hu=e;}function Er(){let e=fu||ya();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Mr(){return hu??Ss()}async function Va(){let e=`${Mr()}/v1/public/onramps/headless/stripe/config`,t=Er(),r=await fetch(e,{method:"GET",headers:{"x-publishable-key":t,"Content-Type":"application/json"}});if(!r.ok)throw new Error(`Failed to load Stripe config: ${r.status}`);let o=await r.json();if(!o?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return o.publishable_key}async function gc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw new Error(`Failed to create auth intent: ${t.status}`);let r=await t.json();return r.auth_intent_id??r.id}async function gu(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!t.ok)throw new Error(`Failed to exchange auth intent for tokens: ${t.status}`);return t.json()}async function yc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})}),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r?.message??`Failed to refresh OAuth token: ${t.status}`);return r}async function yu(e,t){let r={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},o=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t,"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await o.text();if(!o.ok)throw new Error(`Failed to create onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function bu(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}}),o=await r.text();if(!r.ok)throw new Error(`Failed to confirm onramp session: ${r.status} ${o}`);return JSON.parse(o)}async function La(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp customer: ${o.status} ${n}`);return JSON.parse(n)}async function Cu(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function bc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}});if(!r.ok){let o=await r.text();throw new Error(`Failed to refresh quote: ${r.status} ${o}`)}return r.json()}async function wu(e){let t=new URLSearchParams({destinationNetwork:e.destinationNetwork,walletAddress:e.walletAddress});e.destinationTag&&t.set("destinationTag",e.destinationTag),e.cryptoCustomerId&&t.set("crypto_customer_id",e.cryptoCustomerId);let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":e.accessToken}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch transaction limits: ${r.status} ${o}`)}return r.json()}async function Cc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Er(),"x-stripe-oauth-token":t}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch payment tokens: ${r.status} ${o}`)}return r.json()}async function ku(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let t={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},r=await fetch(`${Mr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.status}`);return r.json()}function wc(e,t){if(e?.length){let r=e.find(n=>n.format==="png");if(r)return r.url;let o=e.find(n=>n.format==="svg");if(o)return o.url}return t}async function Su(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Er()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}var Sc="@unifold/stripe_oauth";async function Tu(){try{let e=await kc.getItem(Sc);return e?JSON.parse(e):null}catch{return null}}async function Tc(e){try{await kc.setItem(Sc,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function Cn(){try{await kc.removeItem(Sc);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Yf=5,kn=null,xu={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Ba(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:a,authorize:i,attachKycInfo:s,presentKycInfoVerification:l,verifyIdentity:p,registerWalletAddress:c,collectPaymentMethod:g,createCryptoPaymentToken:S}=useOnramp(),[h,y]=useState(r),[w,d]=useState(!!e?.externalUserId),[k,b]=useState(false),[m,f]=useState(""),[x,_]=useState(null),[T,C]=useState(e?.email??""),[I,W]=useState(e?.phone??""),[z,F]=useState(""),[P,j]=useState("US"),[E,de]=useState(""),[He,Be]=useState(""),K=useRef(""),ue=useRef(""),ye=useRef(""),[Te,Ne]=useState(false),[tt,ie]=useState(false),se=useRef(0),Ke=useRef(false),De=useRef(false),rt=useRef(false),xe=useRef(""),Pe=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),Ye=useRef(null),[oe,G]=useState(xu),[fe,ot]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[A,B]=useState(""),[te,pe]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[Ve,je]=useState(e?.defaultSourceAmount??"100"),[yt,nt]=useState(e?.defaultSourceCurrency??"usd"),[$e,Ut]=useState(e?.defaultDestinationCurrency??"usdc"),[Je,ir]=useState(null),[We,st]=useState(),[pt,Or]=useState(),[Cr,ce]=useState(false),it=useRef(null),he=useRef(false),Ze=useRef(0),$=useRef(e?.onComplete),re=useRef(e?.onError),Se=useRef(e?.onStepChange),me=useRef(r);useEffect(()=>{$.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{re.current=e?.onError;},[e?.onError]),useEffect(()=>{Se.current=e?.onStepChange;},[e?.onStepChange]);let ne=useRef(r);useEffect(()=>{h!==ne.current&&(Se.current?.(h,ne.current),ne.current=h),me.current=h;},[h]),useEffect(()=>{w&&h!==r&&d(false);},[w,h,r]);let O=useCallback((R,v,H)=>{let X={code:R,message:v,step:me.current,stripeErrorCode:H};_(X),f(""),re.current?.(X);},[]),bt=useCallback(R=>{let v={sessionId:R.id,status:R.status,sourceAmount:R.transaction_details.source_amount,sourceCurrency:R.transaction_details.source_currency,destinationAmount:R.transaction_details.destination_amount,destinationCurrency:R.transaction_details.destination_currency,destinationNetwork:R.transaction_details.destination_network,walletAddress:R.transaction_details.wallet_address,fees:{networkFee:R.transaction_details.fees.network_fee_amount,transactionFee:R.transaction_details.fees.transaction_fee_amount}};return $.current?.(v),v},[]),Ie=useCallback(()=>_(null),[]),un=R=>R.refresh_token??R.refresh?.refresh_token??"",Ti=useCallback((R,v,H,X,ge)=>{ue.current=v,K.current=H,e?.externalUserId&&Tc({accessToken:v,refreshToken:H,customerId:R,externalUserId:e.externalUserId,email:ge||T,expiresAt:Date.now()+X*1e3});},[e?.externalUserId,T]),xi=useCallback(async()=>{let R=K.current;if(!R)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let v=await yc(R),H=v.access_token,X=un(v)||R;return Be(H),Ti(ye.current,H,X,v.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),H}catch(v){return console.error("[tryRefreshAccessToken] refresh failed:",v?.message),await Cn(),kn=null,ue.current="",K.current="",ye.current="",Be(""),de(""),null}},[Ti]),go=useCallback(async R=>{try{return await R(ue.current)}catch(v){let H=v?.message??"";if(H.includes("stripe_onramp_forbidden")||H.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let X=await xi();if(!X)throw O("authorization_error","Session expired. Please sign in again."),y("email"),v;return await R(X)}throw v}},[xi,O]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){ce(false);return}let v=false;return isPlatformPaySupported().then(H=>{v||ce(H);}),()=>{v=true;}},[e?.merchantIdentifier]),useEffect(()=>(he.current=false,()=>{he.current=true,it.current&&clearTimeout(it.current);}),[]);let _i=useRef(false);useEffect(()=>{if(_i.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),Cn(),kn=null,d(false);return}let R=false;return (async()=>{try{let v=await Tu();if(R||!v){R||d(!1);return}if(v.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",v.externalUserId,"current:",e.externalUserId),await Cn(),kn=null,R||d(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",v.customerId);let H=Date.now()>=v.expiresAt,X=v.accessToken,ge=v.refreshToken;if(H){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Ae=await yc(v.refreshToken);if(R)return;X=Ae.access_token,ge=Ae.refresh_token??Ae.refresh?.refresh_token??v.refreshToken,await Tc({accessToken:X,refreshToken:ge,customerId:v.customerId,externalUserId:e.externalUserId,email:v.email,expiresAt:Date.now()+(Ae.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Ae){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Ae?.message),await Cn(),kn=null,R||d(!1);return}}if(R)return;if(_i.current=!0,de(v.customerId),ye.current=v.customerId,Be(X),ue.current=X,K.current=ge,v.email&&C(v.email),kn===v.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",v.customerId,"\u2014 skipping configure()"),Ye.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",v.customerId);let Ae=await o({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}},cryptoCustomerId:v.customerId});Ae.error?console.error("[useStripeOnramp] restore configureSDK error:",Ae.error.message):kn=v.customerId,Ye.current=Promise.resolve(Ae);}if(R)return;let mt=()=>new Promise(Ae=>{let ur=()=>{rt.current&&xe.current?Ae():setTimeout(ur,200);};ur();});try{if(await Promise.race([mt(),new Promise((ur,Dt)=>setTimeout(()=>Dt(new Error("timeout")),1e4))]),R)return;let Ae=xe.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Ae,"network:",Pe.current),await c(Ae,Pe.current);}catch(Ae){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Ae?.message);}if(R)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),y("session_params");}finally{R||d(false);}})(),()=>{R=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||Te||tt)return;let R=false;ie(true);async function v(){try{let[H,X]=await Promise.all([ku({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?Su({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Vt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Vt?.message),null)):Promise.resolve(null)]);if(R)return;let ge=e?.destinationChainType??"ethereum",mt=H.data.find(Vt=>Vt.chain_type===ge);if(mt?.address){let Vt=mt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Vt,"recipient:",mt.recipient_address),ot(Vt),xe.current=Vt,mt.recipient_address&&B(mt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",ge,"in",H.data?.length,"wallets");let Ae={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},ur={8453:"base",1:"ethereum",137:"polygon"},Dt=X?.destination_network,sr="none";if(Dt&&Ae[Dt])pe(Ae[Dt]),Pe.current=Ae[Dt],sr=Dt+" (from default_token API)";else if(e?.destinationChainId&&ur[e.destinationChainId]){let Vt=ur[e.destinationChainId];Ae[Vt]&&(pe(Ae[Vt]),Pe.current=Ae[Vt]),sr=Vt+" (from chain_id "+e.destinationChainId+")";}else Ae[ge]&&(pe(Ae[ge]),Pe.current=Ae[ge],sr=ge+" (from chain_type fallback)");X?.destination_currency&&Ut(X.destination_currency.toLowerCase());let er=X?.destination_token_metadata,qr=wc(er?.icon_urls,er?.icon_url),Qr=wc(er?.chain?.icon_urls,er?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",qr,"network:",Qr),qr&&st(qr),Qr&&Or(Qr),Ne(!0),rt.current=!0;}catch(H){console.error("[useStripeOnramp] Failed to resolve wallet:",H?.message),Ne(true),rt.current=true;}finally{R||ie(false);}}return v(),()=>{R=true;}},[e?.publishableKey,e?.externalUserId]);let io=useCallback(async()=>{if(Ye.current)return Ye.current;let R=o({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(v=>(v.error&&(console.error("[useStripeOnramp] configureSDK error:",v.error.message,v.error.code),Ye.current=null),v)).catch(v=>{throw console.error("[useStripeOnramp] configureSDK threw:",v?.message??v),Ye.current=null,v});return Ye.current=R,R},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||io();},[]);let Mo=useCallback(async R=>{if(!Ke.current){Ke.current=true,b(true),Ie(),f("Creating auth intent...");try{let v=await gc(R);f("Waiting for authorization...");let H=await i(v);if(H?.error){console.log("[proceedToAuthorize] authorize error:",H.error.message),O("authorization_error","Something went wrong during authorization. Please try again."),y("email");return}if(H?.status==="Denied"){O("authorization_error","Authorization denied by user."),y("email");return}if(H?.status!=="Consented"||!H.customerId){O("authorization_error","Authorization was canceled."),y("email");return}f("Exchanging tokens...");let X=await gu(v),ge=H.customerId,mt=X.access_token,Ae=un(X);console.log("[useStripeOnramp] customerId:",ge),console.log("[useStripeOnramp] accessToken acquired, length:",mt.length),de(ge),ye.current=ge,kn=ge,Be(mt),Ti(ge,mt,Ae,X.expires_in??3600),f("Checking verification status...");try{let ur=await La(ge,mt),Dt=ur.verifications.find(pn=>pn.name==="kyc_verified"),sr=ur.verifications.find(pn=>pn.name==="id_document_verified"),er=Dt?.status==="verified",qr=Dt?.status==="rejected",Qr=sr?.status==="verified",Vt=ur.provided_fields.includes("first_name");if(f(""),qr&&!Vt)O("kyc_error","KYC was previously rejected. Please submit with correct info."),y("kyc");else if(qr&&Vt)y(Qr?"wallet":"identity");else if(!er&&!Vt)y("kyc");else if(!Qr)y("identity");else if(rt.current&&xe.current)try{let pn=xe.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",pn,"network:",te);let la=await c(pn,te);la?.error?(console.warn("[proceedToAuthorize] wallet registration error:",la.error.message),O("wallet_error",la.error.message,la.error.code),y("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),y("session_params"));}catch(pn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",pn?.message),y("wallet");}else y("wallet");}catch(ur){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",ur?.message),f(""),y("kyc");}}catch(v){O("authorization_error",v?.message??String(v)),y("email");}finally{Ke.current=false,b(false);}}},[i,Ie,O,Ti,c,te]),q=useCallback(async()=>{if(Keyboard.dismiss(),!T){O("validation_error","Please enter an email address.");return}b(true),Ie(),f("");try{f("Configuring...");let R=await io();if(R.error){O("configuration_error",R.error.message,R.error.code);return}f("Checking Link account...");let v=await n(T);if(v.error){O("authorization_error",v.error.message,v.error.code);return}v.hasLinkAccount?await Mo(T):(f(""),y("register"));}catch(R){O("unknown_error",R?.message??String(R));}finally{b(false);}},[Ie,io,T,O,n,Mo]),ae=useCallback(async()=>{if(!I){O("validation_error","Please enter your phone number.");return}b(true),Ie(),f("");try{f("Creating Link account...");let R=await a({email:T,phone:I,fullName:z||T,country:P||"US"});if(R.error){O("registration_error",R.error.message,R.error.code);return}await Mo(T);}catch(R){O("registration_error",R?.message??String(R));}finally{b(false);}},[Ie,P,T,O,z,I,a,Mo]);useEffect(()=>{if(h!=="email"||!e?.email)return;let R=++se.current,v=false,H=()=>v||se.current!==R;return e?.phone?(async()=>{b(true),Ie();try{f("Configuring...");let X=await io();if(H())return;if(X.error){O("configuration_error",X.error.message,X.error.code);return}f("Checking Link account...");let ge=await n(e.email);if(H())return;if(ge.error){O("authorization_error",ge.error.message,ge.error.code);return}if(ge.hasLinkAccount){if(H())return;await Mo(e.email);}else {f("Creating Link account...");let mt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(H())return;if(mt.error){O("registration_error",mt.error.message,mt.error.code);return}if(H())return;await Mo(e.email);}}catch(X){H()||O("unknown_error",X?.message??String(X));}finally{b(false);}})():(async()=>{b(true),Ie();try{f("Configuring...");let X=await io();if(H())return;if(X.error){O("configuration_error",X.error.message,X.error.code);return}f("Checking Link account...");let ge=await n(e.email);if(H())return;if(ge.error){O("authorization_error",ge.error.message,ge.error.code);return}if(ge.hasLinkAccount){if(H())return;await Mo(e.email);}else {if(H())return;f(""),y("register");}}catch(X){H()||O("unknown_error",X?.message??String(X));}finally{b(false);}})(),()=>{v=true;}},[h,e?.email,e?.phone]);let Tt=useCallback(async R=>{b(true),Ie(),f(""),G(R);try{let v={firstName:R.firstName,lastName:R.lastName,idNumber:R.idNumber||void 0,dateOfBirth:{day:parseInt(R.dobDay,10),month:parseInt(R.dobMonth,10),year:parseInt(R.dobYear,10)},address:{line1:R.addressLine1,line2:R.addressLine2||void 0,city:R.city,state:R.state,postalCode:R.postalCode,country:R.country}},H=await s(v);if(H?.error){if(H.error.stripeErrorCode==="consumer_person_already_verified"){f(""),y("identity");return}O("kyc_error",H.error.message,H.error.stripeErrorCode??H.error.code),y("kyc");return}f("Please review your KYC information...");let X=await l(null);if(X?.error){O("kyc_error",X.error.message,X.error.stripeErrorCode??X.error.code),y("kyc");return}if(X?.status==="UpdateAddress"){O("kyc_error","Please update your address and resubmit."),y("kyc");return}f(""),y("identity");}catch(v){O("kyc_error",v?.message??String(v)),y("kyc");}finally{b(false);}},[s,Ie,O,l]),Fr=useCallback(async()=>{if(!De.current){De.current=true,b(true),Ie(),f("Launching identity verification...");try{let R=await p();if(R?.error){O("identity_error",R.error.message,R.error.code);return}f(""),y("wallet");}catch(R){O("identity_error",R?.message??String(R));}finally{De.current=false,b(false);}}},[Ie,O,p]);useEffect(()=>{h==="identity"&&!k&&Fr();},[h]);let hs=useCallback(async()=>{if(!fe){O("validation_error","Please enter a wallet address.");return}b(true),Ie(),f("");try{let R=fe.toLowerCase();console.log("[registerWallet] registering wallet:",R,"network:",te);let v=await c(R,te);if(v?.error){console.warn("[registerWallet] error:",v.error.message),O("wallet_error",v.error.message,v.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),y("session_params");}catch(R){O("wallet_error",R?.message??String(R));}finally{b(false);}},[Ie,O,fe,te,c]);useEffect(()=>{h==="wallet"&&Te&&fe&&hs();},[h,Te,fe]);let so=useCallback(R=>{he.current=false,Ze.current=0;let v=0,H=async()=>{v+=1;let X=ue.current;try{let ge=await Cu(R,X);if(console.log(`[pollSessionStatus] poll #${v} session=${R} status="${ge.status}"`),he.current)return;Ze.current=0,ge.status==="fulfillment_complete"?(ir(ge),y("success")):it.current=setTimeout(H,3e3);}catch(ge){if(he.current)return;let mt=ge?.message??"";if((mt.includes("stripe_onramp_forbidden")||mt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await xi()&&!he.current)){it.current=setTimeout(H,1e3);return}if(Ze.current+=1,console.error(`[pollSessionStatus] poll #${v} error:`,mt),Ze.current>=Yf){O("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}it.current=setTimeout(H,5e3);}};it.current=setTimeout(H,3e3);},[O,xi]),ao=useCallback(()=>{if(me.current==="processing"&&Je?.id){if(!ue.current){O("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}Ie(),Ze.current=0,it.current&&(clearTimeout(it.current),it.current=null),so(Je.id);}},[Ie,O,so,Je?.id]),Dr=useCallback(async R=>{b(true),Ie(),f("");try{f("Confirming purchase...");let v=await go(H=>bu(R,H));console.log("[finalizeOnrampSession] confirmed session:",v.id,"status:",v.status),ir(v),y("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",v.id),so(v.id);}finally{b(false);}},[Ie,so,go]),zo=useRef(false),Bm=useCallback(async()=>{if(!(!Je||zo.current)){zo.current=true;try{b(!0),Ie(),f("Refreshing quote...");let R=await go(v=>bc(Je.id,v));ir(R),await Dr(R.id);}catch(R){console.log("[confirmCheckout] error:",R?.message),O("session_error","Something went wrong. Please try again."),y("quote");}finally{b(false),zo.current=false;}}},[Ie,O,Dr,Je,go]),Ed=useCallback(async()=>{let R=T;if(!R)return console.warn("[reauthorizeLink] no email available for re-authorization"),false;try{console.log("[reauthorizeLink] re-establishing Link session for:",R),f("Verifying identity...");let v=await gc(R),H=await i(v);return H?.status==="Consented"&&H.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",H.customerId),ye.current=H.customerId,de(H.customerId),kn=H.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",H?.status),!1)}catch(v){return console.warn("[reauthorizeLink] failed:",v?.message),false}},[i,T]),Wm=useCallback(async(R=false,v,H)=>{let X=v??Ve;if(console.log("[collectPaymentMethod] called:",{useApplePay:R,amt:X,amountOverride:v,sourceAmount:Ve,hasSavedToken:!!H}),!X||isNaN(Number(X))||Number(X)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),O("validation_error","Please enter a valid amount.");return}v&&je(v),b(true),Ie(),f("");try{let ge=await io();if(ge.error){O("configuration_error",ge.error.message,ge.error.code);return}let mt;if(H)console.log("[collectPaymentMethod] using saved payment token"),mt=H;else if(R){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),O("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),y("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Dt={applePay:{merchantCountryCode:"US",currencyCode:yt.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${$e.toUpperCase()} purchase + fees`,amount:X}]}},sr=await g("PlatformPay",Dt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!sr?.error),sr?.error){let qr=sr.error.message??"",Qr=sr.error.code??"",Vt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",sr.error,"isCancellation:",Vt),Vt||(O("payment_error",qr,Qr),y("session_params"));return}if(!sr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let er=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){O("payment_error",er.error.message,er.error.code),y("session_params");return}mt=er.cryptoPaymentToken;}else {f("Select a payment method...");let Dt=await g("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Dt?.error),Dt?.error){let qr=Dt.error.message??"",Qr=Dt.error.code??"",Vt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",Dt.error,"isCancellation:",Vt),Vt||(O("payment_error",qr,Qr),y("session_params"));return}if(!Dt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let sr=Dt.displayData;console.log("[collectPaymentMethod] displayData:",{type:sr.type,label:sr.label,sublabel:sr.sublabel,hasIcon:!!sr.icon}),f("Creating payment token...");let er=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){O("payment_error",er.error.message,er.error.code),y("session_params");return}mt=er.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",fe,"walletAddressRef:",xe.current);let Ae=xe.current||fe.toLowerCase(),ur=await go(Dt=>yu({cryptoCustomerId:ye.current,paymentToken:mt,sourceAmount:Number(X),sourceCurrency:yt,destinationCurrency:$e,walletAddress:Ae,destinationNetwork:te},Dt));console.log("[collectPaymentMethod] session created:",ur?.id,"useApplePay:",R),ir(ur),f(""),R?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await Dr(ur.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):y("quote");}catch(ge){console.log("[collectPaymentMethod] error caught:",ge?.message),O("session_error","Something went wrong. Please try again."),y("session_params");}finally{b(false),f("");}},[Ie,io,g,S,$e,O,Dr,je,Ve,yt,fe,te,go,e?.merchantIdentifier]),Am=useCallback(async()=>{b(true),Ie(),f("Select a payment method...");try{let R=await io();if(R.error)return O("configuration_error",R.error.message,R.error.code),null;let v=await g("Card");if(console.log("[addPaymentMethod] Card result ok:",!v?.error),v?.error?.message&&/no active link consumer/i.test(v.error.message)){if(console.log("[addPaymentMethod] no active Link consumer \u2014 attempting re-authorization"),!await Ed())return O("authorization_error","Please verify your identity to add a payment method."),null;v=await g("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!v?.error);}if(v?.error){let ge=v.error.message??"",mt=v.error.code??"",Ae=/cancel/i.test(ge)||/cancel/i.test(mt);return console.log("[addPaymentMethod] pmResult error:",v.error,"isCancellation:",Ae),Ae||O("payment_error",ge,mt),null}if(!v?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let H=v.displayData;console.log("[addPaymentMethod] displayData:",{type:H.type,label:H.label,sublabel:H.sublabel,hasIcon:!!H.icon}),f("Saving payment method...");let X=await S();return console.log("[addPaymentMethod] tokenResult ok:",!X?.error),X?.error?(O("payment_error",X.error.message,X.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:X.cryptoPaymentToken,sublabel:H.sublabel??""})}catch(R){return console.log("[addPaymentMethod] error:",R?.message),O("session_error",R?.message??String(R)),null}finally{b(false),f("");}},[Ie,io,g,S,O,Ed]),Em=useCallback(async()=>{if(Je){b(true),Ie(),f("");try{let R=await go(v=>bc(Je.id,v));ir(R);}catch(R){console.log("[refreshQuote] error:",R?.message),O("session_error","Something went wrong. Please try again.");}finally{b(false);}}},[Ie,O,Je,go]),Mm=useCallback(()=>{he.current=true,Ze.current=0,it.current&&(clearTimeout(it.current),it.current=null),y(r),b(false),f(""),_(null),C(e?.email??""),W(e?.phone??""),F(""),j("US"),de(""),ye.current="",Be(""),ue.current="",K.current="",Ne(false),ie(false),G(xu),ot(e?.recipientAddress??""),xe.current="",rt.current=false,pe(Onramp.CryptoNetwork.ethereum),je(e?.defaultSourceAmount??"100"),nt(e?.defaultSourceCurrency??"usd"),Ut(e?.defaultDestinationCurrency??"usdc"),B(""),st(void 0),Or(void 0),ir(null),se.current+=1,Ke.current=false,De.current=false;},[e,r]);return {step:h,restoring:w,loading:k,status:m,error:x,email:T,phone:I,fullName:z,country:P,customerId:E,accessToken:He,session:Je,kycData:oe,walletAddress:fe,resolvedRecipientAddress:A,walletNetwork:te,sourceAmount:Ve,sourceCurrency:yt,destinationCurrency:$e,tokenIconUrl:We,networkIconUrl:pt,applePaySupported:Cr,walletReady:Te,walletLoading:tt,setStep:y,setStatus:f,setEmail:C,setPhone:W,setFullName:F,setCountry:j,setWalletAddress:ot,setWalletNetwork:pe,setSourceAmount:je,setSourceCurrency:nt,setDestinationCurrency:Ut,checkEmail:q,register:ae,attachKyc:Tt,verifyIdentity:Fr,registerWallet:hs,collectPaymentMethod:Wm,addPaymentMethod:Am,refreshQuote:Em,confirmCheckout:Bm,reset:Mm,clearError:Ie,emitComplete:bt,resumeFulfillmentPolling:ao,amountFirst:t}}function _u({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:a,email:i,setEmail:s,checkEmail:l,onClose:p}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.flow.centered,children:[jsx(Ct,{size:56,strokeWidth:3}),jsx(kr,{error:n,progress:a,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your email"}),jsx(Text,{style:e.form.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Email address"}),jsx(TextInput,{style:e.form.input,placeholder:"jane@example.com",placeholderTextColor:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:s,autoFocus:true,returnKeyType:"done",onSubmitEditing:l})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(kr,{error:n,progress:a,loading:o})]})]})})}function Iu({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Ct,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:r||"Preparing identity verification..."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Text,{style:e.flow.idIcon,children:"\u{1FAAA}"})}),jsx(Text,{style:e.flow.heading,children:"Identity verification"}),jsx(Text,{style:e.flow.sub,children:r||"Tap below to continue verification."})]}),jsx(kr,{error:o,progress:r,loading:false})]}),!t&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:n,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function Pu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:p,onRetryStatusCheck:c}){let g=!!t;return jsxs(View,{style:e.form.screen,children:[g?jsx(Jt,{onPress:p}):jsx(View,{style:Ra}),jsx(View,{style:e.flow.centered,children:t?jsxs(Fragment,{children:[jsx(Text,{style:e.flow.heading,children:"Could not confirm status"}),jsx(Text,{style:e.flow.sub,children:"Your payment may still be completing. Try checking again, or close this screen and verify your wallet balance."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Ct,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Processing your purchase"}),jsxs(Text,{style:e.flow.sub,children:["Your payment has been confirmed.",`
2
+ `,"We're sending your crypto \u2014 this usually takes less than a minute."]}),n&&a&&i&&jsx(va,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(kr,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:c,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Ou({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:p}){let c=t.transaction_details,g=xa(c.destination_amount,c.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p??l,title:"Review your purchase",variant:p?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(au,{currency:c.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(lo,{quote:e.quote,label:"You pay",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"You receive",value:`${g} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Network fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Transaction fee",value:`$${c.fees.transaction_fee_amount}`,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(kr,{error:o,progress:n,loading:r})]})]})}function Fu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:p}){let c=V();return t?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.flow.centered,children:[jsx(Ct,{size:56,strokeWidth:3}),jsx(kr,{error:o,progress:n,loading:r})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your phone"}),jsx(Text,{style:e.form.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Phone number"}),jsx(TextInput,{style:e.form.input,placeholder:"+12125551234",placeholderTextColor:c.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:g=>s(g.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:l}),jsx(Text,{style:e.form.hint,children:"Include country code, e.g. +12125551234"})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:a})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(kr,{error:o,progress:n,loading:r})]})]})})}function mh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=V(),n=e.toLowerCase(),a=Ia[n]??o.primary,i=Math.round(r*.36);return jsxs(View,{style:{width:r,height:r,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:r,height:r,borderRadius:r/2}}):jsx(View,{style:[xo.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[xo.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[xo.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(qe,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Du({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:p}=V(),c=t.transaction_details,g=xa(c.destination_amount,c.destination_currency),S=r||o||"";_a(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(ScrollView,{style:e.form.flex,contentContainerStyle:xo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:xo.iconSection,children:[jsx(mh,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:xo.statusRow,children:[jsx(View,{style:[xo.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[xo.statusText,{color:s.foreground,fontFamily:p.semibold}],children:"Completed"})]}),jsx(Text,{style:[xo.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(va,{sourceCurrency:c.source_currency,destinationCurrency:c.destination_currency,destinationNetwork:c.destination_network,tokenIconUrl:n,networkIconUrl:a,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor},xo.detailCard],children:[jsx(lo,{quote:e.quote,label:"You Bought",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"You Received",value:`${g} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(lo,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(cc,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),S?jsx(cc,{quote:e.quote,label:"Recipient Address",address:S,last:true}):jsx(lo,{quote:e.quote,label:"Session",value:t.id.slice(0,8)+"..."+t.id.slice(-6),last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var xo=StyleSheet.create({scrollContent:{paddingBottom:24,alignItems:"center"},iconSection:{alignItems:"center",marginTop:24,marginBottom:24},tokenCircle:{alignItems:"center",justifyContent:"center"},tokenLetter:{color:"#FFFFFF",fontWeight:"700",letterSpacing:.5},checkBadge:{position:"absolute",bottom:0,right:0,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",marginTop:16,gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16},subtitle:{fontSize:14,marginTop:4},detailCard:{width:"100%"}});function Vu({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:p,registerWallet:c,onClose:g}){let{components:S}=V();if(t){let h=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:g}),jsxs(View,{style:e.flow.centered,children:[!h&&jsx(Ct,{size:56,strokeWidth:3}),jsx(kr,{error:o,progress:n,loading:r})]}),h&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:c,children:jsx(Text,{style:e.form.continueBtnText,children:"Retry"})})})]})}return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:g}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Your crypto wallet"}),jsx(Text,{style:e.form.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[e.form.input,e.wallet.input],placeholder:"0x...",placeholderTextColor:S.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:a,onChangeText:s})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:Ta.map(h=>{let y=i===h.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,y&&e.wallet.rowSelected],onPress:()=>{l(h.value),p(h.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(h.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,y&&e.wallet.rowTextSelected],children:h.label}),y&&jsx(View,{style:e.wallet.checkCircle,children:jsx(qe,{size:14,color:S.container.buttonTitleColor,strokeWidth:2.5})})]},h.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:c,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(kr,{error:o,progress:n,loading:r})]})]})})}function za({config:e,onClose:t}){let r=V(),o=Li(),{step:n,restoring:a,loading:i,status:s,error:l,email:p,phone:c,session:g,kycData:S,walletAddress:h,resolvedRecipientAddress:y,walletNetwork:w,sourceAmount:d,sourceCurrency:k,destinationCurrency:b,tokenIconUrl:m,networkIconUrl:f,applePaySupported:x,setStep:_,setEmail:T,setPhone:C,setWalletAddress:I,setWalletNetwork:W,setSourceAmount:z,setDestinationCurrency:F,checkEmail:P,register:j,attachKyc:E,verifyIdentity:de,registerWallet:He,collectPaymentMethod:Be,addPaymentMethod:K,confirmCheckout:ue,reset:ye,emitComplete:Te,resumeFulfillmentPolling:Ne,amountFirst:tt,customerId:ie,accessToken:se}=Ba(e),Ke=!!e?.email,De=!!e?.phone,rt=!!e?.publishableKey&&!!e?.externalUserId,[xe,Pe]=useState(void 0),[Ye,oe]=useState([]);useEffect(()=>{if(n!=="session_params"||!ie||!se)return;console.log("[OnrampScreen] customerId:",ie);let B=pe=>{let Ve=pe?.message??"";return Ve.includes("stripe_onramp_forbidden")||Ve.includes("403")},te=pe=>{B(pe)&&(Cn(),ye());};La(ie,se).then(pe=>{console.log("[OnrampScreen] customer fetched, id:",pe?.id);}).catch(pe=>{console.warn("[OnrampScreen] customer fetch error:",pe?.message),te(pe);}),Cc(ie,se).then(pe=>{console.log("[OnrampScreen] payment_tokens fetched, count:",pe.data?.length??0),oe(pe.data??[]);}).catch(pe=>{console.warn("[OnrampScreen] payment_tokens error:",pe?.message),te(pe);}),console.log("[OnrampScreen] walletAddress:",h,"walletNetwork:",w),h&&(console.log("[OnrampScreen] calling getTransactionLimits..."),wu({destinationNetwork:w||"ethereum",walletAddress:h,accessToken:se,cryptoCustomerId:ie}).then(pe=>{console.log("[OnrampScreen] transaction_limits fetched");let Ve=pe.limits?.usd;if(Ve?.card?.length){let je=Math.max(...Ve.card.map(yt=>yt.limit));Pe(je),console.log("[OnrampScreen] card max amount:",je);}}).catch(pe=>{console.warn("[OnrampScreen] transaction_limits error:",pe?.message),te(pe);}));},[n,ie,se,h,w,ye]);let G=async()=>{if(!(!ie||!se))try{let B=await Cc(ie,se);console.log("[OnrampScreen] payment_tokens refreshed, count:",B.data?.length??0),oe(B.data??[]);}catch(B){console.warn("[OnrampScreen] payment_tokens refresh error:",B?.message);let te=B?.message??"";(te.includes("stripe_onramp_forbidden")||te.includes("403"))&&(Cn(),ye());}},fe=async()=>{let B=await K();return B&&await G(),B},ot=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&ot&&g&&(Te(g),ye(),t?.());},[n,ot,g,Te,ye,t]);let A=()=>{ye(),t?.();};return a?jsx(View,{style:Ch.container,children:jsx(Ct,{size:56,strokeWidth:3})}):n==="email"?jsx(_u,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:Ke,loading:i,error:l,status:s,email:p,setEmail:T,checkEmail:P,onClose:A}):n==="register"?jsx(Fu,{styles:o,hasPrefilledPhone:De,loading:i,error:l,status:s,email:p,phone:c,setPhone:C,register:j,onClose:A}):n==="kyc"?jsx(Oa,{initialData:S,loading:i,onComplete:E,onCancel:()=>_("email")}):n==="identity"?jsx(Iu,{styles:o,loading:i,status:s,error:l,verifyIdentity:de,onClose:A}):n==="wallet"?jsx(Vu,{styles:o,hasAutoWallet:rt,loading:i,error:l,status:s,walletAddress:h,walletNetwork:w,setWalletAddress:I,setWalletNetwork:W,setDestinationCurrency:F,registerWallet:He,onClose:A}):n==="session_params"?jsx(Pa,{initialAmount:d,currency:k,applePaySupported:x,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:xe,paymentTokens:Ye,onAddPaymentMethod:fe,onCollectPayment:(B,te)=>{Be(B,te);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(B,te)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:B,selectedMethod:te,amountFirst:tt}),tt&&!ie)z(B),_("email");else {let pe=te==="apple_pay",Ve=!pe&&te?te:void 0;console.log("[OnrampScreen] isApplePay:",pe,"hasSavedToken:",!!Ve),Be(pe,B,Ve);}},onCancel:A}):n==="quote"&&g?jsx(Ou,{styles:o,session:g,loading:i,error:l,status:s,confirmCheckout:ue,tokenIconUrl:m,networkIconUrl:f,onClose:A,onBack:()=>_("session_params")}):n==="processing"?jsx(Pu,{styles:o,error:l,status:s,loading:i,sourceCurrency:g?.transaction_details.source_currency,destinationCurrency:g?.transaction_details.destination_currency??b,destinationNetwork:g?.transaction_details.destination_network??"base",tokenIconUrl:m,networkIconUrl:f,onClose:A,onRetryStatusCheck:Ne}):n==="success"&&g&&!ot?jsx(Du,{styles:o,session:g,resolvedRecipientAddress:y,recipientFromConfig:e?.recipientAddress,tokenIconUrl:m,networkIconUrl:f,onDone:()=>{Te(g),ye(),t?.();}}):null}var Ch=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000"}});function Wu(){try{let e=wh.expoConfig?.plugins;if(!Array.isArray(e))return;for(let t of e){if(!Array.isArray(t))continue;let[r,o]=t;if(r!=="@stripe/stripe-react-native"||!o||typeof o!="object")continue;let n=o.merchantIdentifier;if(typeof n=="string"){let a=n.trim();if(a.length>0)return a}}}catch{}}function Ua({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:p,onError:c,onStepChange:g,onClose:S,merchantIdentifier:h="",urlScheme:y="unifoldOnramp",paymentSelectorPosition:w,skipSuccessConfirmation:d=false}){let k=e||ya(),b=useMemo(()=>{let C=h.trim();return C.length>0?C:Wu()??""},[h]),[m,f]=useState("loading"),[x,_]=useState(null);useEffect(()=>{let C=false;async function I(){try{k&&(Fa(k),Da(Ss()));let W=await Va();if(C)return;let z=b.trim();if(await initStripe({publishableKey:W,urlScheme:y,...z?{merchantIdentifier:z}:{}}),C)return;f("ready");}catch(W){if(C)return;console.error("[StripeOnramp] Init failed:",W),_(W?.message??"Failed to load Stripe configuration"),f("error");}}return I(),()=>{C=true;}},[k,b,y]);let T=useMemo(()=>{let C={publishableKey:k,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:p,onError:c,onStepChange:g};return s&&(C.destinationTokenAddress=s),l&&(C.recipientAddress=l),t&&(C.email=t),r&&(C.phone=r),n&&(C.flowOrder=n),w&&(C.paymentSelectorPosition=w),C.skipSuccessConfirmation=d,C.merchantIdentifier=b,C},[k,o,a,i,s,l,t,r,n,w,d,b,p,c,g]);return m==="error"?jsxs(View,{style:Mi.centered,children:[jsx(Text,{style:Mi.errorText,children:"Unable to initialize"}),jsx(Text,{style:Mi.errorDetail,children:x}),S&&jsx(TouchableOpacity,{style:Mi.retryBtn,onPress:S,children:jsx(Text,{style:Mi.retryBtnText,children:"Go Back"})})]}):m==="loading"?jsx(View,{style:Mi.centered,children:jsx(Ct,{size:56,strokeWidth:3})}):jsx(za,{config:T,onClose:S})}var Mi=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function zu(){let{configure:e}=useOnramp(),t=useRef(false);return useEffect(()=>{t.current||(t.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(r=>{r.error&&console.error("[StripeOnrampPreconfigure] error:",r.error.message);}).catch(r=>{console.error("[StripeOnrampPreconfigure] threw:",r?.message);}));},[e]),null}var Uu="__unifold_stripe_onramp__";function Ha(e){globalThis[Uu]=e;}function Hu(){return globalThis[Uu]}Ha(Ua);var _o=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this);}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe();}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var Xn,xn,zi,Nu,Ph=(Nu=class extends _o{constructor(){super();J(this,Xn);J(this,xn);J(this,zi);L(this,zi,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){u(this,xn)||this.setEventListener(u(this,zi));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,xn))==null||t.call(this),L(this,xn,void 0));}setEventListener(t){var r;L(this,zi,t),(r=u(this,xn))==null||r.call(this),L(this,xn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){u(this,Xn)!==t&&(L(this,Xn,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof u(this,Xn)=="boolean"?u(this,Xn):globalThis.document?.visibilityState!=="hidden"}},Xn=new WeakMap,xn=new WeakMap,zi=new WeakMap,Nu),Ui=new Ph;var Oh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ro,ei,ju,Fh=(ju=class{constructor(){J(this,Ro,Oh);J(this,ei,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&u(this,ei)&&e!==u(this,Ro)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:u(this,Ro),provider:e}),L(this,Ro,e),process.env.NODE_ENV!=="production"&&L(this,ei,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&L(this,ei,true),u(this,Ro).setTimeout(e,t)}clearTimeout(e){u(this,Ro).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&L(this,ei,true),u(this,Ro).setInterval(e,t)}clearInterval(e){u(this,Ro).clearInterval(e);}},Ro=new WeakMap,ei=new WeakMap,ju),Io=new Fh;function $u(e){setTimeout(e,0);}var Ic=typeof window>"u"||"Deno"in globalThis;function Gt(){}function Ku(e,t){return typeof e=="function"?e(t):e}function Ls(e){return typeof e=="number"&&e>=0&&e!==1/0}function ja(e,t){return Math.max(e+(t||0)-Date.now(),0)}function po(e,t){return typeof e=="function"?e(t):e}function Rr(e,t){return typeof e=="function"?e(t):e}function $a(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Bs(i,t.options))return false}else if(!oi(t.queryKey,i))return false}if(r!=="all"){let l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return false}return !(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||a&&!a(t))}function qa(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(ti(t.options.mutationKey)!==ti(a))return false}else if(!oi(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Bs(e,t){return (t?.queryKeyHashFn||ti)(e)}function ti(e){return JSON.stringify(e,(t,r)=>Rc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function oi(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>oi(e[r],t[r])):false}var Dh=Object.prototype.hasOwnProperty;function Na(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=qu(e)&&qu(t);if(!o&&!(Rc(e)&&Rc(t)))return t;let a=(o?e:Object.keys(e)).length,i=o?t:Object.keys(t),s=i.length,l=o?new Array(s):{},p=0;for(let c=0;c<s;c++){let g=o?c:i[c],S=e[g],h=t[g];if(S===h){l[g]=S,(o?c<a:Dh.call(e,g))&&p++;continue}if(S===null||h===null||typeof S!="object"||typeof h!="object"){l[g]=h;continue}let y=Na(S,h,r+1);l[g]=y,y===S&&p++;}return a===s&&p===a?e:l}function Qa(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return false;for(let r in e)if(e[r]!==t[r])return false;return true}function qu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Rc(e){if(!Qu(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!Qu(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Qu(e){return Object.prototype.toString.call(e)==="[object Object]"}function Gu(e){return new Promise(t=>{Io.setTimeout(t,e);})}function Ws(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==false){if(process.env.NODE_ENV!=="production")try{return Na(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return Na(e,t)}return t}function Yu(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function Ju(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var ri=Symbol();function Ka(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===ri&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ri?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ga(e,t){return typeof e=="function"?e(...t):!!e}function Zu(e,t,r){let o=false,n;return Object.defineProperty(e,"signal",{enumerable:true,get:()=>(n??(n=t()),o||(o=true,n.aborted?r():n.addEventListener("abort",r,{once:true})),n)}),e}var vo=(()=>{let e=()=>Ic;return {isServer(){return e()},setIsServer(t){e=t;}}})();function As(){let e,t,r=new Promise((n,a)=>{e=n,t=a;});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject;}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n);},r.reject=n=>{o({status:"rejected",reason:n}),t(n);},r}var Xu=$u;function Vh(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=Xu,a=s=>{t?e.push(s):n(()=>{r(s);});},i=()=>{let s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(l);});});});};return {batch:s=>{let l;t++;try{l=s();}finally{t--,t||i();}return l},batchCalls:s=>(...l)=>{a(()=>{s(...l);});},schedule:a,setNotifyFunction:s=>{r=s;},setBatchNotifyFunction:s=>{o=s;},setScheduler:s=>{n=s;}}}var xt=Vh();var Hi,_n,Ni,ep,Lh=(ep=class extends _o{constructor(){super();J(this,Hi,true);J(this,_n);J(this,Ni);L(this,Ni,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t(true),o=()=>t(false);return window.addEventListener("online",r,false),window.addEventListener("offline",o,false),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o);}}});}onSubscribe(){u(this,_n)||this.setEventListener(u(this,Ni));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,_n))==null||t.call(this),L(this,_n,void 0));}setEventListener(t){var r;L(this,Ni,t),(r=u(this,_n))==null||r.call(this),L(this,_n,t(this.setOnline.bind(this)));}setOnline(t){u(this,Hi)!==t&&(L(this,Hi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return u(this,Hi)}},Hi=new WeakMap,_n=new WeakMap,Ni=new WeakMap,ep),ji=new Lh;function Bh(e){return Math.min(1e3*2**e,3e4)}function vc(e){return (e??"online")==="online"?ji.isOnline():true}var Ya=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function Ja(e){let t=false,r=0,o,n=As(),a=()=>n.status!=="pending",i=w=>{if(!a()){let d=new Ya(w);S(d),e.onCancel?.(d);}},s=()=>{t=true;},l=()=>{t=false;},p=()=>Ui.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),c=()=>vc(e.networkMode)&&e.canRun(),g=w=>{a()||(o?.(),n.resolve(w));},S=w=>{a()||(o?.(),n.reject(w));},h=()=>new Promise(w=>{o=d=>{(a()||p())&&w(d);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),y=()=>{if(a())return;let w,d=r===0?e.initialPromise:void 0;try{w=d??e.fn();}catch(k){w=Promise.reject(k);}Promise.resolve(w).then(g).catch(k=>{if(a())return;let b=e.retry??(vo.isServer()?0:3),m=e.retryDelay??Bh,f=typeof m=="function"?m(r,k):m,x=b===true||typeof b=="number"&&r<b||typeof b=="function"&&b(r,k);if(t||!x){S(k);return}r++,e.onFail?.(r,k),Gu(f).then(()=>p()?void 0:h()).then(()=>{t?S(k):y();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?y():h().then(y),n)}}var ni,tp,Za=(tp=class{constructor(){J(this,ni);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),Ls(this.gcTime)&&L(this,ni,Io.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(vo.isServer()?1/0:300*1e3));}clearGcTimeout(){u(this,ni)!==void 0&&(Io.clearTimeout(u(this,ni)),L(this,ni,void 0));}},ni=new WeakMap,tp);var ii,$i,to,si,rr,Es,ai,Hr,sp,Qo,np,ip=(np=class extends Za{constructor(t){super();J(this,Hr);J(this,ii);J(this,$i);J(this,to);J(this,si);J(this,rr);J(this,Es);J(this,ai);L(this,ai,false),L(this,Es,t.defaultOptions),this.setOptions(t.options),this.observers=[],L(this,si,t.client),L(this,to,u(this,si).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,L(this,ii,op(this.options)),this.state=t.state??u(this,ii),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return u(this,rr)?.promise}setOptions(t){if(this.options={...u(this,Es),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=op(this.options);r.data!==void 0&&(this.setState(rp(r.data,r.dataUpdatedAt)),L(this,ii,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&u(this,to).remove(this);}setData(t,r){let o=Ws(this.state.data,t,this.options);return Oe(this,Hr,Qo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Oe(this,Hr,Qo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=u(this,rr)?.promise;return u(this,rr)?.cancel(t),r?r.then(Gt).catch(Gt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return u(this,ii)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Rr(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ri||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>po(t.options.staleTime,this)==="static"):false}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?true:t==="static"?false:this.state.isInvalidated?true:!ja(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),u(this,rr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),u(this,rr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),u(this,to).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(u(this,rr)&&(u(this,ai)||Oe(this,Hr,sp).call(this)?u(this,rr).cancel({revert:true}):u(this,rr).cancelRetry()),this.scheduleGc()),u(this,to).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Oe(this,Hr,Qo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&u(this,rr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(u(this,rr))return u(this,rr).continueRetry(),u(this,rr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(p=>p.options.queryFn);l&&this.setOptions(l.options);}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));let o=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:true,get:()=>(L(this,ai,true),o.signal)});},a=()=>{let l=Ka(this.options,r),c=(()=>{let g={client:u(this,si),queryKey:this.queryKey,meta:this.meta};return n(g),g})();return L(this,ai,false),this.options.persister?this.options.persister(l,c,this):l(c)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:u(this,si),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),L(this,$i,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Oe(this,Hr,Qo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),L(this,rr,Ja({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof Ya&&l.revert&&this.setState({...u(this,$i),fetchStatus:"idle"}),o.abort();},onFail:(l,p)=>{Oe(this,Hr,Qo).call(this,{type:"failed",failureCount:l,error:p});},onPause:()=>{Oe(this,Hr,Qo).call(this,{type:"pause"});},onContinue:()=>{Oe(this,Hr,Qo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await u(this,rr).start();if(l===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(l),u(this,to).config.onSuccess?.(l,this),u(this,to).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Ya){if(l.silent)return u(this,rr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Oe(this,Hr,Qo).call(this,{type:"error",error:l}),u(this,to).config.onError?.(l,this),u(this,to).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ii=new WeakMap,$i=new WeakMap,to=new WeakMap,si=new WeakMap,rr=new WeakMap,Es=new WeakMap,ai=new WeakMap,Hr=new WeakSet,sp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Qo=function(t){let r=o=>{switch(t.type){case "failed":return {...o,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case "pause":return {...o,fetchStatus:"paused"};case "continue":return {...o,fetchStatus:"fetching"};case "fetch":return {...o,...Pc(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...rp(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return L(this,$i,t.manual?n:void 0),n;case "error":let a=t.error;return {...o,error:a,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:true};case "invalidate":return {...o,isInvalidated:true};case "setState":return {...o,...t.state}}};this.state=r(this.state),xt.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),u(this,to).notify({query:this,type:"updated",action:t});});},np);function Pc(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:vc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function rp(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function op(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return {data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:false,status:r?"success":"pending",fetchStatus:"idle"}}var Ir,Ee,zs,Sr,li,qi,Ko,Rn,Us,Qi,Ki,ci,di,In,Gi,ct,Ms,Oc,Fc,Dc,Vc,Lc,Bc,Wc,dp,cp,Ec=(cp=class extends _o{constructor(t,r){super();J(this,ct);J(this,Ir);J(this,Ee);J(this,zs);J(this,Sr);J(this,li);J(this,qi);J(this,Ko);J(this,Rn);J(this,Us);J(this,Qi);J(this,Ki);J(this,ci);J(this,di);J(this,In);J(this,Gi,new Set);this.options=r,L(this,Ir,t),L(this,Rn,null),L(this,Ko,As()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(u(this,Ee).addObserver(this),ap(u(this,Ee),this.options)?Oe(this,ct,Ms).call(this):this.updateResult(),Oe(this,ct,Vc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Ac(u(this,Ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ac(u(this,Ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Oe(this,ct,Lc).call(this),Oe(this,ct,Bc).call(this),u(this,Ee).removeObserver(this);}setOptions(t){let r=this.options,o=u(this,Ee);if(this.options=u(this,Ir).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Rr(this.options.enabled,u(this,Ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Oe(this,ct,Wc).call(this),u(this,Ee).setOptions(this.options),r._defaulted&&!Qa(this.options,r)&&u(this,Ir).getQueryCache().notify({type:"observerOptionsUpdated",query:u(this,Ee),observer:this});let n=this.hasListeners();n&&lp(u(this,Ee),o,this.options,r)&&Oe(this,ct,Ms).call(this),this.updateResult(),n&&(u(this,Ee)!==o||Rr(this.options.enabled,u(this,Ee))!==Rr(r.enabled,u(this,Ee))||po(this.options.staleTime,u(this,Ee))!==po(r.staleTime,u(this,Ee)))&&Oe(this,ct,Oc).call(this);let a=Oe(this,ct,Fc).call(this);n&&(u(this,Ee)!==o||Rr(this.options.enabled,u(this,Ee))!==Rr(r.enabled,u(this,Ee))||a!==u(this,In))&&Oe(this,ct,Dc).call(this,a);}getOptimisticResult(t){let r=u(this,Ir).getQueryCache().build(u(this,Ir),t),o=this.createResult(r,t);return Ah(this,o)&&(L(this,Sr,o),L(this,qi,this.options),L(this,li,u(this,Ee).state)),o}getCurrentResult(){return u(this,Sr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&u(this,Ko).status==="pending"&&u(this,Ko).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){u(this,Gi).add(t);}getCurrentQuery(){return u(this,Ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=u(this,Ir).defaultQueryOptions(t),o=u(this,Ir).getQueryCache().build(u(this,Ir),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Oe(this,ct,Ms).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),u(this,Sr)))}createResult(t,r){let o=u(this,Ee),n=this.options,a=u(this,Sr),i=u(this,li),s=u(this,qi),p=t!==o?t.state:u(this,zs),{state:c}=t,g={...c},S=false,h;if(r._optimisticResults){let I=this.hasListeners(),W=!I&&ap(t,r),z=I&&lp(t,o,r,n);(W||z)&&(g={...g,...Pc(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle");}let{error:y,errorUpdatedAt:w,status:d}=g;h=g.data;let k=false;if(r.placeholderData!==void 0&&h===void 0&&d==="pending"){let I;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(I=a.data,k=true):I=typeof r.placeholderData=="function"?r.placeholderData(u(this,Ki)?.state.data,u(this,Ki)):r.placeholderData,I!==void 0&&(d="success",h=Ws(a?.data,I,r),S=true);}if(r.select&&h!==void 0&&!k)if(a&&h===i?.data&&r.select===u(this,Us))h=u(this,Qi);else try{L(this,Us,r.select),h=r.select(h),h=Ws(a?.data,h,r),L(this,Qi,h),L(this,Rn,null);}catch(I){L(this,Rn,I);}u(this,Rn)&&(y=u(this,Rn),h=u(this,Qi),w=Date.now(),d="error");let b=g.fetchStatus==="fetching",m=d==="pending",f=d==="error",x=m&&b,_=h!==void 0,C={status:d,fetchStatus:g.fetchStatus,isPending:m,isSuccess:d==="success",isError:f,isInitialLoading:x,isLoading:x,data:h,dataUpdatedAt:g.dataUpdatedAt,error:y,errorUpdatedAt:w,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:g.dataUpdateCount>p.dataUpdateCount||g.errorUpdateCount>p.errorUpdateCount,isFetching:b,isRefetching:b&&!m,isLoadingError:f&&!_,isPaused:g.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:f&&_,isStale:Mc(t,r),refetch:this.refetch,promise:u(this,Ko),isEnabled:Rr(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let I=C.data!==void 0,W=C.status==="error"&&!I,z=j=>{W?j.reject(C.error):I&&j.resolve(C.data);},F=()=>{let j=L(this,Ko,C.promise=As());z(j);},P=u(this,Ko);switch(P.status){case "pending":t.queryHash===o.queryHash&&z(P);break;case "fulfilled":(W||C.data!==P.value)&&F();break;case "rejected":(!W||C.error!==P.reason)&&F();break}}return C}updateResult(){let t=u(this,Sr),r=this.createResult(u(this,Ee),this.options);if(L(this,li,u(this,Ee).state),L(this,qi,this.options),u(this,li).data!==void 0&&L(this,Ki,u(this,Ee)),Qa(r,t))return;L(this,Sr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!u(this,Gi).size)return true;let i=new Set(a??u(this,Gi));return this.options.throwOnError&&i.add("error"),Object.keys(u(this,Sr)).some(s=>{let l=s;return u(this,Sr)[l]!==t[l]&&i.has(l)})};Oe(this,ct,dp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Oe(this,ct,Vc).call(this);}},Ir=new WeakMap,Ee=new WeakMap,zs=new WeakMap,Sr=new WeakMap,li=new WeakMap,qi=new WeakMap,Ko=new WeakMap,Rn=new WeakMap,Us=new WeakMap,Qi=new WeakMap,Ki=new WeakMap,ci=new WeakMap,di=new WeakMap,In=new WeakMap,Gi=new WeakMap,ct=new WeakSet,Ms=function(t){Oe(this,ct,Wc).call(this);let r=u(this,Ee).fetch(this.options,t);return t?.throwOnError||(r=r.catch(Gt)),r},Oc=function(){Oe(this,ct,Lc).call(this);let t=po(this.options.staleTime,u(this,Ee));if(vo.isServer()||u(this,Sr).isStale||!Ls(t))return;let o=ja(u(this,Sr).dataUpdatedAt,t)+1;L(this,ci,Io.setTimeout(()=>{u(this,Sr).isStale||this.updateResult();},o));},Fc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(u(this,Ee)):this.options.refetchInterval)??false},Dc=function(t){Oe(this,ct,Bc).call(this),L(this,In,t),!(vo.isServer()||Rr(this.options.enabled,u(this,Ee))===false||!Ls(u(this,In))||u(this,In)===0)&&L(this,di,Io.setInterval(()=>{(this.options.refetchIntervalInBackground||Ui.isFocused())&&Oe(this,ct,Ms).call(this);},u(this,In)));},Vc=function(){Oe(this,ct,Oc).call(this),Oe(this,ct,Dc).call(this,Oe(this,ct,Fc).call(this));},Lc=function(){u(this,ci)!==void 0&&(Io.clearTimeout(u(this,ci)),L(this,ci,void 0));},Bc=function(){u(this,di)!==void 0&&(Io.clearInterval(u(this,di)),L(this,di,void 0));},Wc=function(){let t=u(this,Ir).getQueryCache().build(u(this,Ir),this.options);if(t===u(this,Ee))return;let r=u(this,Ee);L(this,Ee,t),L(this,zs,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},dp=function(t){xt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(u(this,Sr));}),u(this,Ir).getQueryCache().notify({query:u(this,Ee),type:"observerResultsUpdated"});});},cp);function Wh(e,t){return Rr(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function ap(e,t){return Wh(e,t)||e.state.data!==void 0&&Ac(e,t,t.refetchOnMount)}function Ac(e,t,r){if(Rr(t.enabled,e)!==false&&po(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&Mc(e,t)}return false}function lp(e,t,r,o){return (e!==t||Rr(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&Mc(e,r)}function Mc(e,t){return Rr(t.enabled,e)!==false&&e.isStaleByTime(po(t.staleTime,e))}function Ah(e,t){return !Qa(e.getCurrentResult(),t)}function zc(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],i=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},l=0,p=async()=>{let c=false,g=y=>{Zu(y,()=>t.signal,()=>c=true);},S=Ka(t.options,t.fetchOptions),h=async(y,w,d)=>{if(c)return Promise.reject();if(w==null&&y.pages.length)return Promise.resolve(y);let b=(()=>{let _={client:t.client,queryKey:t.queryKey,pageParam:w,direction:d?"backward":"forward",meta:t.options.meta};return g(_),_})(),m=await S(b),{maxPages:f}=t.options,x=d?Ju:Yu;return {pages:x(y.pages,m,f),pageParams:x(y.pageParams,w,f)}};if(n&&a.length){let y=n==="backward",w=y?Eh:up,d={pages:a,pageParams:i},k=w(o,d);s=await h(d,k,y);}else {let y=e??a.length;do{let w=l===0?i[0]??o.initialPageParam:up(o,s);if(l>0&&w==null)break;s=await h(s,w),l++;}while(l<y)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=p;}}}function up(e,{pages:t,pageParams:r}){let o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function Eh(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var Hs,Po,hr,ui,Oo,vn,pp,mp=(pp=class extends Za{constructor(t){super();J(this,Oo);J(this,Hs);J(this,Po);J(this,hr);J(this,ui);L(this,Hs,t.client),this.mutationId=t.mutationId,L(this,hr,t.mutationCache),L(this,Po,[]),this.state=t.state||Mh(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){u(this,Po).includes(t)||(u(this,Po).push(t),this.clearGcTimeout(),u(this,hr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){L(this,Po,u(this,Po).filter(r=>r!==t)),this.scheduleGc(),u(this,hr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){u(this,Po).length||(this.state.status==="pending"?this.scheduleGc():u(this,hr).remove(this));}continue(){return u(this,ui)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Oe(this,Oo,vn).call(this,{type:"continue"});},o={client:u(this,Hs),meta:this.options.meta,mutationKey:this.options.mutationKey};L(this,ui,Ja({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Oe(this,Oo,vn).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Oe(this,Oo,vn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>u(this,hr).canRun(this)}));let n=this.state.status==="pending",a=!u(this,ui).canStart();try{if(n)r();else {Oe(this,Oo,vn).call(this,{type:"pending",variables:t,isPaused:a}),u(this,hr).config.onMutate&&await u(this,hr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Oe(this,Oo,vn).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await u(this,ui).start();return await u(this,hr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await u(this,hr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Oe(this,Oo,vn).call(this,{type:"success",data:i}),i}catch(i){try{await u(this,hr).config.onError?.(i,t,this.state.context,this,o);}catch(s){Promise.reject(s);}try{await this.options.onError?.(i,t,this.state.context,o);}catch(s){Promise.reject(s);}try{await u(this,hr).config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,o);}catch(s){Promise.reject(s);}try{await this.options.onSettled?.(void 0,i,t,this.state.context,o);}catch(s){Promise.reject(s);}throw Oe(this,Oo,vn).call(this,{type:"error",error:i}),i}finally{u(this,hr).runNext(this);}}},Hs=new WeakMap,Po=new WeakMap,hr=new WeakMap,ui=new WeakMap,Oo=new WeakSet,vn=function(t){let r=o=>{switch(t.type){case "failed":return {...o,failureCount:t.failureCount,failureReason:t.error};case "pause":return {...o,isPaused:true};case "continue":return {...o,isPaused:false};case "pending":return {...o,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case "success":return {...o,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:false};case "error":return {...o,data:void 0,error:t.error,failureCount:o.failureCount+1,failureReason:t.error,isPaused:false,status:"error"}}};this.state=r(this.state),xt.batch(()=>{u(this,Po).forEach(o=>{o.onMutationUpdate(t);}),u(this,hr).notify({mutation:this,type:"updated",action:t});});},pp);function Mh(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Go,mo,Ns,fp,hp=(fp=class extends _o{constructor(t={}){super();J(this,Go);J(this,mo);J(this,Ns);this.config=t,L(this,Go,new Set),L(this,mo,new Map),L(this,Ns,0);}build(t,r,o){let n=new mp({client:t,mutationCache:this,mutationId:++gs(this,Ns)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){u(this,Go).add(t);let r=Xa(t);if(typeof r=="string"){let o=u(this,mo).get(r);o?o.push(t):u(this,mo).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(u(this,Go).delete(t)){let r=Xa(t);if(typeof r=="string"){let o=u(this,mo).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&u(this,mo).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=Xa(t);if(typeof r=="string"){let n=u(this,mo).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=Xa(t);return typeof r=="string"?u(this,mo).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){xt.batch(()=>{u(this,Go).forEach(t=>{this.notify({type:"removed",mutation:t});}),u(this,Go).clear(),u(this,mo).clear();});}getAll(){return Array.from(u(this,Go))}find(t){let r={exact:true,...t};return this.getAll().find(o=>qa(r,o))}findAll(t={}){return this.getAll().filter(r=>qa(t,r))}notify(t){xt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return xt.batch(()=>Promise.all(t.map(r=>r.continue().catch(Gt))))}},Go=new WeakMap,mo=new WeakMap,Ns=new WeakMap,fp);function Xa(e){return e.options.scope?.id}var Fo,gp,yp=(gp=class extends _o{constructor(t={}){super();J(this,Fo);this.config=t,L(this,Fo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Bs(n,r),i=this.get(a);return i||(i=new ip({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){u(this,Fo).has(t.queryHash)||(u(this,Fo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=u(this,Fo).get(t.queryHash);r&&(t.destroy(),r===t&&u(this,Fo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){xt.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return u(this,Fo).get(t)}getAll(){return [...u(this,Fo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>$a(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>$a(t,o)):r}notify(t){xt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){xt.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){xt.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Fo=new WeakMap,gp);var Et,Pn,On,Yi,Ji,Fn,Zi,Xi,bp,Uc=(bp=class{constructor(e={}){J(this,Et);J(this,Pn);J(this,On);J(this,Yi);J(this,Ji);J(this,Fn);J(this,Zi);J(this,Xi);L(this,Et,e.queryCache||new yp),L(this,Pn,e.mutationCache||new hp),L(this,On,e.defaultOptions||{}),L(this,Yi,new Map),L(this,Ji,new Map),L(this,Fn,0);}mount(){gs(this,Fn)._++,u(this,Fn)===1&&(L(this,Zi,Ui.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,Et).onFocus());})),L(this,Xi,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,Et).onOnline());})));}unmount(){var e,t;gs(this,Fn)._--,u(this,Fn)===0&&((e=u(this,Zi))==null||e.call(this),L(this,Zi,void 0),(t=u(this,Xi))==null||t.call(this),L(this,Xi,void 0));}isFetching(e){return u(this,Et).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return u(this,Pn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,Et).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=u(this,Et).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(po(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return u(this,Et).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),a=u(this,Et).get(o.queryHash)?.state.data,i=Ku(t,a);if(i!==void 0)return u(this,Et).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return xt.batch(()=>u(this,Et).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,Et).get(t.queryHash)?.state}removeQueries(e){let t=u(this,Et);xt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=u(this,Et);return xt.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=xt.batch(()=>u(this,Et).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Gt).catch(Gt)}invalidateQueries(e,t={}){return xt.batch(()=>(u(this,Et).findAll(e).forEach(r=>{r.invalidate();}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??true},o=xt.batch(()=>u(this,Et).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(Gt)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(Gt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=u(this,Et).build(this,t);return r.isStaleByTime(po(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Gt).catch(Gt)}fetchInfiniteQuery(e){return e.behavior=zc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Gt).catch(Gt)}ensureInfiniteQueryData(e){return e.behavior=zc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?u(this,Pn).resumePausedMutations():Promise.resolve()}getQueryCache(){return u(this,Et)}getMutationCache(){return u(this,Pn)}getDefaultOptions(){return u(this,On)}setDefaultOptions(e){L(this,On,e);}setQueryDefaults(e,t){u(this,Yi).set(ti(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...u(this,Yi).values()],r={};return t.forEach(o=>{oi(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){u(this,Ji).set(ti(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...u(this,Ji).values()],r={};return t.forEach(o=>{oi(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...u(this,On).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Bs(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ri&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...u(this,On).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){u(this,Et).clear(),u(this,Pn).clear();}},Et=new WeakMap,Pn=new WeakMap,On=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,Fn=new WeakMap,Zi=new WeakMap,Xi=new WeakMap,bp);var Hc=Dn.createContext(void 0),Nc=e=>{let t=Dn.useContext(Hc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},jc=({client:e,children:t})=>(Dn.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(Hc.Provider,{value:e,children:t}));var Cp=Dn.createContext(false),wp=()=>Dn.useContext(Cp);Cp.Provider;function Uh(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var Hh=Dn.createContext(Uh()),kp=()=>Dn.useContext(Hh);var Tp=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?Ga(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},xp=e=>{Dn.useEffect(()=>{e.clearReset();},[e]);},_p=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||Ga(r,[e.error,o]));var Rp=e=>{if(e.suspense){let r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3));}},Ip=(e,t)=>e.isLoading&&e.isFetching&&!t,vp=(e,t)=>e?.suspense&&t.isPending,$c=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Pp(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let o=wp(),n=kp(),a=Nc(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);let s=a.getQueryCache().get(i.queryHash);process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=o?"isRestoring":"optimistic",Rp(i),Tp(i,n,s),xp(n);let l=!a.getQueryCache().get(i.queryHash),[p]=Dn.useState(()=>new t(a,i)),c=p.getOptimisticResult(i),g=!o&&e.subscribed!==false;if(Dn.useSyncExternalStore(Dn.useCallback(S=>{let h=g?p.subscribe(xt.batchCalls(S)):Gt;return p.updateResult(),h},[p,g]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),Dn.useEffect(()=>{p.setOptions(i);},[i,p]),vp(i,c))throw $c(i,p,n);if(_p({result:c,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,c),i.experimental_prefetchInRender&&!vo.isServer()&&Ip(c,o)&&(l?$c(i,p,n):s?.promise)?.catch(Gt).finally(()=>{p.updateResult();}),i.notifyOnChangeProps?c:p.trackResult(c)}function Yo(e,t){return Pp(e,Ec)}var rs=new Map;function Op({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let a=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return a.start(),()=>a.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function Ln({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=V(),[p,c]=useState(false),[g,S]=useState(false),[h,y]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let x=rs.get(e);return x?{uri:e,xml:x}:null}),w=e?.toLowerCase().endsWith(".svg"),d=w&&e&&h?.uri===e?h.xml:null;useEffect(()=>{c(false),S(false);},[e]),useEffect(()=>{if(!w||!e)return;if(rs.has(e)){y({uri:e,xml:rs.get(e)});return}let x=false;return fetch(e).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.text()}).then(_=>{x||(rs.set(e,_),y({uri:e,xml:_}));}).catch(()=>{x||c(true);}),()=>{x=true;}},[e,w]);let k=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:k},s]});let b={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},m=t-n*2,f=r-n*2;return p?jsx(View,{style:[b,{backgroundColor:i||k}]}):w?jsxs(View,{style:b,children:[!!!d&&jsx(Op,{width:m,height:f,borderRadius:o,color:k}),d?jsx(SvgXml,{xml:d,width:m,height:f,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:m,height:f,onError:()=>c(true)})]}):jsxs(View,{style:b,children:[!g&&jsx(Op,{width:m,height:f,borderRadius:o,color:k}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:m,height:f},resizeMode:"contain",onLoad:()=>S(true),onError:()=>c(true)})]})}function Kc(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(rs.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{rs.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Tr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:p,balanceChainId:c,balanceTokenAddress:g,publishableKey:S,projectName:h,leftIcon:y,onLeftAction:w}){let{colors:d,fonts:k,components:b}=V(),[m,f]=useState(null),[x,_]=useState(false),T=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!x)return;let I=Animated.loop(Animated.sequence([Animated.timing(T,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(T,{toValue:0,duration:700,useNativeDriver:true})]));return I.start(),()=>I.stop()},[x,T]),useEffect(()=>{if(!s||!l||!p||!c||!g||!S){f(null),_(false);return}let I=false;return _(true),Sa(l,p,c,g,S).then(W=>{if(I)return;let z=W.balance,F=null;z&&(z.amount_usd!=null&&z.amount_usd!==""?F=`$${z.amount_usd}`:F="$0.00"),f(F);}).catch(()=>{I||f(null);}).finally(()=>{I||_(false);}),()=>{I=true;}},[s,l,p,c,g,S]);let C=T.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:gr.header,children:[jsx(View,{style:gr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(bs,{size:20,color:b.header.buttonColor,strokeWidth:2})}):y&&w?jsx(TouchableOpacity,{onPress:w,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:y}):jsx(View,{style:gr.spacer})}),jsxs(View,{style:gr.titleContainer,children:[jsxs(View,{style:gr.titleRow,children:[jsx(Text,{style:[gr.title,{color:b.header.titleColor,fontFamily:k.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[gr.titleBadge,{backgroundColor:d.card}],children:jsx(Text,{style:[gr.titleBadgeText,{color:d.foregroundMuted,fontFamily:k.regular}],children:i.count})})]}),t?jsx(Text,{style:[gr.balanceText,{color:d.foregroundMuted,fontFamily:k.regular}],children:t}):null,s&&(x?jsx(Animated.View,{style:[gr.balanceSkeleton,{backgroundColor:d.cardHover,opacity:C}]}):m!=null?jsxs(Text,{style:[gr.balanceText,{color:d.foregroundMuted,fontFamily:k.regular}],children:[h?`${h} `:"","Balance: ",m]}):null)]}),jsx(View,{style:gr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:b.header.buttonColor,strokeWidth:2})}):jsx(View,{style:gr.spacer})})]})}var gr=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,alignItems:"center"},titleRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},balanceSkeleton:{height:10,width:120,borderRadius:5,marginTop:4},balanceText:{fontSize:14,marginTop:3,textAlign:"center"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function Yt({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=V(),s=a??i.card,l=s.backShadowColor!=="transparent",p={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},c=[Lp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],g=[p,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[Lp.backShadow,{top:s.backShadowOffset.top,left:s.backShadowOffset.left,right:s.backShadowOffset.right,bottom:s.backShadowOffset.bottom,backgroundColor:s.backShadowColor,borderRadius:s.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:g,children:e}):jsx(View,{style:g,children:e})]})}var Lp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function $s({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=V(),i=a.depositMenu.card,s=o?[...o].sort((l,p)=>l.position-p.position):[];return jsxs(Yt,{cardTokens:i,onPress:e,style:Do.wrapper,contentStyle:Do.container,children:[jsxs(View,{style:Do.leftContent,children:[jsx(View,{style:[Do.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(ql,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Do.textContainer,children:[jsx(Text,{style:[Do.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Do.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Do.rightContent,children:jsx(View,{style:Do.networkIcons,children:s.map((l,p)=>{let c=l.icon_urls.find(g=>g.format==="png")?.url||l.icon_urls.find(g=>g.format==="svg")?.url;return jsx(View,{style:[Do.networkIconWrapper,{marginLeft:p===0?0:-6,zIndex:s.length-p}],children:jsx(Ln,{uri:Z(c),width:20,height:20})},l.name)})})})]})}var Do=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,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 Qs({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=V(),i=a.depositMenu.card;return jsxs(Yt,{cardTokens:i,onPress:e,style:Jo.wrapper,contentStyle:Jo.container,children:[jsxs(View,{style:Jo.leftContent,children:[jsx(View,{style:[Jo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Ii,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Jo.textContainer,children:[jsx(Text,{style:[Jo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Jo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Jo.rightContent,children:jsx(View,{style:Jo.paymentIcons,children:o?.map(s=>{let l=s.icon_urls.find(p=>p.format==="png")?.url||s.icon_urls.find(p=>p.format==="svg")?.url;return jsx(Ln,{uri:Z(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var Jo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,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 Ks({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=V(),i=a.depositMenu.card;return jsx(Yt,{cardTokens:i,onPress:e,style:Zo.wrapper,contentStyle:Zo.container,children:jsxs(View,{style:Zo.leftContent,children:[jsxs(View,{style:[Zo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(yo,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[Zo.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[Zo.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:Zo.textContainer,children:[jsx(Text,{style:[Zo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Zo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var Zo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,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 Ys({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=V(),a=n.depositMenu.card;return jsxs(Yt,{cardTokens:a,onPress:e,style:Vo.wrapper,contentStyle:Vo.container,children:[jsxs(View,{style:Vo.leftContent,children:[jsx(View,{style:[Vo.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(ma,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Vo.textContainer,children:[jsx(Text,{style:[Vo.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Vo.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Vo.rightContent,children:jsx(View,{style:Vo.badge,children:jsx(Text,{style:[Vo.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Vo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,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},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var Ep=1e4,Mp=2500,zp=3e3,Up=6e4;function Js(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:p,setDepositExecutions:c,setTrackedExecutions:g,setLatestExecution:S,setShowStatusSheet:h,onDepositSuccess:y,onExecutionsChange:w,onDepositError:d}=e,[k,b]=useState(false),[m,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;b(false),t==="auto_ui"&&f(false);let _=setTimeout(()=>{b(true),t==="auto_ui"&&f(true);},Ep);return ()=>clearTimeout(_)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let _=new Date(i.getTime()-Up),T=setInterval(async()=>{try{let W=[...(await No(n,a)).data??[]].sort((F,P)=>{let j=F.created_at?new Date(F.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-j}),z=null;for(let F of W){let P=F.created_at?new Date(F.created_at):null;if(!P||P<=_)continue;let j=p.get(F.id);if(!j){z=F;break}if(["pending","waiting","delayed"].includes(j)&&F.status==="succeeded"){z=F;break}}if(z){let F=z;c(P=>{let j=P.findIndex(E=>E.id===F.id);if(j>=0){let E=[...P];return E[j]=F,E}return [...P,F]}),g(P=>{let j=new Map(P);return j.set(F.id,F.status),j}),S(F),h(!0),F.status==="succeeded"&&y?.({message:"Deposit completed successfully",executionId:F.id}),w?.([...l,F]);}}catch(C){d?.({message:"Failed to check deposit status",error:C});}},Mp);return ()=>clearInterval(T)},[n,a,i,p,l,w,y,d]),useEffect(()=>{if(!k||!s)return;let _=async()=>{try{await ba(s,a);}catch{}};_();let T=setInterval(_,zp);return ()=>clearInterval(T)},[k,s,a]),{pollingEnabled:k,showWaitingUi:m,handleIveDeposited:()=>{b(true),f(true);}}}function ss({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=V(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",p=n||s;return jsxs(View,{style:[Np.container,{width:t,height:t}],children:[jsx(tg,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[Np.logoContainer,{width:o+12,height:o+12,backgroundColor:p,borderRadius:(o+12)/2}],children:jsx(Ln,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var Np=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function qp(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function ig(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),a=e.getHours(),i=e.getMinutes(),s=a>=12?"pm":"am";a=a%12,a=a||12;let l=i<10?`0${i}`:i;return `${r} ${o}, ${n} at ${a}:${l}${s}`}function as({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:p}){let{colors:c,fonts:g,components:S}=V(),[h,y]=useState(false),w=t==="pending"||t==="waiting"||t==="delayed",d=t==="succeeded",k=()=>{o&&Linking.openURL(o);},b=()=>{n&&Linking.openURL(n);};return jsx(ft,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:p,children:jsxs(View,{style:Ot.container,children:[jsx(TouchableOpacity,{style:Ot.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:S.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Ot.iconContainer,children:w?jsx(Ct,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:Z(r)},style:Ot.tokenIconFill}):jsx(View,{style:[Ot.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:Z(r)},style:Ot.tokenIconLarge}):jsx(View,{style:[Ot.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[Ot.statusBadge,{backgroundColor:S.container.iconBackgroundColor}],children:jsx(qe,{size:16,color:S.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Ot.title,{color:S.container.titleColor,fontFamily:g.semibold}],children:w?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Ot.amount,{color:S.container.titleColor,fontFamily:g.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[Ot.date,{color:S.container.subtitleColor,fontFamily:g.regular}],children:ig(a)}),jsx(Text,{style:[Ot.subtitle,{color:S.container.subtitleColor,fontFamily:g.regular}],children:w?"This usually takes less than a minute.":"Your account has been credited successfully!"}),d&&(o||n)&&jsxs(View,{style:Ot.detailsSection,children:[jsx(View,{style:[Ot.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:Ot.detailsToggle,onPress:()=>y(!h),children:[jsx(Text,{style:[Ot.detailsToggleText,{color:S.container.actionTitle,fontFamily:g.medium}],children:h?"See less":"See more details"}),h?jsx(Co,{size:18,color:S.container.actionColor,strokeWidth:2}):jsx(Pt,{size:18,color:S.container.actionColor,strokeWidth:2})]}),h&&jsxs(View,{style:Ot.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Ot.txButton,{backgroundColor:S.card.backgroundColor,borderColor:c.border}],onPress:k,children:[jsx(Text,{style:[Ot.txLabel,{color:S.card.titleColor,fontFamily:g.medium}],children:"Deposit tx"}),jsx(Text,{style:[Ot.txHash,{color:S.card.subtitleColor,fontFamily:g.regular}],children:qp(o)}),jsx(bo,{size:16,color:S.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Ot.txButton,{backgroundColor:S.card.backgroundColor,borderColor:c.border}],onPress:b,children:[jsx(Text,{style:[Ot.txLabel,{color:S.card.titleColor,fontFamily:g.medium}],children:"Completion tx"}),jsx(Text,{style:[Ot.txHash,{color:S.card.subtitleColor,fontFamily:g.regular}],children:qp(n)}),jsx(bo,{size:16,color:S.card.actionColor,strokeWidth:2})]})]})]})]})})}var Ot=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});function sl({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=V();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[fi.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[fi.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[fi.processingCard,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor,shadowColor:s.card.shadowOpacity>0?s.card.shadowColor:void 0,shadowOffset:s.card.shadowOpacity>0?s.card.shadowOffset:void 0,shadowOpacity:s.card.shadowOpacity,shadowRadius:s.card.shadowRadius,elevation:s.card.elevation}],children:[jsx(View,{style:[fi.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(Ql,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:fi.processingCardText,children:[jsx(Text,{style:[fi.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[fi.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var fi=StyleSheet.create({iveDepositedButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginBottom:12},iveDepositedButtonText:{fontSize:16},processingCard:{flexDirection:"row",alignItems:"center",padding:12,marginBottom:12,gap:12},processingCardText:{flex:1,gap:4},processingCardTitle:{fontSize:14},processingCardSubtitle:{fontSize:12,lineHeight:18},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"}});var Zs=(e,t)=>`${t}:${e}`,fg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function ll({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:p,depositConfirmationMode:c="auto_ui",onExecutionsChange:g,onDepositSuccess:S,onDepositError:h,borderTopLeftRadius:y,borderTopRightRadius:w,sheetBorderRadius:d}){let{colors:k,fonts:b,components:m}=V(),f=s&&l?`${s}:${l}`:"solana:mainnet",[x,_]=useState("USDC"),[T,C]=useState(f),[I,W]=useState([]),[z,F]=useState(true),[P,j]=useState([]),[E,de]=useState(true),[He,Be]=useState(false),[K,ue]=useState(false),[ye,Te]=useState(false),[Ne,tt]=useState(false),[ie,se]=useState([]),[Ke,De]=useState(new Map),[rt]=useState(()=>new Date),[xe,Pe]=useState(null),[Ye,oe]=useState(false),[G,fe]=useState(null),[ot,A]=useState(false),B=new Map;P.forEach($=>{$.chains.forEach(re=>{let Se=`${re.chain_type}:${re.chain_id}`;B.has(Se)||B.set(Se,re);});});let te=Array.from(B.values()),pe=fg(T),je=te.find($=>$.chain_type===pe.chainType&&$.chain_id===pe.chainId)?.chain_type||"ethereum",yt=Ho(I,je),nt=yt?.address||"",$e=useRef(false);useEffect(()=>{async function $(){try{de(!0),Pe(null);let Se=await qn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(j(Se.data),Se.data.length>0&&!$e.current){$e.current=!0;let me,ne;if(s&&l)if(p)for(let O of Se.data){let bt=O.chains.find(Ie=>Ie.chain_type===s&&Ie.chain_id===l&&Ie.token_address.toLowerCase()===p.toLowerCase());if(bt){me=O,ne=bt;break}}else for(let O of Se.data){let bt=O.chains.find(Ie=>Ie.chain_type===s&&Ie.chain_id===l);if(bt){me=O,ne=bt;break}}if(!me&&a)for(let O of Se.data){let bt=O.chains.find(Ie=>Ie.token_address.toLowerCase()===a.toLowerCase());if(bt){me=O,ne=bt;break}}me||(me=Se.data.find(O=>O.symbol==="USDC"),me&&me.chains.length>0&&(ne=me.chains[0])),me||(me=Se.data.find(O=>O.symbol==="USDT"),me&&me.chains.length>0&&(ne=me.chains[0])),me||(me=Se.data[0],me.chains.length>0&&(ne=me.chains[0])),me&&_(me.symbol),ne&&C(Zs(ne.chain_id,ne.chain_type));}}catch(re){console.error("Error fetching supported tokens:",re),Pe("Failed to load supported tokens"),h?.({message:"Failed to load supported tokens",error:re});}finally{de(false);}}$();},[t,h,s,l,p,a,n,o]),useEffect(()=>{async function $(){try{F(!0),Pe(null);let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);W(re.data);}catch(re){console.error("Error fetching wallets:",re),Pe("Failed to load wallets"),h?.({message:"Failed to load wallets",error:re});}finally{F(false);}}$();},[e,r,o,n,a,t,h]);let Ut=yt?.id??"",{showWaitingUi:Je,handleIveDeposited:ir}=Js({depositConfirmationMode:c,depositAddress:nt,chain:T,externalUserId:e,publishableKey:t,modalOpenedAt:rt,depositWalletId:Ut,depositExecutions:ie,trackedExecutions:Ke,setDepositExecutions:se,setTrackedExecutions:De,setLatestExecution:fe,setShowStatusSheet:oe,onDepositSuccess:S,onExecutionsChange:g,onDepositError:h});useEffect(()=>{if(!P.length)return;let $=P.find(Se=>Se.symbol===x);if(!$||$.chains.length===0)return;if(!$.chains.some(Se=>Zs(Se.chain_id,Se.chain_type)===T)){let Se=$.chains[0];C(Zs(Se.chain_id,Se.chain_type));}},[x,P,T]);let We=P.find($=>$.symbol===x),st=We?.chains||[],pt=st.find($=>Zs($.chain_id,$.chain_type)===T),Or=async()=>{if(nt)try{Clipboard.setString(nt),Be(!0),setTimeout(()=>Be(!1),2e3);}catch($){console.error("Failed to copy:",$);}},Cr=pt?.estimated_price_impact_percent??0,ce=pt?.max_slippage_percent??.25,it=pt?.minimum_deposit_amount_usd??3;if(E)return jsxs(View,{style:D.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:k.primary}),jsx(Text,{style:[D.loadingText,{color:k.foregroundMuted,fontFamily:b.regular}],children:"Loading currencies..."})]});if(xe&&P.length===0)return jsxs(View,{style:D.errorContainer,children:[jsx(Text,{style:[D.errorText,{color:k.error,fontFamily:b.regular}],children:xe}),jsx(Text,{style:[D.errorHint,{color:k.foregroundMuted,fontFamily:b.regular}],children:"Please check your network connection and try again."})]});let he=()=>jsxs(ft,{visible:ye,onClose:()=>Te(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:d?.tokenSelector?.borderTopLeftRadius??y,borderTopRightRadius:d?.tokenSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[D.sheetHeader,{borderBottomColor:k.border}],children:[jsx(View,{style:D.sheetHeaderSpacer}),jsx(Text,{style:[D.sheetTitle,{color:m.header.titleColor,fontFamily:b.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Te(false),style:D.sheetCloseButton,children:jsx(at,{size:20,color:m.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:D.sheetList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:P.map($=>jsxs(TouchableOpacity$1,{onPress:()=>{_($.symbol),Te(false);},activeOpacity:.7,style:[D.sheetItem,{backgroundColor:x===$.symbol?m.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:Z(be($,"png"))},style:D.sheetItemIcon}),jsxs(View,{style:D.sheetItemText,children:[jsx(Text,{style:[D.sheetItemTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:$.symbol}),jsxs(Text,{style:[D.sheetItemSubtitle,{color:m.card.subtitleColor,fontFamily:b.regular}],children:[$.chains.length," network",$.chains.length!==1?"s":""," available"]})]}),x===$.symbol&&jsx(qe,{size:20,color:k.primary,strokeWidth:2})]},$.symbol))})]}),Ze=()=>jsxs(ft,{visible:Ne,onClose:()=>tt(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:d?.chainSelector?.borderTopLeftRadius??y,borderTopRightRadius:d?.chainSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[D.sheetHeader,{borderBottomColor:k.border}],children:[jsx(View,{style:D.sheetHeaderSpacer}),jsx(Text,{style:[D.sheetTitle,{color:m.header.titleColor,fontFamily:b.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>tt(false),style:D.sheetCloseButton,children:jsx(at,{size:20,color:m.header.buttonColor,strokeWidth:2})})]}),jsx(ScrollView,{style:D.sheetList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:st.map($=>{let re=Zs($.chain_id,$.chain_type),Se=T===re;return jsxs(TouchableOpacity$1,{onPress:()=>{C(re),tt(false);},activeOpacity:.7,style:[D.sheetItem,{backgroundColor:Se?m.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:Z(be($,"png"))},style:D.sheetItemIcon}),jsxs(View,{style:D.sheetItemText,children:[jsx(Text,{style:[D.sheetItemTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:$.chain_name}),jsxs(Text,{style:[D.sheetItemSubtitle,{color:m.card.subtitleColor,fontFamily:b.regular}],children:["Min deposit: $",$.minimum_deposit_amount_usd]})]}),Se&&jsx(qe,{size:20,color:k.primary,strokeWidth:2})]},re)})})]});return jsxs(View,{style:D.container,children:[jsxs(View,{style:D.selectorSection,children:[jsx(Text,{style:[D.selectorLabel,{color:m.card.labelColor,fontFamily:b.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Te(true),style:[D.selector,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[We&&jsx(Image,{source:{uri:Z(be(We,"png"))},style:D.selectorIcon}),jsx(Text,{style:[D.selectorText,{color:m.card.titleColor,fontFamily:b.medium}],children:x}),jsx(Pt,{size:16,color:m.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:D.selectorSection,children:[jsxs(Text,{style:[D.selectorLabel,{color:m.card.labelColor,fontFamily:b.regular}],children:["Network"," ",jsxs(Text,{style:[D.minDeposit,{fontFamily:b.regular}],children:["($",it," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>tt(true),style:[D.selector,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[pt&&jsx(Image,{source:{uri:Z(be(pt,"png"))},style:D.selectorIcon}),jsx(Text,{style:[D.selectorText,{color:m.card.titleColor,fontFamily:b.medium}],numberOfLines:1,children:pt?.chain_name||"Select network"}),jsx(Pt,{size:16,color:m.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:D.qrContainer,children:jsx(View,{style:[D.qrWrapper,{backgroundColor:k.background,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth>0?m.card.borderWidth:1,borderColor:m.card.borderColor}],children:z?jsxs(View,{style:D.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:k.primary}),jsx(Text,{style:[D.loadingText,{color:k.foregroundMuted,fontFamily:b.regular}],children:"Loading..."})]}):nt?jsx(ss,{value:nt,size:160,logoUri:Z(be(pt,"png")||Nt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:D.qrLoading,children:jsx(Text,{style:[D.errorText,{color:k.error,fontFamily:b.regular}],children:"No address available"})})})}),jsxs(View,{style:D.addressSection,children:[jsxs(View,{style:D.addressHeader,children:[jsx(Text,{style:[D.addressLabel,{color:m.card.labelColor,fontFamily:b.medium}],children:"Deposit Address"}),He&&jsxs(View,{style:D.copiedIndicator,children:[jsx(qe,{size:14,color:k.success,strokeWidth:2}),jsx(Text,{style:[D.copiedText,{color:k.success,fontFamily:b.regular}],children:"Copied"})]})]}),jsxs(Yt,{cardTokens:m.transferCrypto.depositAddress.card,onPress:!z&&nt?Or:void 0,contentStyle:D.addressBox,children:[jsx(Text,{style:[D.addressText,{color:m.card.titleColor,fontFamily:b.regular}],numberOfLines:2,children:z?"Loading...":nt||"No address available"}),jsx(View,{style:D.addressCopyIcon,children:jsx(jn,{size:16,color:m.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[D.detailsCard,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>ue(!K),style:D.detailsHeader,children:[jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(yo,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:D.chevronContainer,children:K?jsx(Co,{size:16,color:m.card.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:m.card.actionColor,strokeWidth:2})})]}),K&&jsxs(View,{style:D.detailsContent,children:[jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:["Price impact: ",Cr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>A(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Pi,{size:14,color:m.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:["Slippage: Auto \u2022 ",ce.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>A(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Pi,{size:14,color:m.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:D.detailsRow,children:[jsx(View,{style:[D.detailIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(ua,{size:12,color:m.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[D.detailsLabel,{color:m.card.titleColor,fontFamily:b.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(sl,{depositConfirmationMode:c,depositAddress:nt,showWaitingUi:Je,latestExecution:G,onIveDeposited:ir}),jsx(TouchableOpacity$1,{style:D.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[D.termsText,{color:k.primary,fontFamily:b.regular}],children:"Terms apply"})}),he(),Ze(),jsxs(ft,{visible:ot,onClose:()=>A(false),closeOnBackdropPress:true,showHandle:true,borderTopLeftRadius:d?.infoSheet?.borderTopLeftRadius??y,borderTopRightRadius:d?.infoSheet?.borderTopRightRadius??w,children:[jsxs(View,{style:[D.sheetHeader,{borderBottomColor:k.border}],children:[jsx(View,{style:D.sheetHeaderSpacer}),jsx(Text,{style:[D.sheetTitle,{color:m.header.titleColor,fontFamily:b.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>A(false),style:D.sheetCloseButton,children:jsx(at,{size:20,color:m.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:D.infoSheetContent,children:[jsxs(View,{style:[D.infoCard,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[jsxs(View,{style:D.infoCardHeader,children:[jsx(View,{style:[D.infoCardIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:m.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[D.infoCardTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:"Price Impact"}),jsxs(Text,{style:[D.infoCardValue,{color:m.card.titleColor,fontFamily:b.medium}],children:[Cr.toFixed(2),"%"]})]}),jsx(Text,{style:[D.infoCardDescription,{color:m.card.descriptionColor,fontFamily:b.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[D.infoCard,{backgroundColor:m.card.backgroundColor,borderRadius:m.card.borderRadius,borderWidth:m.card.borderWidth,borderColor:m.card.borderColor}],children:[jsxs(View,{style:D.infoCardHeader,children:[jsx(View,{style:[D.infoCardIcon,{backgroundColor:m.card.iconBackgroundColor,borderRadius:m.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:m.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[D.infoCardTitle,{color:m.card.titleColor,fontFamily:b.medium}],children:"Max Slippage"}),jsxs(Text,{style:[D.infoCardValue,{color:m.card.titleColor,fontFamily:b.medium}],children:[ce.toFixed(2),"%"]})]}),jsx(Text,{style:[D.infoCardDescription,{color:m.card.descriptionColor,fontFamily:b.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),G&&jsx(as,{visible:Ye,status:G.status,tokenIconUrl:G.destination_token_metadata?.icon_urls?.find($=>$.format==="png")?.url||G.destination_token_metadata?.icon_url||be(We,"png"),explorerUrl:G.explorer_url,completionExplorerUrl:G.destination_explorer_url,date:G.created_at?new Date(G.created_at):void 0,amountUsd:G.source_amount_usd?parseFloat(G.source_amount_usd):void 0,onClose:()=>oe(false),borderTopLeftRadius:d?.depositStatus?.borderTopLeftRadius??y,borderTopRightRadius:d?.depositStatus?.borderTopRightRadius??w})]})}var D=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{maxHeight:400,paddingTop:8},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function cl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=V();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[hi.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:hi.leftContent,children:[jsx(View,{style:[hi.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:Z(be(e,"png"))},style:hi.icon})}),jsxs(View,{style:hi.textContainer,children:[jsx(Text,{style:[hi.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[hi.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(qe,{size:16,color:o.primary,strokeWidth:2})]})}var hi=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding: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 ea({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=V();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:Jp.headerContainer,children:jsx(Text,{style:[Jp.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(cl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var Jp=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function ul({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:p,components:c}=V(),[g,S]=useState(""),h=o.map(f=>r.find(x=>x.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),y=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),w=f=>{if(!g)return f;let x=g.toLowerCase();return f.filter(_=>_.name.toLowerCase().includes(x)||_.currency_code.toLowerCase().includes(x))},d=w(h),k=w(y),b=f=>{a(f),t(false),S("");},m=()=>{t(false),S("");};return jsxs(ft,{visible:e,onClose:m,closeOnBackdropPress:true,showHandle:false,heightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(Tr,{title:"Currency",showBack:false,onClose:m}),jsx(View,{style:gi.searchContainer,children:jsx(TextInput,{style:[gi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:p.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:g,onChangeText:S,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(ScrollView,{style:gi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:gi.listContent,children:[jsx(ea,{title:"Popular currencies",currencies:d,selectedCurrency:n,onSelect:b}),d.length>0&&k.length>0&&jsx(View,{style:gi.sectionSpacer}),jsx(ea,{title:"All currencies",currencies:k,selectedCurrency:n,onSelect:b}),d.length===0&&k.length===0&&jsx(View,{style:gi.noResultsContainer,children:jsx(Text,{style:[gi.noResultsText,{color:c.container.subtitleColor,fontFamily:p.regular}],children:"No currencies found"})})]})})]})}var gi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:24},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function hd(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 fl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:p,onDepositError:c,borderTopLeftRadius:g,borderTopRightRadius:S,sheetBorderRadius:h}){let{colors:y,fonts:w,components:d}=V(),[k,b]=useState(""),[m,f]=useState("usd"),[x,_]=useState(false),[T,C]=useState(false),[I,W]=useState([]),[z,F]=useState(false),[P,j]=useState(null),[E,de]=useState(null),[He,Be]=useState("amount"),[K,ue]=useState(null),[ye,Te]=useState(true),[Ne,tt]=useState(null),[ie,se]=useState(false),Ke=useRef(null),De=useRef(false);useEffect(()=>{Ke.current=K;},[K]),useEffect(()=>{De.current=ie;},[ie]);let[rt,xe]=useState([]),[Pe,Ye]=useState(true),[oe,G]=useState(60),[fe,ot]=useState([]),[A,B]=useState([]),[te,pe]=useState(null),[Ve,je]=useState(null),[yt,nt]=useState(true),[$e,Ut]=useState(null),[Je,ir]=useState(false),[We,st]=useState(null),[pt,Or]=useState(false),[Cr,ce]=useState(false),[it,he]=useState(false),[Ze,$]=useState(null),re=r??He,Se=useRef(null),me=fe.find(q=>q.currency_code.toLowerCase()===m.toLowerCase()),ne=useCallback(q=>{Be(q),q==="quotes"?o?.(q,I.length):o?.(q);},[I.length,o]);useEffect(()=>{async function q(){try{let ae=await xs();je(ae);}catch(ae){console.error("Error fetching user IP:",ae);}finally{nt(false);}}q();},[]),useEffect(()=>{async function q(){try{let ae=await Uo({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);xe(ae.data);}catch(ae){console.error("Error fetching wallets:",ae),j("Failed to load wallet addresses");}finally{Ye(false);}}q();},[e,a,i,s,l,t]);let O=n||te?.symbol.toUpperCase()||"USDC",bt=Fi(te?.icon_urls,"png")||te?.icon_url,Ie=Fi(te?.chain_icon_urls,"png")||te?.chain_icon_url;useEffect(()=>{async function q(){try{let ae=await ec(t);ot(ae.data),B(ae.preferred||[]);}catch(ae){console.error("Error fetching fiat currencies:",ae);}}q();},[t]),useEffect(()=>{if(x||fe.length===0||!Ve?.alpha2)return;let q=Ve.alpha2.toUpperCase(),ae=fe.find(Tt=>Tt.country_codes.includes(q));if(ae)f(ae.currency_code.toLowerCase()),!k&&!T&&b(String(ae.default_amount??100));else if(!k&&!T){let Tt=fe.find(Fr=>Fr.currency_code.toLowerCase()==="usd");Tt&&b(String(Tt.default_amount??100));}},[fe,Ve,x,k,T]),useEffect(()=>{if(fe.length!==0){if(Se.current!==null&&Se.current!==m){let q=fe.find(ae=>ae.currency_code.toLowerCase()===m.toLowerCase());q&&b(String(q.default_amount??100));}Se.current=m;}},[m,fe]),useEffect(()=>{async function q(){try{let ae=await Yl({chain_type:i||"",chain_id:s||"",token_address:l||""},t);pe(ae);}catch(ae){console.error("Error fetching supported tokens:",ae);}}q();},[i,s,l,t]),useEffect(()=>{async function q(){if(!(!l||!s||!i)&&!yt){ir(true);try{let ae=await Xl({country_code:Ve?.alpha2?.toUpperCase()||"US",subdivision_code:Ve?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);Ut(ae);}catch(ae){console.error("Error fetching default onramp token:",ae);}finally{ir(false);}}}q();},[l,s,i,Ve,yt,t]),useEffect(()=>{let q=parseFloat(k);if(isNaN(q)||q<=0){W([]),de(null);return}if(!$e||Je){W([]),ue(null);return}let ae=fe.find(Fr=>Fr.currency_code.toLowerCase()===m.toLowerCase());if(ae){if(q<ae.minimum_amount){W([]),ue(null),de(`Minimum amount is ${hd(m)}${ae.minimum_amount.toLocaleString()}`);return}if(q>ae.maximum_amount){W([]),ue(null),de(`Maximum amount is ${hd(m)}${ae.maximum_amount.toLocaleString()}`);return}}de(null);let Tt=setTimeout(()=>{un(q);},500);return ()=>clearTimeout(Tt)},[k,m,t,$e,Je,fe]);let un=async q=>{if(!$e){j("Loading token information...");return}F(true),j(null);try{let ae={country_code:Ve?.alpha2?.toUpperCase()||"US",source_amount:q.toString(),source_currency:m.toLowerCase(),destination_currency:$e.destination_currency,destination_network:$e.destination_network,subdivision_code:Ve?.state||void 0},Tt=await Jl(ae,t);W(Tt.data);let Fr=De.current,hs=Ke.current;if(Fr&&hs){let so=Tt.data.find(ao=>ao.service_provider===hs.service_provider);if(so){if(ue(so),Tt.data.length>0){let ao=Tt.data.reduce((Dr,zo)=>zo.destination_amount>Dr.destination_amount?zo:Dr);Ne||tt(ao.service_provider),Te(so.service_provider===Ne);}}else if(Tt.data.length>0){let ao=Tt.data.reduce((Dr,zo)=>zo.destination_amount>Dr.destination_amount?zo:Dr);ue(ao),tt(ao.service_provider),Te(!0),se(!1);}}else if(Tt.data.length>0){let so=Tt.data.reduce((ao,Dr)=>Dr.destination_amount>ao.destination_amount?Dr:ao);ue(so),tt(so.service_provider),Te(!0);}G(60);}catch(ae){console.error("Failed to fetch quotes:",ae),j("Failed to fetch quotes. Please try again."),W([]);}finally{F(false);}};useEffect(()=>{if(I.length===0)return;let q=setInterval(()=>{G(ae=>{if(ae<=1){let Tt=parseFloat(k);return !isNaN(Tt)&&Tt>0&&un(Tt),60}return ae-1});},1e3);return ()=>clearInterval(q)},[I.length,k]);let Ti=q=>{(/^\d*\.?\d{0,2}$/.test(q)||q==="")&&(b(q),C(true));},xi=q=>{b(q.toString()),C(true);},go=async()=>{if(K&&$e)try{let q=$e.destination_token_metadata.chain_type,ae=Ho(rt,q);if(!ae?.address){j("Wallet address not available");return}let Tt={service_provider:K.service_provider,country_code:K.country_code?.toUpperCase()||Ve?.alpha2?.toUpperCase()||"US",source_currency:K.source_currency,source_amount:k,destination_currency:K.destination_currency,destination_network:K.destination_network,wallet_address:ae.address,subdivision_code:Ve?.state||void 0},Fr=await Zl(Tt,t);st({provider:K,sourceCurrency:m,sourceAmount:k,sessionUrl:Fr.url}),$(Fr.url),he(!0);}catch(q){console.error("Failed to create session:",q),j("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:q});}},_i=hd(m),io=()=>{he(false),ne("onramp"),p?.({message:"Payment flow completed"});},Mo=()=>jsx(Pg,{visible:it,onClose:io,url:Ze,providerName:K?.service_provider_display_name||"Complete Payment",colors:y,fonts:w,borderTopLeftRadius:h?.webView?.borderTopLeftRadius??g,borderTopRightRadius:h?.webView?.borderTopRightRadius??S});return re==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:N.amountViewContainer,children:[jsxs(ScrollView,{style:N.scrollContainer,contentContainerStyle:N.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:N.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Or(true),style:[N.currencyButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.input.borderRadius,borderWidth:d.input.borderWidth,borderColor:d.input.borderColor}],children:[me&&jsx(Image,{source:{uri:Z(be(me,"png"))},style:N.currencyIcon}),jsx(Text,{style:[N.currencyText,{color:d.card.titleColor,fontFamily:w.medium}],children:m.toUpperCase()}),jsx(Pt,{size:16,color:d.card.actionColor,strokeWidth:2})]})}),jsx(ul,{open:pt,onOpenChange:Or,currencies:fe,preferredCurrencyCodes:A,selectedCurrency:m,onSelectCurrency:q=>{f(q.toLowerCase()),_(true);},borderTopLeftRadius:h?.currencyModal?.borderTopLeftRadius??g,borderTopRightRadius:h?.currencyModal?.borderTopRightRadius??S}),jsx(View,{style:N.amountContainer,children:jsxs(View,{style:N.amountInputRow,children:[jsx(Text,{style:[N.currencySymbol,{color:d.container.titleColor,fontFamily:w.medium}],children:_i}),jsx(TextInput,{style:[N.amountInput,{color:d.container.titleColor,fontFamily:w.medium}],value:k,onChangeText:Ti,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:y.foregroundMuted})]})}),me?.suggested_amounts&&me.suggested_amounts.length>0&&jsx(View,{style:N.quickAmounts,children:me.suggested_amounts.map(q=>jsx(TouchableOpacity$1,{onPress:()=>xi(q),style:[N.quickAmountButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.button.borderRadius,borderWidth:parseFloat(k)===q?2:d.button.borderWidth,borderColor:parseFloat(k)===q?y.primary:d.button.borderColor}],children:jsxs(Text,{style:[N.quickAmountText,{color:d.card.titleColor,fontFamily:w.medium}],children:[_i,q.toLocaleString()]})},q))}),E&&jsx(Text,{style:[N.validationError,{color:y.error,fontFamily:w.regular}],children:E}),jsxs(View,{style:N.providerSection,children:[jsxs(View,{style:N.providerHeader,children:[jsx(Text,{style:[N.providerLabel,{color:d.card.labelColor,fontFamily:w.medium}],children:"Provider"}),I.length>0&&!z&&jsxs(Text,{style:[N.refreshText,{color:d.card.labelRightColor,fontFamily:w.regular}],children:["Refreshing in ",oe,"s"]})]}),jsx(Yt,{cardTokens:d.depositCard.quoteProvider.card,onPress:z||I.length===0?void 0:()=>ce(true),contentStyle:StyleSheet.flatten([N.providerButton,(z||I.length===0)&&N.disabled]),children:z?jsxs(View,{style:N.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:d.container.subtitleColor}),jsx(Text,{style:[N.loadingText,{color:d.container.subtitleColor,fontFamily:w.regular}],children:"Finding best rates..."})]}):K?jsxs(View,{style:N.providerContent,children:[jsxs(View,{style:N.providerInfo,children:[ye&&jsx(Text,{style:[N.autoPickedText,{color:d.container.subtitleColor,fontFamily:w.regular}],children:"Auto-picked for you"}),jsxs(View,{style:N.providerRow,children:[jsx(Image,{source:{uri:Z(Ca(K.icon_urls,"png",K.icon_url))},style:N.providerIconImage},`provider-${K.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[N.providerName,{color:d.card.titleColor,fontFamily:w.medium}],children:K.service_provider_display_name}),jsxs(Text,{style:[N.bestPriceText,{color:y.success,fontFamily:w.regular}],children:["Best price \u2022 ",K.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(Vr,{size:20,color:d.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[N.noProviderText,{color:d.container.subtitleColor,fontFamily:w.regular}],children:parseFloat(k)>0?"No providers available":"Enter an amount to see providers"})}),P&&jsx(Text,{style:[N.errorText,{color:y.error,fontFamily:w.regular}],children:P})]}),jsxs(ft,{visible:Cr,onClose:()=>ce(false),closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:h?.providerModal?.borderTopLeftRadius??g,borderTopRightRadius:h?.providerModal?.borderTopRightRadius??S,children:[jsx(Tr,{title:"Select Provider",showBack:false,onClose:()=>ce(false)}),jsx(ScrollView,{style:N.providerModalList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsx(View,{style:N.quotesList,children:[...I].sort((q,ae)=>ae.destination_amount-q.destination_amount).map((q,ae)=>{let Tt=K?.service_provider===q.service_provider,Fr=ae===0;return jsxs(Yt,{cardTokens:d.depositCard.quoteProvider.card,onPress:()=>{ue(q),se(true),Te(q.service_provider===Ne),ce(false);},contentStyle:StyleSheet.flatten([N.quoteItem,Tt&&{borderWidth:2,borderColor:y.primary}]),children:[jsxs(View,{style:N.quoteLeft,children:[jsx(Image,{source:{uri:Z(Ca(q.icon_urls,"png",q.icon_url))},style:N.providerIconImage}),jsxs(View,{children:[jsx(Text,{style:[N.quoteName,{color:d.card.titleColor,fontFamily:w.medium}],children:q.service_provider_display_name}),Fr&&jsx(Text,{style:[N.bestPriceLabel,{color:y.success,fontFamily:w.regular}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:N.quoteRight,children:[jsxs(Text,{style:[N.quoteAmount,{color:d.card.textRightColor,fontFamily:w.medium}],children:[q.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[N.quoteSource,{color:d.card.subtextRightColor,fontFamily:w.regular}],children:["Fee: ",_i,q.total_fee.toFixed(2)]})]})]},q.service_provider)})})})]})]}),jsx(View,{style:[N.continueButtonContainer,{backgroundColor:y.background}],children:jsx(TouchableOpacity$1,{onPress:go,disabled:z||Pe||!K||parseFloat(k)<=0,style:[N.continueButton,{backgroundColor:d.container.buttonColor,borderRadius:d.button.borderRadius,borderWidth:d.button.borderWidth,borderColor:d.button.borderColor},(z||Pe||!K)&&N.disabledButton],children:jsx(Text,{style:[N.continueButtonText,{color:d.container.buttonTitleColor,fontFamily:w.medium}],children:Pe?"Loading...":"Continue"})})})]}),Mo()]}):re==="onramp"&&We?jsxs(View,{style:N.onrampContainer,children:[jsx(Image,{source:{uri:Z(Ca(We.provider.icon_urls,"png",We.provider.icon_url))},style:N.onrampProviderIcon}),jsxs(Text,{style:[N.onrampTitle,{color:d.container.titleColor,fontFamily:w.medium}],children:["Complete transaction with ",We.provider.service_provider_display_name]}),jsx(Text,{style:[N.onrampSubtitle,{color:d.container.subtitleColor,fontFamily:w.regular}],children:"You can close this modal."}),jsxs(View,{style:[N.flowDiagram,{backgroundColor:d.card.backgroundColor}],children:[jsxs(View,{style:N.flowStep,children:[jsx(Image,{source:{uri:Nt(`/icons/currencies/png/${We.sourceCurrency.toLowerCase()}.png`)},style:N.flowIconImage}),jsx(Text,{style:[N.flowLabel,{color:d.card.subtitleColor,fontFamily:w.regular}],children:"You use"}),jsx(Text,{style:[N.flowValue,{color:d.card.titleColor,fontFamily:w.medium}],children:We.sourceCurrency.toUpperCase()})]}),jsx(Vr,{size:16,color:d.card.actionColor,strokeWidth:2}),jsxs(View,{style:N.flowStep,children:[jsxs(View,{style:N.flowIconWithBadge,children:[jsx(Image,{source:{uri:Fi($e?.destination_token_metadata?.icon_urls,"png")||$e?.destination_token_metadata?.icon_url||Nt("/icons/tokens/png/usdc.png")},style:N.flowIconImageNoBadge}),jsx(Image,{source:{uri:Fi($e?.destination_token_metadata?.chain?.icon_urls,"png")||$e?.destination_token_metadata?.chain?.icon_url||Nt("/icons/networks/png/polygon.png")},style:[N.flowNetworkBadge,{borderColor:y.background,borderRadius:d.badge.borderRadius}]})]}),jsx(Text,{style:[N.flowLabel,{color:d.card.subtitleColor,fontFamily:w.regular}],children:"You buy"}),jsx(Text,{style:[N.flowValue,{color:d.card.titleColor,fontFamily:w.medium}],children:"USDC"})]}),jsx(Vr,{size:16,color:d.card.actionColor,strokeWidth:2}),jsxs(View,{style:N.flowStep,children:[jsxs(View,{style:N.flowIconWithBadge,children:[jsx(Image,{source:{uri:bt||Nt("/icons/tokens/png/usdc.png")},style:N.flowIconImageNoBadge}),jsx(Image,{source:{uri:Ie||Nt("/icons/networks/png/polygon.png")},style:[N.flowNetworkBadge,{borderColor:y.background,borderRadius:d.badge.borderRadius}]})]}),jsx(Text,{style:[N.flowLabel,{color:d.card.subtitleColor,fontFamily:w.regular}],children:"You receive"}),jsx(Text,{style:[N.flowValue,{color:d.card.titleColor,fontFamily:w.medium}],children:O})]})]}),jsx(View,{style:[N.onrampInfoBox,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:jsx(Text,{style:[N.onrampInfoText,{color:d.card.descriptionColor,fontFamily:w.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function Pg({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(ft,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:yi.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:yi.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(qe,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[yi.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:yi.headerSpacer})]}),r&&jsx(View,{style:yi.container,children:jsx(WebView,{source:{uri:r},style:yi.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:yi.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var yi=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),N=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8},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},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},bestPriceLabel:{fontSize:11,marginTop:2},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function Vg(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 Lg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function yl({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=V(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=Z(be(e.destination_token_metadata,"png")||Nt("/icons/tokens/png/usdc.png")),p=i?"Deposit Processing":"Deposit Completed",c=Vg(e.created_at||new Date().toISOString()),g=Lg(e.source_amount_usd);return jsxs(Yt,{cardTokens:a,onPress:t,contentStyle:rn.container,children:[jsxs(View,{style:rn.iconContainer,children:[jsx(Image,{source:{uri:l},style:rn.tokenIcon}),jsx(View,{style:[rn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(pa,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(qe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:rn.textContainer,children:[jsx(Text,{style:[rn.title,{color:a.titleColor,fontFamily:o.medium}],children:p}),jsx(Text,{style:[rn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:rn.rightContainer,children:[jsx(Text,{style:[rn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:g}),jsx(Vr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var rn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});function om(e,t){let r={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||r[e]||e:r[e]||e}function nm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function Mg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var im=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function sm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function zg(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 Cd({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{height:a}=useWindowDimensions(),{colors:i,fonts:s,components:l}=V(),[p,c]=useState(r),[g,S]=useState(false),[h,y]=useState(null),[w,d]=useState(false),k=useRef(null);useEffect(()=>{if(!e||!o)return;let T=async()=>{S(true);try{let W=[...(await No(o,n)).data].sort((z,F)=>{let P=z.created_at?new Date(z.created_at).getTime():0;return (F.created_at?new Date(F.created_at).getTime():0)-P});c(W);}catch(I){console.error("Failed to fetch executions:",I),c(r);}finally{S(false);}};T();let C=setInterval(T,1e4);return ()=>clearInterval(C)},[e,o,n,r]),useEffect(()=>{r.length>0&&c(T=>{let C=new Set(T.map(W=>W.id)),I=r.filter(W=>!C.has(W.id));return I.length>0?[...I,...T]:T});},[r]),useEffect(()=>{e||y(null);},[e]);let b=T=>{y(T);};return jsxs(Fragment,{children:[jsx(Tr,{title:h?"Deposit Details":"Deposit Tracker",onClose:()=>{y(null),t();},showClose:!h,showBack:!!h,onBack:()=>{y(null),d(false);}}),h?(()=>{if(!h)return null;let T=h,C=T.status==="pending"||T.status==="waiting"||T.status==="delayed",I=T.status==="succeeded",W=Z(be(T.destination_token_metadata,"png")||Nt("/icons/tokens/png/usdc.png")),z=T.provider_metadata?.details,F=z?.currencyIn,P=z?.currencyOut;F?.currency?.symbol||"USDC";P?.currency?.symbol||"USDC";let de=nm(T.source_amount_base_unit,T.source_token_metadata?.decimals),He=nm(T.destination_amount_base_unit,T.destination_token_metadata?.decimals),Be=Mg(T.source_amount_usd),K=om(T.source_chain_type,T.source_chain_id),ue=om(T.destination_chain_type,T.destination_chain_id),ye=()=>{T.explorer_url&&Linking.openURL(T.explorer_url);},Te=()=>{T.destination_explorer_url&&Linking.openURL(T.destination_explorer_url);};return jsxs(ScrollView,{ref:k,style:[le.scrollContainer,{maxHeight:a*.7}],contentContainerStyle:le.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:le.iconSection,children:[jsxs(View,{style:le.iconWrapper,children:[jsx(Image,{source:{uri:W},style:le.tokenIcon}),jsx(View,{style:[le.statusBadge,{backgroundColor:C?i.warning:i.success,borderColor:i.background}],children:C?jsx(Pt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(qe,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:le.statusRow,children:[jsx(View,{style:[le.statusDot,{backgroundColor:C?i.warning:i.success}]}),jsx(Text,{style:[le.statusText,{color:l.container.titleColor,fontFamily:s.semibold}],children:C?"Processing":"Completed"})]}),jsx(Text,{style:[le.dateText,{color:l.container.subtitleColor,fontFamily:s.regular}],children:zg(T.created_at||new Date().toISOString())})]}),jsxs(View,{style:[le.card,{backgroundColor:l.card.backgroundColor,borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor}],children:[jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"Amount Sent"}),jsxs(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:[de," ",sm(T.source_currency)]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"Amount Received"}),jsxs(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:[He," ",sm(T.destination_currency)]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"USD Value"}),jsx(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:Be})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"Source Network"}),jsx(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:K})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"Destination Network"}),jsx(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:ue})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ne=!w;d(Ne),Ne?setTimeout(()=>{k.current?.scrollToEnd({animated:true});},100):k.current?.scrollTo({y:0,animated:true});},style:le.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[le.toggleText,{color:l.container.actionTitle,fontFamily:s.regular}],children:w?"See less":"See more details"}),w?jsx(Co,{size:14,color:l.container.actionColor,strokeWidth:2}):jsx(Pt,{size:14,color:l.container.actionColor,strokeWidth:2})]}),w&&jsxs(View,{style:[le.card,{backgroundColor:l.card.backgroundColor,borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor}],children:[T.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:ye,style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"Deposit Tx"}),jsxs(View,{style:le.cardRowRight,children:[jsx(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:im(T.transaction_hash)}),jsx(bo,{size:14,color:l.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:i.border}]})]}),T.destination_explorer_url&&I&&jsxs(TouchableOpacity,{onPress:Te,style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:l.card.rowLeftLabel,fontFamily:s.regular}],children:"Completion Tx"}),jsxs(View,{style:le.cardRowRight,children:[jsx(Text,{style:[le.cardValue,{color:l.card.rowRightLabel,fontFamily:s.medium}],children:im(T.destination_transaction_hashes[0])}),jsx(bo,{size:14,color:l.card.actionIcon,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:[le.scrollContainer,{maxHeight:a*.7}],contentContainerStyle:le.scrollContent,showsVerticalScrollIndicator:false,children:p.length===0?jsxs(View,{style:le.emptyContainer,children:[jsx(Text,{style:[le.emptyText,{color:l.container.titleColor,fontFamily:s.medium}],children:"No deposits yet"}),jsx(Text,{style:[le.emptySubtext,{color:l.container.subtitleColor,fontFamily:s.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:le.executionsList,children:p.map(T=>jsx(yl,{execution:T,onPress:()=>b(T)},T.id))})})]})}var le=StyleSheet.create({scrollContainer:{paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function ta(e,t=true){let[r,o]=useState(null),[n,a]=useState(null),[i,s]=useState(false),[l,p]=useState(false),[c,g]=useState(null),[S,h]=useState(null);useEffect(()=>{!t||r||(s(true),xs().then(k=>{o(k),g(null);}).catch(k=>{g(k instanceof Error?k:new Error(String(k)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(p(true),Ts(e).then(k=>{a(k),h(null);}).catch(k=>{h(k instanceof Error?k:new Error(String(k)));}).finally(()=>{p(false);}));},[t,e,n]);let y=i||l,w=c||S||null,d=null;if(r&&n){let k=n.blocked_country_codes||[],b=r.alpha2.toUpperCase();d=!k.some(m=>m.toUpperCase()===b);}return {isAllowed:d,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:y,error:w}}var Sd="unifold_recent_tokens",jg=5,um=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function kl(){try{let e=await kc.getItem(Sd);return e?JSON.parse(e):[]}catch{return []}}async function $g(e){try{let r=(await kl()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,jg);await kc.setItem(Sd,JSON.stringify(o));}catch{}}async function qg(e){try{let r=(await kl()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await kc.setItem(Sd,JSON.stringify(r)),r}catch{return []}}function Td({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:p,components:c}=V(),[g,S]=useState(""),[h,y]=useState([]);useEffect(()=>{e&&kl().then(y);},[e]),useEffect(()=>{e||S("");},[e]);let w=useMemo(()=>{let x=[];return r.forEach(_=>{_.chains.forEach(T=>{x.push({token:_,chain:T});});}),x},[r]),d=useMemo(()=>{let x=[],_=new Set,T=(C,I,W,z)=>{let F=`${C}-${I}:${W}`;if(_.has(F))return;let P=r.find(E=>E.symbol===C);if(!P)return;let j=P.chains.find(E=>E.chain_type===I&&E.chain_id===W);j&&(_.add(F),x.push({token:P,chain:j,isRecent:z}));};return h.forEach(C=>{T(C.symbol,C.chainType,C.chainId,true);}),um.forEach(C=>{T(C.symbol,C.chainType,C.chainId,false);}),x},[r,h]),k=useMemo(()=>{if(!g.trim())return w;let x=g.toLowerCase();return w.filter(({token:_,chain:T})=>_.symbol.toLowerCase().includes(x)||_.name.toLowerCase().includes(x)||T.chain_name.toLowerCase().includes(x))},[w,g]),b=(x,_,T)=>um.some(C=>C.symbol===x&&C.chainType===_&&C.chainId===T),m=async(x,_)=>{let T=`${_.chain_type}:${_.chain_id}`;if(!b(x.symbol,_.chain_type,_.chain_id)){await $g({symbol:x.symbol,chainType:_.chain_type,chainId:_.chain_id});let C=await kl();y(C);}S(""),a(x.symbol,T),t();},f=async(x,_)=>{let T=await qg({symbol:x.symbol,chainType:_.chain_type,chainId:_.chain_id});y(T);};return jsxs(ft,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:false,heightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:dt.header,children:[jsx(View,{style:dt.headerSpacer}),jsx(Text,{style:[dt.headerTitle,{color:c.header.titleColor,fontFamily:p.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:dt.closeButton,children:jsx(at,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:dt.searchContainer,children:jsx(TextInput,{style:[dt.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:p.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:g,onChangeText:S,autoCapitalize:"none",autoCorrect:false})}),d.length>0&&!g&&jsxs(View,{style:dt.quickSelectSection,children:[jsx(Text,{style:[dt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:p.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:dt.quickSelectScroll,children:d.map(({token:x,chain:_,isRecent:T})=>{let C=`${_.chain_type}:${_.chain_id}`;x.symbol===o&&C===n;return jsxs(View,{children:[T&&jsx(TouchableOpacity$1,{onPress:()=>f(x,_),style:dt.removeButton,children:jsx(at,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>m(x,_),activeOpacity:.7,style:[dt.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:dt.tokenIconContainer,children:[jsx(Image,{source:{uri:Z(be(x,"png"))},style:dt.quickSelectIcon}),jsx(Image,{source:{uri:Z(be(_,"png"))},style:[dt.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:dt.quickSelectText,children:[jsx(Text,{style:[dt.quickSelectSymbol,{color:c.card.titleColor,fontFamily:p.medium}],children:x.symbol}),jsx(Text,{style:[dt.quickSelectChain,{color:c.card.subtitleColor,fontFamily:p.regular}],children:_.chain_name})]})]})]},`quick-${x.symbol}-${C}`)})})]}),jsx(Text,{style:[dt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:p.regular}],children:"All supported tokens"}),jsx(ScrollView,{style:dt.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:dt.tokenListContent,children:k.length===0?jsx(View,{style:dt.emptyState,children:jsx(Text,{style:[dt.emptyText,{color:l.foregroundMuted,fontFamily:p.regular}],children:"No tokens found"})}):k.map(({token:x,chain:_})=>{let T=`${_.chain_type}:${_.chain_id}`,C=x.symbol===o&&T===n;return jsxs(TouchableOpacity$1,{onPress:()=>m(x,_),activeOpacity:.7,style:[dt.tokenItem,{backgroundColor:C?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:dt.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:Z(be(x,"png"))},style:dt.tokenIcon}),jsx(Image,{source:{uri:Z(be(_,"png"))},style:[dt.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:dt.tokenInfo,children:[jsx(Text,{style:[dt.tokenSymbol,{color:c.card.titleColor,fontFamily:p.medium}],children:x.symbol}),jsx(Text,{style:[dt.tokenChainName,{color:c.card.subtitleColor,fontFamily:p.regular}],children:_.chain_name})]}),jsxs(Text,{style:[dt.minDeposit,{color:c.card.labelColor,fontFamily:p.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:p.regular},children:["$",_.minimum_deposit_amount_usd]})]})]},`${x.symbol}-${T}`)})})]})}var dt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:24,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var Tl=(e,t)=>`${t}:${e}`,Jg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function xd({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:p,depositConfirmationMode:c="auto_ui",onExecutionsChange:g,onDepositSuccess:S,onDepositError:h,wallets:y,borderTopLeftRadius:w,borderTopRightRadius:d,sheetBorderRadius:k}){let{colors:b,fonts:m,components:f}=V(),x=s&&l?`${s}:${l}`:"solana:mainnet",[_,T]=useState("USDC"),[C,I]=useState(x),[W,z]=useState([]),[F,P]=useState(!y?.length),j=y?.length?y:W,[E,de]=useState([]),[He,Be]=useState(true),[K,ue]=useState(false),[ye,Te]=useState(false),[Ne,tt]=useState(false),[ie,se]=useState([]),[Ke,De]=useState(new Map),[rt]=useState(()=>new Date),[xe,Pe]=useState(null),[Ye,oe]=useState(false),[G,fe]=useState(null),[ot,A]=useState(false),B=new Map;E.forEach(he=>{he.chains.forEach(Ze=>{let $=`${Ze.chain_type}:${Ze.chain_id}`;B.has($)||B.set($,Ze);});});let te=Array.from(B.values()),pe=Jg(C),Ve=te.find(he=>he.chain_type===pe.chainType&&he.chain_id===pe.chainId),je=Ve?.chain_type||"ethereum",yt=Ho(j,je),nt=yt?.address||"",$e=useRef(false);useEffect(()=>{async function he(){try{Be(!0),Pe(null);let $=await qn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(de($.data),$.data.length>0&&!$e.current){$e.current=!0;let re,Se;if(s&&l)if(p)for(let me of $.data){let ne=me.chains.find(O=>O.chain_type===s&&O.chain_id===l&&O.token_address.toLowerCase()===p.toLowerCase());if(ne){re=me,Se=ne;break}}else for(let me of $.data){let ne=me.chains.find(O=>O.chain_type===s&&O.chain_id===l);if(ne){re=me,Se=ne;break}}if(!re&&a)for(let me of $.data){let ne=me.chains.find(O=>O.token_address.toLowerCase()===a.toLowerCase());if(ne){re=me,Se=ne;break}}re||(re=$.data.find(me=>me.symbol==="USDC"),re&&re.chains.length>0&&(Se=re.chains[0])),re||(re=$.data.find(me=>me.symbol==="USDT"),re&&re.chains.length>0&&(Se=re.chains[0])),re||(re=$.data[0],re.chains.length>0&&(Se=re.chains[0])),re&&T(re.symbol),Se&&I(Tl(Se.chain_id,Se.chain_type));}}catch(Ze){console.error("Error fetching supported tokens:",Ze),Pe("Failed to load supported tokens"),h?.({message:"Failed to load supported tokens",error:Ze});}finally{Be(false);}}he();},[t,a,n,o,s,l,p,h]),useEffect(()=>{g&&g(ie);},[ie,g]),useEffect(()=>{if(y?.length){P(false);return}if(W.length>0){P(false);return}let he=null,Ze=false,$=async()=>{if(!Ze){P(true);try{let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);Ze||(z(re.data),Pe(null),P(!1));}catch(re){console.error("Error fetching wallets, retrying in 5s:",re),Ze||(Pe(re instanceof Error?re.message:"Failed to load wallets"),P(false),he=setTimeout($,5e3));}}};return $(),()=>{Ze=true,he&&clearTimeout(he);}},[e,r,o,n,a,t,y,W.length]);let Ut=yt?.id??"",{showWaitingUi:Je,handleIveDeposited:ir}=Js({depositConfirmationMode:c,depositAddress:nt,chain:C,externalUserId:e,publishableKey:t,modalOpenedAt:rt,depositWalletId:Ut,depositExecutions:ie,trackedExecutions:Ke,setDepositExecutions:se,setTrackedExecutions:De,setLatestExecution:fe,setShowStatusSheet:oe,onDepositSuccess:S,onExecutionsChange:g,onDepositError:h});useEffect(()=>{if(!E.length)return;let he=E.find($=>$.symbol===_);if(!he||he.chains.length===0)return;if(!he.chains.some($=>Tl($.chain_id,$.chain_type)===C)){let $=he.chains[0];I(Tl($.chain_id,$.chain_type));}},[_,E,C]);let We=E.find(he=>he.symbol===_),pt=(We?.chains||[]).find(he=>Tl(he.chain_id,he.chain_type)===C),Or=async()=>{if(nt)try{Clipboard.setString(nt),ue(!0),setTimeout(()=>ue(!1),2e3);}catch(he){console.error("Failed to copy:",he);}},Cr=pt?.estimated_price_impact_percent??0,ce=pt?.max_slippage_percent??.25,it=pt?.minimum_deposit_amount_usd??3;return He?jsxs(View,{style:U.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:b.primary}),jsx(Text,{style:[U.loadingText,{color:b.foregroundMuted,fontFamily:m.regular}],children:"Loading currencies..."})]}):xe&&E.length===0?jsxs(View,{style:U.errorContainer,children:[jsx(Text,{style:[U.errorText,{color:b.error,fontFamily:m.regular}],children:xe}),jsx(Text,{style:[U.errorHint,{color:b.foregroundMuted,fontFamily:m.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:U.container,children:[jsxs(View,{style:U.selectorSection,children:[jsx(Text,{style:[U.selectorLabel,{color:f.card.labelColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>tt(true),disabled:He||E.length===0,style:[U.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:He?jsxs(View,{style:U.tokenSelectorLoading,children:[jsx(View,{style:[U.loadingIcon,{backgroundColor:b.cardHover}]}),jsxs(View,{style:U.loadingTextContainer,children:[jsx(View,{style:[U.loadingLine,{backgroundColor:b.cardHover,width:60}]}),jsx(View,{style:[U.loadingLine,{backgroundColor:b.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:U.tokenIconWrapper,children:[We&&jsx(Image,{source:{uri:Z(be(We,"png"))},style:U.tokenMainIcon}),(pt||Ve)&&jsx(Image,{source:{uri:Z(be(pt||Ve,"png"))},style:[U.tokenChainBadge,{borderColor:f.card.backgroundColor,borderRadius:f.badge.borderRadius}]})]}),jsxs(View,{style:U.tokenSelectorInfo,children:[jsx(Text,{style:[U.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:m.semibold}],children:We?.symbol||_}),jsx(Text,{style:[U.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:m.regular}],numberOfLines:1,children:pt?.chain_name||Ve?.chain_name||"Select network"})]}),jsxs(View,{style:U.tokenSelectorRight,children:[jsxs(Text,{style:[U.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:m.medium}],children:["$",it," min"]}),jsx(Vr,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Td,{visible:Ne,onClose:()=>tt(false),tokens:E,selectedToken:_,selectedChainKey:C,onSelect:(he,Ze)=>{T(he),I(Ze);},borderTopLeftRadius:k?.tokenSelector?.borderTopLeftRadius??w,borderTopRightRadius:k?.tokenSelector?.borderTopRightRadius??d}),jsx(View,{style:U.qrContainer,children:jsx(View,{style:[U.qrWrapper,{backgroundColor:b.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:F?jsxs(View,{style:U.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[U.loadingText,{color:b.foregroundMuted,fontFamily:m.regular}],children:"Loading..."})]}):nt?jsx(ss,{value:nt,size:180,logoUri:Z(be(pt,"png")||Nt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:U.qrLoading,children:jsx(Text,{style:[U.errorText,{color:b.error,fontFamily:m.regular}],children:"No address available"})})})}),jsxs(View,{style:U.addressSection,children:[jsxs(View,{style:U.addressHeader,children:[jsx(Text,{style:[U.addressLabel,{color:f.card.labelColor,fontFamily:m.medium}],children:"Deposit Address"}),K&&jsxs(View,{style:U.copiedIndicator,children:[jsx(qe,{size:14,color:b.success,strokeWidth:2}),jsx(Text,{style:[U.copiedText,{color:b.success,fontFamily:m.regular}],children:"Copied"})]})]}),jsxs(Yt,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!F&&nt?Or:void 0,contentStyle:U.addressBox,children:[jsx(Text,{style:[U.addressText,{color:f.card.titleColor,fontFamily:m.regular}],numberOfLines:2,children:F?"Loading...":nt||"No address available"}),jsx(View,{style:U.addressCopyIcon,children:jsx(jn,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[U.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Te(!ye),style:U.detailsHeader,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yo,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:U.chevronContainer,children:ye?jsx(Co,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),ye&&jsxs(View,{style:U.detailsContent,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:["Price impact: ",Cr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>A(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Pi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:["Slippage: Auto \u2022 ",ce.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>A(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Pi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(ua,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:m.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(sl,{depositConfirmationMode:c,depositAddress:nt,showWaitingUi:Je,latestExecution:G,onIveDeposited:ir}),jsx(TouchableOpacity$1,{style:U.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[U.termsText,{color:b.primary,fontFamily:m.regular}],children:"Terms apply"})}),jsxs(ft,{visible:ot,onClose:()=>A(false),closeOnBackdropPress:true,showHandle:true,borderTopLeftRadius:k?.infoSheet?.borderTopLeftRadius??w,borderTopRightRadius:k?.infoSheet?.borderTopRightRadius??d,children:[jsxs(View,{style:[U.sheetHeader,{borderBottomColor:b.border}],children:[jsx(View,{style:U.sheetHeaderSpacer}),jsx(Text,{style:[U.sheetTitle,{color:f.header.titleColor,fontFamily:m.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>A(false),style:U.sheetCloseButton,children:jsx(at,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:U.infoSheetContent,children:[jsxs(View,{style:[U.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:f.card.titleColor,fontFamily:m.medium}],children:"Price Impact"}),jsxs(Text,{style:[U.infoCardValue,{color:f.card.titleColor,fontFamily:m.medium}],children:[Cr.toFixed(2),"%"]})]}),jsx(Text,{style:[U.infoCardDescription,{color:f.card.descriptionColor,fontFamily:m.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[U.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:f.card.titleColor,fontFamily:m.medium}],children:"Max Slippage"}),jsxs(Text,{style:[U.infoCardValue,{color:f.card.titleColor,fontFamily:m.medium}],children:[ce.toFixed(2),"%"]})]}),jsx(Text,{style:[U.infoCardDescription,{color:f.card.descriptionColor,fontFamily:m.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),G&&jsx(as,{visible:Ye,status:G.status,tokenIconUrl:G.destination_token_metadata?.icon_urls?.find(he=>he.format==="png")?.url||G.destination_token_metadata?.icon_url||be(We,"png"),explorerUrl:G.explorer_url,completionExplorerUrl:G.destination_explorer_url,date:G.created_at?new Date(G.created_at):void 0,amountUsd:G.source_amount_usd?parseFloat(G.source_amount_usd):void 0,onClose:()=>oe(false),borderTopLeftRadius:k?.depositStatus?.borderTopLeftRadius??w,borderTopRightRadius:k?.depositStatus?.borderTopRightRadius??d})]})}var U=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var nn={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},stripeLinkPay:{title:"Pay with Stripe Link",subtitle:"Apple Pay or Card"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function oy(){let{colors:e,components:t}=V(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[r]);let a=({rightIcons:i=2})=>jsxs(View,{style:[Un.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[Un.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:Un.textBlock,children:[jsx(Animated.View,{style:[Un.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[Un.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:Un.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[Un.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:Un.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var Un=StyleSheet.create({container:{paddingTop:8,paddingBottom:24,gap:8},card:{marginHorizontal:16,flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:12,gap:12},leftIcon:{width:36,height:36},textBlock:{flex:1,gap:6},titleBar:{height:12,width:"70%",borderRadius:6},subtitleBar:{height:10,width:"50%",borderRadius:5},rightIcons:{flexDirection:"row",alignItems:"center",gap:4},rightIcon:{width:20,height:20,borderRadius:10}});function ny({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,defaultChainType:c,defaultChainId:g,defaultTokenAddress:S,showBalance:h=false,hideDepositTracker:y=false,enableStripeLinkPay:w=false,StripeOnrampComponent:d,stripeOnrampEmail:k,stripeOnrampPhone:b,stripeMerchantIdentifier:m,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:x,stripeTheme:_,depositConfirmationMode:T="auto_ui",transferInputVariant:C="double_input",initialScreen:I="main",onDepositSuccess:W,onDepositError:z,sheetBorderRadius:F}){let P=F?.globalBorderTopLeftRadius,j=F?.globalBorderTopRightRadius,{colors:E,fonts:de}=V(),[He,Be]=useState([]),[K,ue]=useState(null),[ye,Te]=useState("amount"),Ne=I==="tracker"&&!y?"tracker":I==="transfer"?"transfer":I==="card"?"card":"main",tt=Ne==="main",[ie,se]=useState(Ne),{isAllowed:Ke,isLoading:De}=ta(o,e);useEffect(()=>{if(!e||K)return;let je=false;return Ts(o).then(async yt=>{if(je)return;let nt=[];for(let $e of yt?.transfer_crypto?.networks??[]){let Ut=$e.icon_urls.find(Je=>Je.format==="png")?.url||$e.icon_urls.find(Je=>Je.format==="svg")?.url;Ut&&nt.push(Z(Ut));}for(let $e of yt?.payment_networks?.networks??[]){let Ut=$e.icon_urls.find(Je=>Je.format==="png")?.url||$e.icon_urls.find(Je=>Je.format==="svg")?.url;Ut&&nt.push(Z(Ut));}nt.length>0&&await Kc(nt),je||ue(yt);}).catch(console.error),()=>{je=true;}},[e,K,o]);let rt=()=>{t();};useEffect(()=>{e&&(se(Ne),Te("amount"));},[e,Ne]);let xe=useCallback(()=>{tt?(se("main"),Te("amount")):rt();},[tt,rt]),Pe=He.filter(je=>je.status==="pending"||je.status==="waiting").length,oe=!!(i&&s&&l&&p&&o)&&h!==false&&!!K,G=De||e&&!K,fe=Ke===false,ot=null;if(ie==="stripe"&&d){let je=jsx(d,{publishableKey:o,email:k,phone:b,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,merchantIdentifier:m,paymentSelectorPosition:f,skipSuccessConfirmation:x,onClose:xe});ot=_?jsx(Oi,{..._,children:je}):je;}let A=ie==="stripe"?1:ie==="transfer"||ie==="card"?.9:ie==="tracker"?.6:void 0,te={main:F?.main,transfer:F?.transferCrypto,card:F?.buyWithCard,stripe:{borderTopLeftRadius:0,borderTopRightRadius:0},tracker:F?.depositsTracker}[ie],pe=te?.borderTopLeftRadius??P,Ve=te?.borderTopRightRadius??j;return jsxs(ft,{visible:e,onClose:ie==="main"?rt:xe,closeOnBackdropPress:false,showHandle:false,heightPercent:A,borderTopLeftRadius:pe,borderTopRightRadius:Ve,children:[ie==="main"&&jsxs(Fragment,{children:[jsx(Tr,{title:n,showBack:false,onClose:rt,showBalance:oe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:p,publishableKey:o,projectName:K?.project_name}),G&&jsx(oy,{}),!G&&fe&&jsxs(View,{style:br.centeredContainer,children:[jsx(View,{style:[br.iconContainer,{backgroundColor:E.cardHover}],children:jsx(ws,{size:32,color:E.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:E.foreground,fontFamily:de.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:E.foreground,opacity:.7,fontFamily:de.regular}],children:"There are no supported tokens available from your current location."})]}),!G&&!fe&&jsxs(View,{style:br.optionsContainer,children:[jsx($s,{onPress:()=>se("transfer"),title:nn.transferCrypto.title,subtitle:nn.transferCrypto.subtitle,featuredTokens:K?.transfer_crypto?.networks}),jsx(Qs,{onPress:()=>se("card"),title:nn.depositWithCard.title,subtitle:nn.depositWithCard.subtitle,paymentNetworks:K?.payment_networks?.networks}),w&&d&&jsx(Ys,{onPress:()=>se("stripe"),title:nn.stripeLinkPay.title,subtitle:nn.stripeLinkPay.subtitle}),!y&&jsx(Ks,{onPress:()=>se("tracker"),title:nn.depositTracker.title,subtitle:nn.depositTracker.subtitle,badge:Pe>0?Pe:void 0})]})]}),ie==="transfer"&&jsxs(Fragment,{children:[jsx(Tr,{title:nn.transferCrypto.title,showBack:false,onClose:xe,showBalance:oe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:p,publishableKey:o,projectName:K?.project_name}),De&&jsx(View,{style:[br.centeredContainer,br.centeredFlex],children:jsx(ActivityIndicator,{color:E.foreground})}),!De&&fe&&jsxs(View,{style:[br.centeredContainer,br.centeredFlex],children:[jsx(View,{style:[br.iconContainer,{backgroundColor:E.cardHover}],children:jsx(ws,{size:32,color:E.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:E.foreground,fontFamily:de.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:E.foreground,opacity:.7,fontFamily:de.regular}],children:"There are no supported tokens available from your current location."})]}),!De&&!fe&&jsx(ScrollView,{style:br.transferScrollContainer,contentContainerStyle:br.scrollContent,showsVerticalScrollIndicator:false,children:C==="single_input"?jsx(xd,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:g,defaultTokenAddress:S,depositConfirmationMode:T,onExecutionsChange:Be,onDepositSuccess:W,onDepositError:z,borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{tokenSelector:F?.tokenSelector,infoSheet:F?.infoSheet,depositStatus:F?.depositStatus}}):jsx(ll,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:g,defaultTokenAddress:S,depositConfirmationMode:T,onExecutionsChange:Be,onDepositSuccess:W,onDepositError:z,borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{tokenSelector:F?.tokenSelector,chainSelector:F?.chainSelector,infoSheet:F?.infoSheet,depositStatus:F?.depositStatus}})})]}),ie==="card"&&jsxs(Fragment,{children:[jsx(Tr,{title:`Deposit ${a||"USDC"}`,showBack:ye==="onramp",onBack:()=>Te("amount"),onClose:xe,showBalance:oe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:p,publishableKey:o,projectName:K?.project_name}),jsx(View,{style:br.buyWithCardContainer,children:jsx(fl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,onDepositSuccess:W,onDepositError:z,view:ye,onViewChange:je=>Te(je),borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{providerModal:F?.providerModal,webView:F?.webView,currencyModal:F?.currencyModal}})})]}),ie==="stripe"&&ot&&jsx(View,{style:br.stripeLinkPayContainer,children:ot}),ie==="tracker"&&jsx(Cd,{active:ie==="tracker",onClose:xe,executions:He,externalUserId:r,publishableKey:o})]})}function Rl({theme:e="auto",...t}){return jsx(ny,{...t})}var br=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},stripeLinkPayContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},centeredFlex:{flex:1},iconContainer:{width:64,height:64,borderRadius:32,alignItems:"center",justifyContent:"center",marginBottom:16},blockedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},blockedDescription:{fontSize:14,textAlign:"center",maxWidth:280,lineHeight:20}});function Il(e,t=true){return Yo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>ka(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Id(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Yo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await qn(a),p=null,c=null,g=null,S=null,h,y,w,d=l.data.some(k=>k.chains.some(b=>{let m=b.chain_type===t&&b.chain_id===r&&b.token_address.toLowerCase()===o.toLowerCase();return m&&(p=b.minimum_deposit_amount_usd,c=b.estimated_processing_time,g=b.max_slippage_percent,S=b.estimated_price_impact_percent,w=b.chain_name,y=k),m}));if(y){let k=be(y,"png");k&&(h=Z(k));}return {isSupported:d,minimumAmountUsd:p,estimatedProcessingTime:c,maxSlippagePercent:g,priceImpactPercent:S,errorMessage:d?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:h,chainName:w}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function vd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Yo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await Sa(t,r,o,n,a);if(l.balance){let p=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",g=l.balance.amount,S=BigInt(g),h=BigInt(10**p),y=S/h,d=(S%h).toString().padStart(p,"0").replace(/0+$/,""),k=d?`${y}.${d}`:y.toString();return {balanceBaseUnit:g,balanceHuman:k,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:p,symbol:c}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:i&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var sy=2500,ay=3e3,ly=6e4;function Pd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,p]=useState(false),c=useRef(new Date),g=useRef(new Map),S=useRef(false),h=useRef(n),y=useRef(a);return useEffect(()=>{h.current=n;},[n]),useEffect(()=>{y.current=a;},[a]),useEffect(()=>{o&&!S.current&&(c.current=new Date,g.current.clear()),o||g.current.clear(),S.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let w=c.current,d=async()=>{try{let b=await No(e,t,"withdraw"),m=new Date(w.getTime()-ly),f=[...b.data].sort((C,I)=>{let W=C.created_at?new Date(C.created_at).getTime():0;return (I.created_at?new Date(I.created_at).getTime():0)-W}),x=["pending","waiting","delayed"],_=["succeeded","failed"],T=null;for(let C of f){let I=C.created_at?new Date(C.created_at):null;if(!I||I<m)continue;let W=g.current.get(C.id);if(!W){T=C;break}if(x.includes(W)&&_.includes(C.status)){T=C;break}}if(T){let C=T,I=C.created_at?new Date(C.created_at):null;if(!I||I<c.current)return;let W=g.current.get(C.id);g.current.set(C.id,C.status),s(z=>{let F=z.findIndex(P=>P.id===C.id);if(F>=0){let P=[...z];return P[F]=C,P}return [...z,C]}),C.status==="succeeded"&&(!W||x.includes(W))?h.current?.({message:"Withdrawal completed successfully",transaction:C}):C.status==="failed"&&W!=="failed"&&y.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:C});}}catch(b){console.error("Failed to fetch withdraw executions:",b),y.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:b});}};d();let k=setInterval(d,sy);return p(true),()=>{clearInterval(k),p(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let w=async()=>{try{await oc({deposit_wallet_id:r},t);}catch{}};w();let d=setInterval(w,ay);return ()=>clearInterval(d)},[o,r,t]),{executions:i,isPolling:l}}var Od=(e,t)=>`${t}:${e}`;function na({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:a=false,tokenLabel:i="Receive token",chainLabel:s="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:p,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:g}){let{colors:S,fonts:h,components:y}=V(),[w,d]=useState(false),[k,b]=useState(false),m=y.card,f=t?e.find(C=>C.symbol===t):void 0,x=f?.chains||[],_=r?x.find(C=>Od(C.chain_id,C.chain_type)===r):void 0,T={backgroundColor:m.backgroundColor,borderRadius:m.borderRadius,borderWidth:m.borderWidth||1,borderColor:m.borderColor};return jsxs(View,{style:Qe.row,children:[jsxs(View,{style:Qe.col,children:[jsx(Text,{style:[Qe.label,{color:m.labelColor,fontFamily:h.medium}],children:i}),jsxs(TouchableOpacity,{style:[Qe.selectButton,T],onPress:()=>!a&&e.length>0&&d(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Qe.placeholder,{color:m.subtitleColor,fontFamily:h.regular}],children:"Loading..."}):f?jsxs(View,{style:Qe.selectedItem,children:[jsx(Image,{source:{uri:Z(be(f,"png"))},style:Qe.icon}),jsx(Text,{style:[Qe.selectedText,{color:m.titleColor,fontFamily:h.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Qe.placeholder,{color:m.subtitleColor,fontFamily:h.regular}],children:"Select receive token"}),jsx(Pt,{size:16,color:m.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Qe.col,children:[jsx(Text,{style:[Qe.label,{color:m.labelColor,fontFamily:h.medium}],children:s}),jsxs(TouchableOpacity,{style:[Qe.selectButton,T,(!f||x.length===0)&&Qe.disabled],onPress:()=>!a&&f&&x.length>0&&b(true),activeOpacity:.7,disabled:a||!f||x.length===0,children:[_?jsxs(View,{style:Qe.selectedItem,children:[jsx(Image,{source:{uri:Z(be(_,"png"))},style:Qe.icon}),jsx(Text,{style:[Qe.selectedText,{color:m.titleColor,fontFamily:h.medium}],numberOfLines:1,children:_.chain_name})]}):jsx(Text,{style:[Qe.placeholder,{color:m.subtitleColor,fontFamily:h.regular}],children:"Chain"}),jsx(Pt,{size:16,color:m.actionColor,strokeWidth:2})]})]}),jsxs(ft,{visible:w,onClose:()=>d(false),closeOnBackdropPress:true,showHandle:false,heightPercent:.6,borderTopLeftRadius:l,borderTopRightRadius:p,children:[jsxs(View,{style:Qe.pickerHeader,children:[jsx(View,{style:Qe.pickerHeaderSpacer}),jsx(Text,{style:[Qe.pickerTitle,{color:S.foreground,fontFamily:h.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Qe.pickerHeaderClose,onPress:()=>d(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(FlatList,{data:e,keyExtractor:C=>C.symbol,contentContainerStyle:Qe.listContent,renderItem:({item:C})=>jsxs(TouchableOpacity,{style:[Qe.pickerItem,{backgroundColor:C.symbol===t?S.cardHover:"transparent"}],onPress:()=>{o(C.symbol),d(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:Z(be(C,"png"))},style:Qe.pickerIcon}),jsx(Text,{style:[Qe.pickerItemText,{color:S.foreground,fontFamily:h.medium}],children:C.symbol}),jsx(Text,{style:[Qe.pickerItemSub,{color:S.foregroundMuted,fontFamily:h.regular}],children:C.name}),C.symbol===t&&jsx(qe,{size:18,color:S.primary,strokeWidth:2.5})]})})]}),jsxs(ft,{visible:k,onClose:()=>b(false),closeOnBackdropPress:true,showHandle:false,heightPercent:.6,borderTopLeftRadius:c,borderTopRightRadius:g,children:[jsxs(View,{style:Qe.pickerHeader,children:[jsx(View,{style:Qe.pickerHeaderSpacer}),jsx(Text,{style:[Qe.pickerTitle,{color:S.foreground,fontFamily:h.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Qe.pickerHeaderClose,onPress:()=>b(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(FlatList,{data:x,keyExtractor:C=>Od(C.chain_id,C.chain_type),contentContainerStyle:Qe.listContent,renderItem:({item:C})=>{let I=Od(C.chain_id,C.chain_type);return jsxs(TouchableOpacity,{style:[Qe.pickerItem,{backgroundColor:I===r?S.cardHover:"transparent"}],onPress:()=>{n(I),b(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:Z(be(C,"png"))},style:Qe.pickerIcon}),jsx(Text,{style:[Qe.pickerItemText,{color:S.foreground,fontFamily:h.medium}],children:C.chain_name}),I===r&&jsx(qe,{size:18,color:S.primary,strokeWidth:2.5})]})}})]})]})}var Qe=StyleSheet.create({row:{flexDirection:"column",gap:10},col:{},label:{fontSize:12,marginBottom:6},selectButton:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:12,gap:6,minHeight:48},selectedItem:{flex:1,flexDirection:"row",alignItems:"center",gap:6},icon:{width:20,height:20,borderRadius:10},selectedText:{fontSize:13,flexShrink:1},placeholder:{flex:1,fontSize:13},disabled:{opacity:.4},pickerHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:16,paddingBottom:12},pickerHeaderSpacer:{width:28},pickerHeaderClose:{width:28,alignItems:"flex-end"},pickerTitle:{flex:1,fontSize:16,textAlign:"center"},listContent:{paddingHorizontal:16,paddingVertical:8},pickerItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:12,borderRadius:10,gap:10},pickerIcon:{width:32,height:32,borderRadius:16},pickerItemText:{fontSize:15,flex:1},pickerItemSub:{fontSize:13}});function Fd(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:a,enabled:i=true}=e,s=n?.trim()||"",l=!!t&&!!r&&!!o&&s.length>0;return Yo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>rc({chain_type:t,chain_id:r,token_address:o,recipient_address:s},a),enabled:i&&l,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function py(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function my(e,t){if(e<=0)return "0";if(t===0)return BigInt(Math.round(e)).toString();let r=e.toFixed(t),[o,n=""]=r.split("."),a=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(a)).toString()}function fy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Ol({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:p,balanceData:c,isLoadingBalance:g,minimumWithdrawAmountUsd:S,estimatedProcessingTime:h,maxSlippagePercent:y,priceImpactPercent:w,canWithdraw:d,onDepositWalletCreation:k,onWithdraw:b,onWithdrawError:m,onWithdrawSubmitted:f,onViewTracker:x}){let _="https://unifold.io/terms",T="https://unifold.io/support",{colors:C,fonts:I,components:W}=V(),[z,F]=useState(s||""),[P,j]=useState(""),[E,de]=useState("crypto"),[He,Be]=useState(false),[K,ue]=useState(null),[ye,Te]=useState(false),[Ne,tt]=useState(""),ie=useRef(null);useEffect(()=>{F(s||""),j(""),de("crypto"),ue(null);},[s]);let se=z.trim();useEffect(()=>{let ce=setTimeout(()=>tt(se),500);return ()=>clearTimeout(ce)},[se]);let {data:Ke,isLoading:De,error:rt}=Fd({chainType:p?.chain_type,chainId:p?.chain_id,tokenAddress:p?.token_address,recipientAddress:Ne,publishableKey:e,enabled:Ne.length>5&&!!p}),xe=se!==Ne,Pe=useMemo(()=>!se||se.length<=5||xe||De?null:rt?"Invalid address":Ke&&!Ke.valid?Ke.failure_code==="account_not_found"?`Account not found on ${p?.chain_name}`:Ke.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${p?.chain_name}`:"Invalid address":null,[se,xe,De,rt,Ke,p,l]),Ye=!xe&&!!Ke?.valid&&!Pe,oe=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),G=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),fe=useMemo(()=>c?.balanceUsd?parseFloat(c.balanceUsd):0,[c]),ot=n||c?.symbol||"TOKEN",A=c?.decimals??6,B=useMemo(()=>{let ce=parseFloat(P);return !ce||ce<=0?0:E==="crypto"?ce:oe>0?ce/oe:0},[P,E,oe]),te=useMemo(()=>{let ce=parseFloat(P);return !ce||ce<=0?0:E==="fiat"?ce:ce*oe},[P,E,oe]);useMemo(()=>!P||parseFloat(P)<=0?null:E==="crypto"?`$${te.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`:`${B.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})} ${ot}`,[P,E,te,B,ot]);useMemo(()=>g||!c?null:E==="crypto"?`${G.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})} ${ot}`:`$${fe.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`,[g,c,E,G,fe,ot]);let je=useCallback(async()=>{try{let it=await zm("expo-clipboard").getStringAsync();it&&(F(it.trim()),ue(null));}catch{}},[]),yt=useCallback(()=>{let ce=parseFloat(P);if(!ce||ce<=0||oe<=0){de(it=>it==="crypto"?"fiat":"crypto"),j("");return}E==="crypto"?(j((ce*oe).toFixed(2)),de("fiat")):(j((ce/oe).toFixed(A>6?6:A)),de("crypto"));},[P,E,oe,A]),nt=useCallback(()=>{if(E==="crypto"){if(G<=0)return;j(c?.balanceHuman??"0");}else {if(fe<=0)return;j((Math.floor(fe*100)/100).toFixed(2));}},[E,G,fe,c]),$e=S!==null&&te>0&&te<S,Ut=E==="crypto"?B>0&&G>0&&B>G:te>0&&fe>0&&te>fe,Je=se.length>0&&P.trim().length>0&&B>0&&Ye&&!$e&&!Ut&&!!c,ir=useCallback(async()=>{if(!(!l||!p||!Je||!d)){Be(true),ue(null);try{let ce=await k({destinationChainType:p.chain_type,destinationChainId:p.chain_id,destinationTokenAddress:p.token_address,recipientAddress:se}),it=my(B,A),he=fy(B,A),Ze={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:ot,sourceTokenIconUrl:i,destinationChainType:p.chain_type,destinationChainId:p.chain_id,destinationTokenAddress:p.token_address,destinationTokenSymbol:l.symbol,destinationChainName:p.chain_name,destinationTokenIconUrl:l?Z(be(l,"png")):void 0,amount:he,amountBaseUnit:it,submittedAt:new Date,withdrawIntentAddress:ce.address,recipientAddress:se};await b(Ze),f(Ze);}catch(ce){let it=ce instanceof Error?ce.message:"Withdrawal failed. Please try again.",he=it.length>120?"Withdrawal failed. Please try again.":it;ue(he),m?.({message:it,error:ce,code:"WITHDRAW_FAILED"});}finally{Be(false);}}},[l,p,Je,d,se,t,r,o,ot,i,P,E,G,fe,c,B,A,te,k,b,m,f]),We=W.input,st=W.card,pt=W.button,Or=Pe?C.error:We.borderColor,Cr=useMemo(()=>He?"Processing...":Ut?"Insufficient balance":$e?`Minimum $${S?.toFixed(2)}`:K?"Withdrawal failed \u2014 try again":"Withdraw",[He,Ut,$e,S,K]);return jsxs(View,{style:Ue.container,children:[jsxs(View,{children:[jsxs(View,{style:Ue.labelRow,children:[jsx(Text,{style:[Ue.label,{color:st.labelColor,fontFamily:I.medium}],children:"Recipient address"}),(xe||De)&&se.length>5?jsx(ActivityIndicator,{size:"small",color:C.foregroundMuted}):jsx(TouchableOpacity,{onPress:je,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(Nd,{size:16,color:C.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Ue.inputRow,{backgroundColor:We.backgroundColor,borderRadius:We.borderRadius,borderWidth:We.borderWidth,borderColor:Or}],children:jsx(TextInput,{style:[Ue.textInput,{color:We.textColor,fontFamily:I.regular}],placeholder:"Enter wallet address",placeholderTextColor:We.placeholderColor,value:z,onChangeText:ce=>{F(ce),ue(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>ie.current?.focus()})}),Pe?jsx(Text,{style:[Ue.errorText,{color:C.error,fontFamily:I.regular}],children:Pe}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Ue.label,{color:st.labelColor,fontFamily:I.medium,paddingBottom:8}],children:["Amount",S!=null&&S>0&&jsx(Text,{style:{color:C.warning,fontFamily:I.regular},children:` ($${S.toFixed(2)} min)`})]}),jsxs(View,{style:[Ue.amountRow,{backgroundColor:We.backgroundColor,borderRadius:We.borderRadius,borderWidth:We.borderWidth,borderColor:We.borderColor}],children:[jsx(TextInput,{ref:ie,style:[Ue.amountInput,{color:We.textColor,fontFamily:I.regular}],placeholder:"0.00",placeholderTextColor:We.placeholderColor,value:P,onChangeText:ce=>{(ce===""||/^\d*\.?\d*$/.test(ce))&&(j(ce),ue(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(TouchableOpacity,{onPress:oe>0?yt:void 0,activeOpacity:.7,children:jsx(Text,{style:[Ue.unitLabel,{color:C.foregroundMuted,fontFamily:I.medium}],children:E==="crypto"?ot:"USD"})}),jsx(TouchableOpacity,{style:[Ue.maxButton,{backgroundColor:`${C.primary}20`}],onPress:nt,activeOpacity:.7,children:jsx(Text,{style:[Ue.maxText,{color:C.primary,fontFamily:I.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Ue.detailsCard,{marginTop:24,backgroundColor:st.backgroundColor,borderRadius:st.borderRadius,borderWidth:st.borderWidth||1,borderColor:st.borderColor}],children:[jsx(TouchableOpacity,{style:Ue.detailsToggle,onPress:()=>Te(!ye),activeOpacity:.7,children:jsxs(View,{style:Ue.detailsRow,children:[jsx(View,{style:[Ue.detailIcon,{backgroundColor:st.iconBackgroundColor,borderRadius:st.iconContainerBorderRadius}],children:jsx(yo,{size:12,color:st.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ue.detailsLabel,{color:st.titleColor,fontFamily:I.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:I.medium},children:py(h)})]}),jsx(View,{style:{transform:[{rotate:ye?"180deg":"0deg"}]},children:jsx(Pt,{size:16,color:st.actionColor,strokeWidth:2})})]})}),ye&&jsxs(View,{style:Ue.detailsExpanded,children:[jsxs(View,{style:Ue.detailsRow,children:[jsx(View,{style:[Ue.detailIcon,{backgroundColor:st.iconBackgroundColor,borderRadius:st.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:st.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ue.detailsLabel,{color:st.titleColor,fontFamily:I.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:I.medium},children:["Auto \u2022 ",(y??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Ue.detailsRow,children:[jsx(View,{style:[Ue.detailIcon,{backgroundColor:st.iconBackgroundColor,borderRadius:st.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:st.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ue.detailsLabel,{color:st.titleColor,fontFamily:I.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:I.medium},children:[(w??0).toFixed(2),"%"]})]})]})]})]}),K&&jsx(Text,{style:[Ue.errorText,{color:C.error,fontFamily:I.regular,textAlign:"center"}],children:K}),jsxs(View,{style:Ue.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Ue.withdrawButton,{backgroundColor:pt.primaryBackground,borderRadius:pt.borderRadius,borderWidth:pt.borderWidth,borderColor:pt.borderColor,opacity:!Je||!d||He?.5:1}],onPress:ir,disabled:!Je||!d||He,activeOpacity:.8,children:[He&&jsx(ActivityIndicator,{size:"small",color:pt.primaryText}),jsx(Text,{style:[Ue.withdrawButtonText,{color:pt.primaryText,fontFamily:I.medium}],children:Cr})]}),jsxs(View,{style:Ue.footerRow,children:[jsxs(TouchableOpacity,{style:Ue.historyLink,onPress:x,activeOpacity:.7,children:[jsx(yo,{size:14,color:C.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Ue.historyText,{color:C.foregroundMuted,fontFamily:I.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Ue.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[Ue.legalText,{color:C.foregroundMuted,fontFamily:I.regular}],children:"Terms"})}),jsx(Text,{style:[Ue.legalSeparator,{color:C.foregroundMuted,fontFamily:I.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(T),activeOpacity:.7,children:jsx(Text,{style:[Ue.legalText,{color:C.foregroundMuted,fontFamily:I.regular}],children:"Help"})})]})]})]})]})}var Ue=StyleSheet.create({container:{gap:12,paddingHorizontal:16,paddingBottom:16},label:{fontSize:12},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:6},inputRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:4,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:4,minHeight:48,gap:8},amountInput:{flex:1,fontSize:14,paddingVertical:8},unitLabel:{fontSize:14,flexShrink:0},maxButton:{paddingHorizontal:8,paddingVertical:4,borderRadius:6},maxText:{fontSize:12,fontWeight:"600"},balanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginTop:6,paddingHorizontal:4},convertedText:{fontSize:12},balanceText:{fontSize:12},withdrawRow:{gap:12},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},historyLink:{flexDirection:"row",alignItems:"center",gap:6},historyText:{fontSize:13},legalLinks:{flexDirection:"row",alignItems:"center",gap:6},legalText:{fontSize:13},legalSeparator:{fontSize:13},detailsCard:{paddingHorizontal:12,overflow:"hidden"},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13,flex:1},detailsExpanded:{gap:10,paddingBottom:12},withdrawButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:15,gap:8},withdrawButtonText:{fontSize:16,fontWeight:"600"}});function yy(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 by(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Vl({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=V(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed",s=e.status==="failed"||e.status==="refunded",l=s?r.error:i?r.warning:r.success,p=Z(be(e.destination_token_metadata,"png")||Nt("/icons/tokens/png/usdc.png")),c=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",g=yy(e.created_at||new Date().toISOString()),S=by(e.source_amount_usd);return jsxs(Yt,{cardTokens:a,onPress:t,contentStyle:ln.container,children:[jsxs(View,{style:ln.iconContainer,children:[jsx(Image,{source:{uri:p},style:ln.tokenIcon}),jsx(View,{style:[ln.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Cs,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(pa,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(qe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:ln.textContainer,children:[jsx(Text,{style:[ln.title,{color:a.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[ln.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:g})]}),jsxs(View,{style:ln.rightContainer,children:[jsx(Text,{style:[ln.amount,{color:a.textRightColor,fontFamily:o.medium}],children:S}),jsx(Vr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var ln=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function Vd(e){try{let t=new Date(e),o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=t.getDate(),a=t.getFullYear(),i=t.getHours(),s=t.getMinutes(),l=i>=12?"PM":"AM";i=i%12||12;let p=s<10?`0${s}`:`${s}`;return `${o} ${n}, ${a} at ${i}:${p} ${l}`}catch{return e}}function Im(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function ky(e,t){if(e)try{return `$${Number(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}if(t)try{return `$${(Number(t)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}return "$0.00"}function vm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Pm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function ia({label:e,value:t,isLast:r}){let{fonts:o,components:n}=V(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Fe.detailRow,children:[jsx(Text,{style:[Fe.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Fe.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Fe.divider,{backgroundColor:a.borderColor}]})]})}function Bd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=V(),[p,c]=useState([]),[g,S]=useState(!!n),h=l.card,y=l.button,w=l.header,d=l.container;useEffect(()=>{tc().then(de=>c(de.data)).catch(()=>{});},[]),useEffect(()=>{S(!!n);},[e?.id]);let k=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,b=e?e.status==="failed"||e.status==="refunded":false,m=b?i.error:k?i.warning:i.success,f=b?"Failed":k?"Processing":"Completed",x=e?.destination_token_metadata?Z(be(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?Z(t.destinationTokenIconUrl):Z(Nt("/icons/tokens/png/usdc.png")),_=e?.created_at?Vd(e.created_at):t.submittedAt?Vd(t.submittedAt.toISOString()):Vd(new Date().toISOString()),T=e?`${Im(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${vm(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,C=e?`${Im(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${vm(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,I=e?ky(e.source_amount_usd,e.source_amount_base_unit):"$0.00",W=e?wa(p,e.source_chain_type,e.source_chain_id):t.sourceChainId,z=e?wa(p,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,F=e?.transaction_hash,P=e?.explorer_url,j=e?.destination_transaction_hashes?.[0],E=e?.destination_explorer_url;return jsxs(ScrollView,{style:Fe.scroll,contentContainerStyle:Fe.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Fe.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(vi,{size:22,color:w.buttonColor,strokeWidth:2})}):jsx(View,{style:Fe.headerSpacer}),jsx(Text,{style:[Fe.headerTitle,{color:w.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Fe.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:w.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Fe.iconContainer,children:[jsx(Image,{source:{uri:x},style:Fe.tokenIcon}),jsx(View,{style:[Fe.statusBadge,{backgroundColor:m}],children:b?jsx(Cs,{size:10,color:"#FFFFFF",strokeWidth:3}):k?jsx(View,{style:Fe.spinnerDot}):jsx(qe,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Fe.statusRow,children:[jsx(View,{style:[Fe.statusDot,{backgroundColor:m}]}),jsx(Text,{style:[Fe.statusText,{color:m,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Fe.dateText,{color:d.subtitleColor,fontFamily:s.regular}],children:_}),jsxs(View,{style:[Fe.detailsCard,{backgroundColor:h.backgroundColor,borderRadius:h.borderRadius,borderWidth:h.borderWidth??1,borderColor:h.borderColor}],children:[jsx(ia,{label:"Amount Sent",value:T}),jsx(ia,{label:"Amount Received",value:C}),jsx(ia,{label:"USD Value",value:I}),jsx(ia,{label:"Source Network",value:W}),jsx(ia,{label:"Destination Network",value:z,isLast:true})]}),jsxs(TouchableOpacity,{style:Fe.moreDetailsRow,onPress:()=>S(de=>!de),activeOpacity:.7,children:[jsx(Text,{style:[Fe.moreDetailsText,{color:d.actionTitle,fontFamily:s.regular}],children:g?"See less":n?"See more":"See more details"}),g?jsx(Co,{size:16,color:d.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:d.actionColor,strokeWidth:2})]}),g&&jsx(View,{style:[Fe.detailsCard,{backgroundColor:h.backgroundColor,borderRadius:h.borderRadius,borderWidth:h.borderWidth??1,borderColor:h.borderColor}],children:F&&P?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Fe.txRow,onPress:()=>Linking.openURL(P),activeOpacity:.7,children:[jsx(Text,{style:[Fe.txLabel,{color:h.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Fe.txHash,{color:h.titleColor,fontFamily:s.regular}],children:Pm(F)}),jsx(bo,{size:14,color:h.actionColor,strokeWidth:2})]}),!k&&j&&E&&jsxs(Fragment,{children:[jsx(View,{style:[Fe.divider,{backgroundColor:h.borderColor}]}),jsxs(TouchableOpacity,{style:Fe.txRow,onPress:()=>Linking.openURL(E),activeOpacity:.7,children:[jsx(Text,{style:[Fe.txLabel,{color:h.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Fe.txHash,{color:h.titleColor,fontFamily:s.regular}],children:Pm(j)}),jsx(bo,{size:14,color:h.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Fe.detailRow,children:jsx(Text,{style:[Fe.detailLabel,{color:h.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Fe.buttonRow,children:[jsx(TouchableOpacity,{style:[Fe.button,Fe.halfButton,{backgroundColor:y.secondaryBackground,borderRadius:y.borderRadius,borderWidth:y.borderWidth,borderColor:y.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Fe.buttonText,{color:y.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Fe.button,Fe.halfButton,{backgroundColor:y.primaryBackground,borderRadius:y.borderRadius,borderWidth:y.borderWidth,borderColor:y.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Fe.buttonText,{color:y.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Fe=StyleSheet.create({scroll:{flex:1},container:{alignItems:"center",paddingHorizontal:20,paddingTop:8,paddingBottom:32,gap:12},headerRow:{flexDirection:"row",alignItems:"center",width:"100%",paddingTop:16,marginBottom:4},headerSpacer:{width:28},headerTitle:{flex:1,fontSize:16,textAlign:"center"},iconContainer:{position:"relative",marginTop:8},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center"},spinnerDot:{width:10,height:10,borderRadius:5,borderWidth:2,borderColor:"#FFFFFF",borderTopColor:"transparent"},statusRow:{flexDirection:"row",alignItems:"center",gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:15},dateText:{fontSize:13,marginTop:-4},detailsCard:{width:"100%",paddingHorizontal:16,overflow:"hidden"},detailRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailLabel:{fontSize:13,flex:1},detailValue:{fontSize:13,flexShrink:0,maxWidth:"55%",textAlign:"right"},divider:{height:StyleSheet.hairlineWidth,opacity:.5},moreDetailsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingHorizontal:4},moreDetailsText:{fontSize:14},txRow:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:12},txLabel:{fontSize:13},txHash:{fontSize:13,flex:1,textAlign:"right"},buttonRow:{flexDirection:"row",gap:10,width:"100%",marginTop:4},button:{paddingVertical:14,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:14}});function Om(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Ll({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=V(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",p=s?.status==="failed",c={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:St.container,children:[jsx(TouchableOpacity,{style:St.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[St.iconRing,{backgroundColor:n.successBackground}],children:jsx(qe,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[St.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[St.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",Om(e.recipientAddress)]}),jsxs(View,{style:St.buttonRow,children:[jsx(TouchableOpacity,{style:[St.button,St.halfButton,c,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[St.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[St.button,St.halfButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[St.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):p?jsxs(View,{style:St.container,children:[jsx(TouchableOpacity,{style:St.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[St.iconRing,{backgroundColor:n.errorBackground}],children:jsx(at,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[St.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[St.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[St.button,St.fullButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[St.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:St.container,children:[jsx(TouchableOpacity,{style:St.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(Ct,{size:80,strokeWidth:4,iconSize:68,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:Z(e.sourceTokenIconUrl)},style:St.tokenIconFill}):jsx(View,{style:[St.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[St.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[St.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",Om(e.recipientAddress)]})]})}var St=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:48,paddingBottom:24},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconRing:{width:80,height:80,borderRadius:40,alignItems:"center",justifyContent:"center",marginBottom:20},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},title:{fontSize:20,marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,marginBottom:24},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,alignItems:"center",justifyContent:"center",borderRadius:12},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:15}});function Py(e){let t=e.source_token_metadata?.decimals??6,r=e.source_amount_base_unit??"0",o=Number(r)/Math.pow(10,t),n=o>=1?o.toFixed(2):o.toPrecision(4).replace(/\.?0+$/,"");return {sourceChainType:e.source_chain_type,sourceChainId:e.source_chain_id,sourceTokenAddress:e.source_token_address,sourceTokenSymbol:e.source_currency?.toUpperCase()??"",sourceTokenIconUrl:Z(be(e.source_token_metadata,"png")),destinationChainType:e.destination_chain_type,destinationChainId:e.destination_chain_id,destinationTokenAddress:e.destination_token_address,destinationTokenSymbol:e.destination_currency?.toUpperCase()??"",destinationTokenIconUrl:Z(be(e.destination_token_metadata,"png")),amount:n,amountBaseUnit:r,submittedAt:e.created_at?new Date(e.created_at):void 0,withdrawIntentAddress:e.deposit_wallet?.address??"",recipientAddress:e.recipient_address??""}}var Fm=(e,t)=>`${t}:${e}`;function Oy(){let{colors:e}=V(),t=useRef(new Animated.Value(.5)).current,r=e.cardHover;return useEffect(()=>{let o=Animated.loop(Animated.sequence([Animated.timing(t,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(t,{toValue:.5,duration:800,useNativeDriver:true})]));return o.start(),()=>o.stop()},[t]),jsx(View,{style:{gap:12,paddingHorizontal:16},children:[1,2,3].map(o=>jsx(Animated.View,{style:{height:48,borderRadius:12,backgroundColor:r,opacity:t}},o))})}function Al({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,modalTitle:i="Withdraw Crypto",onWithdraw:s,onWithdrawSuccess:l,onWithdrawError:p,heightPercent:c=.92,sheetBorderRadius:g,sourceChainType:S,sourceChainId:h,sourceTokenAddress:y,sourceTokenSymbol:w,sourceChainName:d,sourceTokenIconUrl:k}){let{colors:b,fonts:m}=V(),[f,x]=useState("form"),[_,T]=useState(S),[C,I]=useState(h),[W,z]=useState(y),[F,P]=useState(w),[j,E]=useState(d),[de,He]=useState(k),[Be,K]=useState(null),[ue,ye]=useState(null),[Te,Ne]=useState(null),[tt,ie]=useState(),[se,Ke]=useState([]),[De,rt]=useState(null),[xe,Pe]=useState("form"),Ye=useRef(new Animated.Value(Dimensions.get("window").width)).current,oe=useRef(null),G=!!_&&!!C&&!!W,{data:fe,isLoading:ot}=Il(r,e&&f==="form"),A=fe?.data??[],{data:B,isLoading:te}=Id({sourceChainType:_,sourceChainId:C,sourceTokenAddress:W,sourceTokenSymbol:F,publishableKey:r,enabled:e&&G&&f==="form"}),{data:pe,isLoading:Ve}=vd({address:n,chainType:_,chainId:C,tokenAddress:W,publishableKey:r,enabled:e&&G}),{executions:je}=Pd({userId:o,publishableKey:r,depositWalletId:tt,enabled:!!tt&&e,onWithdrawSuccess:l,onWithdrawError:p});useEffect(()=>{if(!e||f!=="tracker")return;let ne=false;return No(o,r,"withdraw").then(O=>{ne||Ke(O.data);}).catch(console.error),()=>{ne=true;}},[e,f,o,r]),useEffect(()=>{e&&(oe.current&&(clearTimeout(oe.current),oe.current=null),x("form"),T(S),I(h),z(y),P(w),E(d),He(k),K(null),ye(null),Ne(null),ie(void 0),Ke([]),rt(null),Pe("form"),Ye.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{oe.current&&clearTimeout(oe.current);},[]),useEffect(()=>{de||B?.iconUrl&&He(B.iconUrl);},[B?.iconUrl,de]),useEffect(()=>{j||B?.chainName&&E(B.chainName);},[B?.chainName,j]),useEffect(()=>{f==="confirming"&&je.length>0&&x("details");},[f,je]);let yt=useCallback(()=>{t(),oe.current=setTimeout(()=>{x("form"),T(S),I(h),z(y),P(w),E(d),He(k),K(null),ye(null),Ne(null),ie(void 0),Ke([]),rt(null),Pe("form"),oe.current=null;},300);},[t,S,h,y,w,d,k]),nt=useCallback(ne=>{let O=A.find(bt=>bt.symbol===ne);O&&(K(O),O.chains.length>0&&ye(O.chains[0]));},[A]),$e=useCallback(ne=>{if(!Be)return;let O=Be.chains.find(bt=>Fm(bt.chain_id,bt.chain_type)===ne);O&&ye(O);},[Be]),Ut=useCallback(async ne=>{let O=await Uo({external_user_id:o,destination_chain_type:ne.destinationChainType,destination_chain_id:ne.destinationChainId,destination_token_address:ne.destinationTokenAddress,recipient_address:ne.recipientAddress,action_type:"withdraw"},r),bt=Ho(O.data,_??"");if(!bt)throw new Error(`No deposit wallet found for chain type: ${_}`);return ie(bt.id),{id:bt.id,address:bt.address}},[o,r,_]),Je=useCallback(ne=>{Ne(ne),x("confirming");},[]),ir=useCallback(ne=>{rt(ne),Ye.setValue(Dimensions.get("window").width),Animated.timing(Ye,{toValue:0,duration:280,useNativeDriver:true}).start();},[Ye]),We=useCallback(()=>{Animated.timing(Ye,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>rt(null));},[Ye]),st=ot||te,pt=B?.isSupported??null,Or=f==="confirming"?"Withdrawal Status":i,Cr=g?.globalBorderTopLeftRadius,ce=g?.globalBorderTopRightRadius,it=g?.main?.borderTopLeftRadius??Cr,he=g?.main?.borderTopRightRadius??ce,Ze=g?.tokenSelector?.borderTopLeftRadius??Cr,$=g?.tokenSelector?.borderTopRightRadius??ce,re=g?.chainSelector?.borderTopLeftRadius??Cr,Se=g?.chainSelector?.borderTopRightRadius??ce,me=(()=>{if(f!=="form"||!G||Ve||!pe)return;let ne=F||pe.symbol,O=pe.balanceUsd;if(O!=null){let un=`$${parseFloat(O).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return ne?`Balance: ${un} ${ne}`:`Balance: ${un}`}let bt=pe.balanceHuman;if(!(!bt||bt==="0"))return ne?`Balance: ${bt} ${ne}`:`Balance: ${bt}`})();return jsx(ft,{visible:e,onClose:yt,closeOnBackdropPress:false,showHandle:false,heightPercent:f==="confirming"?.3:f==="details"?.7:c,borderTopLeftRadius:it,borderTopRightRadius:he,children:f==="confirming"&&Te?jsx(Ll,{txInfo:Te,executions:je,onClose:yt,onViewTracker:()=>{Pe("confirming"),x("tracker");}}):f==="details"&&Te?jsx(Bd,{execution:je.length>0?je[je.length-1]:null,txInfo:Te,onClose:yt,onViewHistory:()=>{Pe("details"),x("tracker");},onHeaderClose:()=>x("form")}):f==="tracker"?jsxs(View,{style:Ao.trackerContainer,children:[jsx(Tr,{title:"Withdrawal History",onClose:()=>x(xe)}),se.length===0?jsx(View,{style:Ao.emptyState,children:jsx(Text,{style:[Ao.emptyText,{color:b.foregroundMuted,fontFamily:m.regular}],children:"No withdrawals to track yet"})}):jsx(FlatList,{data:se,keyExtractor:ne=>ne.id,contentContainerStyle:Ao.listContent,renderItem:({item:ne})=>jsx(Vl,{execution:ne,onPress:()=>ir(ne)})}),De&&jsx(Animated.View,{style:[Ao.historyDetailOverlay,{backgroundColor:b.background,transform:[{translateX:Ye}]}],children:jsx(Bd,{execution:De,txInfo:Py(De),onClose:yt,onBack:We,onViewHistory:We})})]}):jsxs(Fragment,{children:[jsx(Tr,{title:Or,subtitle:me,onClose:yt}),st?jsx(Oy,{}):pt===false?jsxs(View,{style:Ao.unsupportedContainer,children:[jsx(Text,{style:[Ao.unsupportedTitle,{color:b.foreground,fontFamily:m.medium}],children:"Unsupported Token"}),jsx(Text,{style:[Ao.unsupportedMessage,{color:b.foregroundMuted,fontFamily:m.regular}],children:B?.errorMessage})]}):jsx(Fy,{publishableKey:r,sourceChainType:_??"",sourceChainId:C??"",sourceTokenAddress:W??"",sourceTokenSymbol:F,sourceChainName:j,sourceTokenIconUrl:de,recipientAddressProp:a,destinationTokens:A,selectedToken:Be,selectedChain:ue,selectedChainKey:ue?Fm(ue.chain_id,ue.chain_type):null,onTokenChange:nt,onChainChange:$e,tokensLoading:ot,balanceData:pe??null,isLoadingBalance:Ve,sourceValidation:B??null,onDepositWalletCreation:Ut,onWithdraw:s,onWithdrawError:p,onWithdrawSubmitted:Je,onViewTracker:()=>{Pe("form"),x("tracker");},tokenSelectorLeft:Ze,tokenSelectorRight:$,chainSelectorLeft:re,chainSelectorRight:Se})]})})}function Fy({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:p,selectedChain:c,selectedChainKey:g,onTokenChange:S,onChainChange:h,tokensLoading:y,balanceData:w,isLoadingBalance:d,sourceValidation:k,onDepositWalletCreation:b,onWithdraw:m,onWithdrawError:f,onWithdrawSubmitted:x,onViewTracker:_,tokenSelectorLeft:T,tokenSelectorRight:C,chainSelectorLeft:I,chainSelectorRight:W}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(ScrollView,{style:{flex:1,paddingTop:16},contentContainerStyle:Ao.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:Ao.doubleInputWrapper,children:jsx(na,{tokens:l,selectedTokenSymbol:p?.symbol??null,selectedChainKey:g,onTokenChange:S,onChainChange:h,isLoading:y,tokenPickerBorderTopLeftRadius:T,tokenPickerBorderTopRightRadius:C,chainPickerBorderTopLeftRadius:I,chainPickerBorderTopRightRadius:W})}),jsx(Ol,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:p,selectedChain:c,balanceData:w,isLoadingBalance:d,minimumWithdrawAmountUsd:k?.minimumAmountUsd??null,estimatedProcessingTime:k?.estimatedProcessingTime??null,maxSlippagePercent:k?.maxSlippagePercent??null,priceImpactPercent:k?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:b,onWithdraw:m,onWithdrawError:f,onWithdrawSubmitted:x,onViewTracker:_})]})})}var Ao=StyleSheet.create({scrollContent:{paddingBottom:32},doubleInputWrapper:{paddingHorizontal:16,paddingBottom:12,paddingTop:4},listContent:{paddingHorizontal:16,paddingBottom:32,gap:8},trackerContainer:{flex:1,overflow:"hidden"},historyDetailOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},emptyState:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:48},emptyText:{fontSize:14},unsupportedContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24,paddingVertical:48},unsupportedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},unsupportedMessage:{fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280}});StyleSheet.create({container:{paddingHorizontal:16,paddingTop:16,paddingBottom:24,gap:16},fieldGroup:{gap:8},fieldLabel:{fontSize:12},walletCard:{paddingHorizontal:12,paddingVertical:12,minHeight:48,justifyContent:"center"},walletAddress:{fontSize:13},primaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginTop:4},primaryButtonText:{fontSize:16},secondaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center"},secondaryButtonText:{fontSize:16}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Lm=createContext(null);function Uy({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new Uc({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,p]=useState(false),[c,g]=useState(null),S=useColorScheme(),h=useRef(false);h.current||(ga({publishableKey:t}),h.current=true);let y=useMemo(()=>{let P=r?.appearance||"dark";return P==="auto"?S==="dark"?"dark":"light":P},[r?.appearance,S]);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.'),ga({publishableKey:t});},[t]),useEffect(()=>()=>{d.current&&clearTimeout(d.current),_.current&&clearTimeout(_.current);},[]);let w=useRef(null),d=useRef(null),k=useCallback(P=>{d.current&&(clearTimeout(d.current),d.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 j=new Promise((E,de)=>{w.current={resolve:E,reject:de};});return s(P),a(true),j},[]),b=useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),a(false),d.current=setTimeout(()=>{s(null),d.current=null;},200);},[]),m=useCallback(P=>{i?.onSuccess&&i.onSuccess(P),w.current&&(w.current.resolve(P),w.current=null);},[i]),f=useCallback(P=>{console.error("[UnifoldProvider] Deposit error:",P),i?.onError&&i.onError(P),w.current&&(w.current.reject(P),w.current=null);},[i]),x=useRef(null),_=useRef(null),T=useRef(void 0),C=useCallback(P=>{_.current&&(clearTimeout(_.current),_.current=null),x.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),x.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),x.current=null);let j=new Promise((E,de)=>{x.current={resolve:E,reject:de};});return T.current=P.onClose,g(P),p(true),j},[]),I=useCallback(()=>{x.current&&(x.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),x.current=null),T.current?.(),T.current=void 0,p(false),_.current=setTimeout(()=>{g(null),_.current=null;},200);},[]),W=useCallback(P=>{c?.onSuccess&&c.onSuccess(P),x.current&&(x.current.resolve(P),x.current=null);},[c]),z=useCallback(P=>{console.error("[UnifoldProvider] Withdraw error:",P),c?.onError&&c.onError(P),x.current&&(x.current.reject(P),x.current=null);},[c]),F=useMemo(()=>({publishableKey:t,beginDeposit:k,closeDeposit:b,beginWithdraw:C,closeWithdraw:I}),[t,k,b,C,I]);return jsx(jc,{client:o,children:jsx(Lm.Provider,{value:F,children:jsxs(Oi,{mode:y,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Rl,{visible:n,onClose:b,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:i.externalUserId,destinationChainType:i.destinationChainType,destinationChainId:i.destinationChainId,destinationTokenSymbol:i.destinationTokenSymbol,recipientAddress:i.recipientAddress,destinationTokenAddress:i.destinationTokenAddress,defaultChainType:i.defaultChainType,defaultChainId:i.defaultChainId,defaultTokenAddress:i.defaultTokenAddress,showBalance:i.showBalance,stripeOnrampEmail:i.stripeOnrampEmail,stripeOnrampPhone:i.stripeOnrampPhone,stripeTheme:{mode:y,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:i.depositConfirmationMode??"auto_ui",initialScreen:i.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?Hu():void 0,onDepositSuccess:m,onDepositError:f,theme:y,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Al,{visible:l,onClose:I,publishableKey:t,externalUserId:c.externalUserId,senderAddress:c.senderAddress,recipientAddress:c.recipientAddress,sourceChainType:c.sourceChainType,sourceChainId:c.sourceChainId,sourceTokenAddress:c.sourceTokenAddress,sourceTokenSymbol:c.sourceTokenSymbol,onWithdraw:c.withdraw,onWithdrawSuccess:W,onWithdrawError:z,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function Hy(){let e=useContext(Lm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
+ export{Pa as AmountScreen,ft as BottomSheet,Oa as KYCWizardScreen,za as OnrampScreen,Ua as StripeOnramp,zu as StripeOnrampPreconfigure,Uy as UnifoldProvider,be as getPreferredIcon,Va as getStripePublishableKey,ka as getSupportedDestinationTokens,Z as normalizeIconUrl,Ha as registerStripeOnramp,Qd as setDevApiUrl,Da as setStripeOnrampApiUrl,Fa as setStripeOnrampPublishableKey,ta as useAllowedCountry,Ba as useStripeOnramp,V as useTheme,Hy as useUnifold};