@unifold/connect-react-native 0.1.42 → 0.1.43

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 An from'react';import An__default,{createContext,useContext,useState,useRef,useCallback,useEffect,useMemo,useId,Fragment as Fragment$1}from'react';import {StyleSheet,ScrollView,useWindowDimensions,Platform,PanResponder,Modal,View,Pressable,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Image,Easing,Dimensions,Clipboard,Linking,FlatList}from'react-native';import Ut,{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 au,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Wc from'@react-native-async-storage/async-storage';import Gh from'expo-constants';import Fg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var tu=e=>{throw TypeError(e)};var tf=(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 ec=(e,t,r)=>t.has(e)||tu("Cannot "+r);var u=(e,t,r)=>(ec(e,t,"read from private field"),r?r.call(e):t.get(e)),ee=(e,t,r)=>t.has(e)?tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(ec(e,t,"write to private field"),t.set(e,r),r),Ae=(e,t,r)=>(ec(e,t,"access private method"),r);var Ts=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return u(e,t,o)}});var tc={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)"}},rc=tc;function ka(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function xs(e,t,r){let o=r?t?.[r]:void 0,n=(c,C,T)=>{let y=o?.[c]?.[C];if(y!==void 0)return y;let b=t?.[c]?.[C];return b!==void 0?b:T},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,m=(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:ka(a,i)},transferCrypto:{depositAddress:{card:ka(a,s)}},depositCard:{quoteProvider:{card:ka(a,l)}},depositTracker:{executionRow:{card:ka(a,m)}}}}function oc(e,t,r){let n={...tc[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var nc=createContext(null);function F(){let e=useContext(nc);if(!e){let t=rc.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:xs(t,void 0,"dark"),isDark:true}}return e}function kt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=F(),l=a??s.warning,m=i??"#FBBF24",c=useRef(new Animated.Value(0)).current,C=useId(),T=useMemo(()=>`circularProgressGrad_${C.replace(/[^a-zA-Z0-9_-]/g,"")}`,[C]),y=(e-t)/2,b=2*Math.PI*y,k=e/2,h=o??Math.max(0,Math.round(e-t*2-8)),p=(e-h)/2;useEffect(()=>{let d=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return d.start(),()=>d.stop()},[c]);let g=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:g}]},children:jsxs(Ut,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:T,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:m})]})}),jsx(Circle,{cx:k,cy:k,r:y,stroke:`url(#${T})`,strokeWidth:t,fill:"none",strokeDasharray:`${b*.75} ${b*.25}`,strokeLinecap:"round",rotation:-90,origin:`${k}, ${k}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:p+1.5,left:p,width:h,height:h},children:r}):null]})}function ac({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{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 Pi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 zr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 _s({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 st({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 Tr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{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 Fi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{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 Bt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{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 No({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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(Ut,{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 Rs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 lc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 ko({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 gn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 xa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 To({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{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 _a({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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(Ut,{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 yn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 Ra({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 Is({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 iu({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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 Di({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]),m=useMemo(()=>{let y=o?.[l];return oc(l,y,r)},[l,o,r]),c=useMemo(()=>xs(m,i,l),[m,i,l]),C=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]),T=useMemo(()=>({mode:l,colors:m,fonts:C,components:c,isDark:l==="dark"}),[l,m,C,c]);return jsx(nc.Provider,{value:T,children:e})}var Os={damping:28,stiffness:300,mass:.8},Df=80,Vf=500;function ft({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:a=true,heightPercent:i,maxHeightPercent:s,startExpanded:l=false,noPadding:m=false,borderTopLeftRadius:c=24,borderTopRightRadius:C=24}){let{colors:T}=F(),{height:y}=useWindowDimensions(),[b,k]=useState(false),h=useRef(e);h.current=e;let p=useRef(0),g=i!=null&&i>=1,d=g||m?0:Platform.OS==="ios"?34:24,f=s!=null&&i!=null&&s>i,_=i!=null?(f?s:i)*y:void 0,R=f?(s-i)*y:0,w=l?0:R,S=useSharedValue(y),x=useRef(null),W=useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),h.current||k(false);},[]);useEffect(()=>{e?(x.current&&(clearTimeout(x.current),x.current=null),k(true),S.value=withSpring(w,Os)):b&&(S.value=withTiming(y,{duration:250},q=>{q&&runOnJS(W)();}),x.current=setTimeout(()=>{x.current=null,W();},350));},[e]),useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]),useEffect(()=>{b&&e&&(S.value=withSpring(w,Os));},[w]);let D=useCallback(()=>{o&&t();},[o,t]),O=useMemo(()=>{if(!(!n&&!f))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{p.current=S.value;},onPanResponderMove:(q,ae)=>{if(Math.abs(ae.dy)<4)return;let Me=p.current+ae.dy;S.value=Math.max(0,Me);},onPanResponderRelease:(q,ae)=>{if(!(Math.abs(ae.dy)<4)){if(n&&(ae.dy>Df||ae.vy>Vf)){t();return}if(f){let Me=R/2,Oe=S.value<Me?0:R;S.value=withSpring(Oe,Os);}else S.value=withSpring(w,Os);}},onPanResponderTerminate:()=>{S.value=withSpring(w,Os);}}).panHandlers},[n,f,R,w,S,t]),P=useAnimatedStyle(()=>({transform:[{translateY:S.value}]})),j=useAnimatedStyle(()=>({opacity:interpolate(S.value,[0,y*.5,y],[.5,.25,0],Extrapolation.CLAMP)}));return b?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:Kn.root,pointerEvents:e?"auto":"none",children:[jsx(au.View,{style:[Kn.backdrop,j],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:D})}),jsxs(au.View,{style:[Kn.sheet,P,{height:_,backgroundColor:T.background,borderTopLeftRadius:g?0:c,borderTopRightRadius:g?0:C}],children:[jsxs(GestureHandlerRootView,{style:Kn.gestureRoot,children:[a&&jsx(View,{style:Kn.handleContainer,pointerEvents:"none",children:jsx(View,{style:[Kn.handle,{backgroundColor:T.foreground+"33"}]})}),r,d>0&&jsx(View,{style:{height:d}})]}),O&&jsx(View,{...O,style:Kn.dragOverlay})]})]})}):null}var Kn=StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject,backgroundColor:"#000"},sheet:{overflow:"hidden"},gestureRoot:{flex:1},handleContainer:{alignItems:"center",paddingTop:10,paddingBottom:4,zIndex:1},dragOverlay:{position:"absolute",top:0,left:0,right:0,height:40,zIndex:2},handle:{width:36,height:5,borderRadius:2.5}}),ht=An__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));ht.displayName="BottomSheetScrollView";function Vi(e){return jsx(FlatList,{...e})}var Lf="https://api.unifold.io",mc="__UnifoldDevApiBaseUrl__",xr="pk_test_123",Ia={};function Bf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[mc];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function er(){return Bf()??Lf}function va(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.'),xr=e.publishableKey;}e.defaultConfig&&(Ia=e.defaultConfig);}function cu(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[mc]=t:delete globalThis[mc];}function Ds(){return er()}function Pa(){return xr}function Ur(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 Gt(e){let t=e.startsWith("/")?e:`/${e}`;return `${er()}/api/public${t}`}function re(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,er()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${er()}${e}`:`${er()}/api/public${e}`:""}async function $o(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||Ia.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||Ia.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Ia.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||xr;Ur(n);let a=await fetch(`${er()}/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 qo(e,t){return e.find(r=>r.chain_type===t)}async function Qo(e,t,r){let o=t||xr;Ur(o);let n=await fetch(`${er()}/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 Fa(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/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 Se(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 Gn(e,t){let r=e||xr;Ur(r);let o=`${er()}/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 fc(e,t){let r=t||xr;Ur(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${er()}/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 Oa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function hc(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/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 gc(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/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 yc(e,t){let r=t||xr;Ur(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(`${er()}/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 bc(e){let t=e||xr;Ur(t);let r=await fetch(`${er()}/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 Li(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 Vs(e){let t=e||xr;Ur(t);let r=await fetch(`${er()}/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 Cc(){let e=await fetch(`${er()}/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 Da(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 Ls(){let e=await fetch(`${er()}/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 Va(e){let t=e||xr;Ur(t);let r=await fetch(`${er()}/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 wc(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/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 Sc(e,t){return Fa(e.deposit_wallet_id,t)}async function La(e,t,r,o,n){let a=n||xr;Ur(a);let i=await fetch(`${er()}/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 uu({size:e=28}){return jsx(Ut,{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 mu({size:e=28}){return jsxs(Ut,{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 gu({size:e=28}){return jsxs(Ut,{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 yu({size:e=28}){return jsxs(Ut,{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 bu({size:e=28}){return jsx(Ut,{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 Ba=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:uu},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:mu},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:gu},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:yu},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:bu}];function Aa(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Wa(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 Wi(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=Ba.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=Ba.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Yt({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:a}=F(),i=r==="back",s=i?jsx(Fi,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(st,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:bn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:i?"Back":"Close",children:s});return t?jsxs(View,{style:bn.headerWithTitle,children:[i?l:o??jsx(View,{style:bn.headerSide}),jsx(Text,{style:[bn.headerTitleText,{color:n.header.titleColor},...a.bold?[{fontFamily:a.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),i?jsx(View,{style:bn.headerSide}):l]}):jsxs(View,{style:i?bn.headerWithTitle:bn.header,children:[i?l:jsx(View,{style:bn.headerSpacer}),!i&&l]})}var Ea={paddingTop:8,paddingBottom:8},bn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ea},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ea},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 _r({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=F();return e?jsx(Text,{style:[Cu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[Cu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var Cu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function fo({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 Ic({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=F(),m=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},c=Aa(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:m,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx($e,{size:14,color:s.success,strokeWidth:2.5}):jsx(No,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Ma={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function Es({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=F(),a=e.toLowerCase(),i=Ma[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 za({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=F(),m=Gt(`/icons/currencies/png/${e.toLowerCase()}.png`),c=Wi(r);return jsxs(View,{style:[eo.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:eo.step,children:[jsx(Image,{source:{uri:m},style:eo.iconImage}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(Tr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:eo.step,children:[jsxs(View,{style:eo.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:eo.tokenIcon}):jsx(View,{style:[eo.tokenIcon,{backgroundColor:Ma[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[eo.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var eo=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 Ei(){let{colors:e,fonts:t,components:r}=F(),o=r.input,n=r.button,a=r.container,i=r.card,s=r.header;return useMemo(()=>{let l=i.borderRadius,m={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},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:12},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:56,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:8,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}:{}}},C={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}:{}}},T=Math.max(16,Math.min(l,22)),y={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:T,borderTopRightRadius:T,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:T,borderBottomRightRadius:T,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}:{}}},b={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"}},k={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:m,quote:C,pm:y,wallet:b,flow:k,amount:c}},[e,t,o,n,a,i,s])}var ku="",Tu;function Ua(e){ku=e;}function Ha(e){Tu=e;}function Dr(){let e=ku||Pa();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Vr(){return Tu??Ds()}async function Na(){let e=`${Vr()}/v1/public/onramps/headless/stripe/config`,t=Dr(),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 vc(e){let t=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Dr(),"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 xu(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e,...t&&{crypto_customer_id:t}})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function Pc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e,...t&&{crypto_customer_id:t}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.message??`Failed to refresh OAuth token: ${r.status}`);return o}async function _u(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(`${Vr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Dr(),"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 Ru(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Dr(),"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 ja(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"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 Iu(e){let t=`${Vr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e}}),o=await r.text();if(!r.ok)throw new Error(`Failed to list onramp sessions: ${r.status} ${o}`);return JSON.parse(o)}async function vu(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"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 Fc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"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 Pu(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(`${Vr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Dr(),"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 Oc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Dr(),"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 Fu(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(`${Vr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Dr(),"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 Cn(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 Ou(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Dr()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function lh({size:e=24}){let t=e,r=e*(471/750);return jsxs(Ut,{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 ch({size:e=24}){return jsx(Ut,{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 dh({size:e=24}){return jsx(Ut,{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 Vc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(lh,{size:t}):o.includes("mastercard")?jsx(ch,{size:t}):o.includes("amex")||o.includes("american express")?jsx(dh,{size:t}):jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75})}var mh=[50,100,500],fh=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Bu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hh(e){return e.card?`${Bu(e.card.brand)} ${Bu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Wu(e){if(!e)return "";let t=new Date(e*1e3);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true})}var Eu={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function Mu(e,t){switch(e){case "fulfillment_complete":return t.success;case "fulfillment_processing":case "requires_payment":return t.warning;case "rejected":return t.error;default:return t.foregroundMuted}}function gh({status:e,colors:t,fontFamily:r}){let o=Mu(e,t);return jsx(View,{style:{paddingHorizontal:8,paddingVertical:2,borderRadius:6,backgroundColor:o+"20"},children:jsx(Text,{style:{fontSize:11,color:o,fontFamily:r},children:Eu[e]??e})})}function yh({session:e,onBack:t}){let{colors:r,components:o,fonts:n}=F(),[a,i]=useState(false),s=()=>{Clipboard.setString(e.id),i(true),setTimeout(()=>i(false),2e3);},l=e.transaction_details,m=e.status!=="fulfillment_complete"&&e.status!=="rejected",c=Mu(e.status,r),C=l?.source_amount?`$${parseFloat(l.source_amount).toFixed(2)}`:"\u2014",T=l?.destination_amount?parseFloat(l.destination_amount).toFixed(2):"\u2014",y=(l?.destination_currency??"").toUpperCase(),b=e.destination_token_metadata,k=Cn(b?.icon_urls,b?.icon_url),h=Cn(b?.chain?.icon_urls,b?.chain?.icon_url),p=Wi(l?.destination_network??""),g=l?.wallet_address?Aa(l.wallet_address):null,d=l?.fees?.network_fee_amount?`$${parseFloat(l.fees.network_fee_amount).toFixed(2)}`:null,f=l?.fees?.transaction_fee_amount?`$${parseFloat(l.fees.transaction_fee_amount).toFixed(2)}`:null,_=e.payment_method?e.payment_method.replace(/_/g," ").replace(/\b\w/g,w=>w.toUpperCase()):null,R=[{label:"Amount",value:C},{label:"Received",value:`${T} ${y}`},..._?[{label:"Payment",value:_}]:[],{label:"Network",value:p},...g?[{label:"Wallet",value:g}]:[],...d?[{label:"Network Fee",value:d}]:[],...f?[{label:"Transaction Fee",value:f}]:[]];return jsxs(Fragment,{children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(Yt,{onPress:t,title:"Purchase Details",variant:"back"})}),jsxs(ht,{style:tr.scroll,contentContainerStyle:tr.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:tr.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(Es,{currency:y||"USD",tokenIconUrl:k,networkIconUrl:h,size:64}),jsx(View,{style:[tr.statusBadge,{backgroundColor:c,borderColor:o.card.backgroundColor??r.background}],children:m?jsx(zr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):e.status==="rejected"?jsx(st,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:tr.statusRow,children:[jsx(View,{style:[tr.statusDot,{backgroundColor:c}]}),jsx(Text,{style:[tr.statusText,{color:o.container.titleColor,fontFamily:n.semibold}],children:Eu[e.status]??e.status})]}),e.created?jsx(Text,{style:[tr.dateText,{color:o.container.subtitleColor,fontFamily:n.regular}],children:Wu(e.created)}):null]}),jsxs(View,{style:[tr.card,{backgroundColor:o.card.backgroundColor,borderRadius:o.card.borderRadius,borderWidth:o.card.borderWidth,borderColor:o.card.borderColor}],children:[jsxs(View,{style:tr.cardRow,children:[jsx(Text,{style:[tr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:"ID"}),jsxs(TouchableOpacity$1,{onPress:s,activeOpacity:.7,style:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},children:[jsx(Text,{style:[tr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium,fontSize:12}],numberOfLines:1,children:e.id.length>12?e.id.slice(0,12)+"\u2026":e.id}),a?jsx($e,{size:14,color:r.primary,strokeWidth:2}):jsx(No,{size:14,color:r.foregroundMuted,strokeWidth:2})]})]}),R.map((w,S)=>jsxs(An__default.Fragment,{children:[jsx(View,{style:[tr.cardDivider,{backgroundColor:r.border}]}),jsxs(View,{style:tr.cardRow,children:[jsx(Text,{style:[tr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:w.label}),jsx(Text,{style:[tr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium}],selectable:true,children:w.value})]})]},w.label))]}),l?.last_error?jsx(View,{style:[tr.card,{backgroundColor:r.errorBackground,borderRadius:o.card.borderRadius}],children:jsxs(View,{style:tr.cardRow,children:[jsx(Text,{style:[tr.cardLabel,{color:r.error,fontFamily:n.regular}],children:"Error"}),jsx(Text,{style:[tr.cardValue,{color:r.error,fontFamily:n.medium,flex:1,textAlign:"right"}],selectable:true,children:l.last_error})]})}):null]})]})}var tr=StyleSheet.create({scroll:{flex:1,paddingTop:8},scrollContent:{paddingHorizontal:24,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},statusBadge:{position:"absolute",bottom:-4,right:-4,width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center",borderWidth:2},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14,marginBottom:2},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"}});function bh({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,a=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:Mi.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[Mi.row,{backgroundColor:t.card,borderRadius:a,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:Mi.left,children:[jsx(Animated.View,{style:[Mi.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[Mi.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[Mi.badgeBar,{backgroundColor:n,opacity:o}]})]},s))})}var Mi=StyleSheet.create({list:{gap:8},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16},left:{flex:1,gap:6},amountBar:{height:16,width:"40%",borderRadius:8},subtitleBar:{height:12,width:"55%",borderRadius:6},badgeBar:{height:20,width:80,borderRadius:6,marginLeft:12}});function Qa({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:a="inline",onCollectPayment:i,paymentLoading:s=false,paymentStatus:l,paymentError:m,paymentTokens:c=[],onAddPaymentMethod:C,onConfirm:T,onCancel:y,sheetBorderTopLeftRadius:b,sheetBorderTopRightRadius:k,accessToken:h}){let p=Ei(),{colors:g,components:d,fonts:f}=F(),_=b??d.card.borderRadius,R=k??d.card.borderRadius,[w,S]=useState(e),[x,W]=useState(r?"apple_pay":c.length>0?c[0].id:null),D=useRef(false),O=U=>{D.current=true,W(U);};useEffect(()=>{D.current||r||c.length>0&&W(c[0].id);},[c,r]);let[P,j]=useState(false),[q,ae]=useState("select"),[Me,Oe]=useState(null),X=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&ae("card");},[s,l]);let De=x==="apple_pay",he=1e3,xe=De?he:n,Ue=xe!=null&&xe>0,we=useMemo(()=>{if(o)return [];let U=mh.map(Q=>({label:`$${Q}`,amount:String(Q),disabled:false}));return De?U.push({label:`$${he}`,amount:String(he),disabled:false}):U.push({label:"MAX",amount:Ue?String(xe):"0",disabled:!Ue}),U},[o,Ue,xe,De]),ne=U=>{if(U==="\u232B"){S(Q=>Q.slice(0,-1));return}if(U==="."){if(w.includes("."))return;S(Q=>Q===""?"0.":Q+".");return}S(Q=>{let se=Q.indexOf(".");return se!==-1&&Q.length-se>2?Q:Q==="0"&&U!=="."?U:Q+U});},Ie=w===""?"0":w,mt=parseFloat(w),Ve=w!==""&&!isNaN(mt)&&mt>0,lt=r||c.length>0,He=a==="header",Ne=useMemo(()=>{let U=[];r&&U.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let Q of c)U.push({id:Q.id,label:hh(Q),hint:Q.card?`Expires ${Q.card.exp_month}/${Q.card.exp_year}`:Q.type,brand:Q.card?.brand,isApplePay:false});return U},[r,c]),je=Ne.find(U=>U.id===x),J=x!=null&&x!=="apple_pay",ce=je?je.label:J&&Me?Me:J?"Card":"Pay With",nt=je?!je.isApplePay:J,it=je?.brand??Me??void 0,[ve,be]=useState(false),[ie,de]=useState([]),[Qt,ue]=useState(false),[le,Ce]=useState(null),[wt,tt]=useState(null),pe=useRef(null);pe.current=wt;let Qe=useRef(false);Qe.current=ve;let ir=useCallback(async(U=false)=>{if(h){U||(ue(true),Ce(null));try{let Q=await Iu(h);if(!Qe.current)return;let se=Array.isArray(Q.data)?Q.data:Array.isArray(Q)?Q:[];de(se),U||Ce(null);let ze=pe.current?.id;if(ze){let E=se.find(te=>te.id===ze);E&&tt(E);}}catch(Q){if(!Qe.current)return;U||Ce(Q?.message??"Failed to load history");}finally{!U&&Qe.current&&ue(false);}}},[h]),xt=useCallback(()=>{be(true),ir();},[ir]);useEffect(()=>{if(!ve||!h)return;let U=setInterval(()=>ir(true),15e3);return ()=>clearInterval(U)},[ve,h,ir]);let Pr=h?jsx(TouchableOpacity,{style:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},onPress:xt,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"History",children:jsx(zr,{size:20,color:g.foreground,strokeWidth:2})}):void 0,Fr=lt?jsx(TouchableOpacity,{style:[He?p.amount.paymentRowHeader:p.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(ae("select"),j(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:p.amount.paymentLeft,children:[je?.isApplePay?jsx(Text,{style:p.amount.applePayIcon,children:"\uF8FF"}):nt?jsx(Vc,{sublabel:it,size:20}):null,jsx(Text,{style:p.amount.paymentLabel,children:ce}),jsx(Bt,{size:12,color:p.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:p.form.screen,children:[jsx(Yt,{onPress:y,title:"Enter amount",leftAction:Pr}),He&&Fr,jsxs(View,{style:p.form.content,children:[jsxs(View,{style:p.amount.amountContainer,children:[jsxs(Text,{style:[p.amount.amountText,Ie==="0"&&p.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",Ie]}),jsx(Text,{style:p.amount.currencyLabel,children:t.toUpperCase()})]}),!He&&Fr,we.length>0&&jsx(View,{style:p.amount.quickRow,children:we.map(U=>{let Q=!U.disabled&&w===U.amount&&w!=="";return jsx(TouchableOpacity,{style:[p.amount.quickPill,Q&&{backgroundColor:g.primary},U.disabled&&{opacity:.4}],activeOpacity:.7,disabled:U.disabled||s,onPress:()=>S(U.amount),children:jsx(Text,{style:[p.amount.quickPillText,Q&&{color:g.primaryForeground}],children:U.label})},U.label)})}),jsx(View,{style:p.amount.numpad,children:fh.map((U,Q)=>jsx(View,{style:p.amount.numpadRow,children:U.map(se=>jsx(TouchableOpacity,{style:[p.amount.numpadKey,s&&{opacity:.3}],onPress:()=>ne(se),activeOpacity:.6,disabled:s,children:jsx(Text,{style:se==="\u232B"?p.amount.backspaceText:p.amount.numpadKeyText,children:se})},se))},Q))}),jsx(TouchableOpacity,{style:[p.form.continueBtn,(!Ve||s)&&p.form.continueBtnDisabled],onPress:()=>Ve&&!s&&T(w,x),disabled:!Ve||s,children:s?jsx(ActivityIndicator,{size:"small",color:g.primaryForeground}):jsx(Text,{style:[p.form.continueBtnText,!Ve&&p.form.continueBtnTextDisabled],children:"Continue"})}),!P&&m?jsx(Text,{style:p.amount.inlineError,children:m}):!P&&s&&l&&__DEV__?jsx(Text,{style:p.amount.inlineStatus,children:l}):null]}),jsx(ft,{visible:P,onClose:()=>{s||(j(false),ae("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:!s,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:_,borderTopRightRadius:R,children:jsx(View,{style:p.amount.sheetContent,children:q==="select"?jsxs(Fragment,{children:[jsxs(View,{style:p.amount.sheetTitleRow,children:[jsx(Text,{style:p.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>j(false),activeOpacity:.7,style:p.amount.sheetCloseBtn,children:jsx(st,{size:16,color:g.foregroundMuted,strokeWidth:2.5})})]}),jsxs(ht,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[Ne.map(U=>{let Q=x===U.id;return jsxs(TouchableOpacity$1,{style:[p.amount.sheetOption,Q&&{borderColor:g.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{O(U.id),Oe(U.isApplePay?null:U.label),j(false);},children:[jsxs(View,{style:p.amount.sheetOptionLeft,children:[jsx(View,{style:p.amount.sheetOptionIcon,children:U.isApplePay?jsx(Text,{style:p.amount.applePayIcon,children:"\uF8FF"}):jsx(Vc,{sublabel:U.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:p.amount.sheetOptionLabel,children:U.label}),jsx(Text,{style:p.amount.sheetOptionHint,children:U.hint})]})]}),Q&&jsx($e,{size:18,color:g.primary,strokeWidth:2.5})]},U.id)}),jsx(TouchableOpacity$1,{style:p.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!X.current){X.current=true;try{let U=await C?.();U&&(O(U.token),Oe(U.sublabel),j(!1));}finally{X.current=false;}}},children:jsx(Text,{style:p.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:p.amount.sheetHeader,children:[jsx(TouchableOpacity$1,{onPress:()=>{s||ae("select");},activeOpacity:.7,style:p.amount.sheetBackBtn,children:jsx(Fi,{size:20,color:g.foreground,strokeWidth:2})}),jsx(Text,{style:p.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:p.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),__DEV__?jsx(Text,{style:p.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):m?jsxs(Fragment,{children:[jsx(View,{style:p.amount.sheetError,children:jsx(Text,{style:p.amount.sheetErrorText,children:m})}),jsx(TouchableOpacity$1,{style:p.form.continueBtn,onPress:()=>{i&&Ve&&i(false,w);},children:jsx(Text,{style:p.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:p.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),__DEV__?jsx(Text,{style:p.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(ft,{visible:ve,onClose:()=>{be(false),tt(null);},closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:_,borderTopRightRadius:R,children:wt?jsx(yh,{session:wt,onBack:()=>tt(null)}):jsxs(View,{style:p.amount.sheetContent,children:[jsx(Yt,{onPress:()=>be(false),title:"Purchase History"}),Qt?jsx(bh,{}):le?jsx(View,{style:p.amount.sheetError,children:jsx(Text,{style:p.amount.sheetErrorText,children:le})}):ie.length===0?jsx(View,{style:p.amount.sheetLoading,children:jsx(Text,{style:[p.amount.sheetStatusText,{color:g.foregroundMuted}],children:"No purchases yet"})}):jsx(ht,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:ie.map(U=>{let Q=U.transaction_details,se=Q?.source_amount?`$${parseFloat(Q.source_amount).toFixed(2)}`:"\u2014",ze=(Q?.destination_currency??"").toUpperCase(),E=Q?.destination_amount?`${parseFloat(Q.destination_amount).toFixed(2)} ${ze}`:"",te=Wu(U.created),ye=U.destination_token_metadata,me=Cn(ye?.icon_urls,ye?.icon_url),gt=Cn(ye?.chain?.icon_urls,ye?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:p.amount.sheetOption,activeOpacity:.7,onPress:()=>tt(U),children:[jsx(Es,{currency:ze||"USD",tokenIconUrl:me,networkIconUrl:gt,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:p.amount.sheetOptionLabel,children:se}),E?jsx(Text,{style:p.amount.sheetOptionHint,children:E}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx(gh,{status:U.status,colors:g,fontFamily:f.regular}),te?jsx(Text,{style:{fontSize:11,color:g.foregroundMuted,fontFamily:f.regular},children:te}):null]}),jsx(Tr,{size:14,color:g.foregroundMuted,strokeWidth:2})]})]},U.id)})})]})})]})}var Us=4;function Ka({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Ei(),{colors:a,fonts:i,components:s}=F(),l=s.input.placeholderColor,[m,c]=useState(1),[C,T]=useState(e.firstName??""),[y,b]=useState(e.lastName??""),[k,h]=useState(e.dobMonth??""),[p,g]=useState(e.dobDay??""),[d,f]=useState(e.dobYear??""),[_,R]=useState(e.addressLine1??""),[w,S]=useState(e.addressLine2??""),[x,W]=useState(e.city??""),[D,O]=useState(e.state??""),[P,j]=useState(e.postalCode??""),[q,ae]=useState(e.country??"US"),[Me,Oe]=useState(e.idNumber??""),X=useRef(null),De=useRef(null),he=useRef(null),xe=useRef(null),Ue=useRef(null),we=useRef(null),ne=useRef(null),Ie=useRef(null),mt=()=>{switch(m){case 1:return C.trim().length>0&&y.trim().length>0;case 2:return k.length===2&&p.length===2&&d.length===4;case 3:return _.trim().length>0&&x.trim().length>0&&D.trim().length>0&&P.trim().length>0;case 4:return Me.trim().length>0;default:return false}},Ve=()=>{mt()&&(m<Us?c(Be=>Be+1):r({firstName:C,lastName:y,idNumber:Me,dobMonth:k,dobDay:p,dobYear:d,addressLine1:_,addressLine2:w,city:x,state:D,postalCode:P,country:q}));},lt=()=>{m>1?c(Be=>Be-1):o();},He=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Ne=["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."],je=[Ht.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:Ht.header,children:[jsx(View,{style:Ht.headerSide,children:jsx(TouchableOpacity,{style:Ht.iconButton,onPress:lt,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:m>1?"Back":"Cancel",children:jsx(_s,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Ht.headerCenter,children:jsxs(Text,{style:je,children:[m," of ",Us]})}),jsx(View,{style:Ht.headerSide,children:jsx(TouchableOpacity,{style:Ht.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Ht.progressTrack,children:Array.from({length:Us}).map((Be,J)=>jsx(View,{style:[Ht.progressSegment,{backgroundColor:J<m||J+1===m?a.primary:a.border}]},J))}),jsxs(ht,{style:n.form.flex,contentContainerStyle:Ht.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:He[m-1]}),jsx(Text,{style:n.form.subtitle,children:Ne[m-1]}),m===1&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:C,onChangeText:T,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>X.current?.focus()})}),jsx(Ko,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:X,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:y,onChangeText:b,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:Ve})})]}),m===2&&jsxs(View,{style:Ht.dobRow,children:[jsxs(View,{style:Ht.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Ht.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Ht.dobInput],placeholder:"MM",placeholderTextColor:l,value:k,onChangeText:Be=>{let J=Be.replace(/\D/g,"").slice(0,2);h(J),J.length===2&&De.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Ht.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Ht.dobLabel],children:"Day"}),jsx(TextInput,{ref:De,style:[n.form.input,Ht.dobInput],placeholder:"DD",placeholderTextColor:l,value:p,onChangeText:Be=>{let J=Be.replace(/\D/g,"").slice(0,2);g(J),J.length===2&&he.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Ht.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Ht.dobLabel],children:"Year"}),jsx(TextInput,{ref:he,style:[n.form.input,Ht.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:d,onChangeText:Be=>{let J=Be.replace(/\D/g,"").slice(0,4);f(J);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:Ve})]})]}),m===3&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:_,onChangeText:R,returnKeyType:"next",onSubmitEditing:()=>xe.current?.focus()})}),jsx(Ko,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:xe,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:w,onChangeText:S,returnKeyType:"next",onSubmitEditing:()=>Ue.current?.focus()})}),jsx(Ko,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ue,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:x,onChangeText:W,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>we.current?.focus()})}),jsxs(View,{style:Ht.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx(Ko,{form:n.form,label:"State",children:jsx(TextInput,{ref:we,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:D,onChangeText:Be=>O(Be.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>ne.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx(Ko,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:ne,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:P,onChangeText:j,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Ie.current?.focus()})})})]}),jsx(Ko,{form:n.form,label:"Country",children:jsx(TextInput,{ref:Ie,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:q,onChangeText:Be=>ae(Be.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:Ve})})]}),m===4&&jsxs(Ko,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:Me,onChangeText:Oe,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:Ve}),jsx(Text,{style:[n.form.hint,Ht.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&m===Us?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!mt()&&n.form.continueBtnDisabled],onPress:Ve,disabled:!mt(),children:jsx(Text,{style:[n.form.continueBtnText,!mt()&&n.form.continueBtnTextDisabled],children:m===Us?"Submit":"Continue"})})})]})})}function Ko({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Ht=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 Ec="@unifold/stripe_oauth";async function Uu(){try{let e=await Wc.getItem(Ec);return e?JSON.parse(e):null}catch{return null}}async function Mc(e){try{await Wc.setItem(Ec,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function Tn(){try{await Wc.removeItem(Ec);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Rh=5,_n=null,Hu={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Ga(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:m,registerWalletAddress:c,collectPaymentMethod:C,createCryptoPaymentToken:T}=useOnramp(),[y,b]=useState(r),[k,h]=useState(!!e?.externalUserId),[p,g]=useState(false),[d,f]=useState(""),[_,R]=useState(null),[w,S]=useState(e?.email??""),[x,W]=useState(e?.phone??""),[D,O]=useState(""),[P,j]=useState("US"),[q,ae]=useState(""),[Me,Oe]=useState(""),X=useRef(""),De=useRef(""),he=useRef(""),[xe,Ue]=useState(false),[we,ne]=useState(false),Ie=useRef(0),mt=useRef(false),Ve=useRef(false),lt=useRef(false),He=useRef(""),Ne=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),je=useRef(null),[Be,J]=useState(Hu),[ce,nt]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[it,ve]=useState(""),[be,ie]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[de,Qt]=useState(e?.defaultSourceAmount??"100"),[ue,le]=useState(e?.defaultSourceCurrency??"usd"),[Ce,wt]=useState(e?.defaultDestinationCurrency??"usdc"),[tt,pe]=useState(null),[Qe,ir]=useState(),[xt,Pr]=useState(),[Fr,U]=useState(false),Q=useRef(null),se=useRef(false),ze=useRef(0),E=useRef(e?.onComplete),te=useRef(e?.onError),ye=useRef(e?.onStepChange),me=useRef(r);useEffect(()=>{E.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{te.current=e?.onError;},[e?.onError]),useEffect(()=>{ye.current=e?.onStepChange;},[e?.onStepChange]);let gt=useRef(r);useEffect(()=>{y!==gt.current&&(ye.current?.(y,gt.current),gt.current=y),me.current=y;},[y]),useEffect(()=>{k&&y!==r&&h(false);},[k,y,r]);let V=useCallback((I,v,N)=>{let G={code:I,message:v,step:me.current,stripeErrorCode:N};R(G),f(""),te.current?.(G);},[]),Or=useCallback(I=>{let v={sessionId:I.id,status:I.status,sourceAmount:I.transaction_details.source_amount,sourceCurrency:I.transaction_details.source_currency,destinationAmount:I.transaction_details.destination_amount,destinationCurrency:I.transaction_details.destination_currency,destinationNetwork:I.transaction_details.destination_network,walletAddress:I.transaction_details.wallet_address,fees:{networkFee:I.transaction_details.fees.network_fee_amount,transactionFee:I.transaction_details.fees.transaction_fee_amount}};return E.current?.(v),v},[]),z=useCallback(()=>R(null),[]),Ft=I=>I.refresh_token??I.refresh?.refresh_token??"",St=useCallback((I,v,N,G,_e)=>{De.current=v,X.current=N,e?.externalUserId&&Mc({accessToken:v,refreshToken:N,customerId:I,externalUserId:e.externalUserId,email:_e||w,expiresAt:Date.now()+G*1e3});},[e?.externalUserId,w]),Mr=useCallback(async()=>{let I=X.current;if(!I)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let v=await Pc(I,he.current??void 0),N=v.access_token,G=Ft(v)||I;return Oe(N),St(he.current,N,G,v.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),N}catch(v){return console.error("[tryRefreshAccessToken] refresh failed:",v?.message),await Tn(),_n=null,De.current="",X.current="",he.current="",Oe(""),ae(""),null}},[St]),Xt=useCallback(async I=>{try{return await I(De.current)}catch(v){let N=v?.message??"";if(N.includes("stripe_onramp_forbidden")||N.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let G=await Mr();if(!G)throw V("authorization_error","Session expired. Please sign in again."),b("email"),v;return await I(G)}throw v}},[Mr,V]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){U(false);return}let v=false;return isPlatformPaySupported().then(N=>{v||U(N);}),()=>{v=true;}},[e?.merchantIdentifier]),useEffect(()=>(se.current=false,()=>{se.current=true,Q.current&&clearTimeout(Q.current);}),[]);let Ii=useRef(false);useEffect(()=>{if(Ii.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),Tn(),_n=null,h(false);return}let I=false;return (async()=>{try{let v=await Uu();if(I||!v){I||h(!1);return}if(v.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",v.externalUserId,"current:",e.externalUserId),await Tn(),_n=null,I||h(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",v.customerId);let N=Date.now()>=v.expiresAt,G=v.accessToken,_e=v.refreshToken;if(N){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Ke=await Pc(v.refreshToken,v.customerId);if(I)return;G=Ke.access_token,_e=Ke.refresh_token??Ke.refresh?.refresh_token??v.refreshToken,await Mc({accessToken:G,refreshToken:_e,customerId:v.customerId,externalUserId:e.externalUserId,email:v.email,expiresAt:Date.now()+(Ke.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Ke){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Ke?.message),await Tn(),_n=null,I||h(!1);return}}if(I)return;if(Ii.current=!0,ae(v.customerId),he.current=v.customerId,Oe(G),De.current=G,X.current=_e,v.email&&S(v.email),_n===v.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",v.customerId,"\u2014 skipping configure()"),je.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",v.customerId);let Ke=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});Ke.error?console.error("[useStripeOnramp] restore configureSDK error:",Ke.error.message):_n=v.customerId,je.current=Promise.resolve(Ke);}if(I)return;let yt=()=>new Promise(Ke=>{let yr=()=>{lt.current&&He.current?Ke():setTimeout(yr,200);};yr();});try{if(await Promise.race([yt(),new Promise((yr,Mt)=>setTimeout(()=>Mt(new Error("timeout")),1e4))]),I)return;let Ke=He.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Ke,"network:",Ne.current),await c(Ke,Ne.current);}catch(Ke){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Ke?.message);}if(I)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),b("session_params");}finally{I||h(false);}})(),()=>{I=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||xe||we)return;let I=false;ne(true);async function v(){try{let[N,G]=await Promise.all([Fu({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?Ou({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(zt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",zt?.message),null)):Promise.resolve(null)]);if(I)return;let _e=e?.destinationChainType??"ethereum",yt=N.data.find(zt=>zt.chain_type===_e);if(yt?.address){let zt=yt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",zt,"recipient:",yt.recipient_address),nt(zt),He.current=zt,yt.recipient_address&&ve(yt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",_e,"in",N.data?.length,"wallets");let Ke={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},yr={8453:"base",1:"ethereum",137:"polygon"},Mt=G?.destination_network,pr="none";if(Mt&&Ke[Mt])ie(Ke[Mt]),Ne.current=Ke[Mt],pr=Mt+" (from default_token API)";else if(e?.destinationChainId&&yr[e.destinationChainId]){let zt=yr[e.destinationChainId];Ke[zt]&&(ie(Ke[zt]),Ne.current=Ke[zt]),pr=zt+" (from chain_id "+e.destinationChainId+")";}else Ke[_e]&&(ie(Ke[_e]),Ne.current=Ke[_e],pr=_e+" (from chain_type fallback)");G?.destination_currency&&wt(G.destination_currency.toLowerCase());let ar=G?.destination_token_metadata,Jr=Cn(ar?.icon_urls,ar?.icon_url),Zr=Cn(ar?.chain?.icon_urls,ar?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",Jr,"network:",Zr),Jr&&ir(Jr),Zr&&Pr(Zr),Ue(!0),lt.current=!0;}catch(N){console.error("[useStripeOnramp] Failed to resolve wallet:",N?.message),Ue(true),lt.current=true;}finally{I||ne(false);}}return v(),()=>{I=true;}},[e?.publishableKey,e?.externalUserId]);let uo=useCallback(async()=>{if(je.current)return je.current;let I=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),je.current=null),v)).catch(v=>{throw console.error("[useStripeOnramp] configureSDK threw:",v?.message??v),je.current=null,v});return je.current=I,I},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||uo();},[]);let Ho=useCallback(async I=>{if(!mt.current){mt.current=true,g(true),z(),f("Creating auth intent...");try{let v=await vc(I);f("Waiting for authorization...");let N=await i(v);if(N?.error){console.log("[proceedToAuthorize] authorize error:",N.error.message),V("authorization_error","Something went wrong during authorization. Please try again."),b("email");return}if(N?.status==="Denied"){V("authorization_error","Authorization denied by user."),b("email");return}if(N?.status!=="Consented"||!N.customerId){V("authorization_error","Authorization was canceled."),b("email");return}f("Exchanging tokens...");let G=N.customerId,_e=await xu(v,G),yt=_e.access_token,Ke=Ft(_e);console.log("[useStripeOnramp] customerId:",G),console.log("[useStripeOnramp] accessToken acquired, length:",yt.length),ae(G),he.current=G,_n=G,Oe(yt),St(G,yt,Ke,_e.expires_in??3600),f("Checking verification status...");try{let yr=await ja(G,yt),Mt=yr.verifications.find(hn=>hn.name==="kyc_verified"),pr=yr.verifications.find(hn=>hn.name==="id_document_verified"),ar=Mt?.status==="verified",Jr=Mt?.status==="rejected",Zr=pr?.status==="verified",zt=yr.provided_fields.includes("first_name");if(f(""),Jr&&!zt)V("kyc_error","KYC was previously rejected. Please submit with correct info."),b("kyc");else if(Jr&&zt)b(Zr?"wallet":"identity");else if(!ar&&!zt)b("kyc");else if(!Zr)b("identity");else if(lt.current&&He.current)try{let hn=He.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",hn,"network:",be);let Sa=await c(hn,be);Sa?.error?(console.warn("[proceedToAuthorize] wallet registration error:",Sa.error.message),V("wallet_error",Sa.error.message,Sa.error.code),b("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),b("session_params"));}catch(hn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",hn?.message),b("wallet");}else b("wallet");}catch(yr){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",yr?.message),f(""),b("kyc");}}catch(v){V("authorization_error",v?.message??String(v)),b("email");}finally{mt.current=false,g(false);}}},[i,z,V,St,c,be]),K=useCallback(async()=>{if(Keyboard.dismiss(),!w){V("validation_error","Please enter an email address.");return}g(true),z(),f("");try{f("Configuring...");let I=await uo();if(I.error){V("configuration_error",I.error.message,I.error.code);return}f("Checking Link account...");let v=await n(w);if(v.error){V("authorization_error",v.error.message,v.error.code);return}v.hasLinkAccount?await Ho(w):(f(""),b("register"));}catch(I){V("unknown_error",I?.message??String(I));}finally{g(false);}},[z,uo,w,V,n,Ho]),ge=useCallback(async()=>{if(!x){V("validation_error","Please enter your phone number.");return}g(true),z(),f("");try{f("Creating Link account...");let I=await a({email:w,phone:x,fullName:D||w,country:P||"US"});if(I.error){V("registration_error",I.error.message,I.error.code);return}await Ho(w);}catch(I){V("registration_error",I?.message??String(I));}finally{g(false);}},[z,P,w,V,D,x,a,Ho]);useEffect(()=>{if(y!=="email"||!e?.email||k)return;let I=++Ie.current,v=false,N=()=>v||Ie.current!==I;return e?.phone?(async()=>{g(true),z();try{f("Configuring...");let G=await uo();if(N())return;if(G.error){V("configuration_error",G.error.message,G.error.code);return}f("Checking Link account...");let _e=await n(e.email);if(N())return;if(_e.error){V("authorization_error",_e.error.message,_e.error.code);return}if(_e.hasLinkAccount){if(N())return;await Ho(e.email);}else {f("Creating Link account...");let yt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(N())return;if(yt.error){V("registration_error",yt.error.message,yt.error.code);return}if(N())return;await Ho(e.email);}}catch(G){N()||V("unknown_error",G?.message??String(G));}finally{g(false);}})():(async()=>{g(true),z();try{f("Configuring...");let G=await uo();if(N())return;if(G.error){V("configuration_error",G.error.message,G.error.code);return}f("Checking Link account...");let _e=await n(e.email);if(N())return;if(_e.error){V("authorization_error",_e.error.message,_e.error.code);return}if(_e.hasLinkAccount){if(N())return;await Ho(e.email);}else {if(N())return;f(""),b("register");}}catch(G){N()||V("unknown_error",G?.message??String(G));}finally{g(false);}})(),()=>{v=true;}},[y,e?.email,e?.phone,k]);let Lt=useCallback(async I=>{g(true),z(),f(""),J(I);try{let v={firstName:I.firstName,lastName:I.lastName,idNumber:I.idNumber||void 0,dateOfBirth:{day:parseInt(I.dobDay,10),month:parseInt(I.dobMonth,10),year:parseInt(I.dobYear,10)},address:{line1:I.addressLine1,line2:I.addressLine2||void 0,city:I.city,state:I.state,postalCode:I.postalCode,country:I.country}},N=await s(v);if(N?.error){if(N.error.stripeErrorCode==="consumer_person_already_verified"){f(""),b("identity");return}V("kyc_error",N.error.message,N.error.stripeErrorCode??N.error.code),b("kyc");return}f("Please review your KYC information...");let G=await l(null);if(G?.error){V("kyc_error",G.error.message,G.error.stripeErrorCode??G.error.code),b("kyc");return}if(G?.status==="UpdateAddress"){V("kyc_error","Please update your address and resubmit."),b("kyc");return}f(""),b("identity");}catch(v){V("kyc_error",v?.message??String(v)),b("kyc");}finally{g(false);}},[s,z,V,l]),po=useCallback(async()=>{if(!Ve.current){Ve.current=true,g(true),z(),f("Launching identity verification...");try{let I=await m();if(I?.error){V("identity_error",I.error.message,I.error.code);return}f(""),b("wallet");}catch(I){V("identity_error",I?.message??String(I));}finally{Ve.current=false,g(false);}}},[z,V,m]);useEffect(()=>{y==="identity"&&!p&&po();},[y]);let ks=useCallback(async()=>{if(!ce){V("validation_error","Please enter a wallet address.");return}g(true),z(),f("");try{let I=ce.toLowerCase();console.log("[registerWallet] registering wallet:",I,"network:",be);let v=await c(I,be);if(v?.error){console.warn("[registerWallet] error:",v.error.message),V("wallet_error",v.error.message,v.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),b("session_params");}catch(I){V("wallet_error",I?.message??String(I));}finally{g(false);}},[z,V,ce,be,c]);useEffect(()=>{y==="wallet"&&xe&&ce&&ks();},[y,xe,ce]);let mo=useCallback(I=>{se.current=false,ze.current=0;let v=0,N=async()=>{v+=1;let G=De.current;try{let _e=await vu(I,G);if(console.log(`[pollSessionStatus] poll #${v} session=${I} status="${_e.status}"`),se.current)return;ze.current=0,_e.status==="fulfillment_complete"?(pe(_e),b("success")):Q.current=setTimeout(N,3e3);}catch(_e){if(se.current)return;let yt=_e?.message??"";if((yt.includes("stripe_onramp_forbidden")||yt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Mr()&&!se.current)){Q.current=setTimeout(N,1e3);return}if(ze.current+=1,console.error(`[pollSessionStatus] poll #${v} error:`,yt),ze.current>=Rh){V("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}Q.current=setTimeout(N,5e3);}};Q.current=setTimeout(N,3e3);},[V,Mr]),fn=useCallback(()=>{if(me.current==="processing"&&tt?.id){if(!De.current){V("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}z(),ze.current=0,Q.current&&(clearTimeout(Q.current),Q.current=null),mo(tt.id);}},[z,V,mo,tt?.id]),wa=useCallback(async I=>{g(true),z(),f("");try{f("Confirming purchase...");let v=await Xt(N=>Ru(I,N));console.log("[finalizeOnrampSession] confirmed session:",v.id,"status:",v.status),pe(v),b("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",v.id),mo(v.id);}finally{g(false);}},[z,mo,Xt]),Xl=useRef(false),Ym=useCallback(async()=>{if(!(!tt||Xl.current)){Xl.current=true;try{g(!0),z(),f("Refreshing quote...");let I=await Xt(v=>Fc(tt.id,v));pe(I),await wa(I.id);}catch(I){console.log("[confirmCheckout] error:",I?.message),V("session_error","Something went wrong. Please try again."),b("quote");}finally{g(false),Xl.current=false;}}},[z,V,wa,tt,Xt]),eu=useCallback(async()=>{let I=w;if(!I)return console.warn("[reauthorizeLink] no email available for re-authorization"),false;try{console.log("[reauthorizeLink] re-establishing Link session for:",I),f("Verifying identity...");let v=await vc(I),N=await i(v);return N?.status==="Consented"&&N.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",N.customerId),he.current=N.customerId,ae(N.customerId),_n=N.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",N?.status),!1)}catch(v){return console.warn("[reauthorizeLink] failed:",v?.message),false}},[i,w]),Jm=useCallback(async(I=false,v,N)=>{let G=v??de;if(console.log("[collectPaymentMethod] called:",{useApplePay:I,amt:G,amountOverride:v,sourceAmount:de,hasSavedToken:!!N}),!G||isNaN(Number(G))||Number(G)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),V("validation_error","Please enter a valid amount.");return}v&&Qt(v),g(true),z(),f("");try{let _e=await uo();if(_e.error){V("configuration_error",_e.error.message,_e.error.code);return}let yt;if(N)console.log("[collectPaymentMethod] using saved payment token"),yt=N;else if(I){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),V("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),b("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Mt={applePay:{merchantCountryCode:"US",currencyCode:ue.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${Ce.toUpperCase()} purchase + fees`,amount:G}]}},pr=await C("PlatformPay",Mt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!pr?.error),pr?.error){let Jr=pr.error.message??"",Zr=pr.error.code??"",zt=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",pr.error,"isCancellation:",zt),zt||(V("payment_error",Jr,Zr),b("session_params"));return}if(!pr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let ar=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),b("session_params");return}yt=ar.cryptoPaymentToken;}else {f("Select a payment method...");let Mt=await C("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Mt?.error),Mt?.error){let Jr=Mt.error.message??"",Zr=Mt.error.code??"",zt=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",Mt.error,"isCancellation:",zt),zt||(V("payment_error",Jr,Zr),b("session_params"));return}if(!Mt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let pr=Mt.displayData;console.log("[collectPaymentMethod] displayData:",{type:pr.type,label:pr.label,sublabel:pr.sublabel,hasIcon:!!pr.icon}),f("Creating payment token...");let ar=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),b("session_params");return}yt=ar.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",ce,"walletAddressRef:",He.current);let Ke=He.current||ce.toLowerCase(),yr=await Xt(Mt=>_u({cryptoCustomerId:he.current,paymentToken:yt,sourceAmount:Number(G),sourceCurrency:ue,destinationCurrency:Ce,walletAddress:Ke,destinationNetwork:be},Mt));console.log("[collectPaymentMethod] session created:",yr?.id,"useApplePay:",I),pe(yr),f(""),I?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await wa(yr.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):b("quote");}catch(_e){console.log("[collectPaymentMethod] error caught:",_e?.message),V("session_error","Something went wrong. Please try again."),b("session_params");}finally{g(false),f("");}},[z,uo,C,T,Ce,V,wa,Qt,de,ue,ce,be,Xt,e?.merchantIdentifier]),Zm=useCallback(async()=>{g(true),z(),f("Select a payment method...");try{let I=await uo();if(I.error)return V("configuration_error",I.error.message,I.error.code),null;let v=await C("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 eu())return V("authorization_error","Please verify your identity to add a payment method."),null;v=await C("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!v?.error);}if(v?.error){let _e=v.error.message??"",yt=v.error.code??"",Ke=/cancel/i.test(_e)||/cancel/i.test(yt);return console.log("[addPaymentMethod] pmResult error:",v.error,"isCancellation:",Ke),Ke||V("payment_error",_e,yt),null}if(!v?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let N=v.displayData;console.log("[addPaymentMethod] displayData:",{type:N.type,label:N.label,sublabel:N.sublabel,hasIcon:!!N.icon}),f("Saving payment method...");let G=await T();return console.log("[addPaymentMethod] tokenResult ok:",!G?.error),G?.error?(V("payment_error",G.error.message,G.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:G.cryptoPaymentToken,sublabel:N.sublabel??""})}catch(I){return console.log("[addPaymentMethod] error:",I?.message),V("session_error",I?.message??String(I)),null}finally{g(false),f("");}},[z,uo,C,T,V,eu]),Xm=useCallback(async()=>{if(tt){g(true),z(),f("");try{let I=await Xt(v=>Fc(tt.id,v));pe(I);}catch(I){console.log("[refreshQuote] error:",I?.message),V("session_error","Something went wrong. Please try again.");}finally{g(false);}}},[z,V,tt,Xt]),ef=useCallback(()=>{se.current=true,ze.current=0,Q.current&&(clearTimeout(Q.current),Q.current=null),b(r),g(false),f(""),R(null),S(e?.email??""),W(e?.phone??""),O(""),j("US"),ae(""),he.current="",Oe(""),De.current="",X.current="",Ue(false),ne(false),J(Hu),nt(e?.recipientAddress??""),He.current="",lt.current=false,ie(Onramp.CryptoNetwork.ethereum),Qt(e?.defaultSourceAmount??"100"),le(e?.defaultSourceCurrency??"usd"),wt(e?.defaultDestinationCurrency??"usdc"),ve(""),ir(void 0),Pr(void 0),pe(null),Ie.current+=1,mt.current=false,Ve.current=false;},[e,r]);return {step:y,restoring:k,loading:p,status:d,error:_,email:w,phone:x,fullName:D,country:P,customerId:q,accessToken:Me,session:tt,kycData:Be,walletAddress:ce,resolvedRecipientAddress:it,walletNetwork:be,sourceAmount:de,sourceCurrency:ue,destinationCurrency:Ce,tokenIconUrl:Qe,networkIconUrl:xt,applePaySupported:Fr,walletReady:xe,walletLoading:we,setStep:b,setStatus:f,setEmail:S,setPhone:W,setFullName:O,setCountry:j,setWalletAddress:nt,setWalletNetwork:ie,setSourceAmount:Qt,setSourceCurrency:le,setDestinationCurrency:wt,checkEmail:K,register:ge,attachKyc:Lt,verifyIdentity:po,registerWallet:ks,collectPaymentMethod:Jm,addPaymentMethod:Zm,refreshQuote:Xm,confirmCheckout:Ym,reset:ef,clearError:z,emitComplete:Or,resumeFulfillmentPolling:fn,amountFirst:t}}function Nu({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:a,email:i,setEmail:s,checkEmail:l,onClose:m}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(_r,{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(Yt,{onPress:m}),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(kt,{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(_r,{error:n,progress:a,loading:o})]})]})})}function $u({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(kt,{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(_r,{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 Qu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:m,onRetryStatusCheck:c}){let{colors:C}=F(),T=!!t;return jsxs(View,{style:e.form.screen,children:[T?jsx(Yt,{onPress:m}):jsx(View,{style:Ea}),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(kt,{size:48,strokeWidth:3,gradientFrom:C.primary,gradientTo:C.primary})}),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(za,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(_r,{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 Ku({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:m}){let{colors:c}=F(),C=t.transaction_details,T=Wa(C.destination_amount,C.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m??l,title:"Review your purchase",variant:m?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(Es,{currency:C.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(fo,{quote:e.quote,label:"You pay",value:`${C.source_amount} ${C.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You receive",value:`${T} ${C.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network fee",value:`$${C.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{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(kt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(_r,{error:o,progress:n,loading:r})]})]})}function Gu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:m}){let c=F();return t?jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(_r,{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(Yt,{onPress:m}),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:C=>s(C.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(kt,{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(_r,{error:o,progress:n,loading:r})]})]})})}function Hh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=F(),n=e.toLowerCase(),a=Ma[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:[Io.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[Io.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[Io.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 Yu({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:m}=F(),c=t.transaction_details,C=Wa(c.destination_amount,c.destination_currency),T=r||o||"";Wi(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(ht,{style:e.form.flex,contentContainerStyle:Io.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Io.iconSection,children:[jsx(Hh,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:Io.statusRow,children:[jsx(View,{style:[Io.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[Io.statusText,{color:s.foreground,fontFamily:m.semibold}],children:"Completed"})]}),jsx(Text,{style:[Io.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(za,{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},Io.detailCard],children:[jsx(fo,{quote:e.quote,label:"You Paid",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You Received",value:`${C} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(Ic,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),T?jsx(Ic,{quote:e.quote,label:"Recipient Address",address:T,last:true}):jsx(fo,{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 Io=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 Ju({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:m,registerWallet:c,onClose:C}){let{components:T}=F();if(t){let y=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:C}),jsxs(View,{style:e.flow.centered,children:[!y&&jsx(kt,{size:56,strokeWidth:3}),jsx(_r,{error:o,progress:n,loading:r})]}),y&&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(Yt,{onPress:C}),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:T.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:Ba.map(y=>{let b=i===y.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,b&&e.wallet.rowSelected],onPress:()=>{l(y.value),m(y.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(y.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,b&&e.wallet.rowTextSelected],children:y.label}),b&&jsx(View,{style:e.wallet.checkCircle,children:jsx($e,{size:14,color:T.container.buttonTitleColor,strokeWidth:2.5})})]},y.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{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(_r,{error:o,progress:n,loading:r})]})]})})}function el({config:e,onClose:t}){let r=F(),o=Ei(),{step:n,restoring:a,loading:i,status:s,error:l,email:m,phone:c,session:C,kycData:T,walletAddress:y,resolvedRecipientAddress:b,walletNetwork:k,sourceAmount:h,sourceCurrency:p,destinationCurrency:g,tokenIconUrl:d,networkIconUrl:f,applePaySupported:_,setStep:R,setEmail:w,setPhone:S,setWalletAddress:x,setWalletNetwork:W,setSourceAmount:D,setDestinationCurrency:O,checkEmail:P,register:j,attachKyc:q,verifyIdentity:ae,registerWallet:Me,collectPaymentMethod:Oe,addPaymentMethod:X,confirmCheckout:De,reset:he,emitComplete:xe,resumeFulfillmentPolling:Ue,amountFirst:we,customerId:ne,accessToken:Ie}=Ga(e),mt=!!e?.email,Ve=!!e?.phone,lt=!!e?.publishableKey&&!!e?.externalUserId,[He,Ne]=useState(void 0),[je,Be]=useState([]);useEffect(()=>{if(a||n!=="session_params"||!ne||!Ie)return;console.log("[OnrampScreen] customerId:",ne);let ve=ie=>{let de=ie?.message??"";return de.includes("stripe_onramp_forbidden")||de.includes("403")},be=ie=>{ve(ie)&&(Tn(),he());};ja(ne,Ie).then(ie=>{console.log("[OnrampScreen] customer fetched, id:",ie?.id);}).catch(ie=>{console.warn("[OnrampScreen] customer fetch error:",ie?.message),be(ie);}),Oc(ne,Ie).then(ie=>{console.log("[OnrampScreen] payment_tokens fetched, count:",ie.data?.length??0),Be(ie.data??[]);}).catch(ie=>{console.warn("[OnrampScreen] payment_tokens error:",ie?.message),be(ie);}),console.log("[OnrampScreen] walletAddress:",y,"walletNetwork:",k),y&&(console.log("[OnrampScreen] calling getTransactionLimits..."),Pu({destinationNetwork:k||"ethereum",walletAddress:y,accessToken:Ie,cryptoCustomerId:ne}).then(ie=>{console.log("[OnrampScreen] transaction_limits fetched");let de=ie.limits?.usd;if(de?.card?.length){let Qt=Math.max(...de.card.map(ue=>ue.limit));Ne(Qt),console.log("[OnrampScreen] card max amount:",Qt);}}).catch(ie=>{console.warn("[OnrampScreen] transaction_limits error:",ie?.message),be(ie);}));},[a,n,ne,Ie,y,k,he]);let J=async()=>{if(!(!ne||!Ie))try{let ve=await Oc(ne,Ie);console.log("[OnrampScreen] payment_tokens refreshed, count:",ve.data?.length??0),Be(ve.data??[]);}catch(ve){console.warn("[OnrampScreen] payment_tokens refresh error:",ve?.message);let be=ve?.message??"";(be.includes("stripe_onramp_forbidden")||be.includes("403"))&&(Tn(),he());}},ce=async()=>{let ve=await X();return ve&&await J(),ve},nt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&nt&&C&&(xe(C),he(),t?.());},[n,nt,C,xe,he,t]);let it=()=>{he(),t?.();};return a?jsx(View,{style:[Kh.container,{backgroundColor:r.colors.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})}):n==="email"?jsx(Nu,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:mt,loading:i,error:l,status:s,email:m,setEmail:w,checkEmail:P,onClose:it}):n==="register"?jsx(Gu,{styles:o,hasPrefilledPhone:Ve,loading:i,error:l,status:s,email:m,phone:c,setPhone:S,register:j,onClose:it}):n==="kyc"?jsx(Ka,{initialData:T,loading:i,onComplete:q,onCancel:()=>R("email")}):n==="identity"?jsx($u,{styles:o,loading:i,status:s,error:l,verifyIdentity:ae,onClose:it}):n==="wallet"?jsx(Ju,{styles:o,hasAutoWallet:lt,loading:i,error:l,status:s,walletAddress:y,walletNetwork:k,setWalletAddress:x,setWalletNetwork:W,setDestinationCurrency:O,registerWallet:Me,onClose:it}):n==="session_params"?jsx(Qa,{initialAmount:h,currency:p,applePaySupported:_,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:He,paymentTokens:je,onAddPaymentMethod:ce,onCollectPayment:(ve,be)=>{Oe(ve,be);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(ve,be)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:ve,selectedMethod:be,amountFirst:we}),we&&!ne)D(ve),R("email");else {let ie=be==="apple_pay",de=!ie&&be?be:void 0;console.log("[OnrampScreen] isApplePay:",ie,"hasSavedToken:",!!de),Oe(ie,ve,de);}},onCancel:it,accessToken:Ie}):n==="quote"&&C?jsx(Ku,{styles:o,session:C,loading:i,error:l,status:s,confirmCheckout:De,tokenIconUrl:d,networkIconUrl:f,onClose:it,onBack:()=>R("session_params")}):n==="processing"?jsx(Qu,{styles:o,error:l,status:s,loading:i,sourceCurrency:C?.transaction_details.source_currency,destinationCurrency:C?.transaction_details.destination_currency??g,destinationNetwork:C?.transaction_details.destination_network??"base",tokenIconUrl:d,networkIconUrl:f,onClose:it,onRetryStatusCheck:Ue}):n==="success"&&C&&!nt?jsx(Yu,{styles:o,session:C,resolvedRecipientAddress:b,recipientFromConfig:e?.recipientAddress,tokenIconUrl:d,networkIconUrl:f,onDone:()=>{xe(C),he(),t?.();}}):null}var Kh=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function ep(){try{let e=Gh.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 tl({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:m,onError:c,onStepChange:C,onClose:T,merchantIdentifier:y="",urlScheme:b="unifoldOnramp",paymentSelectorPosition:k,skipSuccessConfirmation:h=false}){let{colors:p,fonts:g,components:d}=F(),f=e||Pa(),_=useMemo(()=>{let D=y.trim();return D.length>0?D:ep()??""},[y]),[R,w]=useState("loading"),[S,x]=useState(null);useEffect(()=>{let D=false;async function O(){try{f&&(Ua(f),Ha(Ds()));let P=await Na();if(D)return;let j=_.trim();if(await initStripe({publishableKey:P,urlScheme:b,...j?{merchantIdentifier:j}:{}}),D)return;w("ready");}catch(P){if(D)return;console.error("[StripeOnramp] Init failed:",P),x(P?.message??"Failed to load Stripe configuration"),w("error");}}return O(),()=>{D=true;}},[f,_,b]);let W=useMemo(()=>{let D={publishableKey:f,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:m,onError:c,onStepChange:C};return s&&(D.destinationTokenAddress=s),l&&(D.recipientAddress=l),t&&(D.email=t),r&&(D.phone=r),n&&(D.flowOrder=n),k&&(D.paymentSelectorPosition=k),D.skipSuccessConfirmation=h,D.merchantIdentifier=_,D},[f,o,a,i,s,l,t,r,n,k,h,_,m,c,C]);return R==="error"?jsxs(View,{style:[ji.centered,{backgroundColor:p.background}],children:[jsx(Text,{style:[ji.errorText,{color:p.error,fontFamily:g.medium}],children:"Unable to initialize"}),jsx(Text,{style:[ji.errorDetail,{color:p.foregroundMuted,fontFamily:g.regular}],children:S}),T&&jsx(TouchableOpacity,{style:[ji.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:T,children:jsx(Text,{style:[ji.retryBtnText,{color:d.button.primaryText,fontFamily:g.medium}],children:"Go Back"})})]}):R==="loading"?jsx(View,{style:[ji.centered,{backgroundColor:p.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:p.primary,gradientTo:p.primary})}):jsx(el,{config:W,onClose:T})}var ji=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",paddingHorizontal:24},errorText:{fontSize:18,marginBottom:8},errorDetail:{fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{paddingVertical:14,paddingHorizontal:32},retryBtnText:{fontSize:16}});function np(){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 ip="__unifold_stripe_onramp__";function rl(e){globalThis[ip]=e;}function sp(){return globalThis[ip]}rl(tl);var vo=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 oi,vn,$i,ap,ng=(ap=class extends vo{constructor(){super();ee(this,oi);ee(this,vn);ee(this,$i);A(this,$i,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){u(this,vn)||this.setEventListener(u(this,$i));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,vn))==null||t.call(this),A(this,vn,void 0));}setEventListener(t){var r;A(this,$i,t),(r=u(this,vn))==null||r.call(this),A(this,vn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){u(this,oi)!==t&&(A(this,oi,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof u(this,oi)=="boolean"?u(this,oi):globalThis.document?.visibilityState!=="hidden"}},oi=new WeakMap,vn=new WeakMap,$i=new WeakMap,ap),qi=new ng;var ig={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Po,ni,lp,sg=(lp=class{constructor(){ee(this,Po,ig);ee(this,ni,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&u(this,ni)&&e!==u(this,Po)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:u(this,Po),provider:e}),A(this,Po,e),process.env.NODE_ENV!=="production"&&A(this,ni,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setTimeout(e,t)}clearTimeout(e){u(this,Po).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setInterval(e,t)}clearInterval(e){u(this,Po).clearInterval(e);}},Po=new WeakMap,ni=new WeakMap,lp),Fo=new sg;function cp(e){setTimeout(e,0);}var Nc=typeof window>"u"||"Deno"in globalThis;function or(){}function pp(e,t){return typeof e=="function"?e(t):e}function qs(e){return typeof e=="number"&&e>=0&&e!==1/0}function nl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bo(e,t){return typeof e=="function"?e(t):e}function Br(e,t){return typeof e=="function"?e(t):e}function il(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Qs(i,t.options))return false}else if(!ai(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 sl(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(ii(t.options.mutationKey)!==ii(a))return false}else if(!ai(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Qs(e,t){return (t?.queryKeyHashFn||ii)(e)}function ii(e){return JSON.stringify(e,(t,r)=>Hc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ai(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ai(e[r],t[r])):false}var ag=Object.prototype.hasOwnProperty;function ol(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=dp(e)&&dp(t);if(!o&&!(Hc(e)&&Hc(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):{},m=0;for(let c=0;c<s;c++){let C=o?c:i[c],T=e[C],y=t[C];if(T===y){l[C]=T,(o?c<a:ag.call(e,C))&&m++;continue}if(T===null||y===null||typeof T!="object"||typeof y!="object"){l[C]=y;continue}let b=ol(T,y,r+1);l[C]=b,b===T&&m++;}return a===s&&m===a?e:l}function al(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 dp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Hc(e){if(!up(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!up(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function up(e){return Object.prototype.toString.call(e)==="[object Object]"}function mp(e){return new Promise(t=>{Fo.setTimeout(t,e);})}function Ks(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 ol(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 ol(e,t)}return t}function fp(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function hp(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var si=Symbol();function ll(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===si&&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===si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cl(e,t){return typeof e=="function"?e(...t):!!e}function gp(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 Oo=(()=>{let e=()=>Nc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function Gs(){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 yp=cp;function lg(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=yp,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 It=lg();var Qi,Pn,Ki,bp,cg=(bp=class extends vo{constructor(){super();ee(this,Qi,true);ee(this,Pn);ee(this,Ki);A(this,Ki,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,Pn)||this.setEventListener(u(this,Ki));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,Pn))==null||t.call(this),A(this,Pn,void 0));}setEventListener(t){var r;A(this,Ki,t),(r=u(this,Pn))==null||r.call(this),A(this,Pn,t(this.setOnline.bind(this)));}setOnline(t){u(this,Qi)!==t&&(A(this,Qi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return u(this,Qi)}},Qi=new WeakMap,Pn=new WeakMap,Ki=new WeakMap,bp),Gi=new cg;function dg(e){return Math.min(1e3*2**e,3e4)}function jc(e){return (e??"online")==="online"?Gi.isOnline():true}var dl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function ul(e){let t=false,r=0,o,n=Gs(),a=()=>n.status!=="pending",i=k=>{if(!a()){let h=new dl(k);T(h),e.onCancel?.(h);}},s=()=>{t=true;},l=()=>{t=false;},m=()=>qi.isFocused()&&(e.networkMode==="always"||Gi.isOnline())&&e.canRun(),c=()=>jc(e.networkMode)&&e.canRun(),C=k=>{a()||(o?.(),n.resolve(k));},T=k=>{a()||(o?.(),n.reject(k));},y=()=>new Promise(k=>{o=h=>{(a()||m())&&k(h);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),b=()=>{if(a())return;let k,h=r===0?e.initialPromise:void 0;try{k=h??e.fn();}catch(p){k=Promise.reject(p);}Promise.resolve(k).then(C).catch(p=>{if(a())return;let g=e.retry??(Oo.isServer()?0:3),d=e.retryDelay??dg,f=typeof d=="function"?d(r,p):d,_=g===true||typeof g=="number"&&r<g||typeof g=="function"&&g(r,p);if(t||!_){T(p);return}r++,e.onFail?.(r,p),mp(f).then(()=>m()?void 0:y()).then(()=>{t?T(p):b();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?b():y().then(b),n)}}var li,Cp,pl=(Cp=class{constructor(){ee(this,li);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),qs(this.gcTime)&&A(this,li,Fo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Oo.isServer()?1/0:300*1e3));}clearGcTimeout(){u(this,li)!==void 0&&(Fo.clearTimeout(u(this,li)),A(this,li,void 0));}},li=new WeakMap,Cp);var ci,Yi,so,di,cr,Ys,ui,Qr,xp,Yo,kp,Tp=(kp=class extends pl{constructor(t){super();ee(this,Qr);ee(this,ci);ee(this,Yi);ee(this,so);ee(this,di);ee(this,cr);ee(this,Ys);ee(this,ui);A(this,ui,false),A(this,Ys,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,di,t.client),A(this,so,u(this,di).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,ci,Sp(this.options)),this.state=t.state??u(this,ci),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return u(this,cr)?.promise}setOptions(t){if(this.options={...u(this,Ys),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Sp(this.options);r.data!==void 0&&(this.setState(wp(r.data,r.dataUpdatedAt)),A(this,ci,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&u(this,so).remove(this);}setData(t,r){let o=Ks(this.state.data,t,this.options);return Ae(this,Qr,Yo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Ae(this,Qr,Yo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=u(this,cr)?.promise;return u(this,cr)?.cancel(t),r?r.then(or).catch(or):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return u(this,ci)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Br(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===si||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bo(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:!nl(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),u(this,so).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,cr)&&(u(this,ui)||Ae(this,Qr,xp).call(this)?u(this,cr).cancel({revert:true}):u(this,cr).cancelRetry()),this.scheduleGc()),u(this,so).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Qr,Yo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&u(this,cr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(u(this,cr))return u(this,cr).continueRetry(),u(this,cr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(m=>m.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:()=>(A(this,ui,true),o.signal)});},a=()=>{let l=ll(this.options,r),c=(()=>{let C={client:u(this,di),queryKey:this.queryKey,meta:this.meta};return n(C),C})();return A(this,ui,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,di),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),A(this,Yi,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Ae(this,Qr,Yo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),A(this,cr,ul({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof dl&&l.revert&&this.setState({...u(this,Yi),fetchStatus:"idle"}),o.abort();},onFail:(l,m)=>{Ae(this,Qr,Yo).call(this,{type:"failed",failureCount:l,error:m});},onPause:()=>{Ae(this,Qr,Yo).call(this,{type:"pause"});},onContinue:()=>{Ae(this,Qr,Yo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await u(this,cr).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,so).config.onSuccess?.(l,this),u(this,so).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof dl){if(l.silent)return u(this,cr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Ae(this,Qr,Yo).call(this,{type:"error",error:l}),u(this,so).config.onError?.(l,this),u(this,so).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ci=new WeakMap,Yi=new WeakMap,so=new WeakMap,di=new WeakMap,cr=new WeakMap,Ys=new WeakMap,ui=new WeakMap,Qr=new WeakSet,xp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Yo=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,...$c(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...wp(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,Yi,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),It.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),u(this,so).notify({query:this,type:"updated",action:t});});},kp);function $c(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function wp(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Sp(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 Ar,Ge,Zs,Rr,pi,Ji,Jo,Fn,Xs,Zi,Xi,mi,fi,On,es,dt,Js,qc,Qc,Kc,Gc,Yc,Jc,Zc,vp,Ip,ed=(Ip=class extends vo{constructor(t,r){super();ee(this,dt);ee(this,Ar);ee(this,Ge);ee(this,Zs);ee(this,Rr);ee(this,pi);ee(this,Ji);ee(this,Jo);ee(this,Fn);ee(this,Xs);ee(this,Zi);ee(this,Xi);ee(this,mi);ee(this,fi);ee(this,On);ee(this,es,new Set);this.options=r,A(this,Ar,t),A(this,Fn,null),A(this,Jo,Gs()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(u(this,Ge).addObserver(this),_p(u(this,Ge),this.options)?Ae(this,dt,Js).call(this):this.updateResult(),Ae(this,dt,Gc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Xc(u(this,Ge),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xc(u(this,Ge),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,dt,Yc).call(this),Ae(this,dt,Jc).call(this),u(this,Ge).removeObserver(this);}setOptions(t){let r=this.options,o=u(this,Ge);if(this.options=u(this,Ar).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Br(this.options.enabled,u(this,Ge))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,dt,Zc).call(this),u(this,Ge).setOptions(this.options),r._defaulted&&!al(this.options,r)&&u(this,Ar).getQueryCache().notify({type:"observerOptionsUpdated",query:u(this,Ge),observer:this});let n=this.hasListeners();n&&Rp(u(this,Ge),o,this.options,r)&&Ae(this,dt,Js).call(this),this.updateResult(),n&&(u(this,Ge)!==o||Br(this.options.enabled,u(this,Ge))!==Br(r.enabled,u(this,Ge))||bo(this.options.staleTime,u(this,Ge))!==bo(r.staleTime,u(this,Ge)))&&Ae(this,dt,qc).call(this);let a=Ae(this,dt,Qc).call(this);n&&(u(this,Ge)!==o||Br(this.options.enabled,u(this,Ge))!==Br(r.enabled,u(this,Ge))||a!==u(this,On))&&Ae(this,dt,Kc).call(this,a);}getOptimisticResult(t){let r=u(this,Ar).getQueryCache().build(u(this,Ar),t),o=this.createResult(r,t);return pg(this,o)&&(A(this,Rr,o),A(this,Ji,this.options),A(this,pi,u(this,Ge).state)),o}getCurrentResult(){return u(this,Rr)}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,Jo).status==="pending"&&u(this,Jo).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){u(this,es).add(t);}getCurrentQuery(){return u(this,Ge)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=u(this,Ar).defaultQueryOptions(t),o=u(this,Ar).getQueryCache().build(u(this,Ar),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Ae(this,dt,Js).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),u(this,Rr)))}createResult(t,r){let o=u(this,Ge),n=this.options,a=u(this,Rr),i=u(this,pi),s=u(this,Ji),m=t!==o?t.state:u(this,Zs),{state:c}=t,C={...c},T=false,y;if(r._optimisticResults){let x=this.hasListeners(),W=!x&&_p(t,r),D=x&&Rp(t,o,r,n);(W||D)&&(C={...C,...$c(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(C.fetchStatus="idle");}let{error:b,errorUpdatedAt:k,status:h}=C;y=C.data;let p=false;if(r.placeholderData!==void 0&&y===void 0&&h==="pending"){let x;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(x=a.data,p=true):x=typeof r.placeholderData=="function"?r.placeholderData(u(this,Xi)?.state.data,u(this,Xi)):r.placeholderData,x!==void 0&&(h="success",y=Ks(a?.data,x,r),T=true);}if(r.select&&y!==void 0&&!p)if(a&&y===i?.data&&r.select===u(this,Xs))y=u(this,Zi);else try{A(this,Xs,r.select),y=r.select(y),y=Ks(a?.data,y,r),A(this,Zi,y),A(this,Fn,null);}catch(x){A(this,Fn,x);}u(this,Fn)&&(b=u(this,Fn),y=u(this,Zi),k=Date.now(),h="error");let g=C.fetchStatus==="fetching",d=h==="pending",f=h==="error",_=d&&g,R=y!==void 0,S={status:h,fetchStatus:C.fetchStatus,isPending:d,isSuccess:h==="success",isError:f,isInitialLoading:_,isLoading:_,data:y,dataUpdatedAt:C.dataUpdatedAt,error:b,errorUpdatedAt:k,failureCount:C.fetchFailureCount,failureReason:C.fetchFailureReason,errorUpdateCount:C.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:C.dataUpdateCount>m.dataUpdateCount||C.errorUpdateCount>m.errorUpdateCount,isFetching:g,isRefetching:g&&!d,isLoadingError:f&&!R,isPaused:C.fetchStatus==="paused",isPlaceholderData:T,isRefetchError:f&&R,isStale:td(t,r),refetch:this.refetch,promise:u(this,Jo),isEnabled:Br(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let x=S.data!==void 0,W=S.status==="error"&&!x,D=j=>{W?j.reject(S.error):x&&j.resolve(S.data);},O=()=>{let j=A(this,Jo,S.promise=Gs());D(j);},P=u(this,Jo);switch(P.status){case "pending":t.queryHash===o.queryHash&&D(P);break;case "fulfilled":(W||S.data!==P.value)&&O();break;case "rejected":(!W||S.error!==P.reason)&&O();break}}return S}updateResult(){let t=u(this,Rr),r=this.createResult(u(this,Ge),this.options);if(A(this,pi,u(this,Ge).state),A(this,Ji,this.options),u(this,pi).data!==void 0&&A(this,Xi,u(this,Ge)),al(r,t))return;A(this,Rr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!u(this,es).size)return true;let i=new Set(a??u(this,es));return this.options.throwOnError&&i.add("error"),Object.keys(u(this,Rr)).some(s=>{let l=s;return u(this,Rr)[l]!==t[l]&&i.has(l)})};Ae(this,dt,vp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,dt,Gc).call(this);}},Ar=new WeakMap,Ge=new WeakMap,Zs=new WeakMap,Rr=new WeakMap,pi=new WeakMap,Ji=new WeakMap,Jo=new WeakMap,Fn=new WeakMap,Xs=new WeakMap,Zi=new WeakMap,Xi=new WeakMap,mi=new WeakMap,fi=new WeakMap,On=new WeakMap,es=new WeakMap,dt=new WeakSet,Js=function(t){Ae(this,dt,Zc).call(this);let r=u(this,Ge).fetch(this.options,t);return t?.throwOnError||(r=r.catch(or)),r},qc=function(){Ae(this,dt,Yc).call(this);let t=bo(this.options.staleTime,u(this,Ge));if(Oo.isServer()||u(this,Rr).isStale||!qs(t))return;let o=nl(u(this,Rr).dataUpdatedAt,t)+1;A(this,mi,Fo.setTimeout(()=>{u(this,Rr).isStale||this.updateResult();},o));},Qc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(u(this,Ge)):this.options.refetchInterval)??false},Kc=function(t){Ae(this,dt,Jc).call(this),A(this,On,t),!(Oo.isServer()||Br(this.options.enabled,u(this,Ge))===false||!qs(u(this,On))||u(this,On)===0)&&A(this,fi,Fo.setInterval(()=>{(this.options.refetchIntervalInBackground||qi.isFocused())&&Ae(this,dt,Js).call(this);},u(this,On)));},Gc=function(){Ae(this,dt,qc).call(this),Ae(this,dt,Kc).call(this,Ae(this,dt,Qc).call(this));},Yc=function(){u(this,mi)!==void 0&&(Fo.clearTimeout(u(this,mi)),A(this,mi,void 0));},Jc=function(){u(this,fi)!==void 0&&(Fo.clearInterval(u(this,fi)),A(this,fi,void 0));},Zc=function(){let t=u(this,Ar).getQueryCache().build(u(this,Ar),this.options);if(t===u(this,Ge))return;let r=u(this,Ge);A(this,Ge,t),A(this,Zs,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},vp=function(t){It.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(u(this,Rr));}),u(this,Ar).getQueryCache().notify({query:u(this,Ge),type:"observerResultsUpdated"});});},Ip);function ug(e,t){return Br(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function _p(e,t){return ug(e,t)||e.state.data!==void 0&&Xc(e,t,t.refetchOnMount)}function Xc(e,t,r){if(Br(t.enabled,e)!==false&&bo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&td(e,t)}return false}function Rp(e,t,r,o){return (e!==t||Br(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&td(e,r)}function td(e,t){return Br(t.enabled,e)!==false&&e.isStaleByTime(bo(t.staleTime,e))}function pg(e,t){return !al(e.getCurrentResult(),t)}function rd(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,m=async()=>{let c=false,C=b=>{gp(b,()=>t.signal,()=>c=true);},T=ll(t.options,t.fetchOptions),y=async(b,k,h)=>{if(c)return Promise.reject();if(k==null&&b.pages.length)return Promise.resolve(b);let g=(()=>{let R={client:t.client,queryKey:t.queryKey,pageParam:k,direction:h?"backward":"forward",meta:t.options.meta};return C(R),R})(),d=await T(g),{maxPages:f}=t.options,_=h?hp:fp;return {pages:_(b.pages,d,f),pageParams:_(b.pageParams,k,f)}};if(n&&a.length){let b=n==="backward",k=b?mg:Pp,h={pages:a,pageParams:i},p=k(o,h);s=await y(h,p,b);}else {let b=e??a.length;do{let k=l===0?i[0]??o.initialPageParam:Pp(o,s);if(l>0&&k==null)break;s=await y(s,k),l++;}while(l<b)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=m;}}}function Pp(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 mg(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ea,Do,Cr,hi,Vo,Dn,Fp,Op=(Fp=class extends pl{constructor(t){super();ee(this,Vo);ee(this,ea);ee(this,Do);ee(this,Cr);ee(this,hi);A(this,ea,t.client),this.mutationId=t.mutationId,A(this,Cr,t.mutationCache),A(this,Do,[]),this.state=t.state||fg(),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,Do).includes(t)||(u(this,Do).push(t),this.clearGcTimeout(),u(this,Cr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Do,u(this,Do).filter(r=>r!==t)),this.scheduleGc(),u(this,Cr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){u(this,Do).length||(this.state.status==="pending"?this.scheduleGc():u(this,Cr).remove(this));}continue(){return u(this,hi)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Ae(this,Vo,Dn).call(this,{type:"continue"});},o={client:u(this,ea),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,hi,ul({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Ae(this,Vo,Dn).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Ae(this,Vo,Dn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>u(this,Cr).canRun(this)}));let n=this.state.status==="pending",a=!u(this,hi).canStart();try{if(n)r();else {Ae(this,Vo,Dn).call(this,{type:"pending",variables:t,isPaused:a}),u(this,Cr).config.onMutate&&await u(this,Cr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Ae(this,Vo,Dn).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await u(this,hi).start();return await u(this,Cr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await u(this,Cr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Ae(this,Vo,Dn).call(this,{type:"success",data:i}),i}catch(i){try{await u(this,Cr).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,Cr).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 Ae(this,Vo,Dn).call(this,{type:"error",error:i}),i}finally{u(this,Cr).runNext(this);}}},ea=new WeakMap,Do=new WeakMap,Cr=new WeakMap,hi=new WeakMap,Vo=new WeakSet,Dn=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),It.batch(()=>{u(this,Do).forEach(o=>{o.onMutationUpdate(t);}),u(this,Cr).notify({mutation:this,type:"updated",action:t});});},Fp);function fg(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Zo,Co,ta,Dp,Vp=(Dp=class extends vo{constructor(t={}){super();ee(this,Zo);ee(this,Co);ee(this,ta);this.config=t,A(this,Zo,new Set),A(this,Co,new Map),A(this,ta,0);}build(t,r,o){let n=new Op({client:t,mutationCache:this,mutationId:++Ts(this,ta)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){u(this,Zo).add(t);let r=ml(t);if(typeof r=="string"){let o=u(this,Co).get(r);o?o.push(t):u(this,Co).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(u(this,Zo).delete(t)){let r=ml(t);if(typeof r=="string"){let o=u(this,Co).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,Co).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=ml(t);if(typeof r=="string"){let n=u(this,Co).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=ml(t);return typeof r=="string"?u(this,Co).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){It.batch(()=>{u(this,Zo).forEach(t=>{this.notify({type:"removed",mutation:t});}),u(this,Zo).clear(),u(this,Co).clear();});}getAll(){return Array.from(u(this,Zo))}find(t){let r={exact:true,...t};return this.getAll().find(o=>sl(r,o))}findAll(t={}){return this.getAll().filter(r=>sl(t,r))}notify(t){It.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return It.batch(()=>Promise.all(t.map(r=>r.continue().catch(or))))}},Zo=new WeakMap,Co=new WeakMap,ta=new WeakMap,Dp);function ml(e){return e.options.scope?.id}var Lo,Lp,Bp=(Lp=class extends vo{constructor(t={}){super();ee(this,Lo);this.config=t,A(this,Lo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Qs(n,r),i=this.get(a);return i||(i=new Tp({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){u(this,Lo).has(t.queryHash)||(u(this,Lo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=u(this,Lo).get(t.queryHash);r&&(t.destroy(),r===t&&u(this,Lo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){It.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return u(this,Lo).get(t)}getAll(){return [...u(this,Lo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>il(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>il(t,o)):r}notify(t){It.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){It.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){It.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Lo=new WeakMap,Lp);var $t,Vn,Ln,ts,rs,Bn,os,ns,Ap,od=(Ap=class{constructor(e={}){ee(this,$t);ee(this,Vn);ee(this,Ln);ee(this,ts);ee(this,rs);ee(this,Bn);ee(this,os);ee(this,ns);A(this,$t,e.queryCache||new Bp),A(this,Vn,e.mutationCache||new Vp),A(this,Ln,e.defaultOptions||{}),A(this,ts,new Map),A(this,rs,new Map),A(this,Bn,0);}mount(){Ts(this,Bn)._++,u(this,Bn)===1&&(A(this,os,qi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,$t).onFocus());})),A(this,ns,Gi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,$t).onOnline());})));}unmount(){var e,t;Ts(this,Bn)._--,u(this,Bn)===0&&((e=u(this,os))==null||e.call(this),A(this,os,void 0),(t=u(this,ns))==null||t.call(this),A(this,ns,void 0));}isFetching(e){return u(this,$t).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return u(this,Vn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,$t).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=u(this,$t).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(bo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return u(this,$t).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,$t).get(o.queryHash)?.state.data,i=pp(t,a);if(i!==void 0)return u(this,$t).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return It.batch(()=>u(this,$t).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,$t).get(t.queryHash)?.state}removeQueries(e){let t=u(this,$t);It.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=u(this,$t);return It.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=It.batch(()=>u(this,$t).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(or).catch(or)}invalidateQueries(e,t={}){return It.batch(()=>(u(this,$t).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=It.batch(()=>u(this,$t).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(or)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(or)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=u(this,$t).build(this,t);return r.isStaleByTime(bo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(or).catch(or)}fetchInfiniteQuery(e){return e.behavior=rd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(or).catch(or)}ensureInfiniteQueryData(e){return e.behavior=rd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Gi.isOnline()?u(this,Vn).resumePausedMutations():Promise.resolve()}getQueryCache(){return u(this,$t)}getMutationCache(){return u(this,Vn)}getDefaultOptions(){return u(this,Ln)}setDefaultOptions(e){A(this,Ln,e);}setQueryDefaults(e,t){u(this,ts).set(ii(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...u(this,ts).values()],r={};return t.forEach(o=>{ai(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){u(this,rs).set(ii(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...u(this,rs).values()],r={};return t.forEach(o=>{ai(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...u(this,Ln).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Qs(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===si&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...u(this,Ln).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){u(this,$t).clear(),u(this,Vn).clear();}},$t=new WeakMap,Vn=new WeakMap,Ln=new WeakMap,ts=new WeakMap,rs=new WeakMap,Bn=new WeakMap,os=new WeakMap,ns=new WeakMap,Ap);var nd=An.createContext(void 0),id=e=>{let t=An.useContext(nd);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},sd=({client:e,children:t})=>(An.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(nd.Provider,{value:e,children:t}));var Wp=An.createContext(false),Ep=()=>An.useContext(Wp);Wp.Provider;function gg(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var yg=An.createContext(gg()),Mp=()=>An.useContext(yg);var Up=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?cl(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Hp=e=>{An.useEffect(()=>{e.clearReset();},[e]);},Np=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||cl(r,[e.error,o]));var jp=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,qp=(e,t)=>e?.suspense&&t.isPending,ad=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Qp(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=Ep(),n=Mp(),a=id(),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",jp(i),Up(i,n,s),Hp(n);let l=!a.getQueryCache().get(i.queryHash),[m]=An.useState(()=>new t(a,i)),c=m.getOptimisticResult(i),C=!o&&e.subscribed!==false;if(An.useSyncExternalStore(An.useCallback(T=>{let y=C?m.subscribe(It.batchCalls(T)):or;return m.updateResult(),y},[m,C]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),An.useEffect(()=>{m.setOptions(i);},[i,m]),qp(i,c))throw ad(i,m,n);if(Np({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&&!Oo.isServer()&&$p(c,o)&&(l?ad(i,m,n):s?.promise)?.catch(or).finally(()=>{m.updateResult();}),i.notifyOnChangeProps?c:m.trackResult(c)}function Xo(e,t){return Qp(e,ed)}var as=new Map;function Kp({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 En({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=F(),[m,c]=useState(false),[C,T]=useState(false),[y,b]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let _=as.get(e);return _?{uri:e,xml:_}:null}),k=e?.toLowerCase().endsWith(".svg"),h=k&&e&&y?.uri===e?y.xml:null;useEffect(()=>{c(false),T(false);},[e]),useEffect(()=>{if(!k||!e)return;if(as.has(e)){b({uri:e,xml:as.get(e)});return}let _=false;return fetch(e).then(R=>{if(!R.ok)throw new Error(`HTTP ${R.status}`);return R.text()}).then(R=>{_||(as.set(e,R),b({uri:e,xml:R}));}).catch(()=>{_||c(true);}),()=>{_=true;}},[e,k]);let p=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:p},s]});let g={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},d=t-n*2,f=r-n*2;return m?jsx(View,{style:[g,{backgroundColor:i||p}]}):k?jsxs(View,{style:g,children:[!!!h&&jsx(Kp,{width:d,height:f,borderRadius:o,color:p}),h?jsx(SvgXml,{xml:h,width:d,height:f,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:d,height:f,onError:()=>c(true)})]}):jsxs(View,{style:g,children:[!C&&jsx(Kp,{width:d,height:f,borderRadius:o,color:p}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:d,height:f},resizeMode:"contain",onLoad:()=>T(true),onError:()=>c(true)})]})}function dd(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(as.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{as.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Ir({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:m,balanceChainId:c,balanceTokenAddress:C,publishableKey:T,projectName:y,leftIcon:b,onLeftAction:k}){let{colors:h,fonts:p,components:g}=F(),[d,f]=useState(null),[_,R]=useState(false),w=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!_)return;let x=Animated.loop(Animated.sequence([Animated.timing(w,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(w,{toValue:0,duration:700,useNativeDriver:true})]));return x.start(),()=>x.stop()},[_,w]),useEffect(()=>{if(!s||!l||!m||!c||!C||!T){f(null),R(false);return}let x=false;return R(true),La(l,m,c,C,T).then(W=>{if(x)return;let D=W.balance,O=null;D&&(D.amount_usd!=null&&D.amount_usd!==""?O=`$${D.amount_usd}`:O="$0.00"),f(O);}).catch(()=>{x||f(null);}).finally(()=>{x||R(false);}),()=>{x=true;}},[s,l,m,c,C,T]);let S=w.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:wr.header,children:[jsx(View,{style:wr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[wr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(_s,{size:20,color:g.header.buttonColor,strokeWidth:2})}):b&&k?jsx(TouchableOpacity,{onPress:k,style:[wr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:b}):jsx(View,{style:wr.spacer})}),jsxs(View,{style:wr.titleContainer,children:[jsxs(View,{style:wr.titleRow,children:[jsx(Text,{style:[wr.title,{color:g.header.titleColor,fontFamily:p.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[wr.titleBadge,{backgroundColor:h.card}],children:jsx(Text,{style:[wr.titleBadgeText,{color:h.foregroundMuted,fontFamily:p.regular}],children:i.count})})]}),t?jsx(Text,{style:[wr.balanceText,{color:h.foregroundMuted,fontFamily:p.regular}],children:t}):null,s&&(_?jsx(Animated.View,{style:[wr.balanceSkeleton,{backgroundColor:h.cardHover,opacity:S}]}):d!=null?jsxs(Text,{style:[wr.balanceText,{color:h.foregroundMuted,fontFamily:p.regular}],children:[y?`${y} `:"","Balance: ",d]}):null)]}),jsx(View,{style:wr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[wr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:g.header.buttonColor,strokeWidth:2})}):jsx(View,{style:wr.spacer})})]})}var wr=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 nr({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=F(),s=a??i.card,l=s.backShadowColor!=="transparent",m={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},c=[Zp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],C=[m,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[Zp.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:C,children:e}):jsx(View,{style:C,children:e})]})}var Zp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function oa({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card,s=o?[...o].sort((l,m)=>l.position-m.position):[];return jsxs(nr,{cardTokens:i,onPress:e,style:Bo.wrapper,contentStyle:Bo.container,children:[jsxs(View,{style:Bo.leftContent,children:[jsx(View,{style:[Bo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(ac,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Bo.textContainer,children:[jsx(Text,{style:[Bo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Bo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Bo.rightContent,children:jsx(View,{style:Bo.networkIcons,children:s.map((l,m)=>{let c=l.icon_urls.find(C=>C.format==="png")?.url||l.icon_urls.find(C=>C.format==="svg")?.url;return jsx(View,{style:[Bo.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:s.length-m}],children:jsx(En,{uri:re(c),width:20,height:20})},l.name)})})})]})}var Bo=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 ia({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsxs(nr,{cardTokens:i,onPress:e,style:en.wrapper,contentStyle:en.container,children:[jsxs(View,{style:en.leftContent,children:[jsx(View,{style:[en.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Pi,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:en.textContainer,children:[jsx(Text,{style:[en.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[en.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:en.rightContent,children:jsx(View,{style:en.paymentIcons,children:o?.map(s=>{let l=s.icon_urls.find(m=>m.format==="png")?.url||s.icon_urls.find(m=>m.format==="svg")?.url;return jsx(En,{uri:re(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var en=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 sa({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsx(nr,{cardTokens:i,onPress:e,style:tn.wrapper,contentStyle:tn.container,children:jsxs(View,{style:tn.leftContent,children:[jsxs(View,{style:[tn.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(zr,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[tn.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[tn.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:tn.textContainer,children:[jsx(Text,{style:[tn.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[tn.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var tn=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 la({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=F(),a=n.depositMenu.card;return jsxs(nr,{cardTokens:a,onPress:e,style:Ao.wrapper,contentStyle:Ao.container,children:[jsxs(View,{style:Ao.leftContent,children:[jsx(View,{style:[Ao.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(Ra,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Ao.textContainer,children:[jsx(Text,{style:[Ao.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Ao.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Ao.rightContent,children:jsx(View,{style:Ao.badge,children:jsx(Text,{style:[Ao.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Ao=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 rm=1e4,om=2500,nm=3e3,im=6e4;function ca(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:m,setDepositExecutions:c,setTrackedExecutions:C,setLatestExecution:T,setShowStatusSheet:y,onDepositSuccess:b,onExecutionsChange:k,onDepositError:h}=e,[p,g]=useState(false),[d,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;g(false),t==="auto_ui"&&f(false);let R=setTimeout(()=>{g(true),t==="auto_ui"&&f(true);},rm);return ()=>clearTimeout(R)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let R=new Date(i.getTime()-im),w=setInterval(async()=>{try{let W=[...(await Qo(n,a)).data??[]].sort((O,P)=>{let j=O.created_at?new Date(O.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-j}),D=null;for(let O of W){let P=O.created_at?new Date(O.created_at):null;if(!P||P<=R)continue;let j=m.get(O.id);if(!j){D=O;break}if(["pending","waiting","delayed"].includes(j)&&O.status==="succeeded"){D=O;break}}if(D){let O=D;c(P=>{let j=P.findIndex(q=>q.id===O.id);if(j>=0){let q=[...P];return q[j]=O,q}return [...P,O]}),C(P=>{let j=new Map(P);return j.set(O.id,O.status),j}),T(O),y(!0),O.status==="succeeded"&&b?.({message:"Deposit completed successfully",executionId:O.id}),k?.([...l,O]);}}catch(S){h?.({message:"Failed to check deposit status",error:S});}},om);return ()=>clearInterval(w)},[n,a,i,m,l,k,b,h]),useEffect(()=>{if(!p||!s)return;let R=async()=>{try{await Fa(s,a);}catch{}};R();let w=setInterval(R,nm);return ()=>clearInterval(w)},[p,s,a]),{pollingEnabled:p,showWaitingUi:d,handleIveDeposited:()=>{g(true),f(true);}}}function us({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=F(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",m=n||s;return jsxs(View,{style:[am.container,{width:t,height:t}],children:[jsx(Fg,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[am.logoContainer,{width:o+12,height:o+12,backgroundColor:m,borderRadius:(o+12)/2}],children:jsx(En,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var am=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function dm(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function Lg(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 ps({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:m}){let{colors:c,fonts:C,components:T}=F(),[y,b]=useState(false),k=t==="pending"||t==="waiting"||t==="delayed",h=t==="succeeded",p=()=>{o&&Linking.openURL(o);},g=()=>{n&&Linking.openURL(n);};return jsx(ft,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:m,children:jsxs(View,{style:At.container,children:[jsx(TouchableOpacity,{style:At.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.header.buttonColor,strokeWidth:2})}),jsx(View,{style:At.iconContainer,children:k?jsx(kt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:re(r)},style:At.tokenIconFill}):jsx(View,{style:[At.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:re(r)},style:At.tokenIconLarge}):jsx(View,{style:[At.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[At.statusBadge,{backgroundColor:T.container.iconBackgroundColor}],children:jsx($e,{size:16,color:T.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[At.title,{color:T.container.titleColor,fontFamily:C.semibold}],children:k?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[At.amount,{color:T.container.titleColor,fontFamily:C.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[At.date,{color:T.container.subtitleColor,fontFamily:C.regular}],children:Lg(a)}),jsx(Text,{style:[At.subtitle,{color:T.container.subtitleColor,fontFamily:C.regular}],children:k?"This usually takes less than a minute.":"Your account has been credited successfully!"}),h&&(o||n)&&jsxs(View,{style:At.detailsSection,children:[jsx(View,{style:[At.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:At.detailsToggle,onPress:()=>b(!y),children:[jsx(Text,{style:[At.detailsToggleText,{color:T.container.actionTitle,fontFamily:C.medium}],children:y?"See less":"See more details"}),y?jsx(To,{size:18,color:T.container.actionColor,strokeWidth:2}):jsx(Bt,{size:18,color:T.container.actionColor,strokeWidth:2})]}),y&&jsxs(View,{style:At.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[At.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:p,children:[jsx(Text,{style:[At.txLabel,{color:T.card.titleColor,fontFamily:C.medium}],children:"Deposit tx"}),jsx(Text,{style:[At.txHash,{color:T.card.subtitleColor,fontFamily:C.regular}],children:dm(o)}),jsx(ko,{size:16,color:T.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[At.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:g,children:[jsx(Text,{style:[At.txLabel,{color:T.card.titleColor,fontFamily:C.medium}],children:"Completion tx"}),jsx(Text,{style:[At.txHash,{color:T.card.subtitleColor,fontFamily:C.regular}],children:dm(n)}),jsx(ko,{size:16,color:T.card.actionColor,strokeWidth:2})]})]})]})]})})}var At=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 wl({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=F();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[bi.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[bi.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[bi.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:[bi.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(lc,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:bi.processingCardText,children:[jsx(Text,{style:[bi.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[bi.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var bi=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 da=(e,t)=>`${t}:${e}`,Ng=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function kl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:c="auto_ui",onExecutionsChange:C,onDepositSuccess:T,onDepositError:y,borderTopLeftRadius:b,borderTopRightRadius:k,sheetBorderRadius:h}){let{colors:p,fonts:g,components:d}=F(),f=s&&l?`${s}:${l}`:"solana:mainnet",[_,R]=useState("USDC"),[w,S]=useState(f),[x,W]=useState([]),[D,O]=useState(true),[P,j]=useState([]),[q,ae]=useState(true),[Me,Oe]=useState(false),[X,De]=useState(false),[he,xe]=useState(false),[Ue,we]=useState(false),[ne,Ie]=useState([]),[mt,Ve]=useState(new Map),[lt]=useState(()=>new Date),[He,Ne]=useState(null),[je,Be]=useState(false),[J,ce]=useState(null),[nt,it]=useState(false),ve=new Map;P.forEach(E=>{E.chains.forEach(te=>{let ye=`${te.chain_type}:${te.chain_id}`;ve.has(ye)||ve.set(ye,te);});});let be=Array.from(ve.values()),ie=Ng(w),Qt=be.find(E=>E.chain_type===ie.chainType&&E.chain_id===ie.chainId)?.chain_type||"ethereum",ue=qo(x,Qt),le=ue?.address||"",Ce=useRef(false);useEffect(()=>{async function E(){try{ae(!0),Ne(null);let ye=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(j(ye.data),ye.data.length>0&&!Ce.current){Ce.current=!0;let me,gt;if(s&&l)if(m)for(let V of ye.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l&&z.token_address.toLowerCase()===m.toLowerCase());if(Or){me=V,gt=Or;break}}else for(let V of ye.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l);if(Or){me=V,gt=Or;break}}if(!me&&a)for(let V of ye.data){let Or=V.chains.find(z=>z.token_address.toLowerCase()===a.toLowerCase());if(Or){me=V,gt=Or;break}}me||(me=ye.data.find(V=>V.symbol==="USDC"),me&&me.chains.length>0&&(gt=me.chains[0])),me||(me=ye.data.find(V=>V.symbol==="USDT"),me&&me.chains.length>0&&(gt=me.chains[0])),me||(me=ye.data[0],me.chains.length>0&&(gt=me.chains[0])),me&&R(me.symbol),gt&&S(da(gt.chain_id,gt.chain_type));}}catch(te){console.error("Error fetching supported tokens:",te),Ne("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:te});}finally{ae(false);}}E();},[t,y,s,l,m,a,n,o]),useEffect(()=>{async function E(){try{O(!0),Ne(null);let te=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);W(te.data);}catch(te){console.error("Error fetching wallets:",te),Ne("Failed to load wallets"),y?.({message:"Failed to load wallets",error:te});}finally{O(false);}}E();},[e,r,o,n,a,t,y]);let wt=ue?.id??"",{showWaitingUi:tt,handleIveDeposited:pe}=ca({depositConfirmationMode:c,depositAddress:le,chain:w,externalUserId:e,publishableKey:t,modalOpenedAt:lt,depositWalletId:wt,depositExecutions:ne,trackedExecutions:mt,setDepositExecutions:Ie,setTrackedExecutions:Ve,setLatestExecution:ce,setShowStatusSheet:Be,onDepositSuccess:T,onExecutionsChange:C,onDepositError:y});useEffect(()=>{if(!P.length)return;let E=P.find(ye=>ye.symbol===_);if(!E||E.chains.length===0)return;if(!E.chains.some(ye=>da(ye.chain_id,ye.chain_type)===w)){let ye=E.chains[0];S(da(ye.chain_id,ye.chain_type));}},[_,P,w]);let Qe=P.find(E=>E.symbol===_),ir=Qe?.chains||[],xt=ir.find(E=>da(E.chain_id,E.chain_type)===w),Pr=async()=>{if(le)try{Clipboard.setString(le),Oe(!0),setTimeout(()=>Oe(!1),2e3);}catch(E){console.error("Failed to copy:",E);}},Fr=xt?.estimated_price_impact_percent??0,U=xt?.max_slippage_percent??.25,Q=xt?.minimum_deposit_amount_usd??3;if(q)return jsxs(View,{style:L.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:p.primary}),jsx(Text,{style:[L.loadingText,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Loading currencies..."})]});if(He&&P.length===0)return jsxs(View,{style:L.errorContainer,children:[jsx(Text,{style:[L.errorText,{color:p.error,fontFamily:g.regular}],children:He}),jsx(Text,{style:[L.errorHint,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Please check your network connection and try again."})]});let se=()=>jsxs(ft,{visible:he,onClose:()=>xe(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.tokenSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.tokenSelector?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>xe(false),style:L.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(ht,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:P.map(E=>jsxs(TouchableOpacity$1,{onPress:()=>{R(E.symbol),xe(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:_===E.symbol?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:re(Se(E,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:E.symbol}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:g.regular}],children:[E.chains.length," network",E.chains.length!==1?"s":""," available"]})]}),_===E.symbol&&jsx($e,{size:20,color:p.primary,strokeWidth:2})]},E.symbol))})]}),ze=()=>jsxs(ft,{visible:Ue,onClose:()=>we(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.chainSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.chainSelector?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>we(false),style:L.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(ht,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:ir.map(E=>{let te=da(E.chain_id,E.chain_type),ye=w===te;return jsxs(TouchableOpacity$1,{onPress:()=>{S(te),we(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:ye?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:re(Se(E,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:E.chain_name}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:g.regular}],children:["Min deposit: $",E.minimum_deposit_amount_usd]})]}),ye&&jsx($e,{size:20,color:p.primary,strokeWidth:2})]},te)})})]});return jsxs(View,{style:L.container,children:[jsxs(View,{style:L.selectorSection,children:[jsx(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:g.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>xe(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[Qe&&jsx(Image,{source:{uri:re(Se(Qe,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:g.medium}],children:_}),jsx(Bt,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:L.selectorSection,children:[jsxs(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:g.regular}],children:["Network"," ",jsxs(Text,{style:[L.minDeposit,{fontFamily:g.regular}],children:["($",Q," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>we(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[xt&&jsx(Image,{source:{uri:re(Se(xt,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:g.medium}],numberOfLines:1,children:xt?.chain_name||"Select network"}),jsx(Bt,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:L.qrContainer,children:jsx(View,{style:[L.qrWrapper,{backgroundColor:p.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:D?jsxs(View,{style:L.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:p.primary}),jsx(Text,{style:[L.loadingText,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Loading..."})]}):le?jsx(us,{value:le,size:160,logoUri:re(Se(xt,"png")||Gt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:L.qrLoading,children:jsx(Text,{style:[L.errorText,{color:p.error,fontFamily:g.regular}],children:"No address available"})})})}),jsxs(View,{style:L.addressSection,children:[jsxs(View,{style:L.addressHeader,children:[jsx(Text,{style:[L.addressLabel,{color:d.card.labelColor,fontFamily:g.medium}],children:"Deposit Address"}),Me&&jsxs(View,{style:L.copiedIndicator,children:[jsx($e,{size:14,color:p.success,strokeWidth:2}),jsx(Text,{style:[L.copiedText,{color:p.success,fontFamily:g.regular}],children:"Copied"})]})]}),jsxs(nr,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!D&&le?Pr:void 0,contentStyle:L.addressBox,children:[jsx(Text,{style:[L.addressText,{color:d.card.titleColor,fontFamily:g.regular}],numberOfLines:2,children:D?"Loading...":le||"No address available"}),jsx(View,{style:L.addressCopyIcon,children:jsx(No,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[L.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>De(!X),style:L.detailsHeader,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:L.chevronContainer,children:X?jsx(To,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(Bt,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),X&&jsxs(View,{style:L.detailsContent,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Price impact: ",Fr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Slippage: Auto \u2022 ",U.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(wl,{depositConfirmationMode:c,depositAddress:le,showWaitingUi:tt,latestExecution:J,onIveDeposited:pe}),jsx(TouchableOpacity$1,{style:L.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[L.termsText,{color:p.primary,fontFamily:g.regular}],children:"Terms apply"})}),se(),ze(),jsxs(ft,{visible:nt,onClose:()=>it(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:h?.infoSheet?.borderTopLeftRadius??b,borderTopRightRadius:h?.infoSheet?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>it(false),style:L.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:L.infoSheetContent,children:[jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:"Price Impact"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:g.medium}],children:[Fr.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:g.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:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:"Max Slippage"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:g.medium}],children:[U.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:g.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."})]})]})]}),J&&jsx(ps,{visible:je,status:J.status,tokenIconUrl:J.destination_token_metadata?.icon_urls?.find(E=>E.format==="png")?.url||J.destination_token_metadata?.icon_url||Se(Qe,"png"),explorerUrl:J.explorer_url,completionExplorerUrl:J.destination_explorer_url,date:J.created_at?new Date(J.created_at):void 0,amountUsd:J.source_amount_usd?parseFloat(J.source_amount_usd):void 0,onClose:()=>Be(false),borderTopLeftRadius:h?.depositStatus?.borderTopLeftRadius??b,borderTopRightRadius:h?.depositStatus?.borderTopRightRadius??k})]})}var L=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},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:{flex:1,paddingTop:8},sheetListContent:{paddingBottom:56},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 Tl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=F();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ci.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:Ci.leftContent,children:[jsx(View,{style:[Ci.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:re(Se(e,"png"))},style:Ci.icon})}),jsxs(View,{style:Ci.textContainer,children:[jsx(Text,{style:[Ci.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ci.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx($e,{size:16,color:o.primary,strokeWidth:2})]})}var Ci=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 pa({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=F();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:fm.headerContainer,children:jsx(Text,{style:[fm.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(Tl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var fm=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function _l({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:c}=F(),[C,T]=useState(""),y=o.map(f=>r.find(_=>_.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),b=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),k=f=>{if(!C)return f;let _=C.toLowerCase();return f.filter(R=>R.name.toLowerCase().includes(_)||R.currency_code.toLowerCase().includes(_))},h=k(y),p=k(b),g=f=>{a(f),t(false),T("");},d=()=>{t(false),T("");};return jsxs(ft,{visible:e,onClose:d,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(Ir,{title:"Currency",showBack:false,onClose:d}),jsx(View,{style:wi.searchContainer,children:jsx(TextInput,{style:[wi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:m.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:C,onChangeText:T,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(ht,{style:wi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:wi.listContent,children:[jsx(pa,{title:"Popular currencies",currencies:h,selectedCurrency:n,onSelect:g}),h.length>0&&p.length>0&&jsx(View,{style:wi.sectionSpacer}),jsx(pa,{title:"All currencies",currencies:p,selectedCurrency:n,onSelect:g}),h.length===0&&p.length===0&&jsx(View,{style:wi.noResultsContainer,children:jsx(Text,{style:[wi.noResultsText,{color:c.container.subtitleColor,fontFamily:m.regular}],children:"No currencies found"})})]})})]})}var wi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:72},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function Od(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 vl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:m,onDepositError:c,borderTopLeftRadius:C,borderTopRightRadius:T,sheetBorderRadius:y}){let{colors:b,fonts:k,components:h}=F(),[p,g]=useState(""),[d,f]=useState("usd"),[_,R]=useState(false),[w,S]=useState(false),[x,W]=useState([]),[D,O]=useState(false),[P,j]=useState(null),[q,ae]=useState(null),[Me,Oe]=useState("amount"),[X,De]=useState(null),[he,xe]=useState(true),[Ue,we]=useState(null),[ne,Ie]=useState(false),mt=useRef(null),Ve=useRef(false);useEffect(()=>{mt.current=X;},[X]),useEffect(()=>{Ve.current=ne;},[ne]);let[lt,He]=useState([]),[Ne,je]=useState(true),[Be,J]=useState(60),[ce,nt]=useState([]),[it,ve]=useState([]),[be,ie]=useState(null),[de,Qt]=useState(null),[ue,le]=useState(true),[Ce,wt]=useState(null),[tt,pe]=useState(false),[Qe,ir]=useState(null),[xt,Pr]=useState(false),[Fr,U]=useState(false),[Q,se]=useState(false),[ze,E]=useState(null),te=r??Me,ye=useRef(null),me=ce.find(K=>K.currency_code.toLowerCase()===d.toLowerCase()),gt=useCallback(K=>{Oe(K),K==="quotes"?o?.(K,x.length):o?.(K);},[x.length,o]);useEffect(()=>{async function K(){try{let ge=await Ls();Qt(ge);}catch(ge){console.error("Error fetching user IP:",ge);}finally{le(false);}}K();},[]),useEffect(()=>{async function K(){try{let ge=await $o({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);He(ge.data);}catch(ge){console.error("Error fetching wallets:",ge),j("Failed to load wallet addresses");}finally{je(false);}}K();},[e,a,i,s,l,t]);let V=n||be?.symbol.toUpperCase()||"USDC",Or=Li(be?.icon_urls,"png")||be?.icon_url,z=Li(be?.chain_icon_urls,"png")||be?.chain_icon_url;useEffect(()=>{async function K(){try{let ge=await bc(t);nt(ge.data),ve(ge.preferred||[]);}catch(ge){console.error("Error fetching fiat currencies:",ge);}}K();},[t]),useEffect(()=>{if(_||ce.length===0||!de?.alpha2)return;let K=de.alpha2.toUpperCase(),ge=ce.find(Lt=>Lt.country_codes.includes(K));if(ge)f(ge.currency_code.toLowerCase()),!p&&!w&&g(String(ge.default_amount??100));else if(!p&&!w){let Lt=ce.find(po=>po.currency_code.toLowerCase()==="usd");Lt&&g(String(Lt.default_amount??100));}},[ce,de,_,p,w]),useEffect(()=>{if(ce.length!==0){if(ye.current!==null&&ye.current!==d){let K=ce.find(ge=>ge.currency_code.toLowerCase()===d.toLowerCase());K&&g(String(K.default_amount??100));}ye.current=d;}},[d,ce]),useEffect(()=>{async function K(){try{let ge=await fc({chain_type:i||"",chain_id:s||"",token_address:l||""},t);ie(ge);}catch(ge){console.error("Error fetching supported tokens:",ge);}}K();},[i,s,l,t]),useEffect(()=>{async function K(){if(!(!l||!s||!i)&&!ue){pe(true);try{let ge=await yc({country_code:de?.alpha2?.toUpperCase()||"US",subdivision_code:de?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);wt(ge);}catch(ge){console.error("Error fetching default onramp token:",ge);}finally{pe(false);}}}K();},[l,s,i,de,ue,t]),useEffect(()=>{let K=parseFloat(p);if(isNaN(K)||K<=0){W([]),ae(null);return}if(!Ce||tt){W([]),De(null);return}let ge=ce.find(po=>po.currency_code.toLowerCase()===d.toLowerCase());if(ge){if(K<ge.minimum_amount){W([]),De(null),ae(`Minimum amount is ${Od(d)}${ge.minimum_amount.toLocaleString()}`);return}if(K>ge.maximum_amount){W([]),De(null),ae(`Maximum amount is ${Od(d)}${ge.maximum_amount.toLocaleString()}`);return}}ae(null);let Lt=setTimeout(()=>{Ft(K);},500);return ()=>clearTimeout(Lt)},[p,d,t,Ce,tt,ce]);let Ft=async K=>{if(!Ce){j("Loading token information...");return}O(true),j(null);try{let ge={country_code:de?.alpha2?.toUpperCase()||"US",source_amount:K.toString(),source_currency:d.toLowerCase(),destination_currency:Ce.destination_currency,destination_network:Ce.destination_network,subdivision_code:de?.state||void 0},Lt=await hc(ge,t);W(Lt.data);let po=Ve.current,ks=mt.current;if(po&&ks){let mo=Lt.data.find(fn=>fn.service_provider===ks.service_provider);if(mo){if(De(mo),Lt.data.length>0){let fn=Lt.data[0];Ue||we(fn.service_provider),xe(mo.service_provider===Ue);}}else if(Lt.data.length>0){let fn=Lt.data[0];De(fn),we(fn.service_provider),xe(!0),Ie(!1);}}else if(Lt.data.length>0){let mo=Lt.data[0];De(mo),we(mo.service_provider),xe(!0);}J(60);}catch(ge){console.error("Failed to fetch quotes:",ge),j("Failed to fetch quotes. Please try again."),W([]);}finally{O(false);}};useEffect(()=>{if(x.length===0)return;let K=setInterval(()=>{J(ge=>{if(ge<=1){let Lt=parseFloat(p);return !isNaN(Lt)&&Lt>0&&Ft(Lt),60}return ge-1});},1e3);return ()=>clearInterval(K)},[x.length,p]);let St=K=>{(/^\d*\.?\d{0,2}$/.test(K)||K==="")&&(g(K),S(true));},Mr=K=>{g(K.toString()),S(true);},Xt=async()=>{if(X&&Ce)try{let K=Ce.destination_token_metadata.chain_type,ge=qo(lt,K);if(!ge?.address){j("Wallet address not available");return}let Lt={service_provider:X.service_provider,country_code:X.country_code?.toUpperCase()||de?.alpha2?.toUpperCase()||"US",source_currency:X.source_currency,source_amount:p,destination_currency:X.destination_currency,destination_network:X.destination_network,wallet_address:ge.address,subdivision_code:de?.state||void 0},po=await gc(Lt,t);ir({provider:X,sourceCurrency:d,sourceAmount:p,sessionUrl:po.url}),E(po.url),se(!0);}catch(K){console.error("Failed to create session:",K),j("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:K});}},Ii=Od(d),uo=()=>{se(false),gt("onramp"),m?.({message:"Payment flow completed"});},Ho=()=>jsx(oy,{visible:Q,onClose:uo,url:ze,providerName:X?.service_provider_display_name||"Complete Payment",colors:b,fonts:k,borderTopLeftRadius:y?.webView?.borderTopLeftRadius??C,borderTopRightRadius:y?.webView?.borderTopRightRadius??T});return te==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:$.amountViewContainer,children:[jsxs(ht,{style:$.scrollContainer,contentContainerStyle:$.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:$.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Pr(true),style:[$.currencyButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.input.borderRadius,borderWidth:h.input.borderWidth,borderColor:h.input.borderColor}],children:[me&&jsx(Image,{source:{uri:re(Se(me,"png"))},style:$.currencyIcon}),jsx(Text,{style:[$.currencyText,{color:h.card.titleColor,fontFamily:k.medium}],children:d.toUpperCase()}),jsx(Bt,{size:16,color:h.card.actionColor,strokeWidth:2})]})}),jsx(_l,{open:xt,onOpenChange:Pr,currencies:ce,preferredCurrencyCodes:it,selectedCurrency:d,onSelectCurrency:K=>{f(K.toLowerCase()),R(true);},borderTopLeftRadius:y?.currencyModal?.borderTopLeftRadius??C,borderTopRightRadius:y?.currencyModal?.borderTopRightRadius??T}),jsx(View,{style:$.amountContainer,children:jsxs(View,{style:$.amountInputRow,children:[jsx(Text,{style:[$.currencySymbol,{color:h.container.titleColor,fontFamily:k.medium}],children:Ii}),jsx(TextInput,{style:[$.amountInput,{color:h.container.titleColor,fontFamily:k.medium}],value:p,onChangeText:St,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:b.foregroundMuted})]})}),me?.suggested_amounts&&me.suggested_amounts.length>0&&jsx(View,{style:$.quickAmounts,children:me.suggested_amounts.map(K=>jsx(TouchableOpacity$1,{onPress:()=>Mr(K),style:[$.quickAmountButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.button.borderRadius,borderWidth:parseFloat(p)===K?2:h.button.borderWidth,borderColor:parseFloat(p)===K?b.primary:h.button.borderColor}],children:jsxs(Text,{style:[$.quickAmountText,{color:h.card.titleColor,fontFamily:k.medium}],children:[Ii,K.toLocaleString()]})},K))}),q&&jsx(Text,{style:[$.validationError,{color:b.error,fontFamily:k.regular}],children:q}),jsxs(View,{style:$.providerSection,children:[jsxs(View,{style:$.providerHeader,children:[jsx(Text,{style:[$.providerLabel,{color:h.card.labelColor,fontFamily:k.medium}],children:"Provider"}),x.length>0&&!D&&jsxs(Text,{style:[$.refreshText,{color:h.card.labelRightColor,fontFamily:k.regular}],children:["Refreshing in ",Be,"s"]})]}),jsx(nr,{cardTokens:h.depositCard.quoteProvider.card,onPress:D||x.length===0?void 0:()=>U(true),contentStyle:StyleSheet.flatten([$.providerButton,(D||x.length===0)&&$.disabled]),children:D?jsxs(View,{style:$.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[$.loadingText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"Finding best rates..."})]}):X?jsxs(View,{style:$.providerContent,children:[jsxs(View,{style:$.providerInfo,children:[he&&jsx(Text,{style:[$.autoPickedText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"Auto-picked for you"}),jsxs(View,{style:$.providerRow,children:[jsx(Image,{source:{uri:re(Oa(X.icon_urls,"png",X.icon_url))},style:$.providerIconImage},`provider-${X.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[$.providerName,{color:h.card.titleColor,fontFamily:k.medium}],children:X.service_provider_display_name}),jsxs(Text,{style:[$.bestPriceText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:[X.destination_amount.toFixed(2)," ",V]})]})]})]}),jsx(Tr,{size:20,color:h.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[$.noProviderText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:parseFloat(p)>0?"No providers available":"Enter an amount to see providers"})}),P&&jsx(Text,{style:[$.errorText,{color:b.error,fontFamily:k.regular}],children:P})]}),jsxs(ft,{visible:Fr,onClose:()=>U(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:y?.providerModal?.borderTopLeftRadius??C,borderTopRightRadius:y?.providerModal?.borderTopRightRadius??T,children:[jsx(Ir,{title:"Select Provider",showBack:false,onClose:()=>U(false)}),jsx(ht,{style:$.providerModalList,contentContainerStyle:$.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:$.quotesList,children:x.map(K=>{let ge=X?.service_provider===K.service_provider;return jsxs(nr,{cardTokens:h.depositCard.quoteProvider.card,onPress:()=>{De(K),Ie(true),xe(K.service_provider===Ue),U(false);},contentStyle:StyleSheet.flatten([$.quoteItem,ge&&{borderWidth:2,borderColor:b.primary}]),children:[jsxs(View,{style:$.quoteLeft,children:[jsx(Image,{source:{uri:re(Oa(K.icon_urls,"png",K.icon_url))},style:$.providerIconImage}),jsx(View,{children:jsx(Text,{style:[$.quoteName,{color:h.card.titleColor,fontFamily:k.medium}],children:K.service_provider_display_name})})]}),jsxs(View,{style:$.quoteRight,children:[jsxs(Text,{style:[$.quoteAmount,{color:h.card.textRightColor,fontFamily:k.medium}],children:[K.destination_amount.toFixed(2)," ",V]}),jsxs(Text,{style:[$.quoteSource,{color:h.card.subtextRightColor,fontFamily:k.regular}],children:["Fee: ",Ii,K.total_fee.toFixed(2)]})]})]},K.service_provider)})})})]})]}),jsx(View,{style:[$.continueButtonContainer,{backgroundColor:b.background}],children:jsx(View,{style:{opacity:D||Ne||!X||parseFloat(p)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:Xt,disabled:D||Ne||!X||parseFloat(p)<=0,style:[$.continueButton,{backgroundColor:h.container.buttonColor,borderRadius:h.button.borderRadius,borderWidth:h.button.borderWidth,borderColor:h.button.borderColor}],children:jsx(Text,{style:[$.continueButtonText,{color:h.container.buttonTitleColor,fontFamily:k.medium}],children:Ne?"Loading...":"Continue"})})})})]}),Ho()]}):te==="onramp"&&Qe?jsxs(View,{style:$.onrampContainer,children:[jsx(Image,{source:{uri:re(Oa(Qe.provider.icon_urls,"png",Qe.provider.icon_url))},style:$.onrampProviderIcon}),jsxs(Text,{style:[$.onrampTitle,{color:h.container.titleColor,fontFamily:k.medium}],children:["Complete transaction with ",Qe.provider.service_provider_display_name]}),jsx(Text,{style:[$.onrampSubtitle,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"You can close this modal."}),jsxs(View,{style:[$.flowDiagram,{backgroundColor:h.card.backgroundColor}],children:[jsxs(View,{style:$.flowStep,children:[jsx(Image,{source:{uri:Gt(`/icons/currencies/png/${Qe.sourceCurrency.toLowerCase()}.png`)},style:$.flowIconImage}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You use"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:Qe.sourceCurrency.toUpperCase()})]}),jsx(Tr,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:$.flowStep,children:[jsxs(View,{style:$.flowIconWithBadge,children:[jsx(Image,{source:{uri:Li(Ce?.destination_token_metadata?.icon_urls,"png")||Ce?.destination_token_metadata?.icon_url||Gt("/icons/tokens/png/usdc.png")},style:$.flowIconImageNoBadge}),jsx(Image,{source:{uri:Li(Ce?.destination_token_metadata?.chain?.icon_urls,"png")||Ce?.destination_token_metadata?.chain?.icon_url||Gt("/icons/networks/png/polygon.png")},style:[$.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You buy"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:"USDC"})]}),jsx(Tr,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:$.flowStep,children:[jsxs(View,{style:$.flowIconWithBadge,children:[jsx(Image,{source:{uri:Or||Gt("/icons/tokens/png/usdc.png")},style:$.flowIconImageNoBadge}),jsx(Image,{source:{uri:z||Gt("/icons/networks/png/polygon.png")},style:[$.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You receive"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:V})]})]}),jsx(View,{style:[$.onrampInfoBox,{backgroundColor:h.card.backgroundColor,borderRadius:h.card.borderRadius,borderWidth:h.card.borderWidth,borderColor:h.card.borderColor}],children:jsx(Text,{style:[$.onrampInfoText,{color:h.card.descriptionColor,fontFamily:k.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 oy({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,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:Si.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:Si.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx($e,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Si.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:Si.headerSpacer})]}),r&&jsx(View,{style:Si.container,children:jsx(WebView,{source:{uri:r},style:Si.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Si.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var Si=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"}}),$=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:48},continueButton:{paddingVertical:16,alignItems:"center"},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:{flex:1,paddingHorizontal:12,marginTop:8},providerModalListContent:{paddingBottom:72},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"},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 ay(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 ly(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ol({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=F(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=re(Se(e.destination_token_metadata,"png")||Gt("/icons/tokens/png/usdc.png")),m=i?"Deposit Processing":"Deposit Completed",c=ay(e.created_at||new Date().toISOString()),C=ly(e.source_amount_usd);return jsxs(nr,{cardTokens:a,onPress:t,contentStyle:sn.container,children:[jsxs(View,{style:sn.iconContainer,children:[jsx(Image,{source:{uri:l},style:sn.tokenIcon}),jsx(View,{style:[sn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:sn.textContainer,children:[jsx(Text,{style:[sn.title,{color:a.titleColor,fontFamily:o.medium}],children:m}),jsx(Text,{style:[sn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:sn.rightContainer,children:[jsx(Text,{style:[sn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:C}),jsx(Tr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var sn=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 bm(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 Cm(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 dy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var wm=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 uy(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 py({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,a=t.cardHover;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:ki.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[ki.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[ki.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:ki.textBlock,children:[jsx(Animated.View,{style:[ki.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[ki.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[ki.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var ki=StyleSheet.create({list:{paddingTop:16,paddingHorizontal:16,gap:12},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},icon:{width:40,height:40,borderRadius:20,marginRight:12},textBlock:{flex:1,gap:6},titleBar:{height:14,width:"65%",borderRadius:7},subtitleBar:{height:11,width:"45%",borderRadius:5.5},amountBar:{height:14,width:50,borderRadius:7,marginLeft:12}});function Ld({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=F(),[l,m]=useState(r),[c,C]=useState(false),[T,y]=useState(null),[b,k]=useState(false),h=useRef(null);useEffect(()=>{if(!e||!o)return;let w=async()=>{C(true);try{let W=[...(await Qo(o,n)).data].sort((D,O)=>{let P=D.created_at?new Date(D.created_at).getTime():0;return (O.created_at?new Date(O.created_at).getTime():0)-P});m(W);}catch(x){console.error("Failed to fetch executions:",x),m(r);}finally{C(false);}};w();let S=setInterval(w,1e4);return ()=>clearInterval(S)},[e,o,n,r]),useEffect(()=>{r.length>0&&m(w=>{let S=new Set(w.map(W=>W.id)),x=r.filter(W=>!S.has(W.id));return x.length>0?[...x,...w]:w});},[r]),useEffect(()=>{e||y(null);},[e]);let p=w=>{y(w);},g=()=>{y(null),k(false);},d=()=>{y(null),t();},f=()=>{if(!T)return null;let w=T,S=w.status==="pending"||w.status==="waiting"||w.status==="delayed",x=w.status==="succeeded",W=re(Se(w.destination_token_metadata,"png")||Gt("/icons/tokens/png/usdc.png")),D=w.provider_metadata?.details,O=D?.currencyIn,P=D?.currencyOut;O?.currency?.symbol||"USDC";P?.currency?.symbol||"USDC";let ae=Cm(w.source_amount_base_unit,w.source_token_metadata?.decimals),Me=Cm(w.destination_amount_base_unit,w.destination_token_metadata?.decimals),Oe=dy(w.source_amount_usd),X=bm(w.source_chain_type,w.source_chain_id),De=bm(w.destination_chain_type,w.destination_chain_id),he=()=>{w.explorer_url&&Linking.openURL(w.explorer_url);},xe=()=>{w.destination_explorer_url&&Linking.openURL(w.destination_explorer_url);};return jsxs(ht,{ref:h,style:fe.scrollContainer,contentContainerStyle:fe.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:fe.iconSection,children:[jsxs(View,{style:fe.iconWrapper,children:[jsx(Image,{source:{uri:W},style:fe.tokenIcon}),jsx(View,{style:[fe.statusBadge,{backgroundColor:S?a.warning:a.success,borderColor:a.background}],children:S?jsx(Bt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx($e,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:fe.statusRow,children:[jsx(View,{style:[fe.statusDot,{backgroundColor:S?a.warning:a.success}]}),jsx(Text,{style:[fe.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:S?"Processing":"Completed"})]}),jsx(Text,{style:[fe.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:uy(w.created_at||new Date().toISOString())})]}),jsxs(View,{style:[fe.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ae," ",Sm(w.source_currency)]})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[Me," ",Sm(w.destination_currency)]})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Oe})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:X})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:De})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ue=!b;k(Ue),Ue?setTimeout(()=>{h.current?.scrollToEnd({animated:true});},100):h.current?.scrollTo({y:0,animated:true});},style:fe.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[fe.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:b?"See less":"See more details"}),b?jsx(To,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(Bt,{size:14,color:s.container.actionColor,strokeWidth:2})]}),b&&jsxs(View,{style:[fe.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[w.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:he,style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:fe.cardRowRight,children:[jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(w.transaction_hash)}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]})]}),w.destination_explorer_url&&x&&jsxs(TouchableOpacity,{onPress:xe,style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:fe.cardRowRight,children:[jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(w.destination_transaction_hashes[0])}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},_=c&&l.length===0;return jsxs(Fragment,{children:[jsx(Ir,{title:T?"Deposit Details":"Deposit Tracker",onClose:d,showClose:!T,showBack:!!T,onBack:g}),T?f():_?jsx(py,{}):jsx(ht,{style:fe.scrollContainer,contentContainerStyle:fe.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:fe.emptyContainer,children:[jsx(Text,{style:[fe.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[fe.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:fe.executionsList,children:l.map(w=>jsx(Ol,{execution:w,onPress:()=>p(w)},w.id))})})]})}var fe=StyleSheet.create({scrollContainer:{flex:1,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:40},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 ma(e,t=true){let[r,o]=useState(null),[n,a]=useState(null),[i,s]=useState(false),[l,m]=useState(false),[c,C]=useState(null),[T,y]=useState(null);useEffect(()=>{!t||r||(s(true),Ls().then(p=>{o(p),C(null);}).catch(p=>{C(p instanceof Error?p:new Error(String(p)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(m(true),Vs(e).then(p=>{a(p),y(null);}).catch(p=>{y(p instanceof Error?p:new Error(String(p)));}).finally(()=>{m(false);}));},[t,e,n]);let b=i||l,k=c||T||null,h=null;if(r&&n){let p=n.blocked_country_codes||[],g=r.alpha2.toUpperCase();h=!p.some(d=>d.toUpperCase()===g);}return {isAllowed:h,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:b,error:k}}var Wd="unifold_recent_tokens",yy=5,Im=[{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 Al(){try{let e=await Wc.getItem(Wd);return e?JSON.parse(e):[]}catch{return []}}async function by(e){try{let r=(await Al()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,yy);await Wc.setItem(Wd,JSON.stringify(o));}catch{}}async function Cy(e){try{let r=(await Al()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Wc.setItem(Wd,JSON.stringify(r)),r}catch{return []}}function Ed({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:c}=F(),[C,T]=useState(""),[y,b]=useState([]);useEffect(()=>{e&&Al().then(b);},[e]),useEffect(()=>{e||T("");},[e]);let k=useMemo(()=>{let _=[];return r.forEach(R=>{R.chains.forEach(w=>{_.push({token:R,chain:w});});}),_},[r]),h=useMemo(()=>{let _=[],R=new Set,w=(S,x,W,D)=>{let O=`${S}-${x}:${W}`;if(R.has(O))return;let P=r.find(q=>q.symbol===S);if(!P)return;let j=P.chains.find(q=>q.chain_type===x&&q.chain_id===W);j&&(R.add(O),_.push({token:P,chain:j,isRecent:D}));};return y.forEach(S=>{w(S.symbol,S.chainType,S.chainId,true);}),Im.forEach(S=>{w(S.symbol,S.chainType,S.chainId,false);}),_},[r,y]),p=useMemo(()=>{if(!C.trim())return k;let _=C.toLowerCase();return k.filter(({token:R,chain:w})=>R.symbol.toLowerCase().includes(_)||R.name.toLowerCase().includes(_)||w.chain_name.toLowerCase().includes(_))},[k,C]),g=(_,R,w)=>Im.some(S=>S.symbol===_&&S.chainType===R&&S.chainId===w),d=async(_,R)=>{let w=`${R.chain_type}:${R.chain_id}`;if(!g(_.symbol,R.chain_type,R.chain_id)){await by({symbol:_.symbol,chainType:R.chain_type,chainId:R.chain_id});let S=await Al();b(S);}T(""),a(_.symbol,w),t();},f=async(_,R)=>{let w=await Cy({symbol:_.symbol,chainType:R.chain_type,chainId:R.chain_id});b(w);};return jsxs(ft,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:pt.header,children:[jsx(View,{style:pt.headerSpacer}),jsx(Text,{style:[pt.headerTitle,{color:c.header.titleColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:pt.closeButton,children:jsx(st,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:pt.searchContainer,children:jsx(TextInput,{style:[pt.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:m.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:C,onChangeText:T,autoCapitalize:"none",autoCorrect:false})}),h.length>0&&!C&&jsxs(View,{style:pt.quickSelectSection,children:[jsx(Text,{style:[pt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:m.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:pt.quickSelectScroll,children:h.map(({token:_,chain:R,isRecent:w})=>{let S=`${R.chain_type}:${R.chain_id}`;_.symbol===o&&S===n;return jsxs(View,{children:[w&&jsx(TouchableOpacity$1,{onPress:()=>f(_,R),style:pt.removeButton,children:jsx(st,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>d(_,R),activeOpacity:.7,style:[pt.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:pt.tokenIconContainer,children:[jsx(Image,{source:{uri:re(Se(_,"png"))},style:pt.quickSelectIcon}),jsx(Image,{source:{uri:re(Se(R,"png"))},style:[pt.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:pt.quickSelectText,children:[jsx(Text,{style:[pt.quickSelectSymbol,{color:c.card.titleColor,fontFamily:m.medium}],children:_.symbol}),jsx(Text,{style:[pt.quickSelectChain,{color:c.card.subtitleColor,fontFamily:m.regular}],children:R.chain_name})]})]})]},`quick-${_.symbol}-${S}`)})})]}),jsx(Text,{style:[pt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:m.regular}],children:"All supported tokens"}),jsx(ht,{style:pt.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:pt.tokenListContent,children:p.length===0?jsx(View,{style:pt.emptyState,children:jsx(Text,{style:[pt.emptyText,{color:l.foregroundMuted,fontFamily:m.regular}],children:"No tokens found"})}):p.map(({token:_,chain:R})=>{let w=`${R.chain_type}:${R.chain_id}`,S=_.symbol===o&&w===n;return jsxs(TouchableOpacity$1,{onPress:()=>d(_,R),activeOpacity:.7,style:[pt.tokenItem,{backgroundColor:S?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:pt.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:re(Se(_,"png"))},style:pt.tokenIcon}),jsx(Image,{source:{uri:re(Se(R,"png"))},style:[pt.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:pt.tokenInfo,children:[jsx(Text,{style:[pt.tokenSymbol,{color:c.card.titleColor,fontFamily:m.medium}],children:_.symbol}),jsx(Text,{style:[pt.tokenChainName,{color:c.card.subtitleColor,fontFamily:m.regular}],children:R.chain_name})]}),jsxs(Text,{style:[pt.minDeposit,{color:c.card.labelColor,fontFamily:m.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:m.regular},children:["$",R.minimum_deposit_amount_usd]})]})]},`${_.symbol}-${w}`)})})]})}var pt=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:72,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 El=(e,t)=>`${t}:${e}`,xy=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Md({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:c="auto_ui",onExecutionsChange:C,onDepositSuccess:T,onDepositError:y,wallets:b,borderTopLeftRadius:k,borderTopRightRadius:h,sheetBorderRadius:p}){let{colors:g,fonts:d,components:f}=F(),_=s&&l?`${s}:${l}`:"solana:mainnet",[R,w]=useState("USDC"),[S,x]=useState(_),[W,D]=useState([]),[O,P]=useState(!b?.length),j=b?.length?b:W,[q,ae]=useState([]),[Me,Oe]=useState(true),[X,De]=useState(false),[he,xe]=useState(false),[Ue,we]=useState(false),[ne,Ie]=useState([]),[mt,Ve]=useState(new Map),[lt]=useState(()=>new Date),[He,Ne]=useState(null),[je,Be]=useState(false),[J,ce]=useState(null),[nt,it]=useState(false),ve=new Map;q.forEach(se=>{se.chains.forEach(ze=>{let E=`${ze.chain_type}:${ze.chain_id}`;ve.has(E)||ve.set(E,ze);});});let be=Array.from(ve.values()),ie=xy(S),de=be.find(se=>se.chain_type===ie.chainType&&se.chain_id===ie.chainId),Qt=de?.chain_type||"ethereum",ue=qo(j,Qt),le=ue?.address||"",Ce=useRef(false);useEffect(()=>{async function se(){try{Oe(!0),Ne(null);let E=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(ae(E.data),E.data.length>0&&!Ce.current){Ce.current=!0;let te,ye;if(s&&l)if(m)for(let me of E.data){let gt=me.chains.find(V=>V.chain_type===s&&V.chain_id===l&&V.token_address.toLowerCase()===m.toLowerCase());if(gt){te=me,ye=gt;break}}else for(let me of E.data){let gt=me.chains.find(V=>V.chain_type===s&&V.chain_id===l);if(gt){te=me,ye=gt;break}}if(!te&&a)for(let me of E.data){let gt=me.chains.find(V=>V.token_address.toLowerCase()===a.toLowerCase());if(gt){te=me,ye=gt;break}}te||(te=E.data.find(me=>me.symbol==="USDC"),te&&te.chains.length>0&&(ye=te.chains[0])),te||(te=E.data.find(me=>me.symbol==="USDT"),te&&te.chains.length>0&&(ye=te.chains[0])),te||(te=E.data[0],te.chains.length>0&&(ye=te.chains[0])),te&&w(te.symbol),ye&&x(El(ye.chain_id,ye.chain_type));}}catch(ze){console.error("Error fetching supported tokens:",ze),Ne("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:ze});}finally{Oe(false);}}se();},[t,a,n,o,s,l,m,y]),useEffect(()=>{C&&C(ne);},[ne,C]),useEffect(()=>{if(b?.length){P(false);return}if(W.length>0){P(false);return}let se=null,ze=false,E=async()=>{if(!ze){P(true);try{let te=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);ze||(D(te.data),Ne(null),P(!1));}catch(te){console.error("Error fetching wallets, retrying in 5s:",te),ze||(Ne(te instanceof Error?te.message:"Failed to load wallets"),P(false),se=setTimeout(E,5e3));}}};return E(),()=>{ze=true,se&&clearTimeout(se);}},[e,r,o,n,a,t,b,W.length]);let wt=ue?.id??"",{showWaitingUi:tt,handleIveDeposited:pe}=ca({depositConfirmationMode:c,depositAddress:le,chain:S,externalUserId:e,publishableKey:t,modalOpenedAt:lt,depositWalletId:wt,depositExecutions:ne,trackedExecutions:mt,setDepositExecutions:Ie,setTrackedExecutions:Ve,setLatestExecution:ce,setShowStatusSheet:Be,onDepositSuccess:T,onExecutionsChange:C,onDepositError:y});useEffect(()=>{if(!q.length)return;let se=q.find(E=>E.symbol===R);if(!se||se.chains.length===0)return;if(!se.chains.some(E=>El(E.chain_id,E.chain_type)===S)){let E=se.chains[0];x(El(E.chain_id,E.chain_type));}},[R,q,S]);let Qe=q.find(se=>se.symbol===R),xt=(Qe?.chains||[]).find(se=>El(se.chain_id,se.chain_type)===S),Pr=async()=>{if(le)try{Clipboard.setString(le),De(!0),setTimeout(()=>De(!1),2e3);}catch(se){console.error("Failed to copy:",se);}},Fr=xt?.estimated_price_impact_percent??0,U=xt?.max_slippage_percent??.25,Q=xt?.minimum_deposit_amount_usd??3;return Me?jsxs(View,{style:H.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:g.primary}),jsx(Text,{style:[H.loadingText,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Loading currencies..."})]}):He&&q.length===0?jsxs(View,{style:H.errorContainer,children:[jsx(Text,{style:[H.errorText,{color:g.error,fontFamily:d.regular}],children:He}),jsx(Text,{style:[H.errorHint,{color:g.foregroundMuted,fontFamily:d.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:d.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>we(true),disabled:Me||q.length===0,style:[H.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:Me?jsxs(View,{style:H.tokenSelectorLoading,children:[jsx(View,{style:[H.loadingIcon,{backgroundColor:g.cardHover}]}),jsxs(View,{style:H.loadingTextContainer,children:[jsx(View,{style:[H.loadingLine,{backgroundColor:g.cardHover,width:60}]}),jsx(View,{style:[H.loadingLine,{backgroundColor:g.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:H.tokenIconWrapper,children:[Qe&&jsx(Image,{source:{uri:re(Se(Qe,"png"))},style:H.tokenMainIcon}),(xt||de)&&jsx(Image,{source:{uri:re(Se(xt||de,"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:d.semibold}],children:Qe?.symbol||R}),jsx(Text,{style:[H.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:d.regular}],numberOfLines:1,children:xt?.chain_name||de?.chain_name||"Select network"})]}),jsxs(View,{style:H.tokenSelectorRight,children:[jsxs(Text,{style:[H.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:d.medium}],children:["$",Q," min"]}),jsx(Tr,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Ed,{visible:Ue,onClose:()=>we(false),tokens:q,selectedToken:R,selectedChainKey:S,onSelect:(se,ze)=>{w(se),x(ze);},borderTopLeftRadius:p?.tokenSelector?.borderTopLeftRadius??k,borderTopRightRadius:p?.tokenSelector?.borderTopRightRadius??h}),jsx(View,{style:H.qrContainer,children:jsx(View,{style:[H.qrWrapper,{backgroundColor:g.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:g.primary}),jsx(Text,{style:[H.loadingText,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Loading..."})]}):le?jsx(us,{value:le,size:180,logoUri:re(Se(xt,"png")||Gt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:H.qrLoading,children:jsx(Text,{style:[H.errorText,{color:g.error,fontFamily:d.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:d.medium}],children:"Deposit Address"}),X&&jsxs(View,{style:H.copiedIndicator,children:[jsx($e,{size:14,color:g.success,strokeWidth:2}),jsx(Text,{style:[H.copiedText,{color:g.success,fontFamily:d.regular}],children:"Copied"})]})]}),jsxs(nr,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!O&&le?Pr:void 0,contentStyle:H.addressBox,children:[jsx(Text,{style:[H.addressText,{color:f.card.titleColor,fontFamily:d.regular}],numberOfLines:2,children:O?"Loading...":le||"No address available"}),jsx(View,{style:H.addressCopyIcon,children:jsx(No,{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:()=>xe(!he),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(zr,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:H.chevronContainer,children:he?jsx(To,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Bt,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),he&&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(gn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Price impact: ",Fr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(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(yn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Slippage: Auto \u2022 ",U.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(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(xa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(wl,{depositConfirmationMode:c,depositAddress:le,showWaitingUi:tt,latestExecution:J,onIveDeposited:pe}),jsx(TouchableOpacity$1,{style:H.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[H.termsText,{color:g.primary,fontFamily:d.regular}],children:"Terms apply"})}),jsxs(ft,{visible:nt,onClose:()=>it(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:p?.infoSheet?.borderTopLeftRadius??k,borderTopRightRadius:p?.infoSheet?.borderTopRightRadius??h,children:[jsxs(View,{style:[H.sheetHeader,{borderBottomColor:g.border}],children:[jsx(View,{style:H.sheetHeaderSpacer}),jsx(Text,{style:[H.sheetTitle,{color:f.header.titleColor,fontFamily:d.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>it(false),style:H.sheetCloseButton,children:jsx(st,{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(gn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Price Impact"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[Fr.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:d.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(yn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Max Slippage"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[U.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:d.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."})]})]})]}),J&&jsx(ps,{visible:je,status:J.status,tokenIconUrl:J.destination_token_metadata?.icon_urls?.find(se=>se.format==="png")?.url||J.destination_token_metadata?.icon_url||Se(Qe,"png"),explorerUrl:J.explorer_url,completionExplorerUrl:J.destination_explorer_url,date:J.created_at?new Date(J.created_at):void 0,amountUsd:J.source_amount_usd?parseFloat(J.source_amount_usd):void 0,onClose:()=>Be(false),borderTopLeftRadius:p?.depositStatus?.borderTopLeftRadius??k,borderTopRightRadius:p?.depositStatus?.borderTopRightRadius??h})]})}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 cn={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 Py(){let{colors:e,components:t}=F(),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:[$n.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[$n.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:$n.textBlock,children:[jsx(Animated.View,{style:[$n.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[$n.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:$n.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[$n.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:$n.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var $n=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 Fy({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,showBalance:y=false,hideDepositTracker:b=false,enableStripeLinkPay:k=false,StripeOnrampComponent:h,stripeOnrampEmail:p,stripeOnrampPhone:g,stripeMerchantIdentifier:d,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:_,stripeTheme:R,depositConfirmationMode:w="auto_ui",transferInputVariant:S="double_input",initialScreen:x="main",onDepositSuccess:W,onDepositError:D,sheetBorderRadius:O}){let P=O?.globalBorderTopLeftRadius,j=O?.globalBorderTopRightRadius,{colors:q,fonts:ae}=F(),[Me,Oe]=useState([]),[X,De]=useState(null),[he,xe]=useState("amount"),Ue=x==="tracker"&&!b?"tracker":x==="transfer"?"transfer":x==="card"?"card":"main",we=Ue==="main",[ne,Ie]=useState(Ue),{isAllowed:mt,isLoading:Ve}=ma(o,e);useEffect(()=>{if(!e||X)return;let ue=false;return Vs(o).then(async le=>{if(ue)return;let Ce=[];for(let wt of le?.transfer_crypto?.networks??[]){let tt=wt.icon_urls.find(pe=>pe.format==="png")?.url||wt.icon_urls.find(pe=>pe.format==="svg")?.url;tt&&Ce.push(re(tt));}for(let wt of le?.payment_networks?.networks??[]){let tt=wt.icon_urls.find(pe=>pe.format==="png")?.url||wt.icon_urls.find(pe=>pe.format==="svg")?.url;tt&&Ce.push(re(tt));}Ce.length>0&&await dd(Ce),ue||De(le);}).catch(console.error),()=>{ue=true;}},[e,X,o]);let lt=()=>{t();};useEffect(()=>{e&&(Ie(Ue),xe("amount"));},[e,Ue]);let He=useCallback(()=>{we?(Ie("main"),xe("amount")):lt();},[we,lt]),Ne=Me.filter(ue=>ue.status==="pending"||ue.status==="waiting").length,Be=!!(i&&s&&l&&m&&o)&&y!==false&&!!X,J=Ve||e&&!X,ce=mt===false,nt=null;if(ne==="stripe"&&h){let ue=jsx(h,{publishableKey:o,email:p,phone:g,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,merchantIdentifier:d,paymentSelectorPosition:f,skipSuccessConfirmation:_,onClose:He});nt=R?jsx(Di,{...R,children:ue}):ue;}let it=ne==="stripe"?.9:ne==="transfer"||ne==="card"?.94:ne==="tracker"?.6:ne==="main"?.5:void 0,ve=ne==="tracker"||ne==="main"?.9:void 0,ie={main:O?.main,transfer:O?.transferCrypto,card:O?.buyWithCard,stripe:O?.stripeLinkPay,tracker:O?.depositsTracker}[ne],de=ie?.borderTopLeftRadius??P,Qt=ie?.borderTopRightRadius??j;return jsxs(ft,{visible:e,onClose:ne==="main"?lt:He,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:it,maxHeightPercent:ve,borderTopLeftRadius:de,borderTopRightRadius:Qt,children:[ne==="main"&&jsxs(Fragment,{children:[jsx(Ir,{title:n,showBack:false,onClose:lt,showBalance:Be,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:X?.project_name}),J&&jsx(Py,{}),!J&&ce&&jsxs(View,{style:kr.centeredContainer,children:[jsx(View,{style:[kr.iconContainer,{backgroundColor:q.cardHover}],children:jsx(Is,{size:32,color:q.foreground,strokeWidth:1.5})}),jsx(Text,{style:[kr.blockedTitle,{color:q.foreground,fontFamily:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[kr.blockedDescription,{color:q.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!J&&!ce&&jsxs(View,{style:kr.optionsContainer,children:[jsx(oa,{onPress:()=>Ie("transfer"),title:cn.transferCrypto.title,subtitle:cn.transferCrypto.subtitle,featuredTokens:X?.transfer_crypto?.networks}),jsx(ia,{onPress:()=>Ie("card"),title:cn.depositWithCard.title,subtitle:cn.depositWithCard.subtitle,paymentNetworks:X?.payment_networks?.networks}),k&&h&&jsx(la,{onPress:()=>Ie("stripe"),title:cn.stripeLinkPay.title,subtitle:cn.stripeLinkPay.subtitle}),!b&&jsx(sa,{onPress:()=>Ie("tracker"),title:cn.depositTracker.title,subtitle:cn.depositTracker.subtitle,badge:Ne>0?Ne:void 0})]})]}),ne==="transfer"&&jsxs(Fragment,{children:[jsx(Ir,{title:cn.transferCrypto.title,showBack:false,onClose:He,showBalance:Be,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:X?.project_name}),Ve&&jsx(View,{style:[kr.centeredContainer,kr.centeredFlex],children:jsx(ActivityIndicator,{color:q.primary})}),!Ve&&ce&&jsxs(View,{style:[kr.centeredContainer,kr.centeredFlex],children:[jsx(View,{style:[kr.iconContainer,{backgroundColor:q.cardHover}],children:jsx(Is,{size:32,color:q.foreground,strokeWidth:1.5})}),jsx(Text,{style:[kr.blockedTitle,{color:q.foreground,fontFamily:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[kr.blockedDescription,{color:q.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!Ve&&!ce&&jsx(ht,{style:kr.transferScrollContainer,contentContainerStyle:kr.scrollContent,showsVerticalScrollIndicator:false,children:S==="single_input"?jsx(Md,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,depositConfirmationMode:w,onExecutionsChange:Oe,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(kl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,depositConfirmationMode:w,onExecutionsChange:Oe,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),ne==="card"&&jsxs(Fragment,{children:[jsx(Ir,{title:`Deposit ${a||"USDC"}`,showBack:he==="onramp",onBack:()=>xe("amount"),onClose:He,showBalance:Be,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:X?.project_name}),jsx(View,{style:kr.buyWithCardContainer,children:jsx(vl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,onDepositSuccess:W,onDepositError:D,view:he,onViewChange:ue=>xe(ue),borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),ne==="stripe"&&nt&&jsx(View,{style:kr.stripeLinkPayContainer,children:nt}),ne==="tracker"&&jsx(Ld,{active:ne==="tracker",onClose:He,executions:Me,externalUserId:r,publishableKey:o})]})}function Ul({theme:e="auto",...t}){return jsx(Fy,{...t})}var kr=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 Hl(e,t=true){return Xo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Va(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Hd(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await Gn(a),m=null,c=null,C=null,T=null,y,b,k,h=l.data.some(p=>p.chains.some(g=>{let d=g.chain_type===t&&g.chain_id===r&&g.token_address.toLowerCase()===o.toLowerCase();return d&&(m=g.minimum_deposit_amount_usd,c=g.estimated_processing_time,C=g.max_slippage_percent,T=g.estimated_price_impact_percent,k=g.chain_name,b=p),d}));if(b){let p=Se(b,"png");p&&(y=re(p));}return {isSupported:h,minimumAmountUsd:m,estimatedProcessingTime:c,maxSlippagePercent:C,priceImpactPercent:T,errorMessage:h?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:y,chainName:k}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Nd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await La(t,r,o,n,a);if(l.balance){let m=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",C=l.balance.amount,T=BigInt(C),y=BigInt(10**m),b=T/y,h=(T%y).toString().padStart(m,"0").replace(/0+$/,""),p=h?`${b}.${h}`:b.toString();return {balanceBaseUnit:C,balanceHuman:p,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:m,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 Dy=2500,Vy=3e3,Ly=6e4;function jd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,m]=useState(false),c=useRef(new Date),C=useRef(new Map),T=useRef(false),y=useRef(n),b=useRef(a);return useEffect(()=>{y.current=n;},[n]),useEffect(()=>{b.current=a;},[a]),useEffect(()=>{o&&!T.current&&(c.current=new Date,C.current.clear()),o||C.current.clear(),T.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let k=c.current,h=async()=>{try{let g=await Qo(e,t,"withdraw"),d=new Date(k.getTime()-Ly),f=[...g.data].sort((S,x)=>{let W=S.created_at?new Date(S.created_at).getTime():0;return (x.created_at?new Date(x.created_at).getTime():0)-W}),_=["pending","waiting","delayed"],R=["succeeded","failed"],w=null;for(let S of f){let x=S.created_at?new Date(S.created_at):null;if(!x||x<d)continue;let W=C.current.get(S.id);if(!W){w=S;break}if(_.includes(W)&&R.includes(S.status)){w=S;break}}if(w){let S=w,x=S.created_at?new Date(S.created_at):null;if(!x||x<c.current)return;let W=C.current.get(S.id);C.current.set(S.id,S.status),s(D=>{let O=D.findIndex(P=>P.id===S.id);if(O>=0){let P=[...D];return P[O]=S,P}return [...D,S]}),S.status==="succeeded"&&(!W||_.includes(W))?y.current?.({message:"Withdrawal completed successfully",transaction:S}):S.status==="failed"&&W!=="failed"&&b.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:S});}}catch(g){console.error("Failed to fetch withdraw executions:",g),b.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:g});}};h();let p=setInterval(h,Dy);return m(true),()=>{clearInterval(p),m(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let k=async()=>{try{await Sc({deposit_wallet_id:r},t);}catch{}};k();let h=setInterval(k,Vy);return ()=>clearInterval(h)},[o,r,t]),{executions:i,isPolling:l}}var $d=(e,t)=>`${t}:${e}`;function ga({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:a=false,tokenLabel:i="Receive token",chainLabel:s="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:m,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:C}){let{colors:T,fonts:y,components:b}=F(),[k,h]=useState(false),[p,g]=useState(false),d=b.card,f=t?e.find(S=>S.symbol===t):void 0,_=f?.chains||[],R=r?_.find(S=>$d(S.chain_id,S.chain_type)===r):void 0,w={backgroundColor:d.backgroundColor,borderRadius:d.borderRadius,borderWidth:d.borderWidth||1,borderColor:d.borderColor};return jsxs(View,{style:Xe.row,children:[jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:y.medium}],children:i}),jsxs(TouchableOpacity,{style:[Xe.selectButton,w],onPress:()=>!a&&e.length>0&&h(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Loading..."}):f?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:re(Se(f,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:y.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Select receive token"}),jsx(Bt,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:y.medium}],children:s}),jsxs(TouchableOpacity,{style:[Xe.selectButton,w,(!f||_.length===0)&&Xe.disabled],onPress:()=>!a&&f&&_.length>0&&g(true),activeOpacity:.7,disabled:a||!f||_.length===0,children:[R?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:re(Se(R,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:y.medium}],numberOfLines:1,children:R.chain_name})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Chain"}),jsx(Bt,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(ft,{visible:k,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:m,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:T.foreground,fontFamily:y.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>h(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:e,keyExtractor:S=>S.symbol,contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:S})=>jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:S.symbol===t?T.cardHover:"transparent"}],onPress:()=>{o(S.symbol),h(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:re(Se(S,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:T.foreground,fontFamily:y.medium}],children:S.symbol}),jsx(Text,{style:[Xe.pickerItemSub,{color:T.foregroundMuted,fontFamily:y.regular}],children:S.name}),S.symbol===t&&jsx($e,{size:18,color:T.primary,strokeWidth:2.5})]})})]}),jsxs(ft,{visible:p,onClose:()=>g(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c,borderTopRightRadius:C,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:T.foreground,fontFamily:y.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>g(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:_,keyExtractor:S=>$d(S.chain_id,S.chain_type),contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:S})=>{let x=$d(S.chain_id,S.chain_type);return jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:x===r?T.cardHover:"transparent"}],onPress:()=>{n(x),g(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:re(Se(S,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:T.foreground,fontFamily:y.medium}],children:S.chain_name}),x===r&&jsx($e,{size:18,color:T.primary,strokeWidth:2.5})]})}})]})]})}var Xe=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 qd(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 Xo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>wc({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 Ey(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 zy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function jl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:m,balanceData:c,isLoadingBalance:C,minimumWithdrawAmountUsd:T,estimatedProcessingTime:y,maxSlippagePercent:b,priceImpactPercent:k,canWithdraw:h,onDepositWalletCreation:p,onWithdraw:g,onWithdrawError:d,onWithdrawSubmitted:f,onViewTracker:_}){let R="https://unifold.io/terms",w="https://unifold.io/support",{colors:S,fonts:x,components:W}=F(),[D,O]=useState(s||""),[P,j]=useState(""),[q,ae]=useState(false),[Me,Oe]=useState(null),[X,De]=useState(false),[he,xe]=useState(""),Ue=useRef(null);useEffect(()=>{O(s||""),j(""),Oe(null);},[s]);let we=D.trim();useEffect(()=>{let pe=setTimeout(()=>xe(we),500);return ()=>clearTimeout(pe)},[we]);let{data:ne,isLoading:Ie,error:mt}=qd({chainType:m?.chain_type,chainId:m?.chain_id,tokenAddress:m?.token_address,recipientAddress:he,publishableKey:e,enabled:he.length>5&&!!m}),Ve=we!==he,lt=useMemo(()=>!we||we.length<=5||Ve||Ie?null:mt?"Invalid address":ne&&!ne.valid?ne.failure_code==="account_not_found"?`Account not found on ${m?.chain_name}`:ne.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${m?.chain_name}`:"Invalid address":null,[we,Ve,Ie,mt,ne,m,l]),He=!Ve&&!!ne?.valid&&!lt,Ne=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),je=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),Be=n||c?.symbol||"TOKEN",J=c?.decimals??6,ce=useMemo(()=>{let pe=parseFloat(P);return !pe||pe<=0?0:pe},[P]),nt=useMemo(()=>{let pe=parseFloat(P);return !pe||pe<=0?0:pe*Ne},[P,Ne]),it=useCallback(async()=>{try{let Qe=await tf("expo-clipboard").getStringAsync();Qe&&(O(Qe.trim()),Oe(null));}catch{}},[]),ve=useCallback(()=>{je<=0||j(c?.balanceHuman??"0");},[je,c]),be=T!==null&&nt>0&&nt<T,ie=ce>0&&je>0&&ce>je,de=we.length>0&&P.trim().length>0&&ce>0&&He&&!be&&!ie&&!!c,Qt=useCallback(async()=>{if(!(!l||!m||!de||!h)){ae(true),Oe(null);try{let pe=await p({destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,recipientAddress:we}),Qe=My(ce,J),ir=zy(ce,J),xt={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:Be,sourceTokenIconUrl:i,destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,destinationTokenSymbol:l.symbol,destinationChainName:m.chain_name,destinationTokenIconUrl:l?re(Se(l,"png")):void 0,amount:ir,amountBaseUnit:Qe,submittedAt:new Date,withdrawIntentAddress:pe.address,recipientAddress:we};await g(xt),f(xt);}catch(pe){let Qe=pe instanceof Error?pe.message:"Withdrawal failed. Please try again.",ir=Qe.length>120?"Withdrawal failed. Please try again.":Qe;Oe(ir),d?.({message:Qe,error:pe,code:"WITHDRAW_FAILED"});}finally{ae(false);}}},[l,m,de,h,we,t,r,o,Be,i,P,je,c,ce,J,nt,p,g,d,f]),ue=W.input,le=W.card,Ce=W.button,wt=lt?S.error:ue.borderColor,tt=useMemo(()=>q?"Processing...":ie?"Insufficient balance":be?`Minimum $${T?.toFixed(2)}`:Me?"Withdrawal failed \u2014 try again":"Withdraw",[q,ie,be,T,Me]);return jsxs(View,{style:Je.container,children:[jsxs(View,{children:[jsxs(View,{style:Je.labelRow,children:[jsx(Text,{style:[Je.label,{color:le.labelColor,fontFamily:x.medium}],children:"Recipient address"}),(Ve||Ie)&&we.length>5?jsx(ActivityIndicator,{size:"small",color:S.primary}):jsx(TouchableOpacity,{onPress:it,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(iu,{size:16,color:S.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Je.inputRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:wt}],children:jsx(TextInput,{style:[Je.textInput,{color:ue.textColor,fontFamily:x.regular}],placeholder:"Enter wallet address",placeholderTextColor:ue.placeholderColor,value:D,onChangeText:pe=>{O(pe),Oe(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Ue.current?.focus()})}),lt?jsx(Text,{style:[Je.errorText,{color:S.error,fontFamily:x.regular}],children:lt}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Je.label,{color:le.labelColor,fontFamily:x.medium,paddingBottom:8}],children:["Amount",T!=null&&T>0&&jsx(Text,{style:{color:S.warning,fontFamily:x.regular},children:` ($${T.toFixed(2)} min)`})]}),jsxs(View,{style:[Je.amountRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:ue.borderColor}],children:[jsx(TextInput,{ref:Ue,style:[Je.amountInput,{color:ue.textColor,fontFamily:x.regular}],placeholder:"0.00",placeholderTextColor:ue.placeholderColor,value:P,onChangeText:pe=>{(pe===""||/^\d*\.?\d*$/.test(pe))&&(j(pe),Oe(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[Je.unitLabel,{color:S.foregroundMuted,fontFamily:x.medium}],children:Be}),jsx(TouchableOpacity,{style:[Je.maxButton,{backgroundColor:`${S.primary}20`}],onPress:ve,activeOpacity:.7,children:jsx(Text,{style:[Je.maxText,{color:S.primary,fontFamily:x.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Je.detailsCard,{marginTop:24,backgroundColor:le.backgroundColor,borderRadius:le.borderRadius,borderWidth:le.borderWidth||1,borderColor:le.borderColor}],children:[jsx(TouchableOpacity,{style:Je.detailsToggle,onPress:()=>De(!X),activeOpacity:.7,children:jsxs(View,{style:Je.detailsRow,children:[jsx(View,{style:[Je.detailIcon,{backgroundColor:le.iconBackgroundColor,borderRadius:le.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:le.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Je.detailsLabel,{color:le.titleColor,fontFamily:x.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:x.medium},children:Ey(y)})]}),jsx(View,{style:{transform:[{rotate:X?"180deg":"0deg"}]},children:jsx(Bt,{size:16,color:le.actionColor,strokeWidth:2})})]})}),X&&jsxs(View,{style:Je.detailsExpanded,children:[jsxs(View,{style:Je.detailsRow,children:[jsx(View,{style:[Je.detailIcon,{backgroundColor:le.iconBackgroundColor,borderRadius:le.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:le.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Je.detailsLabel,{color:le.titleColor,fontFamily:x.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:["Auto \u2022 ",(b??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Je.detailsRow,children:[jsx(View,{style:[Je.detailIcon,{backgroundColor:le.iconBackgroundColor,borderRadius:le.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:le.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Je.detailsLabel,{color:le.titleColor,fontFamily:x.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:[(k??0).toFixed(2),"%"]})]})]})]})]}),Me&&jsx(Text,{style:[Je.errorText,{color:S.error,fontFamily:x.regular,textAlign:"center"}],children:Me}),jsxs(View,{style:Je.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Je.withdrawButton,{backgroundColor:Ce.primaryBackground,borderRadius:Ce.borderRadius,borderWidth:Ce.borderWidth,borderColor:Ce.borderColor,opacity:!de||!h||q?.5:1}],onPress:Qt,disabled:!de||!h||q,activeOpacity:.8,children:[q&&jsx(ActivityIndicator,{size:"small",color:Ce.primaryText}),jsx(Text,{style:[Je.withdrawButtonText,{color:Ce.primaryText,fontFamily:x.medium}],children:tt})]}),jsxs(View,{style:Je.footerRow,children:[jsxs(TouchableOpacity,{style:Je.historyLink,onPress:_,activeOpacity:.7,children:[jsx(zr,{size:14,color:S.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Je.historyText,{color:S.foregroundMuted,fontFamily:x.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Je.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(R),activeOpacity:.7,children:jsx(Text,{style:[Je.legalText,{color:S.foregroundMuted,fontFamily:x.regular}],children:"Terms"})}),jsx(Text,{style:[Je.legalSeparator,{color:S.foregroundMuted,fontFamily:x.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(w),activeOpacity:.7,children:jsx(Text,{style:[Je.legalText,{color:S.foregroundMuted,fontFamily:x.regular}],children:"Help"})})]})]})]})]})}var Je=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:6,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,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"},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 Ny(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 jy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ql({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=F(),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,m=re(Se(e.destination_token_metadata,"png")||Gt("/icons/tokens/png/usdc.png")),c=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",C=Ny(e.created_at||new Date().toISOString()),T=jy(e.source_amount_usd);return jsxs(nr,{cardTokens:a,onPress:t,contentStyle:un.container,children:[jsxs(View,{style:un.iconContainer,children:[jsx(Image,{source:{uri:m},style:un.tokenIcon}),jsx(View,{style:[un.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Rs,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:un.textContainer,children:[jsx(Text,{style:[un.title,{color:a.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[un.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:C})]}),jsxs(View,{style:un.rightContainer,children:[jsx(Text,{style:[un.amount,{color:a.textRightColor,fontFamily:o.medium}],children:T}),jsx(Tr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var un=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 Gd(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 m=s<10?`0${s}`:`${s}`;return `${o} ${n}, ${a} at ${i}:${m} ${l}`}catch{return e}}function Hm(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 qy(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 Nm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function jm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function ya({label:e,value:t,isLast:r}){let{fonts:o,components:n}=F(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Ee.detailRow,children:[jsx(Text,{style:[Ee.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Ee.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Ee.divider,{backgroundColor:a.borderColor}]})]})}function Jd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=F(),[m,c]=useState([]),[C,T]=useState(!!n),y=l.card,b=l.button,k=l.header,h=l.container;useEffect(()=>{Cc().then(ae=>c(ae.data)).catch(()=>{});},[]),useEffect(()=>{T(!!n);},[e?.id]);let p=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,g=e?e.status==="failed"||e.status==="refunded":false,d=g?i.error:p?i.warning:i.success,f=g?"Failed":p?"Processing":"Completed",_=e?.destination_token_metadata?re(Se(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?re(t.destinationTokenIconUrl):re(Gt("/icons/tokens/png/usdc.png")),R=e?.created_at?Gd(e.created_at):t.submittedAt?Gd(t.submittedAt.toISOString()):Gd(new Date().toISOString()),w=e?`${Hm(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Nm(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,S=e?`${Hm(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Nm(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,x=e?qy(e.source_amount_usd,e.source_amount_base_unit):"$0.00",W=e?Da(m,e.source_chain_type,e.source_chain_id):t.sourceChainId,D=e?Da(m,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,P=e?.explorer_url,j=e?.destination_transaction_hashes?.[0],q=e?.destination_explorer_url;return jsxs(ht,{style:Ee.scroll,contentContainerStyle:Ee.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Ee.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Fi,{size:22,color:k.buttonColor,strokeWidth:2})}):jsx(View,{style:Ee.headerSpacer}),jsx(Text,{style:[Ee.headerTitle,{color:k.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Ee.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:k.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Ee.iconContainer,children:[jsx(Image,{source:{uri:_},style:Ee.tokenIcon}),jsx(View,{style:[Ee.statusBadge,{backgroundColor:d}],children:g?jsx(Rs,{size:10,color:"#FFFFFF",strokeWidth:3}):p?jsx(View,{style:Ee.spinnerDot}):jsx($e,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Ee.statusRow,children:[jsx(View,{style:[Ee.statusDot,{backgroundColor:d}]}),jsx(Text,{style:[Ee.statusText,{color:d,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Ee.dateText,{color:h.subtitleColor,fontFamily:s.regular}],children:R}),jsxs(View,{style:[Ee.detailsCard,{backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,borderWidth:y.borderWidth??1,borderColor:y.borderColor}],children:[jsx(ya,{label:"Amount Sent",value:w}),jsx(ya,{label:"Amount Received",value:S}),jsx(ya,{label:"USD Value",value:x}),jsx(ya,{label:"Source Network",value:W}),jsx(ya,{label:"Destination Network",value:D,isLast:true})]}),jsxs(TouchableOpacity,{style:Ee.moreDetailsRow,onPress:()=>T(ae=>!ae),activeOpacity:.7,children:[jsx(Text,{style:[Ee.moreDetailsText,{color:h.actionTitle,fontFamily:s.regular}],children:C?"See less":n?"See more":"See more details"}),C?jsx(To,{size:16,color:h.actionColor,strokeWidth:2}):jsx(Bt,{size:16,color:h.actionColor,strokeWidth:2})]}),C&&jsx(View,{style:[Ee.detailsCard,{backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,borderWidth:y.borderWidth??1,borderColor:y.borderColor}],children:O&&P?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(P),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Ee.txHash,{color:y.titleColor,fontFamily:s.regular}],children:jm(O)}),jsx(ko,{size:14,color:y.actionColor,strokeWidth:2})]}),!p&&j&&q&&jsxs(Fragment,{children:[jsx(View,{style:[Ee.divider,{backgroundColor:y.borderColor}]}),jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(q),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Ee.txHash,{color:y.titleColor,fontFamily:s.regular}],children:jm(j)}),jsx(ko,{size:14,color:y.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Ee.detailRow,children:jsx(Text,{style:[Ee.detailLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Ee.buttonRow,children:[jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:b.secondaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:b.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:b.primaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:b.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Ee=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 $m(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Kl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=F(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",m=s?.status==="failed",c={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:Rt.container,children:[jsx(TouchableOpacity,{style:Rt.closeButton,onPress:r,children:jsx(st,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Rt.iconRing,{backgroundColor:n.successBackground}],children:jsx($e,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[Rt.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[Rt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]}),jsxs(View,{style:Rt.buttonRow,children:[jsx(TouchableOpacity,{style:[Rt.button,Rt.halfButton,c,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Rt.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[Rt.button,Rt.halfButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Rt.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):m?jsxs(View,{style:Rt.container,children:[jsx(TouchableOpacity,{style:Rt.closeButton,onPress:r,children:jsx(st,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Rt.iconRing,{backgroundColor:n.errorBackground}],children:jsx(st,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[Rt.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[Rt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[Rt.button,Rt.fullButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Rt.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:Rt.container,children:[jsx(TouchableOpacity,{style:Rt.closeButton,onPress:r,children:jsx(st,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(kt,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:re(e.sourceTokenIconUrl)},style:Rt.tokenIconFill}):jsx(View,{style:[Rt.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[Rt.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[Rt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]})]})}var Rt=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 Zy(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:re(Se(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:re(Se(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 qm=(e,t)=>`${t}:${e}`;function Xy(){let{colors:e}=F(),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 Jl({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,defaultDestinationChainType:i,defaultDestinationChainId:s,defaultDestinationTokenAddress:l,modalTitle:m="Withdraw Crypto",onWithdraw:c,onWithdrawSuccess:C,onWithdrawError:T,heightPercent:y=.94,sheetBorderRadius:b,sourceChainType:k,sourceChainId:h,sourceTokenAddress:p,sourceTokenSymbol:g,sourceChainName:d,sourceTokenIconUrl:f}){let{colors:_,fonts:R}=F(),[w,S]=useState("form"),[x,W]=useState(k),[D,O]=useState(h),[P,j]=useState(p),[q,ae]=useState(g),[Me,Oe]=useState(d),[X,De]=useState(f),[he,xe]=useState(null),[Ue,we]=useState(null),[ne,Ie]=useState(null),[mt,Ve]=useState(),[lt,He]=useState([]),[Ne,je]=useState(null),[Be,J]=useState("form"),ce=useRef(new Animated.Value(Dimensions.get("window").width)).current,nt=useRef(null),it=!!x&&!!D&&!!P,{data:ve,isLoading:be}=Hl(r,e&&w==="form"),ie=ve?.data??[],{data:de,isLoading:Qt}=Hd({sourceChainType:x,sourceChainId:D,sourceTokenAddress:P,sourceTokenSymbol:q,publishableKey:r,enabled:e&&it&&w==="form"}),{data:ue,isLoading:le}=Nd({address:n,chainType:x,chainId:D,tokenAddress:P,publishableKey:r,enabled:e&&it}),{executions:Ce}=jd({userId:o,publishableKey:r,depositWalletId:mt,enabled:!!mt&&e,onWithdrawSuccess:C,onWithdrawError:T});useEffect(()=>{if(!e||w!=="tracker")return;let z=false;return Qo(o,r,"withdraw").then(Ft=>{z||He(Ft.data);}).catch(console.error),()=>{z=true;}},[e,w,o,r]),useEffect(()=>{e&&(nt.current&&(clearTimeout(nt.current),nt.current=null),S("form"),W(k),O(h),j(p),ae(g),Oe(d),De(f),xe(null),we(null),Ie(null),Ve(void 0),He([]),je(null),J("form"),ce.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{nt.current&&clearTimeout(nt.current);},[]),useEffect(()=>{X||de?.iconUrl&&De(de.iconUrl);},[de?.iconUrl,X]),useEffect(()=>{Me||de?.chainName&&Oe(de.chainName);},[de?.chainName,Me]),useEffect(()=>{if(!ie.length||he)return;let z,Ft;if(i&&s)if(l)for(let St of ie){let Mr=St.chains.find(Xt=>Xt.chain_type===i&&Xt.chain_id===s&&Xt.token_address.toLowerCase()===l.toLowerCase());if(Mr){z=St,Ft=Mr;break}}else for(let St of ie){let Mr=St.chains.find(Xt=>Xt.chain_type===i&&Xt.chain_id===s);if(Mr){z=St,Ft=Mr;break}}z||(z=ie[0]),z&&(xe(z),we(Ft??z.chains[0]??null));},[ie,he,i,s,l]),useEffect(()=>{w==="confirming"&&Ce.length>0&&S("details");},[w,Ce]);let wt=useCallback(()=>{t(),nt.current=setTimeout(()=>{S("form"),W(k),O(h),j(p),ae(g),Oe(d),De(f),xe(null),we(null),Ie(null),Ve(void 0),He([]),je(null),J("form"),nt.current=null;},300);},[t,k,h,p,g,d,f]),tt=useCallback(z=>{let Ft=ie.find(St=>St.symbol===z);Ft&&(xe(Ft),Ft.chains.length>0&&we(Ft.chains[0]));},[ie]),pe=useCallback(z=>{if(!he)return;let Ft=he.chains.find(St=>qm(St.chain_id,St.chain_type)===z);Ft&&we(Ft);},[he]),Qe=useCallback(async z=>{let Ft=await $o({external_user_id:o,destination_chain_type:z.destinationChainType,destination_chain_id:z.destinationChainId,destination_token_address:z.destinationTokenAddress,recipient_address:z.recipientAddress,action_type:"withdraw"},r),St=qo(Ft.data,x??"");if(!St)throw new Error(`No deposit wallet found for chain type: ${x}`);return Ve(St.id),{id:St.id,address:St.address}},[o,r,x]),ir=useCallback(z=>{Ie(z),S("confirming");},[]),xt=useCallback(z=>{je(z),ce.setValue(Dimensions.get("window").width),Animated.timing(ce,{toValue:0,duration:280,useNativeDriver:true}).start();},[ce]),Pr=useCallback(()=>{Animated.timing(ce,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>je(null));},[ce]),Fr=be||Qt,U=de?.isSupported??null,Q=w==="confirming"?"Withdrawal Status":m,se=b?.globalBorderTopLeftRadius,ze=b?.globalBorderTopRightRadius,E=b?.main?.borderTopLeftRadius??se,te=b?.main?.borderTopRightRadius??ze,ye=b?.tokenSelector?.borderTopLeftRadius??se,me=b?.tokenSelector?.borderTopRightRadius??ze,gt=b?.chainSelector?.borderTopLeftRadius??se,V=b?.chainSelector?.borderTopRightRadius??ze,Or=(()=>{if(w!=="form"||!it||le||!ue)return;let z=q||ue.symbol,Ft=ue.balanceUsd;if(Ft!=null){let Xt=`$${parseFloat(Ft).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return z?`Balance: ${Xt} ${z}`:`Balance: ${Xt}`}let St=ue.balanceHuman;if(!(!St||St==="0"))return z?`Balance: ${St} ${z}`:`Balance: ${St}`})();return jsx(ft,{visible:e,onClose:wt,closeOnBackdropPress:false,enablePanDownToClose:w==="tracker"||w==="form",showHandle:w==="tracker"||w==="form",heightPercent:w==="confirming"?.3:w==="details"?.7:w==="tracker"?.6:y,maxHeightPercent:w==="tracker"?.9:void 0,borderTopLeftRadius:E,borderTopRightRadius:te,children:w==="confirming"&&ne?jsx(Kl,{txInfo:ne,executions:Ce,onClose:wt,onViewTracker:()=>{J("confirming"),S("tracker");}}):w==="details"&&ne?jsx(Jd,{execution:Ce.length>0?Ce[Ce.length-1]:null,txInfo:ne,onClose:wt,onViewHistory:()=>{J("details"),S("tracker");},onHeaderClose:()=>S("form")}):w==="tracker"?jsxs(View,{style:zo.trackerContainer,children:[jsx(Ir,{title:"Withdrawal History",onClose:()=>S(Be)}),lt.length===0?jsx(View,{style:zo.emptyState,children:jsx(Text,{style:[zo.emptyText,{color:_.foregroundMuted,fontFamily:R.regular}],children:"No withdrawals to track yet"})}):jsx(Vi,{data:lt,keyExtractor:z=>z.id,contentContainerStyle:zo.listContent,showsVerticalScrollIndicator:false,renderItem:({item:z})=>jsx(Ql,{execution:z,onPress:()=>xt(z)})}),Ne&&jsx(Animated.View,{style:[zo.historyDetailOverlay,{backgroundColor:_.background,transform:[{translateX:ce}]}],children:jsx(Jd,{execution:Ne,txInfo:Zy(Ne),onClose:wt,onBack:Pr,onViewHistory:Pr})})]}):jsxs(Fragment,{children:[jsx(Ir,{title:Q,subtitle:Or,onClose:wt}),Fr?jsx(Xy,{}):U===false?jsxs(View,{style:zo.unsupportedContainer,children:[jsx(Text,{style:[zo.unsupportedTitle,{color:_.foreground,fontFamily:R.medium}],children:"Unsupported Token"}),jsx(Text,{style:[zo.unsupportedMessage,{color:_.foregroundMuted,fontFamily:R.regular}],children:de?.errorMessage})]}):jsx(eb,{publishableKey:r,sourceChainType:x??"",sourceChainId:D??"",sourceTokenAddress:P??"",sourceTokenSymbol:q,sourceChainName:Me,sourceTokenIconUrl:X,recipientAddressProp:a,destinationTokens:ie,selectedToken:he,selectedChain:Ue,selectedChainKey:Ue?qm(Ue.chain_id,Ue.chain_type):null,onTokenChange:tt,onChainChange:pe,tokensLoading:be,balanceData:ue??null,isLoadingBalance:le,sourceValidation:de??null,onDepositWalletCreation:Qe,onWithdraw:c,onWithdrawError:T,onWithdrawSubmitted:ir,onViewTracker:()=>{J("form"),S("tracker");},tokenSelectorLeft:ye,tokenSelectorRight:me,chainSelectorLeft:gt,chainSelectorRight:V})]})})}function eb({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:m,selectedChain:c,selectedChainKey:C,onTokenChange:T,onChainChange:y,tokensLoading:b,balanceData:k,isLoadingBalance:h,sourceValidation:p,onDepositWalletCreation:g,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:_,onViewTracker:R,tokenSelectorLeft:w,tokenSelectorRight:S,chainSelectorLeft:x,chainSelectorRight:W}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(ht,{style:{flex:1,paddingTop:16},contentContainerStyle:zo.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:zo.doubleInputWrapper,children:jsx(ga,{tokens:l,selectedTokenSymbol:m?.symbol??null,selectedChainKey:C,onTokenChange:T,onChainChange:y,isLoading:b,tokenPickerBorderTopLeftRadius:w,tokenPickerBorderTopRightRadius:S,chainPickerBorderTopLeftRadius:x,chainPickerBorderTopRightRadius:W})}),jsx(jl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:m,selectedChain:c,balanceData:k,isLoadingBalance:h,minimumWithdrawAmountUsd:p?.minimumAmountUsd??null,estimatedProcessingTime:p?.estimatedProcessingTime??null,maxSlippagePercent:p?.maxSlippagePercent??null,priceImpactPercent:p?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:g,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:_,onViewTracker:R})]})})}var zo=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 Gm=createContext(null);function db({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new od({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,m]=useState(false),[c,C]=useState(null),T=useColorScheme(),y=useRef(false);y.current||(va({publishableKey:t}),y.current=true);let b=useMemo(()=>{let P=r?.appearance||"dark";return P==="auto"?T==="dark"?"dark":"light":P},[r?.appearance,T]);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.'),va({publishableKey:t});},[t]),useEffect(()=>()=>{h.current&&clearTimeout(h.current),R.current&&clearTimeout(R.current);},[]);let k=useRef(null),h=useRef(null),p=useCallback(P=>{h.current&&(clearTimeout(h.current),h.current=null),k.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),k.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),k.current=null);let j=new Promise((q,ae)=>{k.current={resolve:q,reject:ae};});return s(P),a(true),j},[]),g=useCallback(()=>{k.current&&(k.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),k.current=null),a(false),h.current=setTimeout(()=>{s(null),h.current=null;},200);},[]),d=useCallback(P=>{i?.onSuccess&&i.onSuccess(P),k.current&&(k.current.resolve(P),k.current=null);},[i]),f=useCallback(P=>{console.error("[UnifoldProvider] Deposit error:",P),i?.onError&&i.onError(P),k.current&&(k.current.reject(P),k.current=null);},[i]),_=useRef(null),R=useRef(null),w=useRef(void 0),S=useCallback(P=>{R.current&&(clearTimeout(R.current),R.current=null),_.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),_.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),_.current=null);let j=new Promise((q,ae)=>{_.current={resolve:q,reject:ae};});return w.current=P.onClose,C(P),m(true),j},[]),x=useCallback(()=>{_.current&&(_.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),_.current=null),w.current?.(),w.current=void 0,m(false),R.current=setTimeout(()=>{C(null),R.current=null;},200);},[]),W=useCallback(P=>{c?.onSuccess&&c.onSuccess(P),_.current&&(_.current.resolve(P),_.current=null);},[c]),D=useCallback(P=>{console.error("[UnifoldProvider] Withdraw error:",P),c?.onError&&c.onError(P),_.current&&(_.current.reject(P),_.current=null);},[c]),O=useMemo(()=>({publishableKey:t,beginDeposit:p,closeDeposit:g,beginWithdraw:S,closeWithdraw:x}),[t,p,g,S,x]);return jsx(sd,{client:o,children:jsx(Gm.Provider,{value:O,children:jsxs(Di,{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Ul,{visible:n,onClose:g,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:b,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?sp():void 0,onDepositSuccess:d,onDepositError:f,theme:b,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Jl,{visible:l,onClose:x,publishableKey:t,externalUserId:c.externalUserId,senderAddress:c.senderAddress,recipientAddress:c.recipientAddress,sourceChainType:c.sourceChainType,sourceChainId:c.sourceChainId,sourceTokenAddress:c.sourceTokenAddress,sourceTokenSymbol:c.sourceTokenSymbol,defaultDestinationChainType:c.defaultDestinationChainType,defaultDestinationChainId:c.defaultDestinationChainId,defaultDestinationTokenAddress:c.defaultDestinationTokenAddress,onWithdraw:c.withdraw,onWithdrawSuccess:W,onWithdrawError:D,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function ub(){let e=useContext(Gm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
- export{Qa as AmountScreen,ft as BottomSheet,Ka as KYCWizardScreen,el as OnrampScreen,tl as StripeOnramp,np as StripeOnrampPreconfigure,db as UnifoldProvider,Se as getPreferredIcon,Na as getStripePublishableKey,Va as getSupportedDestinationTokens,re as normalizeIconUrl,rl as registerStripeOnramp,cu as setDevApiUrl,Ha as setStripeOnrampApiUrl,Ua as setStripeOnrampPublishableKey,ma as useAllowedCountry,Ga as useStripeOnramp,F as useTheme,ub as useUnifold};
1
+ import*as Un from'react';import Un__default,{createContext,useContext,useState,useRef,useCallback,useEffect,useMemo,useId,Fragment as Fragment$1}from'react';import {StyleSheet,ScrollView,useWindowDimensions,Platform,PanResponder,Modal,View,Pressable,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Image,Easing,Dimensions,Clipboard,Linking,FlatList}from'react-native';import Et,{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 gu,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import qc from'@react-native-async-storage/async-storage';import dg from'expo-constants';import $g from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var du=e=>{throw TypeError(e)};var ff=(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 ic=(e,t,r)=>t.has(e)||du("Cannot "+r);var p=(e,t,r)=>(ic(e,t,"read from private field"),r?r.call(e):t.get(e)),X=(e,t,r)=>t.has(e)?du("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(ic(e,t,"write to private field"),t.set(e,r),r),Be=(e,t,r)=>(ic(e,t,"access private method"),r);var Ps=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return p(e,t,o)}});var sc={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)"}},ac=sc;function Ia(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function Fs(e,t,r){let o=r?t?.[r]:void 0,n=(u,y,S)=>{let g=o?.[u]?.[y];if(g!==void 0)return g;let b=t?.[u]?.[y];return b!==void 0?b: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,m=(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:Ia(a,i)},transferCrypto:{depositAddress:{card:Ia(a,s)}},depositCard:{quoteProvider:{card:Ia(a,l)}},depositTracker:{executionRow:{card:Ia(a,m)}}}}function lc(e,t,r){let n={...sc[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var cc=createContext(null);function F(){let e=useContext(cc);if(!e){let t=ac.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:Fs(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}=F(),l=a??s.warning,m=i??"#FBBF24",u=useRef(new Animated.Value(0)).current,y=useId(),S=useMemo(()=>`circularProgressGrad_${y.replace(/[^a-zA-Z0-9_-]/g,"")}`,[y]),g=(e-t)/2,b=2*Math.PI*g,w=e/2,h=o??Math.max(0,Math.round(e-t*2-8)),k=(e-h)/2;useEffect(()=>{let d=Animated.loop(Animated.timing(u,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return d.start(),()=>d.stop()},[u]);let c=u.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:c}]},children:jsxs(Et,{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:m})]})}),jsx(Circle,{cx:w,cy:w,r:g,stroke:`url(#${S})`,strokeWidth:t,fill:"none",strokeDasharray:`${b*.75} ${b*.25}`,strokeLinecap:"round",rotation:-90,origin:`${w}, ${w}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:k+1.5,left:k,width:h,height:h},children:r}):null]})}function pc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Et,{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(Et,{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 Dr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Os({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Ze({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 xr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Et,{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 Li({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Et,{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 Dt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Et,{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 Qo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 ze({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Et,{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 Ds({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 mc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 xo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 wn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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(Et,{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 _o({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Et,{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 Fa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Bi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Sn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Oa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Vs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 fu({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Et,{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 Ai({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]),m=useMemo(()=>{let g=o?.[l];return lc(l,g,r)},[l,o,r]),u=useMemo(()=>Fs(m,i,l),[m,i,l]),y=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:m,fonts:y,components:u,isDark:l==="dark"}),[l,m,y,u]);return jsx(cc.Provider,{value:S,children:e})}var Ws={damping:28,stiffness:300,mass:.8},jf=80,$f=500;function pt({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:a=true,heightPercent:i,maxHeightPercent:s,startExpanded:l=false,noPadding:m=false,borderTopLeftRadius:u=24,borderTopRightRadius:y=24}){let{colors:S}=F(),{height:g}=useWindowDimensions(),[b,w]=useState(false),h=useRef(e);h.current=e;let k=useRef(0),c=i!=null&&i>=1,d=c||m?0:Platform.OS==="ios"?34:24,f=s!=null&&i!=null&&s>i,R=i!=null?(f?s:i)*g:void 0,_=f?(s-i)*g:0,T=l?0:_,C=useSharedValue(g),x=useRef(null),W=useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),h.current||w(false);},[]);useEffect(()=>{e?(x.current&&(clearTimeout(x.current),x.current=null),w(true),C.value=withSpring(T,Ws)):b&&(C.value=withTiming(g,{duration:250},N=>{N&&runOnJS(W)();}),x.current=setTimeout(()=>{x.current=null,W();},350));},[e]),useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]),useEffect(()=>{b&&e&&(C.value=withSpring(T,Ws));},[T]);let V=useCallback(()=>{o&&t();},[o,t]),O=useMemo(()=>{if(!(!n&&!f))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{k.current=C.value;},onPanResponderMove:(N,ue)=>{if(Math.abs(ue.dy)<4)return;let Le=k.current+ue.dy;C.value=Math.max(0,Le);},onPanResponderRelease:(N,ue)=>{if(!(Math.abs(ue.dy)<4)){if(n&&(ue.dy>jf||ue.vy>$f)){t();return}if(f){let Le=_/2,ve=C.value<Le?0:_;C.value=withSpring(ve,Ws);}else C.value=withSpring(T,Ws);}},onPanResponderTerminate:()=>{C.value=withSpring(T,Ws);}}).panHandlers},[n,f,_,T,C,t]),P=useAnimatedStyle(()=>({transform:[{translateY:C.value}]})),q=useAnimatedStyle(()=>({opacity:interpolate(C.value,[0,g*.5,g],[.5,.25,0],Extrapolation.CLAMP)}));return b?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:Xn.root,pointerEvents:e?"auto":"none",children:[jsx(gu.View,{style:[Xn.backdrop,q],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:V})}),jsxs(gu.View,{style:[Xn.sheet,P,{height:R,backgroundColor:S.background,borderTopLeftRadius:c?0:u,borderTopRightRadius:c?0:y}],children:[jsxs(GestureHandlerRootView,{style:Xn.gestureRoot,children:[a&&jsx(View,{style:Xn.handleContainer,pointerEvents:"none",children:jsx(View,{style:[Xn.handle,{backgroundColor:S.foreground+"33"}]})}),r,d>0&&jsx(View,{style:{height:d}})]}),O&&jsx(View,{...O,style:Xn.dragOverlay})]})]})}):null}var Xn=StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject,backgroundColor:"#000"},sheet:{overflow:"hidden"},gestureRoot:{flex:1},handleContainer:{alignItems:"center",paddingTop:10,paddingBottom:4,zIndex:1},dragOverlay:{position:"absolute",top:0,left:0,right:0,height:40,zIndex:2},handle:{width:36,height:5,borderRadius:2.5}}),it=Un__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));it.displayName="BottomSheetScrollView";function Wi(e){return jsx(FlatList,{...e})}var qf="https://api.unifold.io",bc="__UnifoldDevApiBaseUrl__",_r="pk_test_123",Da={};function Qf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[bc];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Xt(){return Qf()??qf}function Va(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.'),_r=e.publishableKey;}e.defaultConfig&&(Da=e.defaultConfig);}function bu(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[bc]=t:delete globalThis[bc];}function Es(){return Xt()}function La(){return _r}function Hr(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 Kt(e){let t=e.startsWith("/")?e:`/${e}`;return `${Xt()}/api/public${t}`}function te(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,Xt()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${Xt()}${e}`:`${Xt()}/api/public${e}`:""}async function Go(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||Da.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||Da.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Da.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||_r;Hr(n);let a=await fetch(`${Xt()}/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 Yo(e,t){return e.find(r=>r.chain_type===t)}async function Jo(e,t,r){let o=t||_r;Hr(o);let n=await fetch(`${Xt()}/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||_r;Hr(r);let o=await fetch(`${Xt()}/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 ke(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 ei(e,t){let r=e||_r;Hr(r);let o=`${Xt()}/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 Cc(e,t){let r=t||_r;Hr(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${Xt()}/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 Aa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function wc(e,t){let r=t||_r;Hr(r);let o=await fetch(`${Xt()}/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 Sc(e,t){let r=t||_r;Hr(r);let o=await fetch(`${Xt()}/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 kc(e,t){let r=t||_r;Hr(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(`${Xt()}/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||_r;Hr(t);let r=await fetch(`${Xt()}/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 Ei(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 Ms(e){let t=e||_r;Hr(t);let r=await fetch(`${Xt()}/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 xc(){let e=await fetch(`${Xt()}/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 zs(){let e=await fetch(`${Xt()}/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 Ea(e){let t=e||_r;Hr(t);let r=await fetch(`${Xt()}/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 _c(e,t){let r=t||_r;Hr(r);let o=await fetch(`${Xt()}/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 Rc(e,t){return Ba(e.deposit_wallet_id,t)}async function Ma(e,t,r,o,n){let a=n||_r;Hr(a);let i=await fetch(`${Xt()}/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 wu({size:e=28}){return jsx(Et,{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 ku({size:e=28}){return jsxs(Et,{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 _u({size:e=28}){return jsxs(Et,{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 Ru({size:e=28}){return jsxs(Et,{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 Iu({size:e=28}){return jsx(Et,{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 za=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:wu},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:ku},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:_u},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:Ru},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:Iu}];function Ua(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Ha(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 Ui(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=za.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=za.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Mt({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:a}=F(),i=r==="back",s=i?jsx(Li,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(Ze,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:kn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:i?"Back":"Close",children:s});return t?jsxs(View,{style:kn.headerWithTitle,children:[i?l:o??jsx(View,{style:kn.headerSide}),jsx(Text,{style:[kn.headerTitleText,{color:n.header.titleColor},...a.bold?[{fontFamily:a.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),i?jsx(View,{style:kn.headerSide}):l]}):jsxs(View,{style:i?kn.headerWithTitle:kn.header,children:[i?l:jsx(View,{style:kn.headerSpacer}),!i&&l]})}var Na={paddingTop:8,paddingBottom:8},kn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Na},headerWithTitle:{flexDirection:"row",alignItems:"center",...Na},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 Rr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=F();return e?jsx(Text,{style:[vu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[vu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var vu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function ho({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[a,i]=useState(false),{colors:s,components:l}=F(),m=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},u=Ua(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:u}),jsx(TouchableOpacity,{onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx(ze,{size:14,color:s.success,strokeWidth:2.5}):jsx(Qo,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var ja={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function Hi({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=F(),a=e.toLowerCase(),i=ja[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 $a({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=F(),m=Kt(`/icons/currencies/png/${e.toLowerCase()}.png`),u=Ui(r);return jsxs(View,{style:[to.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:to.step,children:[jsx(Image,{source:{uri:m},style:to.iconImage}),jsx(Text,{style:[to.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[to.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(xr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:to.step,children:[jsxs(View,{style:to.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:to.tokenIcon}):jsx(View,{style:[to.tokenIcon,{backgroundColor:ja[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[to.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[to.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[to.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",u]})]})]})}var to=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 Ni(){let{colors:e,fonts:t,components:r}=F(),o=r.input,n=r.button,a=r.container,i=r.card,s=r.header;return useMemo(()=>{let l=i.borderRadius,m={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},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"}},u={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:12},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:56,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:8,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}:{}}},y={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)),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}:{}}},b={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:m,quote:y,pm:g,wallet:b,flow:w,amount:u}},[e,t,o,n,a,i,s])}var Ou="",Du;function qa(e){Ou=e;}function Qa(e){Du=e;}function Vr(){let e=Ou||La();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Lr(){return Du??Es()}async function Ka(){let e=`${Lr()}/v1/public/onramps/headless/stripe/config`,t=Vr(),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 Vc(e){let t=await fetch(`${Lr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Vr(),"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 Vu(e,t){let r=await fetch(`${Lr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Vr(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e,...t&&{crypto_customer_id:t}})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function Lc(e,t){let r=await fetch(`${Lr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Vr(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e,...t&&{crypto_customer_id:t}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.message??`Failed to refresh OAuth token: ${r.status}`);return o}async function Lu(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(`${Lr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Vr(),"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(`${Lr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Vr(),"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 Ga(e,t){let r=`${Lr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Vr(),"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 Au(e){let t=`${Lr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":Vr(),"x-stripe-oauth-token":e}}),o=await r.text();if(!r.ok)throw new Error(`Failed to list onramp sessions: ${r.status} ${o}`);return JSON.parse(o)}async function Wu(e,t){let r=`${Lr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Vr(),"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(`${Lr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Vr(),"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 Eu(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(`${Lr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Vr(),"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 Ac(e,t){let r=await fetch(`${Lr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Vr(),"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 Mu(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(`${Lr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Vr(),"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 Tn(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 zu(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Lr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Vr()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function wh({size:e=24}){let t=e,r=e*(471/750);return jsxs(Et,{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 Sh({size:e=24}){return jsx(Et,{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 kh({size:e=24}){return jsx(Et,{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 Ec({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(wh,{size:t}):o.includes("mastercard")?jsx(Sh,{size:t}):o.includes("amex")||o.includes("american express")?jsx(kh,{size:t}):jsx(Vi,{size:t*.75,color:r,strokeWidth:1.75})}function Ya(e){if(!e)return "";let t=new Date(e*1e3);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true})}var zc={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function Uc(e,t){switch(e){case "fulfillment_complete":return t.success;case "fulfillment_processing":case "requires_payment":return t.warning;case "rejected":return t.error;default:return t.foregroundMuted}}function $u({status:e,colors:t,fontFamily:r}){let o=Uc(e,t);return jsx(View,{style:{paddingHorizontal:8,paddingVertical:2,borderRadius:6,backgroundColor:o+"20"},children:jsx(Text,{style:{fontSize:11,color:o,fontFamily:r},children:zc[e]??e})})}function qu({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,a=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:ji.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[ji.row,{backgroundColor:t.card,borderRadius:a,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:ji.left,children:[jsx(Animated.View,{style:[ji.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[ji.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[ji.badgeBar,{backgroundColor:n,opacity:o}]})]},s))})}var ji=StyleSheet.create({list:{gap:8},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16},left:{flex:1,gap:6},amountBar:{height:16,width:"40%",borderRadius:8},subtitleBar:{height:12,width:"55%",borderRadius:6},badgeBar:{height:20,width:80,borderRadius:6,marginLeft:12}});function Qu({active:e,interval:t=15e3,color:r}){let o=useRef(new Animated.Value(0)).current;return useEffect(()=>{if(!e){o.setValue(0);return}let n=()=>{o.setValue(0),Animated.timing(o,{toValue:1,duration:t,useNativeDriver:false}).start(({finished:a})=>{a&&n();});};return n(),()=>o.stopAnimation()},[e,t,o]),e?jsx(View,{style:{height:2,borderRadius:1,overflow:"hidden",opacity:.5},children:jsx(Animated.View,{style:{height:2,borderRadius:1,backgroundColor:r,width:o.interpolate({inputRange:[0,1],outputRange:["0%","100%"]})}})}):null}function Ku({session:e,onBack:t}){let{colors:r,components:o,fonts:n}=F(),[a,i]=useState(false),s=()=>{Clipboard.setString(e.id),i(true),setTimeout(()=>i(false),2e3);},l=e.transaction_details,m=e.status!=="fulfillment_complete"&&e.status!=="rejected",u=Uc(e.status,r),y=l?.source_amount?`$${parseFloat(l.source_amount).toFixed(2)}`:"\u2014",S=l?.destination_amount?parseFloat(l.destination_amount).toFixed(2):"\u2014",g=(l?.destination_currency??"").toUpperCase(),b=e.destination_token_metadata,w=Tn(b?.icon_urls,b?.icon_url),h=Ui(l?.destination_network??""),k=l?.wallet_address?Ua(l.wallet_address):null,c=l?.fees?.network_fee_amount?`$${parseFloat(l.fees.network_fee_amount).toFixed(2)}`:null,d=l?.fees?.transaction_fee_amount?`$${parseFloat(l.fees.transaction_fee_amount).toFixed(2)}`:null,f=e.payment_method?e.payment_method.replace(/_/g," ").replace(/\b\w/g,_=>_.toUpperCase()):null,R=[{label:"Amount",value:y},{label:"Received",value:`${S} ${g}`},...f?[{label:"Payment",value:f}]:[],{label:"Network",value:h},...k?[{label:"Wallet",value:k}]:[],...c?[{label:"Network Fee",value:c}]:[],...d?[{label:"Transaction Fee",value:d}]:[]];return jsxs(Fragment,{children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(Mt,{onPress:t,title:"Purchase Details",variant:"back"})}),jsxs(it,{style:ir.scroll,contentContainerStyle:ir.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:ir.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(Hi,{currency:g||"USD",tokenIconUrl:w,size:64}),jsx(View,{style:[ir.statusBadge,{backgroundColor:u,borderColor:o.card.backgroundColor??r.background}],children:m?jsx(Dr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):e.status==="rejected"?jsx(Ze,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx(ze,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:ir.statusRow,children:[jsx(View,{style:[ir.statusDot,{backgroundColor:u}]}),jsx(Text,{style:[ir.statusText,{color:o.container.titleColor,fontFamily:n.semibold}],children:zc[e.status]??e.status})]}),e.created?jsx(Text,{style:[ir.dateText,{color:o.container.subtitleColor,fontFamily:n.regular}],children:Ya(e.created)}):null]}),jsxs(View,{style:[ir.card,{backgroundColor:o.card.backgroundColor,borderRadius:o.card.borderRadius,borderWidth:o.card.borderWidth,borderColor:o.card.borderColor}],children:[jsxs(View,{style:ir.cardRow,children:[jsx(Text,{style:[ir.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:"ID"}),jsxs(TouchableOpacity$1,{onPress:s,activeOpacity:.7,style:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},children:[jsx(Text,{style:[ir.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium,fontSize:12}],numberOfLines:1,children:e.id.length>12?e.id.slice(0,12)+"\u2026":e.id}),a?jsx(ze,{size:14,color:r.primary,strokeWidth:2}):jsx(Qo,{size:14,color:r.foregroundMuted,strokeWidth:2})]})]}),R.map(_=>jsx(Un__default.Fragment,{children:jsxs(View,{style:ir.cardRow,children:[jsx(Text,{style:[ir.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:_.label}),jsx(Text,{style:[ir.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium}],selectable:true,children:_.value})]})},_.label))]}),l?.last_error?jsx(View,{style:[ir.card,{backgroundColor:r.errorBackground,borderRadius:o.card.borderRadius}],children:jsxs(View,{style:ir.cardRow,children:[jsx(Text,{style:[ir.cardLabel,{color:r.error,fontFamily:n.regular}],children:"Error"}),jsx(Text,{style:[ir.cardValue,{color:r.error,fontFamily:n.medium,flex:1,textAlign:"right"}],selectable:true,children:l.last_error})]})}):null]})]})}var ir=StyleSheet.create({scroll:{flex:1,paddingTop:8},scrollContent:{paddingHorizontal:24,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},statusBadge:{position:"absolute",bottom:-4,right:-4,width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center",borderWidth:2},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14,marginBottom:2},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"}});var Oh=[50,100,500],Dh=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Ju(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Vh(e){return e.card?`${Ju(e.card.brand)} ${Ju(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Za({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:a="inline",onCollectPayment:i,paymentLoading:s=false,paymentStatus:l,paymentError:m,paymentTokens:u=[],onAddPaymentMethod:y,onConfirm:S,onCancel:g,sheetBorderTopLeftRadius:b,sheetBorderTopRightRadius:w,accessToken:h,showHistoryProgressBar:k=true}){let c=Ni(),{colors:d,components:f,fonts:R}=F(),_=b??f.card.borderRadius,T=w??f.card.borderRadius,[C,x]=useState(e),[W,V]=useState(r?"apple_pay":u.length>0?u[0].id:null),O=useRef(false),P=E=>{O.current=true,V(E);};useEffect(()=>{O.current||r||u.length>0&&V(u[0].id);},[u,r]);let[q,N]=useState(false),[ue,Le]=useState("select"),[ve,ee]=useState(null),Oe=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&Le("card");},[s,l]);let fe=W==="apple_pay",Re=1e3,We=fe?Re:n,be=We!=null&&We>0,oe=useMemo(()=>{if(o)return [];let E=Oh.map(B=>({label:`$${B}`,amount:String(B),disabled:false}));return fe?E.push({label:`$${Re}`,amount:String(Re),disabled:false}):E.push({label:"MAX",amount:be?String(We):"0",disabled:!be}),E},[o,be,We,fe]),De=E=>{if(E==="\u232B"){x(B=>B.slice(0,-1));return}if(E==="."){if(C.includes("."))return;x(B=>B===""?"0.":B+".");return}x(B=>{let Se=B.indexOf(".");return Se!==-1&&B.length-Se>2?B:B==="0"&&E!=="."?E:B+E});},dt=C===""?"0":C,Ue=parseFloat(C),Qe=C!==""&&!isNaN(Ue)&&Ue>0,Ke=r||u.length>0,Ee=a==="header",Je=useMemo(()=>{let E=[];r&&E.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let B of u)E.push({id:B.id,label:Vh(B),hint:B.card?`Expires ${B.card.exp_month}/${B.card.exp_year}`:B.type,brand:B.card?.brand,isApplePay:false});return E},[r,u]),Ce=Je.find(E=>E.id===W),ae=W!=null&&W!=="apple_pay",tt=Ce?Ce.label:ae&&ve?ve:ae?"Card":"Pay With",rt=Ce?!Ce.isApplePay:ae,Me=Ce?.brand??ve??void 0,[he,ne]=useState(false),[le,qt]=useState([]),[pe,se]=useState(false),[we,yt]=useState(null),[ot,ce]=useState(null),Ye=useRef(null);Ye.current=ot;let nr=useRef(false);nr.current=he;let ut=useCallback(async(E=false)=>{if(h){E||(se(true),yt(null));try{let B=await Au(h);if(!nr.current)return;let Se=Array.isArray(B.data)?B.data:Array.isArray(B)?B:[];qt(Se),E||yt(null);let M=Ye.current?.id;if(M){let Z=Se.find(ye=>ye.id===M);Z&&ce(Z);}}catch(B){if(!nr.current)return;E||yt(B?.message??"Failed to load history");}finally{!E&&nr.current&&se(false);}}},[h]),Fr=useCallback(()=>{ne(true),ut();},[ut]);useEffect(()=>{if(!he||!h)return;let E=setInterval(()=>ut(true),15e3);return ()=>clearInterval(E)},[he,h,ut]);let zr=h?jsx(TouchableOpacity,{style:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},onPress:Fr,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"History",children:jsx(Dr,{size:20,color:d.foreground,strokeWidth:2})}):void 0,ar=Ke?jsx(TouchableOpacity,{style:[Ee?c.amount.paymentRowHeader:c.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(Le("select"),N(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:c.amount.paymentLeft,children:[Ce?.isApplePay?jsx(Text,{style:c.amount.applePayIcon,children:"\uF8FF"}):rt?jsx(Ec,{sublabel:Me,size:20}):null,jsx(Text,{style:c.amount.paymentLabel,children:tt}),jsx(Dt,{size:12,color:c.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:c.form.screen,children:[jsx(Mt,{onPress:g,title:"Enter amount",leftAction:zr}),Ee&&ar,jsxs(View,{style:c.form.content,children:[jsxs(View,{style:c.amount.amountContainer,children:[jsxs(Text,{style:[c.amount.amountText,dt==="0"&&c.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",dt]}),jsx(Text,{style:c.amount.currencyLabel,children:t.toUpperCase()})]}),!Ee&&ar,oe.length>0&&jsx(View,{style:c.amount.quickRow,children:oe.map(E=>{let B=!E.disabled&&C===E.amount&&C!=="";return jsx(TouchableOpacity,{style:[c.amount.quickPill,B&&{backgroundColor:d.primary},E.disabled&&{opacity:.4}],activeOpacity:.7,disabled:E.disabled||s,onPress:()=>x(E.amount),children:jsx(Text,{style:[c.amount.quickPillText,B&&{color:d.primaryForeground}],children:E.label})},E.label)})}),jsx(View,{style:c.amount.numpad,children:Dh.map((E,B)=>jsx(View,{style:c.amount.numpadRow,children:E.map(Se=>jsx(TouchableOpacity,{style:[c.amount.numpadKey,s&&{opacity:.3}],onPress:()=>De(Se),activeOpacity:.6,disabled:s,children:jsx(Text,{style:Se==="\u232B"?c.amount.backspaceText:c.amount.numpadKeyText,children:Se})},Se))},B))}),jsx(TouchableOpacity,{style:[c.form.continueBtn,(!Qe||s)&&c.form.continueBtnDisabled],onPress:()=>Qe&&!s&&S(C,W),disabled:!Qe||s,children:s?jsx(ActivityIndicator,{size:"small",color:d.primaryForeground}):jsx(Text,{style:[c.form.continueBtnText,!Qe&&c.form.continueBtnTextDisabled],children:"Continue"})}),!q&&m?jsx(Text,{style:c.amount.inlineError,children:m}):!q&&s&&l&&__DEV__?jsx(Text,{style:c.amount.inlineStatus,children:l}):null]}),jsx(pt,{visible:q,onClose:()=>{s||(N(false),Le("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:!s,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:_,borderTopRightRadius:T,children:jsx(View,{style:c.amount.sheetContent,children:ue==="select"?jsxs(Fragment,{children:[jsxs(View,{style:c.amount.sheetTitleRow,children:[jsx(Text,{style:c.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>N(false),activeOpacity:.7,style:c.amount.sheetCloseBtn,children:jsx(Ze,{size:16,color:d.foregroundMuted,strokeWidth:2.5})})]}),jsxs(it,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[Je.map(E=>{let B=W===E.id;return jsxs(TouchableOpacity$1,{style:[c.amount.sheetOption,B&&{borderColor:d.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{P(E.id),ee(E.isApplePay?null:E.label),N(false);},children:[jsxs(View,{style:c.amount.sheetOptionLeft,children:[jsx(View,{style:c.amount.sheetOptionIcon,children:E.isApplePay?jsx(Text,{style:c.amount.applePayIcon,children:"\uF8FF"}):jsx(Ec,{sublabel:E.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:c.amount.sheetOptionLabel,children:E.label}),jsx(Text,{style:c.amount.sheetOptionHint,children:E.hint})]})]}),B&&jsx(ze,{size:18,color:d.primary,strokeWidth:2.5})]},E.id)}),jsx(TouchableOpacity$1,{style:c.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!Oe.current){Oe.current=true;try{let E=await y?.();E&&(P(E.token),ee(E.sublabel),N(!1));}finally{Oe.current=false;}}},children:jsx(Text,{style:c.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:c.amount.sheetHeader,children:[jsx(TouchableOpacity$1,{onPress:()=>{s||Le("select");},activeOpacity:.7,style:c.amount.sheetBackBtn,children:jsx(Li,{size:20,color:d.foreground,strokeWidth:2})}),jsx(Text,{style:c.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:c.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:d.primary}),__DEV__?jsx(Text,{style:c.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):m?jsxs(Fragment,{children:[jsx(View,{style:c.amount.sheetError,children:jsx(Text,{style:c.amount.sheetErrorText,children:m})}),jsx(TouchableOpacity$1,{style:c.form.continueBtn,onPress:()=>{i&&Qe&&i(false,C);},children:jsx(Text,{style:c.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:c.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:d.primary}),__DEV__?jsx(Text,{style:c.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(pt,{visible:he,onClose:()=>{ne(false),ce(null);},closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:_,borderTopRightRadius:T,children:ot?jsx(Ku,{session:ot,onBack:()=>ce(null)}):jsxs(View,{style:c.amount.sheetContent,children:[jsx(Mt,{onPress:()=>ne(false),title:"Purchase History"}),k&&jsx(Qu,{active:he&&!pe&&le.length>0,color:d.primary}),pe?jsx(qu,{}):we?jsx(View,{style:c.amount.sheetError,children:jsx(Text,{style:c.amount.sheetErrorText,children:we})}):le.length===0?jsx(View,{style:c.amount.sheetLoading,children:jsx(Text,{style:[c.amount.sheetStatusText,{color:d.foregroundMuted}],children:"No purchases yet"})}):jsx(it,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:le.map(E=>{let B=E.transaction_details,Se=B?.source_amount?`$${parseFloat(B.source_amount).toFixed(2)}`:"\u2014",M=(B?.destination_currency??"").toUpperCase(),Z=B?.destination_amount?`${parseFloat(B.destination_amount).toFixed(2)} ${M}`:"",ye=Ya(E.created),de=E.destination_token_metadata,mt=Tn(de?.icon_urls,de?.icon_url),D=Tn(de?.chain?.icon_urls,de?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:c.amount.sheetOption,activeOpacity:.7,onPress:()=>ce(E),children:[jsx(Hi,{currency:M||"USD",tokenIconUrl:mt,networkIconUrl:D,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:c.amount.sheetOptionLabel,children:Se}),Z?jsx(Text,{style:c.amount.sheetOptionHint,children:Z}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx($u,{status:E.status,colors:d,fontFamily:R.regular}),ye?jsx(Text,{style:{fontSize:11,color:d.foregroundMuted,fontFamily:R.regular},children:ye}):null]}),jsx(xr,{size:14,color:d.foregroundMuted,strokeWidth:2})]})]},E.id)})})]})})]})}var qs=4;function Xa({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Ni(),{colors:a,fonts:i,components:s}=F(),l=s.input.placeholderColor,[m,u]=useState(1),[y,S]=useState(e.firstName??""),[g,b]=useState(e.lastName??""),[w,h]=useState(e.dobMonth??""),[k,c]=useState(e.dobDay??""),[d,f]=useState(e.dobYear??""),[R,_]=useState(e.addressLine1??""),[T,C]=useState(e.addressLine2??""),[x,W]=useState(e.city??""),[V,O]=useState(e.state??""),[P,q]=useState(e.postalCode??""),[N,ue]=useState(e.country??"US"),[Le,ve]=useState(e.idNumber??""),ee=useRef(null),Oe=useRef(null),fe=useRef(null),Re=useRef(null),We=useRef(null),be=useRef(null),oe=useRef(null),De=useRef(null),dt=()=>{switch(m){case 1:return y.trim().length>0&&g.trim().length>0;case 2:return w.length===2&&k.length===2&&d.length===4;case 3:return R.trim().length>0&&x.trim().length>0&&V.trim().length>0&&P.trim().length>0;case 4:return Le.trim().length>0;default:return false}},Ue=()=>{dt()&&(m<qs?u(Ce=>Ce+1):r({firstName:y,lastName:g,idNumber:Le,dobMonth:w,dobDay:k,dobYear:d,addressLine1:R,addressLine2:T,city:x,state:V,postalCode:P,country:N}));},Qe=()=>{m>1?u(Ce=>Ce-1):o();},Ke=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Ee=["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."],Je=[Ut.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:Ut.header,children:[jsx(View,{style:Ut.headerSide,children:jsx(TouchableOpacity,{style:Ut.iconButton,onPress:Qe,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:m>1?"Back":"Cancel",children:jsx(Os,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Ut.headerCenter,children:jsxs(Text,{style:Je,children:[m," of ",qs]})}),jsx(View,{style:Ut.headerSide,children:jsx(TouchableOpacity,{style:Ut.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(Ze,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Ut.progressTrack,children:Array.from({length:qs}).map((Ce,re)=>jsx(View,{style:[Ut.progressSegment,{backgroundColor:re<m||re+1===m?a.primary:a.border}]},re))}),jsxs(it,{style:n.form.flex,contentContainerStyle:Ut.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:Ke[m-1]}),jsx(Text,{style:n.form.subtitle,children:Ee[m-1]}),m===1&&jsxs(Fragment,{children:[jsx(Zo,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:y,onChangeText:S,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>ee.current?.focus()})}),jsx(Zo,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:ee,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:g,onChangeText:b,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:Ue})})]}),m===2&&jsxs(View,{style:Ut.dobRow,children:[jsxs(View,{style:Ut.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Ut.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Ut.dobInput],placeholder:"MM",placeholderTextColor:l,value:w,onChangeText:Ce=>{let re=Ce.replace(/\D/g,"").slice(0,2);h(re),re.length===2&&Oe.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Ut.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Ut.dobLabel],children:"Day"}),jsx(TextInput,{ref:Oe,style:[n.form.input,Ut.dobInput],placeholder:"DD",placeholderTextColor:l,value:k,onChangeText:Ce=>{let re=Ce.replace(/\D/g,"").slice(0,2);c(re),re.length===2&&fe.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Ut.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Ut.dobLabel],children:"Year"}),jsx(TextInput,{ref:fe,style:[n.form.input,Ut.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:d,onChangeText:Ce=>{let re=Ce.replace(/\D/g,"").slice(0,4);f(re);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:Ue})]})]}),m===3&&jsxs(Fragment,{children:[jsx(Zo,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:R,onChangeText:_,returnKeyType:"next",onSubmitEditing:()=>Re.current?.focus()})}),jsx(Zo,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:Re,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:T,onChangeText:C,returnKeyType:"next",onSubmitEditing:()=>We.current?.focus()})}),jsx(Zo,{form:n.form,label:"City",children:jsx(TextInput,{ref:We,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:x,onChangeText:W,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>be.current?.focus()})}),jsxs(View,{style:Ut.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx(Zo,{form:n.form,label:"State",children:jsx(TextInput,{ref:be,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:V,onChangeText:Ce=>O(Ce.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>oe.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx(Zo,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:oe,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:P,onChangeText:q,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>De.current?.focus()})})})]}),jsx(Zo,{form:n.form,label:"Country",children:jsx(TextInput,{ref:De,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:N,onChangeText:Ce=>ue(Ce.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:Ue})})]}),m===4&&jsxs(Zo,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:Le,onChangeText:ve,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:Ue}),jsx(Text,{style:[n.form.hint,Ut.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&m===qs?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!dt()&&n.form.continueBtnDisabled],onPress:Ue,disabled:!dt(),children:jsx(Text,{style:[n.form.continueBtnText,!dt()&&n.form.continueBtnTextDisabled],children:m===qs?"Submit":"Continue"})})})]})})}function Zo({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Ut=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 Qc="@unifold/stripe_oauth";async function Xu(){try{let e=await qc.getItem(Qc);return e?JSON.parse(e):null}catch{return null}}async function Kc(e){try{await qc.setItem(Qc,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function vn(){try{await qc.removeItem(Qc);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Uh=5,Fn=null,ep={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function el(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:m,registerWalletAddress:u,collectPaymentMethod:y,createCryptoPaymentToken:S}=useOnramp(),[g,b]=useState(r),[w,h]=useState(!!e?.externalUserId),[k,c]=useState(false),[d,f]=useState(""),[R,_]=useState(null),[T,C]=useState(e?.email??""),[x,W]=useState(e?.phone??""),[V,O]=useState(""),[P,q]=useState("US"),[N,ue]=useState(""),[Le,ve]=useState(""),ee=useRef(""),Oe=useRef(""),fe=useRef(""),[Re,We]=useState(false),[be,oe]=useState(false),De=useRef(0),dt=useRef(false),Ue=useRef(false),Qe=useRef(false),Ke=useRef(""),Ee=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),Je=useRef(null),[Ce,re]=useState(ep),[ae,tt]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[rt,Me]=useState(""),[he,ne]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[le,qt]=useState(e?.defaultSourceAmount??"100"),[pe,se]=useState(e?.defaultSourceCurrency??"usd"),[we,yt]=useState(e?.defaultDestinationCurrency??"usdc"),[ot,ce]=useState(null),[Ye,nr]=useState(),[ut,Fr]=useState(),[zr,ar]=useState(false),E=useRef(null),B=useRef(false),Se=useRef(0),M=useRef(e?.onComplete),Z=useRef(e?.onError),ye=useRef(e?.onStepChange),de=useRef(r);useEffect(()=>{M.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{Z.current=e?.onError;},[e?.onError]),useEffect(()=>{ye.current=e?.onStepChange;},[e?.onStepChange]);let mt=useRef(r);useEffect(()=>{g!==mt.current&&(ye.current?.(g,mt.current),mt.current=g),de.current=g;},[g]),useEffect(()=>{w&&g!==r&&h(false);},[w,g,r]);let D=useCallback((I,v,j)=>{let K={code:I,message:v,step:de.current,stripeErrorCode:j};_(K),f(""),Z.current?.(K);},[]),Or=useCallback(I=>{let v={sessionId:I.id,status:I.status,sourceAmount:I.transaction_details.source_amount,sourceCurrency:I.transaction_details.source_currency,destinationAmount:I.transaction_details.destination_amount,destinationCurrency:I.transaction_details.destination_currency,destinationNetwork:I.transaction_details.destination_network,walletAddress:I.transaction_details.wallet_address,fees:{networkFee:I.transaction_details.fees.network_fee_amount,transactionFee:I.transaction_details.fees.transaction_fee_amount}};return M.current?.(v),v},[]),U=useCallback(()=>_(null),[]),Rt=I=>I.refresh_token??I.refresh?.refresh_token??"",bt=useCallback((I,v,j,K,_e)=>{Oe.current=v,ee.current=j,e?.externalUserId&&Kc({accessToken:v,refreshToken:j,customerId:I,externalUserId:e.externalUserId,email:_e||T,expiresAt:Date.now()+K*1e3});},[e?.externalUserId,T]),Ur=useCallback(async()=>{let I=ee.current;if(!I)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let v=await Lc(I,fe.current??void 0),j=v.access_token,K=Rt(v)||I;return ve(j),bt(fe.current,j,K,v.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),j}catch(v){return console.error("[tryRefreshAccessToken] refresh failed:",v?.message),await vn(),Fn=null,Oe.current="",ee.current="",fe.current="",ve(""),ue(""),null}},[bt]),Zt=useCallback(async I=>{try{return await I(Oe.current)}catch(v){let j=v?.message??"";if(j.includes("stripe_onramp_forbidden")||j.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let K=await Ur();if(!K)throw D("authorization_error","Session expired. Please sign in again."),b("email"),v;return await I(K)}throw v}},[Ur,D]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){ar(false);return}let v=false;return isPlatformPaySupported().then(j=>{v||ar(j);}),()=>{v=true;}},[e?.merchantIdentifier]),useEffect(()=>(B.current=false,()=>{B.current=true,E.current&&clearTimeout(E.current);}),[]);let Oi=useRef(false);useEffect(()=>{if(Oi.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),vn(),Fn=null,h(false);return}let I=false;return (async()=>{try{let v=await Xu();if(I||!v){I||h(!1);return}if(v.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",v.externalUserId,"current:",e.externalUserId),await vn(),Fn=null,I||h(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",v.customerId);let j=Date.now()>=v.expiresAt,K=v.accessToken,_e=v.refreshToken;if(j){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Ne=await Lc(v.refreshToken,v.customerId);if(I)return;K=Ne.access_token,_e=Ne.refresh_token??Ne.refresh?.refresh_token??v.refreshToken,await Kc({accessToken:K,refreshToken:_e,customerId:v.customerId,externalUserId:e.externalUserId,email:v.email,expiresAt:Date.now()+(Ne.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Ne){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Ne?.message),await vn(),Fn=null,I||h(!1);return}}if(I)return;if(Oi.current=!0,ue(v.customerId),fe.current=v.customerId,ve(K),Oe.current=K,ee.current=_e,v.email&&C(v.email),Fn===v.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",v.customerId,"\u2014 skipping configure()"),Je.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",v.customerId);let Ne=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});Ne.error?console.error("[useStripeOnramp] restore configureSDK error:",Ne.error.message):Fn=v.customerId,Je.current=Promise.resolve(Ne);}if(I)return;let ft=()=>new Promise(Ne=>{let br=()=>{Qe.current&&Ke.current?Ne():setTimeout(br,200);};br();});try{if(await Promise.race([ft(),new Promise((br,At)=>setTimeout(()=>At(new Error("timeout")),1e4))]),I)return;let Ne=Ke.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Ne,"network:",Ee.current),await u(Ne,Ee.current);}catch(Ne){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Ne?.message);}if(I)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),b("session_params");}finally{I||h(false);}})(),()=>{I=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||Re||be)return;let I=false;oe(true);async function v(){try{let[j,K]=await Promise.all([Mu({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?zu({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Wt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Wt?.message),null)):Promise.resolve(null)]);if(I)return;let _e=e?.destinationChainType??"ethereum",ft=j.data.find(Wt=>Wt.chain_type===_e);if(ft?.address){let Wt=ft.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Wt,"recipient:",ft.recipient_address),tt(Wt),Ke.current=Wt,ft.recipient_address&&Me(ft.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",_e,"in",j.data?.length,"wallets");let Ne={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},br={8453:"base",1:"ethereum",137:"polygon"},At=K?.destination_network,mr="none";if(At&&Ne[At])ne(Ne[At]),Ee.current=Ne[At],mr=At+" (from default_token API)";else if(e?.destinationChainId&&br[e.destinationChainId]){let Wt=br[e.destinationChainId];Ne[Wt]&&(ne(Ne[Wt]),Ee.current=Ne[Wt]),mr=Wt+" (from chain_id "+e.destinationChainId+")";}else Ne[_e]&&(ne(Ne[_e]),Ee.current=Ne[_e],mr=_e+" (from chain_type fallback)");K?.destination_currency&&yt(K.destination_currency.toLowerCase());let lr=K?.destination_token_metadata,Zr=Tn(lr?.icon_urls,lr?.icon_url),Xr=Tn(lr?.chain?.icon_urls,lr?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",Zr,"network:",Xr),Zr&&nr(Zr),Xr&&Fr(Xr),We(!0),Qe.current=!0;}catch(j){console.error("[useStripeOnramp] Failed to resolve wallet:",j?.message),We(true),Qe.current=true;}finally{I||oe(false);}}return v(),()=>{I=true;}},[e?.publishableKey,e?.externalUserId]);let po=useCallback(async()=>{if(Je.current)return Je.current;let I=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),Je.current=null),v)).catch(v=>{throw console.error("[useStripeOnramp] configureSDK threw:",v?.message??v),Je.current=null,v});return Je.current=I,I},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||po();},[]);let qo=useCallback(async I=>{if(!dt.current){dt.current=true,c(true),U(),f("Creating auth intent...");try{let v=await Vc(I);f("Waiting for authorization...");let j=await i(v);if(j?.error){console.log("[proceedToAuthorize] authorize error:",j.error.message),D("authorization_error","Something went wrong during authorization. Please try again."),b("email");return}if(j?.status==="Denied"){D("authorization_error","Authorization denied by user."),b("email");return}if(j?.status!=="Consented"||!j.customerId){D("authorization_error","Authorization was canceled."),b("email");return}f("Exchanging tokens...");let K=j.customerId,_e=await Vu(v,K),ft=_e.access_token,Ne=Rt(_e);console.log("[useStripeOnramp] customerId:",K),console.log("[useStripeOnramp] accessToken acquired, length:",ft.length),ue(K),fe.current=K,Fn=K,ve(ft),bt(K,ft,Ne,_e.expires_in??3600),f("Checking verification status...");try{let br=await Ga(K,ft),At=br.verifications.find(Cn=>Cn.name==="kyc_verified"),mr=br.verifications.find(Cn=>Cn.name==="id_document_verified"),lr=At?.status==="verified",Zr=At?.status==="rejected",Xr=mr?.status==="verified",Wt=br.provided_fields.includes("first_name");if(f(""),Zr&&!Wt)D("kyc_error","KYC was previously rejected. Please submit with correct info."),b("kyc");else if(Zr&&Wt)b(Xr?"wallet":"identity");else if(!lr&&!Wt)b("kyc");else if(!Xr)b("identity");else if(Qe.current&&Ke.current)try{let Cn=Ke.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",Cn,"network:",he);let Ra=await u(Cn,he);Ra?.error?(console.warn("[proceedToAuthorize] wallet registration error:",Ra.error.message),D("wallet_error",Ra.error.message,Ra.error.code),b("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),b("session_params"));}catch(Cn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Cn?.message),b("wallet");}else b("wallet");}catch(br){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",br?.message),f(""),b("kyc");}}catch(v){D("authorization_error",v?.message??String(v)),b("email");}finally{dt.current=false,c(false);}}},[i,U,D,bt,u,he]),Q=useCallback(async()=>{if(Keyboard.dismiss(),!T){D("validation_error","Please enter an email address.");return}c(true),U(),f("");try{f("Configuring...");let I=await po();if(I.error){D("configuration_error",I.error.message,I.error.code);return}f("Checking Link account...");let v=await n(T);if(v.error){D("authorization_error",v.error.message,v.error.code);return}v.hasLinkAccount?await qo(T):(f(""),b("register"));}catch(I){D("unknown_error",I?.message??String(I));}finally{c(false);}},[U,po,T,D,n,qo]),ge=useCallback(async()=>{if(!x){D("validation_error","Please enter your phone number.");return}c(true),U(),f("");try{f("Creating Link account...");let I=await a({email:T,phone:x,fullName:V||T,country:P||"US"});if(I.error){D("registration_error",I.error.message,I.error.code);return}await qo(T);}catch(I){D("registration_error",I?.message??String(I));}finally{c(false);}},[U,P,T,D,V,x,a,qo]);useEffect(()=>{if(g!=="email"||!e?.email||w)return;let I=++De.current,v=false,j=()=>v||De.current!==I;return e?.phone?(async()=>{c(true),U();try{f("Configuring...");let K=await po();if(j())return;if(K.error){D("configuration_error",K.error.message,K.error.code);return}f("Checking Link account...");let _e=await n(e.email);if(j())return;if(_e.error){D("authorization_error",_e.error.message,_e.error.code);return}if(_e.hasLinkAccount){if(j())return;await qo(e.email);}else {f("Creating Link account...");let ft=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(j())return;if(ft.error){D("registration_error",ft.error.message,ft.error.code);return}if(j())return;await qo(e.email);}}catch(K){j()||D("unknown_error",K?.message??String(K));}finally{c(false);}})():(async()=>{c(true),U();try{f("Configuring...");let K=await po();if(j())return;if(K.error){D("configuration_error",K.error.message,K.error.code);return}f("Checking Link account...");let _e=await n(e.email);if(j())return;if(_e.error){D("authorization_error",_e.error.message,_e.error.code);return}if(_e.hasLinkAccount){if(j())return;await qo(e.email);}else {if(j())return;f(""),b("register");}}catch(K){j()||D("unknown_error",K?.message??String(K));}finally{c(false);}})(),()=>{v=true;}},[g,e?.email,e?.phone,w]);let Ot=useCallback(async I=>{c(true),U(),f(""),re(I);try{let v={firstName:I.firstName,lastName:I.lastName,idNumber:I.idNumber||void 0,dateOfBirth:{day:parseInt(I.dobDay,10),month:parseInt(I.dobMonth,10),year:parseInt(I.dobYear,10)},address:{line1:I.addressLine1,line2:I.addressLine2||void 0,city:I.city,state:I.state,postalCode:I.postalCode,country:I.country}},j=await s(v);if(j?.error){if(j.error.stripeErrorCode==="consumer_person_already_verified"){f(""),b("identity");return}D("kyc_error",j.error.message,j.error.stripeErrorCode??j.error.code),b("kyc");return}f("Please review your KYC information...");let K=await l(null);if(K?.error){D("kyc_error",K.error.message,K.error.stripeErrorCode??K.error.code),b("kyc");return}if(K?.status==="UpdateAddress"){D("kyc_error","Please update your address and resubmit."),b("kyc");return}f(""),b("identity");}catch(v){D("kyc_error",v?.message??String(v)),b("kyc");}finally{c(false);}},[s,U,D,l]),mo=useCallback(async()=>{if(!Ue.current){Ue.current=true,c(true),U(),f("Launching identity verification...");try{let I=await m();if(I?.error){D("identity_error",I.error.message,I.error.code);return}f(""),b("wallet");}catch(I){D("identity_error",I?.message??String(I));}finally{Ue.current=false,c(false);}}},[U,D,m]);useEffect(()=>{g==="identity"&&!k&&mo();},[g]);let vs=useCallback(async()=>{if(!ae){D("validation_error","Please enter a wallet address.");return}c(true),U(),f("");try{let I=ae.toLowerCase();console.log("[registerWallet] registering wallet:",I,"network:",he);let v=await u(I,he);if(v?.error){console.warn("[registerWallet] error:",v.error.message),D("wallet_error",v.error.message,v.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),b("session_params");}catch(I){D("wallet_error",I?.message??String(I));}finally{c(false);}},[U,D,ae,he,u]);useEffect(()=>{g==="wallet"&&Re&&ae&&vs();},[g,Re,ae]);let fo=useCallback(I=>{B.current=false,Se.current=0;let v=0,j=async()=>{v+=1;let K=Oe.current;try{let _e=await Wu(I,K);if(console.log(`[pollSessionStatus] poll #${v} session=${I} status="${_e.status}"`),B.current)return;Se.current=0,_e.status==="fulfillment_complete"?(ce(_e),b("success")):E.current=setTimeout(j,3e3);}catch(_e){if(B.current)return;let ft=_e?.message??"";if((ft.includes("stripe_onramp_forbidden")||ft.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Ur()&&!B.current)){E.current=setTimeout(j,1e3);return}if(Se.current+=1,console.error(`[pollSessionStatus] poll #${v} error:`,ft),Se.current>=Uh){D("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}E.current=setTimeout(j,5e3);}};E.current=setTimeout(j,3e3);},[D,Ur]),bn=useCallback(()=>{if(de.current==="processing"&&ot?.id){if(!Oe.current){D("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}U(),Se.current=0,E.current&&(clearTimeout(E.current),E.current=null),fo(ot.id);}},[U,D,fo,ot?.id]),_a=useCallback(async I=>{c(true),U(),f("");try{f("Confirming purchase...");let v=await Zt(j=>Bu(I,j));console.log("[finalizeOnrampSession] confirmed session:",v.id,"status:",v.status),ce(v),b("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",v.id),fo(v.id);}finally{c(false);}},[U,fo,Zt]),nc=useRef(false),cf=useCallback(async()=>{if(!(!ot||nc.current)){nc.current=true;try{c(!0),U(),f("Refreshing quote...");let I=await Zt(v=>Bc(ot.id,v));ce(I),await _a(I.id);}catch(I){console.log("[confirmCheckout] error:",I?.message),D("session_error","Something went wrong. Please try again."),b("quote");}finally{c(false),nc.current=false;}}},[U,D,_a,ot,Zt]),cu=useCallback(async()=>{let I=T;if(!I)return console.warn("[reauthorizeLink] no email available for re-authorization"),false;try{console.log("[reauthorizeLink] re-establishing Link session for:",I),f("Verifying identity...");let v=await Vc(I),j=await i(v);return j?.status==="Consented"&&j.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",j.customerId),fe.current=j.customerId,ue(j.customerId),Fn=j.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",j?.status),!1)}catch(v){return console.warn("[reauthorizeLink] failed:",v?.message),false}},[i,T]),df=useCallback(async(I=false,v,j)=>{let K=v??le;if(console.log("[collectPaymentMethod] called:",{useApplePay:I,amt:K,amountOverride:v,sourceAmount:le,hasSavedToken:!!j}),!K||isNaN(Number(K))||Number(K)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),D("validation_error","Please enter a valid amount.");return}v&&qt(v),c(true),U(),f("");try{let _e=await po();if(_e.error){D("configuration_error",_e.error.message,_e.error.code);return}let ft;if(j)console.log("[collectPaymentMethod] using saved payment token"),ft=j;else if(I){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),D("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),b("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let At={applePay:{merchantCountryCode:"US",currencyCode:pe.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${we.toUpperCase()} purchase + fees`,amount:K}]}},mr=await y("PlatformPay",At);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!mr?.error),mr?.error){let Zr=mr.error.message??"",Xr=mr.error.code??"",Wt=/cancel/i.test(Zr)||/cancel/i.test(Xr);console.log("[collectPaymentMethod] pmResult error:",mr.error,"isCancellation:",Wt),Wt||(D("payment_error",Zr,Xr),b("session_params"));return}if(!mr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let lr=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!lr?.error),lr?.error){D("payment_error",lr.error.message,lr.error.code),b("session_params");return}ft=lr.cryptoPaymentToken;}else {f("Select a payment method...");let At=await y("Card");if(console.log("[collectPaymentMethod] Card result ok:",!At?.error),At?.error){let Zr=At.error.message??"",Xr=At.error.code??"",Wt=/cancel/i.test(Zr)||/cancel/i.test(Xr);console.log("[collectPaymentMethod] pmResult error:",At.error,"isCancellation:",Wt),Wt||(D("payment_error",Zr,Xr),b("session_params"));return}if(!At?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let mr=At.displayData;console.log("[collectPaymentMethod] displayData:",{type:mr.type,label:mr.label,sublabel:mr.sublabel,hasIcon:!!mr.icon}),f("Creating payment token...");let lr=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!lr?.error),lr?.error){D("payment_error",lr.error.message,lr.error.code),b("session_params");return}ft=lr.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",ae,"walletAddressRef:",Ke.current);let Ne=Ke.current||ae.toLowerCase(),br=await Zt(At=>Lu({cryptoCustomerId:fe.current,paymentToken:ft,sourceAmount:Number(K),sourceCurrency:pe,destinationCurrency:we,walletAddress:Ne,destinationNetwork:he},At));console.log("[collectPaymentMethod] session created:",br?.id,"useApplePay:",I),ce(br),f(""),I?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await _a(br.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):b("quote");}catch(_e){console.log("[collectPaymentMethod] error caught:",_e?.message),D("session_error","Something went wrong. Please try again."),b("session_params");}finally{c(false),f("");}},[U,po,y,S,we,D,_a,qt,le,pe,ae,he,Zt,e?.merchantIdentifier]),uf=useCallback(async()=>{c(true),U(),f("Select a payment method...");try{let I=await po();if(I.error)return D("configuration_error",I.error.message,I.error.code),null;let v=await y("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 cu())return D("authorization_error","Please verify your identity to add a payment method."),null;v=await y("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!v?.error);}if(v?.error){let _e=v.error.message??"",ft=v.error.code??"",Ne=/cancel/i.test(_e)||/cancel/i.test(ft);return console.log("[addPaymentMethod] pmResult error:",v.error,"isCancellation:",Ne),Ne||D("payment_error",_e,ft),null}if(!v?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let j=v.displayData;console.log("[addPaymentMethod] displayData:",{type:j.type,label:j.label,sublabel:j.sublabel,hasIcon:!!j.icon}),f("Saving payment method...");let K=await S();return console.log("[addPaymentMethod] tokenResult ok:",!K?.error),K?.error?(D("payment_error",K.error.message,K.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:K.cryptoPaymentToken,sublabel:j.sublabel??""})}catch(I){return console.log("[addPaymentMethod] error:",I?.message),D("session_error",I?.message??String(I)),null}finally{c(false),f("");}},[U,po,y,S,D,cu]),pf=useCallback(async()=>{if(ot){c(true),U(),f("");try{let I=await Zt(v=>Bc(ot.id,v));ce(I);}catch(I){console.log("[refreshQuote] error:",I?.message),D("session_error","Something went wrong. Please try again.");}finally{c(false);}}},[U,D,ot,Zt]),mf=useCallback(()=>{B.current=true,Se.current=0,E.current&&(clearTimeout(E.current),E.current=null),b(r),c(false),f(""),_(null),C(e?.email??""),W(e?.phone??""),O(""),q("US"),ue(""),fe.current="",ve(""),Oe.current="",ee.current="",We(false),oe(false),re(ep),tt(e?.recipientAddress??""),Ke.current="",Qe.current=false,ne(Onramp.CryptoNetwork.ethereum),qt(e?.defaultSourceAmount??"100"),se(e?.defaultSourceCurrency??"usd"),yt(e?.defaultDestinationCurrency??"usdc"),Me(""),nr(void 0),Fr(void 0),ce(null),De.current+=1,dt.current=false,Ue.current=false;},[e,r]);return {step:g,restoring:w,loading:k,status:d,error:R,email:T,phone:x,fullName:V,country:P,customerId:N,accessToken:Le,session:ot,kycData:Ce,walletAddress:ae,resolvedRecipientAddress:rt,walletNetwork:he,sourceAmount:le,sourceCurrency:pe,destinationCurrency:we,tokenIconUrl:Ye,networkIconUrl:ut,applePaySupported:zr,walletReady:Re,walletLoading:be,setStep:b,setStatus:f,setEmail:C,setPhone:W,setFullName:O,setCountry:q,setWalletAddress:tt,setWalletNetwork:ne,setSourceAmount:qt,setSourceCurrency:se,setDestinationCurrency:yt,checkEmail:Q,register:ge,attachKyc:Ot,verifyIdentity:mo,registerWallet:vs,collectPaymentMethod:df,addPaymentMethod:uf,refreshQuote:pf,confirmCheckout:cf,reset:mf,clearError:U,emitComplete:Or,resumeFulfillmentPolling:bn,amountFirst:t}}function tp({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:a,email:i,setEmail:s,checkEmail:l,onClose:m}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Mt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(Ct,{size:56,strokeWidth:3}),jsx(Rr,{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(Mt,{onPress:m}),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(Rr,{error:n,progress:a,loading:o})]})]})})}function op({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Mt,{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(Rr,{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 ip({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:m,onRetryStatusCheck:u}){let{colors:y}=F(),S=!!t;return jsxs(View,{style:e.form.screen,children:[S?jsx(Mt,{onPress:m}):jsx(View,{style:Na}),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,gradientFrom:y.primary,gradientTo:y.primary})}),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($a,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(Rr,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:u,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function sp({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:m}){let{colors:u}=F(),y=t.transaction_details,S=Ha(y.destination_amount,y.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Mt,{onPress:m??l,title:"Review your purchase",variant:m?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(Hi,{currency:y.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(ho,{quote:e.quote,label:"You pay",value:`${y.source_amount} ${y.source_currency.toUpperCase()}`,hideDivider:true}),jsx(ho,{quote:e.quote,label:"You receive",value:`${S} ${y.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(ho,{quote:e.quote,label:"Network fee",value:`$${y.fees.network_fee_amount}`,hideDivider:true}),jsx(ho,{quote:e.quote,label:"Transaction fee",value:`$${y.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,gradientFrom:u.primaryForeground,gradientTo:u.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(Rr,{error:o,progress:n,loading:r})]})]})}function ap({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:m}){let u=F();return t?jsxs(View,{style:e.form.screen,children:[jsx(Mt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(Ct,{size:56,strokeWidth:3}),jsx(Rr,{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(Mt,{onPress:m}),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:u.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:y=>s(y.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(Rr,{error:o,progress:n,loading:r})]})]})})}function og({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=F(),n=e.toLowerCase(),a=ja[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:[Oo.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[Oo.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[Oo.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(ze,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function lp({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:m}=F(),u=t.transaction_details,y=Ha(u.destination_amount,u.destination_currency),S=r||o||"";Ui(u.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Mt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(it,{style:e.form.flex,contentContainerStyle:Oo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Oo.iconSection,children:[jsx(og,{currency:u.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:Oo.statusRow,children:[jsx(View,{style:[Oo.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[Oo.statusText,{color:s.foreground,fontFamily:m.semibold}],children:"Completed"})]}),jsx(Text,{style:[Oo.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx($a,{sourceCurrency:u.source_currency,destinationCurrency:u.destination_currency,destinationNetwork:u.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},Oo.detailCard],children:[jsx(ho,{quote:e.quote,label:"You Paid",value:`${u.source_amount} ${u.source_currency.toUpperCase()}`,hideDivider:true}),jsx(ho,{quote:e.quote,label:"You Received",value:`${y} ${u.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(ho,{quote:e.quote,label:"Network Fee",value:`$${u.fees.network_fee_amount}`,hideDivider:true}),jsx(ho,{quote:e.quote,label:"Transaction Fee",value:`$${u.fees.transaction_fee_amount}`,hideDivider:true}),jsx(Dc,{quote:e.quote,label:"Intent Address",address:u.wallet_address,hideDivider:true}),S?jsx(Dc,{quote:e.quote,label:"Recipient Address",address:S,last:true}):jsx(ho,{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 Oo=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 cp({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:m,registerWallet:u,onClose:y}){let{components:S}=F();if(t){let g=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Mt,{onPress:y}),jsxs(View,{style:e.flow.centered,children:[!g&&jsx(Ct,{size:56,strokeWidth:3}),jsx(Rr,{error:o,progress:n,loading:r})]}),g&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:u,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(Mt,{onPress:y}),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:za.map(g=>{let b=i===g.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,b&&e.wallet.rowSelected],onPress:()=>{l(g.value),m(g.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(g.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,b&&e.wallet.rowTextSelected],children:g.label}),b&&jsx(View,{style:e.wallet.checkCircle,children:jsx(ze,{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(Ct,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:u,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Rr,{error:o,progress:n,loading:r})]})]})})}function il({config:e,onClose:t}){let r=F(),o=Ni(),{step:n,restoring:a,loading:i,status:s,error:l,email:m,phone:u,session:y,kycData:S,walletAddress:g,resolvedRecipientAddress:b,walletNetwork:w,sourceAmount:h,sourceCurrency:k,destinationCurrency:c,tokenIconUrl:d,networkIconUrl:f,applePaySupported:R,setStep:_,setEmail:T,setPhone:C,setWalletAddress:x,setWalletNetwork:W,setSourceAmount:V,setDestinationCurrency:O,checkEmail:P,register:q,attachKyc:N,verifyIdentity:ue,registerWallet:Le,collectPaymentMethod:ve,addPaymentMethod:ee,confirmCheckout:Oe,reset:fe,emitComplete:Re,resumeFulfillmentPolling:We,amountFirst:be,customerId:oe,accessToken:De}=el(e),dt=!!e?.email,Ue=!!e?.phone,Qe=!!e?.publishableKey&&!!e?.externalUserId,[Ke,Ee]=useState(void 0),[Je,Ce]=useState([]);useEffect(()=>{if(a||n!=="session_params"||!oe||!De)return;console.log("[OnrampScreen] customerId:",oe);let Me=ne=>{let le=ne?.message??"";return le.includes("stripe_onramp_forbidden")||le.includes("403")},he=ne=>{Me(ne)&&(vn(),fe());};Ga(oe,De).then(ne=>{console.log("[OnrampScreen] customer fetched, id:",ne?.id);}).catch(ne=>{console.warn("[OnrampScreen] customer fetch error:",ne?.message),he(ne);}),Ac(oe,De).then(ne=>{console.log("[OnrampScreen] payment_tokens fetched, count:",ne.data?.length??0),Ce(ne.data??[]);}).catch(ne=>{console.warn("[OnrampScreen] payment_tokens error:",ne?.message),he(ne);}),console.log("[OnrampScreen] walletAddress:",g,"walletNetwork:",w),g&&(console.log("[OnrampScreen] calling getTransactionLimits..."),Eu({destinationNetwork:w||"ethereum",walletAddress:g,accessToken:De,cryptoCustomerId:oe}).then(ne=>{console.log("[OnrampScreen] transaction_limits fetched");let le=ne.limits?.usd;if(le?.card?.length){let qt=Math.max(...le.card.map(pe=>pe.limit));Ee(qt),console.log("[OnrampScreen] card max amount:",qt);}}).catch(ne=>{console.warn("[OnrampScreen] transaction_limits error:",ne?.message),he(ne);}));},[a,n,oe,De,g,w,fe]);let re=async()=>{if(!(!oe||!De))try{let Me=await Ac(oe,De);console.log("[OnrampScreen] payment_tokens refreshed, count:",Me.data?.length??0),Ce(Me.data??[]);}catch(Me){console.warn("[OnrampScreen] payment_tokens refresh error:",Me?.message);let he=Me?.message??"";(he.includes("stripe_onramp_forbidden")||he.includes("403"))&&(vn(),fe());}},ae=async()=>{let Me=await ee();return Me&&await re(),Me},tt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&tt&&y&&(Re(y),fe(),t?.());},[n,tt,y,Re,fe,t]);let rt=()=>{fe(),t?.();};return a?jsx(View,{style:[cg.container,{backgroundColor:r.colors.background}],children:jsx(Ct,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})}):n==="email"?jsx(tp,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:dt,loading:i,error:l,status:s,email:m,setEmail:T,checkEmail:P,onClose:rt}):n==="register"?jsx(ap,{styles:o,hasPrefilledPhone:Ue,loading:i,error:l,status:s,email:m,phone:u,setPhone:C,register:q,onClose:rt}):n==="kyc"?jsx(Xa,{initialData:S,loading:i,onComplete:N,onCancel:()=>_("email")}):n==="identity"?jsx(op,{styles:o,loading:i,status:s,error:l,verifyIdentity:ue,onClose:rt}):n==="wallet"?jsx(cp,{styles:o,hasAutoWallet:Qe,loading:i,error:l,status:s,walletAddress:g,walletNetwork:w,setWalletAddress:x,setWalletNetwork:W,setDestinationCurrency:O,registerWallet:Le,onClose:rt}):n==="session_params"?jsx(Za,{initialAmount:h,currency:k,applePaySupported:R,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:Ke,paymentTokens:Je,onAddPaymentMethod:ae,onCollectPayment:(Me,he)=>{ve(Me,he);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(Me,he)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:Me,selectedMethod:he,amountFirst:be}),be&&!oe)V(Me),_("email");else {let ne=he==="apple_pay",le=!ne&&he?he:void 0;console.log("[OnrampScreen] isApplePay:",ne,"hasSavedToken:",!!le),ve(ne,Me,le);}},onCancel:rt,accessToken:De,showHistoryProgressBar:e?.showHistoryProgressBar}):n==="quote"&&y?jsx(sp,{styles:o,session:y,loading:i,error:l,status:s,confirmCheckout:Oe,tokenIconUrl:d,networkIconUrl:f,onClose:rt,onBack:()=>_("session_params")}):n==="processing"?jsx(ip,{styles:o,error:l,status:s,loading:i,sourceCurrency:y?.transaction_details.source_currency,destinationCurrency:y?.transaction_details.destination_currency??c,destinationNetwork:y?.transaction_details.destination_network??"base",tokenIconUrl:d,networkIconUrl:f,onClose:rt,onRetryStatusCheck:We}):n==="success"&&y&&!tt?jsx(lp,{styles:o,session:y,resolvedRecipientAddress:b,recipientFromConfig:e?.recipientAddress,tokenIconUrl:d,networkIconUrl:f,onDone:()=>{Re(y),fe(),t?.();}}):null}var cg=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function pp(){try{let e=dg.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 sl({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:m,onError:u,onStepChange:y,onClose:S,merchantIdentifier:g="",urlScheme:b="unifoldOnramp",paymentSelectorPosition:w,skipSuccessConfirmation:h=false}){let{colors:k,fonts:c,components:d}=F(),f=e||La(),R=useMemo(()=>{let V=g.trim();return V.length>0?V:pp()??""},[g]),[_,T]=useState("loading"),[C,x]=useState(null);useEffect(()=>{let V=false;async function O(){try{f&&(qa(f),Qa(Es()));let P=await Ka();if(V)return;let q=R.trim();if(await initStripe({publishableKey:P,urlScheme:b,...q?{merchantIdentifier:q}:{}}),V)return;T("ready");}catch(P){if(V)return;console.error("[StripeOnramp] Init failed:",P),x(P?.message??"Failed to load Stripe configuration"),T("error");}}return O(),()=>{V=true;}},[f,R,b]);let W=useMemo(()=>{let V={publishableKey:f,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:m,onError:u,onStepChange:y};return s&&(V.destinationTokenAddress=s),l&&(V.recipientAddress=l),t&&(V.email=t),r&&(V.phone=r),n&&(V.flowOrder=n),w&&(V.paymentSelectorPosition=w),V.skipSuccessConfirmation=h,V.merchantIdentifier=R,V},[f,o,a,i,s,l,t,r,n,w,h,R,m,u,y]);return _==="error"?jsxs(View,{style:[Yi.centered,{backgroundColor:k.background}],children:[jsx(Text,{style:[Yi.errorText,{color:k.error,fontFamily:c.medium}],children:"Unable to initialize"}),jsx(Text,{style:[Yi.errorDetail,{color:k.foregroundMuted,fontFamily:c.regular}],children:C}),S&&jsx(TouchableOpacity,{style:[Yi.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:S,children:jsx(Text,{style:[Yi.retryBtnText,{color:d.button.primaryText,fontFamily:c.medium}],children:"Go Back"})})]}):_==="loading"?jsx(View,{style:[Yi.centered,{backgroundColor:k.background}],children:jsx(Ct,{size:56,strokeWidth:3,gradientFrom:k.primary,gradientTo:k.primary})}):jsx(il,{config:W,onClose:S})}var Yi=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",paddingHorizontal:24},errorText:{fontSize:18,marginBottom:8},errorDetail:{fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{paddingVertical:14,paddingHorizontal:32},retryBtnText:{fontSize:16}});function gp(){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 yp="__unifold_stripe_onramp__";function al(e){globalThis[yp]=e;}function bp(){return globalThis[yp]}al(sl);var Do=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 ai,Vn,Ji,Cp,Cg=(Cp=class extends Do{constructor(){super();X(this,ai);X(this,Vn);X(this,Ji);A(this,Ji,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){p(this,Vn)||this.setEventListener(p(this,Ji));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Vn))==null||t.call(this),A(this,Vn,void 0));}setEventListener(t){var r;A(this,Ji,t),(r=p(this,Vn))==null||r.call(this),A(this,Vn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){p(this,ai)!==t&&(A(this,ai,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof p(this,ai)=="boolean"?p(this,ai):globalThis.document?.visibilityState!=="hidden"}},ai=new WeakMap,Vn=new WeakMap,Ji=new WeakMap,Cp),Zi=new Cg;var wg={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Vo,li,wp,Sg=(wp=class{constructor(){X(this,Vo,wg);X(this,li,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&p(this,li)&&e!==p(this,Vo)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:p(this,Vo),provider:e}),A(this,Vo,e),process.env.NODE_ENV!=="production"&&A(this,li,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,li,true),p(this,Vo).setTimeout(e,t)}clearTimeout(e){p(this,Vo).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,li,true),p(this,Vo).setInterval(e,t)}clearInterval(e){p(this,Vo).clearInterval(e);}},Vo=new WeakMap,li=new WeakMap,wp),Lo=new Sg;function Sp(e){setTimeout(e,0);}var Zc=typeof window>"u"||"Deno"in globalThis;function rr(){}function xp(e,t){return typeof e=="function"?e(t):e}function Js(e){return typeof e=="number"&&e>=0&&e!==1/0}function cl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function wo(e,t){return typeof e=="function"?e(t):e}function Ar(e,t){return typeof e=="function"?e(t):e}function dl(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Zs(i,t.options))return false}else if(!ui(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 ul(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(ci(t.options.mutationKey)!==ci(a))return false}else if(!ui(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Zs(e,t){return (t?.queryKeyHashFn||ci)(e)}function ci(e){return JSON.stringify(e,(t,r)=>Jc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ui(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ui(e[r],t[r])):false}var kg=Object.prototype.hasOwnProperty;function ll(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=kp(e)&&kp(t);if(!o&&!(Jc(e)&&Jc(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):{},m=0;for(let u=0;u<s;u++){let y=o?u:i[u],S=e[y],g=t[y];if(S===g){l[y]=S,(o?u<a:kg.call(e,y))&&m++;continue}if(S===null||g===null||typeof S!="object"||typeof g!="object"){l[y]=g;continue}let b=ll(S,g,r+1);l[y]=b,b===S&&m++;}return a===s&&m===a?e:l}function pl(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 kp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Jc(e){if(!Tp(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!Tp(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Tp(e){return Object.prototype.toString.call(e)==="[object Object]"}function _p(e){return new Promise(t=>{Lo.setTimeout(t,e);})}function Xs(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 ll(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 ll(e,t)}return t}function Rp(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function Ip(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var di=Symbol();function ml(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===di&&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===di?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fl(e,t){return typeof e=="function"?e(...t):!!e}function vp(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 Bo=(()=>{let e=()=>Zc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function ea(){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 Pp=Sp;function Tg(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=Pp,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 Tt=Tg();var Xi,Ln,es,Fp,xg=(Fp=class extends Do{constructor(){super();X(this,Xi,true);X(this,Ln);X(this,es);A(this,es,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,Ln)||this.setEventListener(p(this,es));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Ln))==null||t.call(this),A(this,Ln,void 0));}setEventListener(t){var r;A(this,es,t),(r=p(this,Ln))==null||r.call(this),A(this,Ln,t(this.setOnline.bind(this)));}setOnline(t){p(this,Xi)!==t&&(A(this,Xi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return p(this,Xi)}},Xi=new WeakMap,Ln=new WeakMap,es=new WeakMap,Fp),ts=new xg;function _g(e){return Math.min(1e3*2**e,3e4)}function Xc(e){return (e??"online")==="online"?ts.isOnline():true}var hl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function gl(e){let t=false,r=0,o,n=ea(),a=()=>n.status!=="pending",i=w=>{if(!a()){let h=new hl(w);S(h),e.onCancel?.(h);}},s=()=>{t=true;},l=()=>{t=false;},m=()=>Zi.isFocused()&&(e.networkMode==="always"||ts.isOnline())&&e.canRun(),u=()=>Xc(e.networkMode)&&e.canRun(),y=w=>{a()||(o?.(),n.resolve(w));},S=w=>{a()||(o?.(),n.reject(w));},g=()=>new Promise(w=>{o=h=>{(a()||m())&&w(h);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),b=()=>{if(a())return;let w,h=r===0?e.initialPromise:void 0;try{w=h??e.fn();}catch(k){w=Promise.reject(k);}Promise.resolve(w).then(y).catch(k=>{if(a())return;let c=e.retry??(Bo.isServer()?0:3),d=e.retryDelay??_g,f=typeof d=="function"?d(r,k):d,R=c===true||typeof c=="number"&&r<c||typeof c=="function"&&c(r,k);if(t||!R){S(k);return}r++,e.onFail?.(r,k),_p(f).then(()=>m()?void 0:g()).then(()=>{t?S(k):b();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:u,start:()=>(u()?b():g().then(b),n)}}var pi,Op,yl=(Op=class{constructor(){X(this,pi);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),Js(this.gcTime)&&A(this,pi,Lo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Bo.isServer()?1/0:300*1e3));}clearGcTimeout(){p(this,pi)!==void 0&&(Lo.clearTimeout(p(this,pi)),A(this,pi,void 0));}},pi=new WeakMap,Op);var mi,rs,ao,fi,dr,ta,hi,Kr,Ap,en,Lp,Bp=(Lp=class extends yl{constructor(t){super();X(this,Kr);X(this,mi);X(this,rs);X(this,ao);X(this,fi);X(this,dr);X(this,ta);X(this,hi);A(this,hi,false),A(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,fi,t.client),A(this,ao,p(this,fi).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,mi,Vp(this.options)),this.state=t.state??p(this,mi),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return p(this,dr)?.promise}setOptions(t){if(this.options={...p(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Vp(this.options);r.data!==void 0&&(this.setState(Dp(r.data,r.dataUpdatedAt)),A(this,mi,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&p(this,ao).remove(this);}setData(t,r){let o=Xs(this.state.data,t,this.options);return Be(this,Kr,en).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Be(this,Kr,en).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=p(this,dr)?.promise;return p(this,dr)?.cancel(t),r?r.then(rr).catch(rr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return p(this,mi)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Ar(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===di||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>wo(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:!cl(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),p(this,dr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),p(this,dr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),p(this,ao).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,dr)&&(p(this,hi)||Be(this,Kr,Ap).call(this)?p(this,dr).cancel({revert:true}):p(this,dr).cancelRetry()),this.scheduleGc()),p(this,ao).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Be(this,Kr,en).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&p(this,dr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(p(this,dr))return p(this,dr).continueRetry(),p(this,dr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(m=>m.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:()=>(A(this,hi,true),o.signal)});},a=()=>{let l=ml(this.options,r),u=(()=>{let y={client:p(this,fi),queryKey:this.queryKey,meta:this.meta};return n(y),y})();return A(this,hi,false),this.options.persister?this.options.persister(l,u,this):l(u)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:p(this,fi),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),A(this,rs,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Be(this,Kr,en).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),A(this,dr,gl({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof hl&&l.revert&&this.setState({...p(this,rs),fetchStatus:"idle"}),o.abort();},onFail:(l,m)=>{Be(this,Kr,en).call(this,{type:"failed",failureCount:l,error:m});},onPause:()=>{Be(this,Kr,en).call(this,{type:"pause"});},onContinue:()=>{Be(this,Kr,en).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await p(this,dr).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),p(this,ao).config.onSuccess?.(l,this),p(this,ao).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof hl){if(l.silent)return p(this,dr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Be(this,Kr,en).call(this,{type:"error",error:l}),p(this,ao).config.onError?.(l,this),p(this,ao).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},mi=new WeakMap,rs=new WeakMap,ao=new WeakMap,fi=new WeakMap,dr=new WeakMap,ta=new WeakMap,hi=new WeakMap,Kr=new WeakSet,Ap=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},en=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,...ed(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...Dp(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,rs,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),Tt.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),p(this,ao).notify({query:this,type:"updated",action:t});});},Lp);function ed(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Xc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Dp(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Vp(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 Wr,je,oa,Ir,gi,os,tn,Bn,na,ns,is,yi,bi,An,ss,at,ra,td,rd,od,nd,id,sd,ad,zp,Mp,cd=(Mp=class extends Do{constructor(t,r){super();X(this,at);X(this,Wr);X(this,je);X(this,oa);X(this,Ir);X(this,gi);X(this,os);X(this,tn);X(this,Bn);X(this,na);X(this,ns);X(this,is);X(this,yi);X(this,bi);X(this,An);X(this,ss,new Set);this.options=r,A(this,Wr,t),A(this,Bn,null),A(this,tn,ea()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(p(this,je).addObserver(this),Wp(p(this,je),this.options)?Be(this,at,ra).call(this):this.updateResult(),Be(this,at,nd).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return ld(p(this,je),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ld(p(this,je),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Be(this,at,id).call(this),Be(this,at,sd).call(this),p(this,je).removeObserver(this);}setOptions(t){let r=this.options,o=p(this,je);if(this.options=p(this,Wr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ar(this.options.enabled,p(this,je))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Be(this,at,ad).call(this),p(this,je).setOptions(this.options),r._defaulted&&!pl(this.options,r)&&p(this,Wr).getQueryCache().notify({type:"observerOptionsUpdated",query:p(this,je),observer:this});let n=this.hasListeners();n&&Ep(p(this,je),o,this.options,r)&&Be(this,at,ra).call(this),this.updateResult(),n&&(p(this,je)!==o||Ar(this.options.enabled,p(this,je))!==Ar(r.enabled,p(this,je))||wo(this.options.staleTime,p(this,je))!==wo(r.staleTime,p(this,je)))&&Be(this,at,td).call(this);let a=Be(this,at,rd).call(this);n&&(p(this,je)!==o||Ar(this.options.enabled,p(this,je))!==Ar(r.enabled,p(this,je))||a!==p(this,An))&&Be(this,at,od).call(this,a);}getOptimisticResult(t){let r=p(this,Wr).getQueryCache().build(p(this,Wr),t),o=this.createResult(r,t);return Ig(this,o)&&(A(this,Ir,o),A(this,os,this.options),A(this,gi,p(this,je).state)),o}getCurrentResult(){return p(this,Ir)}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,tn).status==="pending"&&p(this,tn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){p(this,ss).add(t);}getCurrentQuery(){return p(this,je)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=p(this,Wr).defaultQueryOptions(t),o=p(this,Wr).getQueryCache().build(p(this,Wr),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Be(this,at,ra).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),p(this,Ir)))}createResult(t,r){let o=p(this,je),n=this.options,a=p(this,Ir),i=p(this,gi),s=p(this,os),m=t!==o?t.state:p(this,oa),{state:u}=t,y={...u},S=false,g;if(r._optimisticResults){let x=this.hasListeners(),W=!x&&Wp(t,r),V=x&&Ep(t,o,r,n);(W||V)&&(y={...y,...ed(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(y.fetchStatus="idle");}let{error:b,errorUpdatedAt:w,status:h}=y;g=y.data;let k=false;if(r.placeholderData!==void 0&&g===void 0&&h==="pending"){let x;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(x=a.data,k=true):x=typeof r.placeholderData=="function"?r.placeholderData(p(this,is)?.state.data,p(this,is)):r.placeholderData,x!==void 0&&(h="success",g=Xs(a?.data,x,r),S=true);}if(r.select&&g!==void 0&&!k)if(a&&g===i?.data&&r.select===p(this,na))g=p(this,ns);else try{A(this,na,r.select),g=r.select(g),g=Xs(a?.data,g,r),A(this,ns,g),A(this,Bn,null);}catch(x){A(this,Bn,x);}p(this,Bn)&&(b=p(this,Bn),g=p(this,ns),w=Date.now(),h="error");let c=y.fetchStatus==="fetching",d=h==="pending",f=h==="error",R=d&&c,_=g!==void 0,C={status:h,fetchStatus:y.fetchStatus,isPending:d,isSuccess:h==="success",isError:f,isInitialLoading:R,isLoading:R,data:g,dataUpdatedAt:y.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:y.dataUpdateCount>m.dataUpdateCount||y.errorUpdateCount>m.errorUpdateCount,isFetching:c,isRefetching:c&&!d,isLoadingError:f&&!_,isPaused:y.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:f&&_,isStale:dd(t,r),refetch:this.refetch,promise:p(this,tn),isEnabled:Ar(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let x=C.data!==void 0,W=C.status==="error"&&!x,V=q=>{W?q.reject(C.error):x&&q.resolve(C.data);},O=()=>{let q=A(this,tn,C.promise=ea());V(q);},P=p(this,tn);switch(P.status){case "pending":t.queryHash===o.queryHash&&V(P);break;case "fulfilled":(W||C.data!==P.value)&&O();break;case "rejected":(!W||C.error!==P.reason)&&O();break}}return C}updateResult(){let t=p(this,Ir),r=this.createResult(p(this,je),this.options);if(A(this,gi,p(this,je).state),A(this,os,this.options),p(this,gi).data!==void 0&&A(this,is,p(this,je)),pl(r,t))return;A(this,Ir,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!p(this,ss).size)return true;let i=new Set(a??p(this,ss));return this.options.throwOnError&&i.add("error"),Object.keys(p(this,Ir)).some(s=>{let l=s;return p(this,Ir)[l]!==t[l]&&i.has(l)})};Be(this,at,zp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Be(this,at,nd).call(this);}},Wr=new WeakMap,je=new WeakMap,oa=new WeakMap,Ir=new WeakMap,gi=new WeakMap,os=new WeakMap,tn=new WeakMap,Bn=new WeakMap,na=new WeakMap,ns=new WeakMap,is=new WeakMap,yi=new WeakMap,bi=new WeakMap,An=new WeakMap,ss=new WeakMap,at=new WeakSet,ra=function(t){Be(this,at,ad).call(this);let r=p(this,je).fetch(this.options,t);return t?.throwOnError||(r=r.catch(rr)),r},td=function(){Be(this,at,id).call(this);let t=wo(this.options.staleTime,p(this,je));if(Bo.isServer()||p(this,Ir).isStale||!Js(t))return;let o=cl(p(this,Ir).dataUpdatedAt,t)+1;A(this,yi,Lo.setTimeout(()=>{p(this,Ir).isStale||this.updateResult();},o));},rd=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(p(this,je)):this.options.refetchInterval)??false},od=function(t){Be(this,at,sd).call(this),A(this,An,t),!(Bo.isServer()||Ar(this.options.enabled,p(this,je))===false||!Js(p(this,An))||p(this,An)===0)&&A(this,bi,Lo.setInterval(()=>{(this.options.refetchIntervalInBackground||Zi.isFocused())&&Be(this,at,ra).call(this);},p(this,An)));},nd=function(){Be(this,at,td).call(this),Be(this,at,od).call(this,Be(this,at,rd).call(this));},id=function(){p(this,yi)!==void 0&&(Lo.clearTimeout(p(this,yi)),A(this,yi,void 0));},sd=function(){p(this,bi)!==void 0&&(Lo.clearInterval(p(this,bi)),A(this,bi,void 0));},ad=function(){let t=p(this,Wr).getQueryCache().build(p(this,Wr),this.options);if(t===p(this,je))return;let r=p(this,je);A(this,je,t),A(this,oa,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},zp=function(t){Tt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(p(this,Ir));}),p(this,Wr).getQueryCache().notify({query:p(this,je),type:"observerResultsUpdated"});});},Mp);function Rg(e,t){return Ar(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function Wp(e,t){return Rg(e,t)||e.state.data!==void 0&&ld(e,t,t.refetchOnMount)}function ld(e,t,r){if(Ar(t.enabled,e)!==false&&wo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&dd(e,t)}return false}function Ep(e,t,r,o){return (e!==t||Ar(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&dd(e,r)}function dd(e,t){return Ar(t.enabled,e)!==false&&e.isStaleByTime(wo(t.staleTime,e))}function Ig(e,t){return !pl(e.getCurrentResult(),t)}function ud(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,m=async()=>{let u=false,y=b=>{vp(b,()=>t.signal,()=>u=true);},S=ml(t.options,t.fetchOptions),g=async(b,w,h)=>{if(u)return Promise.reject();if(w==null&&b.pages.length)return Promise.resolve(b);let c=(()=>{let _={client:t.client,queryKey:t.queryKey,pageParam:w,direction:h?"backward":"forward",meta:t.options.meta};return y(_),_})(),d=await S(c),{maxPages:f}=t.options,R=h?Ip:Rp;return {pages:R(b.pages,d,f),pageParams:R(b.pageParams,w,f)}};if(n&&a.length){let b=n==="backward",w=b?vg:Up,h={pages:a,pageParams:i},k=w(o,h);s=await g(h,k,b);}else {let b=e??a.length;do{let w=l===0?i[0]??o.initialPageParam:Up(o,s);if(l>0&&w==null)break;s=await g(s,w),l++;}while(l<b)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=m;}}}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 vg(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ia,Ao,wr,Ci,Wo,Wn,Hp,Np=(Hp=class extends yl{constructor(t){super();X(this,Wo);X(this,ia);X(this,Ao);X(this,wr);X(this,Ci);A(this,ia,t.client),this.mutationId=t.mutationId,A(this,wr,t.mutationCache),A(this,Ao,[]),this.state=t.state||Pg(),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,Ao).includes(t)||(p(this,Ao).push(t),this.clearGcTimeout(),p(this,wr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Ao,p(this,Ao).filter(r=>r!==t)),this.scheduleGc(),p(this,wr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){p(this,Ao).length||(this.state.status==="pending"?this.scheduleGc():p(this,wr).remove(this));}continue(){return p(this,Ci)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Be(this,Wo,Wn).call(this,{type:"continue"});},o={client:p(this,ia),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,Ci,gl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Be(this,Wo,Wn).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Be(this,Wo,Wn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(this,wr).canRun(this)}));let n=this.state.status==="pending",a=!p(this,Ci).canStart();try{if(n)r();else {Be(this,Wo,Wn).call(this,{type:"pending",variables:t,isPaused:a}),p(this,wr).config.onMutate&&await p(this,wr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Be(this,Wo,Wn).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await p(this,Ci).start();return await p(this,wr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await p(this,wr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Be(this,Wo,Wn).call(this,{type:"success",data:i}),i}catch(i){try{await p(this,wr).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 p(this,wr).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 Be(this,Wo,Wn).call(this,{type:"error",error:i}),i}finally{p(this,wr).runNext(this);}}},ia=new WeakMap,Ao=new WeakMap,wr=new WeakMap,Ci=new WeakMap,Wo=new WeakSet,Wn=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,Ao).forEach(o=>{o.onMutationUpdate(t);}),p(this,wr).notify({mutation:this,type:"updated",action:t});});},Hp);function Pg(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var rn,So,sa,jp,$p=(jp=class extends Do{constructor(t={}){super();X(this,rn);X(this,So);X(this,sa);this.config=t,A(this,rn,new Set),A(this,So,new Map),A(this,sa,0);}build(t,r,o){let n=new Np({client:t,mutationCache:this,mutationId:++Ps(this,sa)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){p(this,rn).add(t);let r=bl(t);if(typeof r=="string"){let o=p(this,So).get(r);o?o.push(t):p(this,So).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(p(this,rn).delete(t)){let r=bl(t);if(typeof r=="string"){let o=p(this,So).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,So).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=bl(t);if(typeof r=="string"){let n=p(this,So).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=bl(t);return typeof r=="string"?p(this,So).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Tt.batch(()=>{p(this,rn).forEach(t=>{this.notify({type:"removed",mutation:t});}),p(this,rn).clear(),p(this,So).clear();});}getAll(){return Array.from(p(this,rn))}find(t){let r={exact:true,...t};return this.getAll().find(o=>ul(r,o))}findAll(t={}){return this.getAll().filter(r=>ul(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(rr))))}},rn=new WeakMap,So=new WeakMap,sa=new WeakMap,jp);function bl(e){return e.options.scope?.id}var Eo,qp,Qp=(qp=class extends Do{constructor(t={}){super();X(this,Eo);this.config=t,A(this,Eo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Zs(n,r),i=this.get(a);return i||(i=new Bp({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){p(this,Eo).has(t.queryHash)||(p(this,Eo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=p(this,Eo).get(t.queryHash);r&&(t.destroy(),r===t&&p(this,Eo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){Tt.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return p(this,Eo).get(t)}getAll(){return [...p(this,Eo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>dl(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>dl(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();});});}},Eo=new WeakMap,qp);var jt,En,Mn,as,ls,zn,cs,ds,Kp,pd=(Kp=class{constructor(e={}){X(this,jt);X(this,En);X(this,Mn);X(this,as);X(this,ls);X(this,zn);X(this,cs);X(this,ds);A(this,jt,e.queryCache||new Qp),A(this,En,e.mutationCache||new $p),A(this,Mn,e.defaultOptions||{}),A(this,as,new Map),A(this,ls,new Map),A(this,zn,0);}mount(){Ps(this,zn)._++,p(this,zn)===1&&(A(this,cs,Zi.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,jt).onFocus());})),A(this,ds,ts.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,jt).onOnline());})));}unmount(){var e,t;Ps(this,zn)._--,p(this,zn)===0&&((e=p(this,cs))==null||e.call(this),A(this,cs,void 0),(t=p(this,ds))==null||t.call(this),A(this,ds,void 0));}isFetching(e){return p(this,jt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return p(this,En).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,jt).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=p(this,jt).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(wo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return p(this,jt).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=p(this,jt).get(o.queryHash)?.state.data,i=xp(t,a);if(i!==void 0)return p(this,jt).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return Tt.batch(()=>p(this,jt).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,jt).get(t.queryHash)?.state}removeQueries(e){let t=p(this,jt);Tt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=p(this,jt);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,jt).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(rr).catch(rr)}invalidateQueries(e,t={}){return Tt.batch(()=>(p(this,jt).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,jt).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(rr)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(rr)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=p(this,jt).build(this,t);return r.isStaleByTime(wo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(rr).catch(rr)}fetchInfiniteQuery(e){return e.behavior=ud(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(rr).catch(rr)}ensureInfiniteQueryData(e){return e.behavior=ud(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ts.isOnline()?p(this,En).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(this,jt)}getMutationCache(){return p(this,En)}getDefaultOptions(){return p(this,Mn)}setDefaultOptions(e){A(this,Mn,e);}setQueryDefaults(e,t){p(this,as).set(ci(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...p(this,as).values()],r={};return t.forEach(o=>{ui(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){p(this,ls).set(ci(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...p(this,ls).values()],r={};return t.forEach(o=>{ui(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...p(this,Mn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Zs(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===di&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...p(this,Mn).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){p(this,jt).clear(),p(this,En).clear();}},jt=new WeakMap,En=new WeakMap,Mn=new WeakMap,as=new WeakMap,ls=new WeakMap,zn=new WeakMap,cs=new WeakMap,ds=new WeakMap,Kp);var md=Un.createContext(void 0),fd=e=>{let t=Un.useContext(md);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},hd=({client:e,children:t})=>(Un.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(md.Provider,{value:e,children:t}));var Gp=Un.createContext(false),Yp=()=>Un.useContext(Gp);Gp.Provider;function Og(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var Dg=Un.createContext(Og()),Jp=()=>Un.useContext(Dg);var Xp=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?fl(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},em=e=>{Un.useEffect(()=>{e.clearReset();},[e]);},tm=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||fl(r,[e.error,o]));var rm=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));}},om=(e,t)=>e.isLoading&&e.isFetching&&!t,nm=(e,t)=>e?.suspense&&t.isPending,gd=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function im(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=Yp(),n=Jp(),a=fd(),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",rm(i),Xp(i,n,s),em(n);let l=!a.getQueryCache().get(i.queryHash),[m]=Un.useState(()=>new t(a,i)),u=m.getOptimisticResult(i),y=!o&&e.subscribed!==false;if(Un.useSyncExternalStore(Un.useCallback(S=>{let g=y?m.subscribe(Tt.batchCalls(S)):rr;return m.updateResult(),g},[m,y]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),Un.useEffect(()=>{m.setOptions(i);},[i,m]),nm(i,u))throw gd(i,m,n);if(tm({result:u,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,u),i.experimental_prefetchInRender&&!Bo.isServer()&&om(u,o)&&(l?gd(i,m,n):s?.promise)?.catch(rr).finally(()=>{m.updateResult();}),i.notifyOnChangeProps?u:m.trackResult(u)}function on(e,t){return im(e,cd)}var ms=new Map;function sm({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 Nn({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=F(),[m,u]=useState(false),[y,S]=useState(false),[g,b]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let R=ms.get(e);return R?{uri:e,xml:R}:null}),w=e?.toLowerCase().endsWith(".svg"),h=w&&e&&g?.uri===e?g.xml:null;useEffect(()=>{u(false),S(false);},[e]),useEffect(()=>{if(!w||!e)return;if(ms.has(e)){b({uri:e,xml:ms.get(e)});return}let R=false;return fetch(e).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.text()}).then(_=>{R||(ms.set(e,_),b({uri:e,xml:_}));}).catch(()=>{R||u(true);}),()=>{R=true;}},[e,w]);let k=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:k},s]});let c={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},d=t-n*2,f=r-n*2;return m?jsx(View,{style:[c,{backgroundColor:i||k}]}):w?jsxs(View,{style:c,children:[!!!h&&jsx(sm,{width:d,height:f,borderRadius:o,color:k}),h?jsx(SvgXml,{xml:h,width:d,height:f,onError:()=>u(true)}):jsx(SvgUri,{uri:e,width:d,height:f,onError:()=>u(true)})]}):jsxs(View,{style:c,children:[!y&&jsx(sm,{width:d,height:f,borderRadius:o,color:k}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:d,height:f},resizeMode:"contain",onLoad:()=>S(true),onError:()=>u(true)})]})}function Cd(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(ms.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{ms.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function vr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:m,balanceChainId:u,balanceTokenAddress:y,publishableKey:S,projectName:g,leftIcon:b,onLeftAction:w}){let{colors:h,fonts:k,components:c}=F(),[d,f]=useState(null),[R,_]=useState(false),T=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!R)return;let x=Animated.loop(Animated.sequence([Animated.timing(T,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(T,{toValue:0,duration:700,useNativeDriver:true})]));return x.start(),()=>x.stop()},[R,T]),useEffect(()=>{if(!s||!l||!m||!u||!y||!S){f(null),_(false);return}let x=false;return _(true),Ma(l,m,u,y,S).then(W=>{if(x)return;let V=W.balance,O=null;V&&(V.amount_usd!=null&&V.amount_usd!==""?O=`$${V.amount_usd}`:O="$0.00"),f(O);}).catch(()=>{x||f(null);}).finally(()=>{x||_(false);}),()=>{x=true;}},[s,l,m,u,y,S]);let C=T.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:Sr.header,children:[jsx(View,{style:Sr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[Sr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Os,{size:20,color:c.header.buttonColor,strokeWidth:2})}):b&&w?jsx(TouchableOpacity,{onPress:w,style:[Sr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:b}):jsx(View,{style:Sr.spacer})}),jsxs(View,{style:Sr.titleContainer,children:[jsxs(View,{style:Sr.titleRow,children:[jsx(Text,{style:[Sr.title,{color:c.header.titleColor,fontFamily:k.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[Sr.titleBadge,{backgroundColor:h.card}],children:jsx(Text,{style:[Sr.titleBadgeText,{color:h.foregroundMuted,fontFamily:k.regular}],children:i.count})})]}),t?jsx(Text,{style:[Sr.balanceText,{color:h.foregroundMuted,fontFamily:k.regular}],children:t}):null,s&&(R?jsx(Animated.View,{style:[Sr.balanceSkeleton,{backgroundColor:h.cardHover,opacity:C}]}):d!=null?jsxs(Text,{style:[Sr.balanceText,{color:h.foregroundMuted,fontFamily:k.regular}],children:[g?`${g} `:"","Balance: ",d]}):null)]}),jsx(View,{style:Sr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[Sr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ze,{size:20,color:c.header.buttonColor,strokeWidth:2})}):jsx(View,{style:Sr.spacer})})]})}var Sr=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 or({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=F(),s=a??i.card,l=s.backShadowColor!=="transparent",m={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},u=[dm.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],y=[m,r];return jsxs(View,{style:u,children:[l&&jsx(View,{style:[dm.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:y,children:e}):jsx(View,{style:y,children:e})]})}var dm=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function la({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card,s=o?[...o].sort((l,m)=>l.position-m.position):[];return jsxs(or,{cardTokens:i,onPress:e,style:Mo.wrapper,contentStyle:Mo.container,children:[jsxs(View,{style:Mo.leftContent,children:[jsx(View,{style:[Mo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(pc,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Mo.textContainer,children:[jsx(Text,{style:[Mo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Mo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Mo.rightContent,children:jsx(View,{style:Mo.networkIcons,children:s.map((l,m)=>{let u=l.icon_urls.find(y=>y.format==="png")?.url||l.icon_urls.find(y=>y.format==="svg")?.url;return jsx(View,{style:[Mo.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:s.length-m}],children:jsx(Nn,{uri:te(u),width:20,height:20})},l.name)})})})]})}var Mo=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 da({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsxs(or,{cardTokens:i,onPress:e,style:nn.wrapper,contentStyle:nn.container,children:[jsxs(View,{style:nn.leftContent,children:[jsx(View,{style:[nn.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Vi,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:nn.textContainer,children:[jsx(Text,{style:[nn.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[nn.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:nn.rightContent,children:jsx(View,{style:nn.paymentIcons,children:o?.map(s=>{let l=s.icon_urls.find(m=>m.format==="png")?.url||s.icon_urls.find(m=>m.format==="svg")?.url;return jsx(Nn,{uri:te(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var nn=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 ua({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsx(or,{cardTokens:i,onPress:e,style:sn.wrapper,contentStyle:sn.container,children:jsxs(View,{style:sn.leftContent,children:[jsxs(View,{style:[sn.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(Dr,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[sn.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[sn.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:sn.textContainer,children:[jsx(Text,{style:[sn.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[sn.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var sn=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 ma({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=F(),a=n.depositMenu.card;return jsxs(or,{cardTokens:a,onPress:e,style:zo.wrapper,contentStyle:zo.container,children:[jsxs(View,{style:zo.leftContent,children:[jsx(View,{style:[zo.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(Oa,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:zo.textContainer,children:[jsx(Text,{style:[zo.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[zo.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:zo.rightContent,children:jsx(View,{style:zo.badge,children:jsx(Text,{style:[zo.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}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"},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 fm=1e4,hm=2500,gm=3e3,ym=6e4;function fa(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:m,setDepositExecutions:u,setTrackedExecutions:y,setLatestExecution:S,setShowStatusSheet:g,onDepositSuccess:b,onExecutionsChange:w,onDepositError:h}=e,[k,c]=useState(false),[d,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;c(false),t==="auto_ui"&&f(false);let _=setTimeout(()=>{c(true),t==="auto_ui"&&f(true);},fm);return ()=>clearTimeout(_)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let _=new Date(i.getTime()-ym),T=setInterval(async()=>{try{let W=[...(await Jo(n,a)).data??[]].sort((O,P)=>{let q=O.created_at?new Date(O.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-q}),V=null;for(let O of W){let P=O.created_at?new Date(O.created_at):null;if(!P||P<=_)continue;let q=m.get(O.id);if(!q){V=O;break}if(["pending","waiting","delayed"].includes(q)&&O.status==="succeeded"){V=O;break}}if(V){let O=V;u(P=>{let q=P.findIndex(N=>N.id===O.id);if(q>=0){let N=[...P];return N[q]=O,N}return [...P,O]}),y(P=>{let q=new Map(P);return q.set(O.id,O.status),q}),S(O),g(!0),O.status==="succeeded"&&b?.({message:"Deposit completed successfully",executionId:O.id}),w?.([...l,O]);}}catch(C){h?.({message:"Failed to check deposit status",error:C});}},hm);return ()=>clearInterval(T)},[n,a,i,m,l,w,b,h]),useEffect(()=>{if(!k||!s)return;let _=async()=>{try{await Ba(s,a);}catch{}};_();let T=setInterval(_,gm);return ()=>clearInterval(T)},[k,s,a]),{pollingEnabled:k,showWaitingUi:d,handleIveDeposited:()=>{c(true),f(true);}}}function ys({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=F(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",m=n||s;return jsxs(View,{style:[Cm.container,{width:t,height:t}],children:[jsx($g,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[Cm.logoContainer,{width:o+12,height:o+12,backgroundColor:m,borderRadius:(o+12)/2}],children:jsx(Nn,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var Cm=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function km(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function Gg(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 bs({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:m}){let{colors:u,fonts:y,components:S}=F(),[g,b]=useState(false),w=t==="pending"||t==="waiting"||t==="delayed",h=t==="succeeded",k=()=>{o&&Linking.openURL(o);},c=()=>{n&&Linking.openURL(n);};return jsx(pt,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:m,children:jsxs(View,{style:Vt.container,children:[jsx(TouchableOpacity,{style:Vt.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ze,{size:20,color:S.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Vt.iconContainer,children:w?jsx(Ct,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:te(r)},style:Vt.tokenIconFill}):jsx(View,{style:[Vt.tokenIconFill,{backgroundColor:u.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:te(r)},style:Vt.tokenIconLarge}):jsx(View,{style:[Vt.tokenIconLarge,{backgroundColor:u.cardHover}]}),jsx(View,{style:[Vt.statusBadge,{backgroundColor:S.container.iconBackgroundColor}],children:jsx(ze,{size:16,color:S.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Vt.title,{color:S.container.titleColor,fontFamily:y.semibold}],children:w?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Vt.amount,{color:S.container.titleColor,fontFamily:y.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[Vt.date,{color:S.container.subtitleColor,fontFamily:y.regular}],children:Gg(a)}),jsx(Text,{style:[Vt.subtitle,{color:S.container.subtitleColor,fontFamily:y.regular}],children:w?"This usually takes less than a minute.":"Your account has been credited successfully!"}),h&&(o||n)&&jsxs(View,{style:Vt.detailsSection,children:[jsx(View,{style:[Vt.divider,{backgroundColor:u.border}]}),jsxs(TouchableOpacity,{style:Vt.detailsToggle,onPress:()=>b(!g),children:[jsx(Text,{style:[Vt.detailsToggleText,{color:S.container.actionTitle,fontFamily:y.medium}],children:g?"See less":"See more details"}),g?jsx(_o,{size:18,color:S.container.actionColor,strokeWidth:2}):jsx(Dt,{size:18,color:S.container.actionColor,strokeWidth:2})]}),g&&jsxs(View,{style:Vt.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Vt.txButton,{backgroundColor:S.card.backgroundColor,borderColor:u.border}],onPress:k,children:[jsx(Text,{style:[Vt.txLabel,{color:S.card.titleColor,fontFamily:y.medium}],children:"Deposit tx"}),jsx(Text,{style:[Vt.txHash,{color:S.card.subtitleColor,fontFamily:y.regular}],children:km(o)}),jsx(xo,{size:16,color:S.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Vt.txButton,{backgroundColor:S.card.backgroundColor,borderColor:u.border}],onPress:c,children:[jsx(Text,{style:[Vt.txLabel,{color:S.card.titleColor,fontFamily:y.medium}],children:"Completion tx"}),jsx(Text,{style:[Vt.txHash,{color:S.card.subtitleColor,fontFamily:y.regular}],children:km(n)}),jsx(xo,{size:16,color:S.card.actionColor,strokeWidth:2})]})]})]})]})})}var Vt=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 _l({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=F();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[ki.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[ki.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[ki.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:[ki.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(mc,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:ki.processingCardText,children:[jsx(Text,{style:[ki.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[ki.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var ki=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 ha=(e,t)=>`${t}:${e}`,ny=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Il({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:u="auto_ui",onExecutionsChange:y,onDepositSuccess:S,onDepositError:g,borderTopLeftRadius:b,borderTopRightRadius:w,sheetBorderRadius:h}){let{colors:k,fonts:c,components:d}=F(),f=s&&l?`${s}:${l}`:"solana:mainnet",[R,_]=useState("USDC"),[T,C]=useState(f),[x,W]=useState([]),[V,O]=useState(true),[P,q]=useState([]),[N,ue]=useState(true),[Le,ve]=useState(false),[ee,Oe]=useState(false),[fe,Re]=useState(false),[We,be]=useState(false),[oe,De]=useState([]),[dt,Ue]=useState(new Map),[Qe]=useState(()=>new Date),[Ke,Ee]=useState(null),[Je,Ce]=useState(false),[re,ae]=useState(null),[tt,rt]=useState(false),Me=new Map;P.forEach(M=>{M.chains.forEach(Z=>{let ye=`${Z.chain_type}:${Z.chain_id}`;Me.has(ye)||Me.set(ye,Z);});});let he=Array.from(Me.values()),ne=ny(T),qt=he.find(M=>M.chain_type===ne.chainType&&M.chain_id===ne.chainId)?.chain_type||"ethereum",pe=Yo(x,qt),se=pe?.address||"",we=useRef(false);useEffect(()=>{async function M(){try{ue(!0),Ee(null);let ye=await ei(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(q(ye.data),ye.data.length>0&&!we.current){we.current=!0;let de,mt;if(s&&l)if(m)for(let D of ye.data){let Or=D.chains.find(U=>U.chain_type===s&&U.chain_id===l&&U.token_address.toLowerCase()===m.toLowerCase());if(Or){de=D,mt=Or;break}}else for(let D of ye.data){let Or=D.chains.find(U=>U.chain_type===s&&U.chain_id===l);if(Or){de=D,mt=Or;break}}if(!de&&a)for(let D of ye.data){let Or=D.chains.find(U=>U.token_address.toLowerCase()===a.toLowerCase());if(Or){de=D,mt=Or;break}}de||(de=ye.data.find(D=>D.symbol==="USDC"),de&&de.chains.length>0&&(mt=de.chains[0])),de||(de=ye.data.find(D=>D.symbol==="USDT"),de&&de.chains.length>0&&(mt=de.chains[0])),de||(de=ye.data[0],de.chains.length>0&&(mt=de.chains[0])),de&&_(de.symbol),mt&&C(ha(mt.chain_id,mt.chain_type));}}catch(Z){console.error("Error fetching supported tokens:",Z),Ee("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:Z});}finally{ue(false);}}M();},[t,g,s,l,m,a,n,o]),useEffect(()=>{async function M(){try{O(!0),Ee(null);let Z=await Go({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);W(Z.data);}catch(Z){console.error("Error fetching wallets:",Z),Ee("Failed to load wallets"),g?.({message:"Failed to load wallets",error:Z});}finally{O(false);}}M();},[e,r,o,n,a,t,g]);let yt=pe?.id??"",{showWaitingUi:ot,handleIveDeposited:ce}=fa({depositConfirmationMode:u,depositAddress:se,chain:T,externalUserId:e,publishableKey:t,modalOpenedAt:Qe,depositWalletId:yt,depositExecutions:oe,trackedExecutions:dt,setDepositExecutions:De,setTrackedExecutions:Ue,setLatestExecution:ae,setShowStatusSheet:Ce,onDepositSuccess:S,onExecutionsChange:y,onDepositError:g});useEffect(()=>{if(!P.length)return;let M=P.find(ye=>ye.symbol===R);if(!M||M.chains.length===0)return;if(!M.chains.some(ye=>ha(ye.chain_id,ye.chain_type)===T)){let ye=M.chains[0];C(ha(ye.chain_id,ye.chain_type));}},[R,P,T]);let Ye=P.find(M=>M.symbol===R),nr=Ye?.chains||[],ut=nr.find(M=>ha(M.chain_id,M.chain_type)===T),Fr=async()=>{if(se)try{Clipboard.setString(se),ve(!0),setTimeout(()=>ve(!1),2e3);}catch(M){console.error("Failed to copy:",M);}},zr=ut?.estimated_price_impact_percent??0,ar=ut?.max_slippage_percent??.25,E=ut?.minimum_deposit_amount_usd??3;if(N)return jsxs(View,{style:L.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:k.primary}),jsx(Text,{style:[L.loadingText,{color:k.foregroundMuted,fontFamily:c.regular}],children:"Loading currencies..."})]});if(Ke&&P.length===0)return jsxs(View,{style:L.errorContainer,children:[jsx(Text,{style:[L.errorText,{color:k.error,fontFamily:c.regular}],children:Ke}),jsx(Text,{style:[L.errorHint,{color:k.foregroundMuted,fontFamily:c.regular}],children:"Please check your network connection and try again."})]});let B=()=>jsxs(pt,{visible:fe,onClose:()=>Re(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.tokenSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.tokenSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:k.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:c.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Re(false),style:L.sheetCloseButton,children:jsx(Ze,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(it,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:P.map(M=>jsxs(TouchableOpacity$1,{onPress:()=>{_(M.symbol),Re(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:R===M.symbol?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:te(ke(M,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:c.medium}],children:M.symbol}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:c.regular}],children:[M.chains.length," network",M.chains.length!==1?"s":""," available"]})]}),R===M.symbol&&jsx(ze,{size:20,color:k.primary,strokeWidth:2})]},M.symbol))})]}),Se=()=>jsxs(pt,{visible:We,onClose:()=>be(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.chainSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.chainSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:k.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:c.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>be(false),style:L.sheetCloseButton,children:jsx(Ze,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(it,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:nr.map(M=>{let Z=ha(M.chain_id,M.chain_type),ye=T===Z;return jsxs(TouchableOpacity$1,{onPress:()=>{C(Z),be(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:ye?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:te(ke(M,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:c.medium}],children:M.chain_name}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:c.regular}],children:["Min deposit: $",M.minimum_deposit_amount_usd]})]}),ye&&jsx(ze,{size:20,color:k.primary,strokeWidth:2})]},Z)})})]});return jsxs(View,{style:L.container,children:[jsxs(View,{style:L.selectorSection,children:[jsx(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:c.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Re(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[Ye&&jsx(Image,{source:{uri:te(ke(Ye,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:c.medium}],children:R}),jsx(Dt,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:L.selectorSection,children:[jsxs(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:c.regular}],children:["Network"," ",jsxs(Text,{style:[L.minDeposit,{fontFamily:c.regular}],children:["($",E," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>be(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[ut&&jsx(Image,{source:{uri:te(ke(ut,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:c.medium}],numberOfLines:1,children:ut?.chain_name||"Select network"}),jsx(Dt,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:L.qrContainer,children:jsx(View,{style:[L.qrWrapper,{backgroundColor:k.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:V?jsxs(View,{style:L.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:k.primary}),jsx(Text,{style:[L.loadingText,{color:k.foregroundMuted,fontFamily:c.regular}],children:"Loading..."})]}):se?jsx(ys,{value:se,size:160,logoUri:te(ke(ut,"png")||Kt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:L.qrLoading,children:jsx(Text,{style:[L.errorText,{color:k.error,fontFamily:c.regular}],children:"No address available"})})})}),jsxs(View,{style:L.addressSection,children:[jsxs(View,{style:L.addressHeader,children:[jsx(Text,{style:[L.addressLabel,{color:d.card.labelColor,fontFamily:c.medium}],children:"Deposit Address"}),Le&&jsxs(View,{style:L.copiedIndicator,children:[jsx(ze,{size:14,color:k.success,strokeWidth:2}),jsx(Text,{style:[L.copiedText,{color:k.success,fontFamily:c.regular}],children:"Copied"})]})]}),jsxs(or,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!V&&se?Fr:void 0,contentStyle:L.addressBox,children:[jsx(Text,{style:[L.addressText,{color:d.card.titleColor,fontFamily:c.regular}],numberOfLines:2,children:V?"Loading...":se||"No address available"}),jsx(View,{style:L.addressCopyIcon,children:jsx(Qo,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[L.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Oe(!ee),style:L.detailsHeader,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(Dr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:c.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:L.chevronContainer,children:ee?jsx(_o,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(Dt,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),ee&&jsxs(View,{style:L.detailsContent,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(wn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:c.regular}],children:["Price impact: ",zr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>rt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Bi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(Sn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:c.regular}],children:["Slippage: Auto \u2022 ",ar.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>rt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Bi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(Pa,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:c.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(_l,{depositConfirmationMode:u,depositAddress:se,showWaitingUi:ot,latestExecution:re,onIveDeposited:ce}),jsx(TouchableOpacity$1,{style:L.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[L.termsText,{color:k.primary,fontFamily:c.regular}],children:"Terms apply"})}),B(),Se(),jsxs(pt,{visible:tt,onClose:()=>rt(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:h?.infoSheet?.borderTopLeftRadius??b,borderTopRightRadius:h?.infoSheet?.borderTopRightRadius??w,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:k.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:c.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>rt(false),style:L.sheetCloseButton,children:jsx(Ze,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:L.infoSheetContent,children:[jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(wn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:c.medium}],children:"Price Impact"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:c.medium}],children:[zr.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:c.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:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(Sn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:c.medium}],children:"Max Slippage"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:c.medium}],children:[ar.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:c.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."})]})]})]}),re&&jsx(bs,{visible:Je,status:re.status,tokenIconUrl:re.destination_token_metadata?.icon_urls?.find(M=>M.format==="png")?.url||re.destination_token_metadata?.icon_url||ke(Ye,"png"),explorerUrl:re.explorer_url,completionExplorerUrl:re.destination_explorer_url,date:re.created_at?new Date(re.created_at):void 0,amountUsd:re.source_amount_usd?parseFloat(re.source_amount_usd):void 0,onClose:()=>Ce(false),borderTopLeftRadius:h?.depositStatus?.borderTopLeftRadius??b,borderTopRightRadius:h?.depositStatus?.borderTopRightRadius??w})]})}var L=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},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:{flex:1,paddingTop:8},sheetListContent:{paddingBottom:56},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 vl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=F();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ti.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:Ti.leftContent,children:[jsx(View,{style:[Ti.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:te(ke(e,"png"))},style:Ti.icon})}),jsxs(View,{style:Ti.textContainer,children:[jsx(Text,{style:[Ti.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ti.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(ze,{size:16,color:o.primary,strokeWidth:2})]})}var Ti=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 ya({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=F();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:Rm.headerContainer,children:jsx(Text,{style:[Rm.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(vl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var Rm=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Fl({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:u}=F(),[y,S]=useState(""),g=o.map(f=>r.find(R=>R.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),b=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),w=f=>{if(!y)return f;let R=y.toLowerCase();return f.filter(_=>_.name.toLowerCase().includes(R)||_.currency_code.toLowerCase().includes(R))},h=w(g),k=w(b),c=f=>{a(f),t(false),S("");},d=()=>{t(false),S("");};return jsxs(pt,{visible:e,onClose:d,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(vr,{title:"Currency",showBack:false,onClose:d}),jsx(View,{style:xi.searchContainer,children:jsx(TextInput,{style:[xi.searchInput,{backgroundColor:u.search.backgroundColor,color:u.search.inputColor,fontFamily:m.regular,borderRadius:u.input.borderRadius,borderWidth:u.input.borderWidth,borderColor:u.input.borderColor}],value:y,onChangeText:S,placeholder:"Search",placeholderTextColor:u.search.placeholderColor})}),jsx(it,{style:xi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:xi.listContent,children:[jsx(ya,{title:"Popular currencies",currencies:h,selectedCurrency:n,onSelect:c}),h.length>0&&k.length>0&&jsx(View,{style:xi.sectionSpacer}),jsx(ya,{title:"All currencies",currencies:k,selectedCurrency:n,onSelect:c}),h.length===0&&k.length===0&&jsx(View,{style:xi.noResultsContainer,children:jsx(Text,{style:[xi.noResultsText,{color:u.container.subtitleColor,fontFamily:m.regular}],children:"No currencies found"})})]})})]})}var xi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:72},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function zd(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 Vl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:m,onDepositError:u,borderTopLeftRadius:y,borderTopRightRadius:S,sheetBorderRadius:g}){let{colors:b,fonts:w,components:h}=F(),[k,c]=useState(""),[d,f]=useState("usd"),[R,_]=useState(false),[T,C]=useState(false),[x,W]=useState([]),[V,O]=useState(false),[P,q]=useState(null),[N,ue]=useState(null),[Le,ve]=useState("amount"),[ee,Oe]=useState(null),[fe,Re]=useState(true),[We,be]=useState(null),[oe,De]=useState(false),dt=useRef(null),Ue=useRef(false);useEffect(()=>{dt.current=ee;},[ee]),useEffect(()=>{Ue.current=oe;},[oe]);let[Qe,Ke]=useState([]),[Ee,Je]=useState(true),[Ce,re]=useState(60),[ae,tt]=useState([]),[rt,Me]=useState([]),[he,ne]=useState(null),[le,qt]=useState(null),[pe,se]=useState(true),[we,yt]=useState(null),[ot,ce]=useState(false),[Ye,nr]=useState(null),[ut,Fr]=useState(false),[zr,ar]=useState(false),[E,B]=useState(false),[Se,M]=useState(null),Z=r??Le,ye=useRef(null),de=ae.find(Q=>Q.currency_code.toLowerCase()===d.toLowerCase()),mt=useCallback(Q=>{ve(Q),Q==="quotes"?o?.(Q,x.length):o?.(Q);},[x.length,o]);useEffect(()=>{async function Q(){try{let ge=await zs();qt(ge);}catch(ge){console.error("Error fetching user IP:",ge);}finally{se(false);}}Q();},[]),useEffect(()=>{async function Q(){try{let ge=await Go({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);Ke(ge.data);}catch(ge){console.error("Error fetching wallets:",ge),q("Failed to load wallet addresses");}finally{Je(false);}}Q();},[e,a,i,s,l,t]);let D=n||he?.symbol.toUpperCase()||"USDC",Or=Ei(he?.icon_urls,"png")||he?.icon_url,U=Ei(he?.chain_icon_urls,"png")||he?.chain_icon_url;useEffect(()=>{async function Q(){try{let ge=await Tc(t);tt(ge.data),Me(ge.preferred||[]);}catch(ge){console.error("Error fetching fiat currencies:",ge);}}Q();},[t]),useEffect(()=>{if(R||ae.length===0||!le?.alpha2)return;let Q=le.alpha2.toUpperCase(),ge=ae.find(Ot=>Ot.country_codes.includes(Q));if(ge)f(ge.currency_code.toLowerCase()),!k&&!T&&c(String(ge.default_amount??100));else if(!k&&!T){let Ot=ae.find(mo=>mo.currency_code.toLowerCase()==="usd");Ot&&c(String(Ot.default_amount??100));}},[ae,le,R,k,T]),useEffect(()=>{if(ae.length!==0){if(ye.current!==null&&ye.current!==d){let Q=ae.find(ge=>ge.currency_code.toLowerCase()===d.toLowerCase());Q&&c(String(Q.default_amount??100));}ye.current=d;}},[d,ae]),useEffect(()=>{async function Q(){try{let ge=await Cc({chain_type:i||"",chain_id:s||"",token_address:l||""},t);ne(ge);}catch(ge){console.error("Error fetching supported tokens:",ge);}}Q();},[i,s,l,t]),useEffect(()=>{async function Q(){if(!(!l||!s||!i)&&!pe){ce(true);try{let ge=await kc({country_code:le?.alpha2?.toUpperCase()||"US",subdivision_code:le?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);yt(ge);}catch(ge){console.error("Error fetching default onramp token:",ge);}finally{ce(false);}}}Q();},[l,s,i,le,pe,t]),useEffect(()=>{let Q=parseFloat(k);if(isNaN(Q)||Q<=0){W([]),ue(null);return}if(!we||ot){W([]),Oe(null);return}let ge=ae.find(mo=>mo.currency_code.toLowerCase()===d.toLowerCase());if(ge){if(Q<ge.minimum_amount){W([]),Oe(null),ue(`Minimum amount is ${zd(d)}${ge.minimum_amount.toLocaleString()}`);return}if(Q>ge.maximum_amount){W([]),Oe(null),ue(`Maximum amount is ${zd(d)}${ge.maximum_amount.toLocaleString()}`);return}}ue(null);let Ot=setTimeout(()=>{Rt(Q);},500);return ()=>clearTimeout(Ot)},[k,d,t,we,ot,ae]);let Rt=async Q=>{if(!we){q("Loading token information...");return}O(true),q(null);try{let ge={country_code:le?.alpha2?.toUpperCase()||"US",source_amount:Q.toString(),source_currency:d.toLowerCase(),destination_currency:we.destination_currency,destination_network:we.destination_network,subdivision_code:le?.state||void 0},Ot=await wc(ge,t);W(Ot.data);let mo=Ue.current,vs=dt.current;if(mo&&vs){let fo=Ot.data.find(bn=>bn.service_provider===vs.service_provider);if(fo){if(Oe(fo),Ot.data.length>0){let bn=Ot.data[0];We||be(bn.service_provider),Re(fo.service_provider===We);}}else if(Ot.data.length>0){let bn=Ot.data[0];Oe(bn),be(bn.service_provider),Re(!0),De(!1);}}else if(Ot.data.length>0){let fo=Ot.data[0];Oe(fo),be(fo.service_provider),Re(!0);}re(60);}catch(ge){console.error("Failed to fetch quotes:",ge),q("Failed to fetch quotes. Please try again."),W([]);}finally{O(false);}};useEffect(()=>{if(x.length===0)return;let Q=setInterval(()=>{re(ge=>{if(ge<=1){let Ot=parseFloat(k);return !isNaN(Ot)&&Ot>0&&Rt(Ot),60}return ge-1});},1e3);return ()=>clearInterval(Q)},[x.length,k]);let bt=Q=>{(/^\d*\.?\d{0,2}$/.test(Q)||Q==="")&&(c(Q),C(true));},Ur=Q=>{c(Q.toString()),C(true);},Zt=async()=>{if(ee&&we)try{let Q=we.destination_token_metadata.chain_type,ge=Yo(Qe,Q);if(!ge?.address){q("Wallet address not available");return}let Ot={service_provider:ee.service_provider,country_code:ee.country_code?.toUpperCase()||le?.alpha2?.toUpperCase()||"US",source_currency:ee.source_currency,source_amount:k,destination_currency:ee.destination_currency,destination_network:ee.destination_network,wallet_address:ge.address,subdivision_code:le?.state||void 0},mo=await Sc(Ot,t);nr({provider:ee,sourceCurrency:d,sourceAmount:k,sessionUrl:mo.url}),M(mo.url),B(!0);}catch(Q){console.error("Failed to create session:",Q),q("Failed to start payment flow"),u?.({message:"Failed to start payment flow",error:Q});}},Oi=zd(d),po=()=>{B(false),mt("onramp"),m?.({message:"Payment flow completed"});},qo=()=>jsx(by,{visible:E,onClose:po,url:Se,providerName:ee?.service_provider_display_name||"Complete Payment",colors:b,fonts:w,borderTopLeftRadius:g?.webView?.borderTopLeftRadius??y,borderTopRightRadius:g?.webView?.borderTopRightRadius??S});return Z==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:$.amountViewContainer,children:[jsxs(it,{style:$.scrollContainer,contentContainerStyle:$.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:$.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Fr(true),style:[$.currencyButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.input.borderRadius,borderWidth:h.input.borderWidth,borderColor:h.input.borderColor}],children:[de&&jsx(Image,{source:{uri:te(ke(de,"png"))},style:$.currencyIcon}),jsx(Text,{style:[$.currencyText,{color:h.card.titleColor,fontFamily:w.medium}],children:d.toUpperCase()}),jsx(Dt,{size:16,color:h.card.actionColor,strokeWidth:2})]})}),jsx(Fl,{open:ut,onOpenChange:Fr,currencies:ae,preferredCurrencyCodes:rt,selectedCurrency:d,onSelectCurrency:Q=>{f(Q.toLowerCase()),_(true);},borderTopLeftRadius:g?.currencyModal?.borderTopLeftRadius??y,borderTopRightRadius:g?.currencyModal?.borderTopRightRadius??S}),jsx(View,{style:$.amountContainer,children:jsxs(View,{style:$.amountInputRow,children:[jsx(Text,{style:[$.currencySymbol,{color:h.container.titleColor,fontFamily:w.medium}],children:Oi}),jsx(TextInput,{style:[$.amountInput,{color:h.container.titleColor,fontFamily:w.medium}],value:k,onChangeText:bt,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:b.foregroundMuted})]})}),de?.suggested_amounts&&de.suggested_amounts.length>0&&jsx(View,{style:$.quickAmounts,children:de.suggested_amounts.map(Q=>jsx(TouchableOpacity$1,{onPress:()=>Ur(Q),style:[$.quickAmountButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.button.borderRadius,borderWidth:parseFloat(k)===Q?2:h.button.borderWidth,borderColor:parseFloat(k)===Q?b.primary:h.button.borderColor}],children:jsxs(Text,{style:[$.quickAmountText,{color:h.card.titleColor,fontFamily:w.medium}],children:[Oi,Q.toLocaleString()]})},Q))}),N&&jsx(Text,{style:[$.validationError,{color:b.error,fontFamily:w.regular}],children:N}),jsxs(View,{style:$.providerSection,children:[jsxs(View,{style:$.providerHeader,children:[jsx(Text,{style:[$.providerLabel,{color:h.card.labelColor,fontFamily:w.medium}],children:"Provider"}),x.length>0&&!V&&jsxs(Text,{style:[$.refreshText,{color:h.card.labelRightColor,fontFamily:w.regular}],children:["Refreshing in ",Ce,"s"]})]}),jsx(or,{cardTokens:h.depositCard.quoteProvider.card,onPress:V||x.length===0?void 0:()=>ar(true),contentStyle:StyleSheet.flatten([$.providerButton,(V||x.length===0)&&$.disabled]),children:V?jsxs(View,{style:$.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[$.loadingText,{color:h.container.subtitleColor,fontFamily:w.regular}],children:"Finding best rates..."})]}):ee?jsxs(View,{style:$.providerContent,children:[jsxs(View,{style:$.providerInfo,children:[fe&&jsx(Text,{style:[$.autoPickedText,{color:h.container.subtitleColor,fontFamily:w.regular}],children:"Auto-picked for you"}),jsxs(View,{style:$.providerRow,children:[jsx(Image,{source:{uri:te(Aa(ee.icon_urls,"png",ee.icon_url))},style:$.providerIconImage},`provider-${ee.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[$.providerName,{color:h.card.titleColor,fontFamily:w.medium}],children:ee.service_provider_display_name}),jsxs(Text,{style:[$.bestPriceText,{color:h.container.subtitleColor,fontFamily:w.regular}],children:[ee.destination_amount.toFixed(2)," ",D]})]})]})]}),jsx(xr,{size:20,color:h.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[$.noProviderText,{color:h.container.subtitleColor,fontFamily:w.regular}],children:parseFloat(k)>0?"No providers available":"Enter an amount to see providers"})}),P&&jsx(Text,{style:[$.errorText,{color:b.error,fontFamily:w.regular}],children:P})]}),jsxs(pt,{visible:zr,onClose:()=>ar(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:g?.providerModal?.borderTopLeftRadius??y,borderTopRightRadius:g?.providerModal?.borderTopRightRadius??S,children:[jsx(vr,{title:"Select Provider",showBack:false,onClose:()=>ar(false)}),jsx(it,{style:$.providerModalList,contentContainerStyle:$.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:$.quotesList,children:x.map(Q=>{let ge=ee?.service_provider===Q.service_provider;return jsxs(or,{cardTokens:h.depositCard.quoteProvider.card,onPress:()=>{Oe(Q),De(true),Re(Q.service_provider===We),ar(false);},contentStyle:StyleSheet.flatten([$.quoteItem,ge&&{borderWidth:2,borderColor:b.primary}]),children:[jsxs(View,{style:$.quoteLeft,children:[jsx(Image,{source:{uri:te(Aa(Q.icon_urls,"png",Q.icon_url))},style:$.providerIconImage}),jsx(View,{children:jsx(Text,{style:[$.quoteName,{color:h.card.titleColor,fontFamily:w.medium}],children:Q.service_provider_display_name})})]}),jsxs(View,{style:$.quoteRight,children:[jsxs(Text,{style:[$.quoteAmount,{color:h.card.textRightColor,fontFamily:w.medium}],children:[Q.destination_amount.toFixed(2)," ",D]}),jsxs(Text,{style:[$.quoteSource,{color:h.card.subtextRightColor,fontFamily:w.regular}],children:["Fee: ",Oi,Q.total_fee.toFixed(2)]})]})]},Q.service_provider)})})})]})]}),jsx(View,{style:[$.continueButtonContainer,{backgroundColor:b.background}],children:jsx(View,{style:{opacity:V||Ee||!ee||parseFloat(k)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:Zt,disabled:V||Ee||!ee||parseFloat(k)<=0,style:[$.continueButton,{backgroundColor:h.container.buttonColor,borderRadius:h.button.borderRadius,borderWidth:h.button.borderWidth,borderColor:h.button.borderColor}],children:jsx(Text,{style:[$.continueButtonText,{color:h.container.buttonTitleColor,fontFamily:w.medium}],children:Ee?"Loading...":"Continue"})})})})]}),qo()]}):Z==="onramp"&&Ye?jsxs(View,{style:$.onrampContainer,children:[jsx(Image,{source:{uri:te(Aa(Ye.provider.icon_urls,"png",Ye.provider.icon_url))},style:$.onrampProviderIcon}),jsxs(Text,{style:[$.onrampTitle,{color:h.container.titleColor,fontFamily:w.medium}],children:["Complete transaction with ",Ye.provider.service_provider_display_name]}),jsx(Text,{style:[$.onrampSubtitle,{color:h.container.subtitleColor,fontFamily:w.regular}],children:"You can close this modal."}),jsxs(View,{style:[$.flowDiagram,{backgroundColor:h.card.backgroundColor}],children:[jsxs(View,{style:$.flowStep,children:[jsx(Image,{source:{uri:Kt(`/icons/currencies/png/${Ye.sourceCurrency.toLowerCase()}.png`)},style:$.flowIconImage}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:w.regular}],children:"You use"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:w.medium}],children:Ye.sourceCurrency.toUpperCase()})]}),jsx(xr,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:$.flowStep,children:[jsxs(View,{style:$.flowIconWithBadge,children:[jsx(Image,{source:{uri:Ei(we?.destination_token_metadata?.icon_urls,"png")||we?.destination_token_metadata?.icon_url||Kt("/icons/tokens/png/usdc.png")},style:$.flowIconImageNoBadge}),jsx(Image,{source:{uri:Ei(we?.destination_token_metadata?.chain?.icon_urls,"png")||we?.destination_token_metadata?.chain?.icon_url||Kt("/icons/networks/png/polygon.png")},style:[$.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:w.regular}],children:"You buy"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:w.medium}],children:"USDC"})]}),jsx(xr,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:$.flowStep,children:[jsxs(View,{style:$.flowIconWithBadge,children:[jsx(Image,{source:{uri:Or||Kt("/icons/tokens/png/usdc.png")},style:$.flowIconImageNoBadge}),jsx(Image,{source:{uri:U||Kt("/icons/networks/png/polygon.png")},style:[$.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:w.regular}],children:"You receive"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:w.medium}],children:D})]})]}),jsx(View,{style:[$.onrampInfoBox,{backgroundColor:h.card.backgroundColor,borderRadius:h.card.borderRadius,borderWidth:h.card.borderWidth,borderColor:h.card.borderColor}],children:jsx(Text,{style:[$.onrampInfoText,{color:h.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 by({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(pt,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:_i.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:_i.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ze,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[_i.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:_i.headerSpacer})]}),r&&jsx(View,{style:_i.container,children:jsx(WebView,{source:{uri:r},style:_i.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:_i.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var _i=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"}}),$=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:48},continueButton:{paddingVertical:16,alignItems:"center"},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:{flex:1,paddingHorizontal:12,marginTop:8},providerModalListContent:{paddingBottom:72},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"},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 ky(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 Ty(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Al({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=F(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=te(ke(e.destination_token_metadata,"png")||Kt("/icons/tokens/png/usdc.png")),m=i?"Deposit Processing":"Deposit Completed",u=ky(e.created_at||new Date().toISOString()),y=Ty(e.source_amount_usd);return jsxs(or,{cardTokens:a,onPress:t,contentStyle:dn.container,children:[jsxs(View,{style:dn.iconContainer,children:[jsx(Image,{source:{uri:l},style:dn.tokenIcon}),jsx(View,{style:[dn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(Fa,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(ze,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:dn.textContainer,children:[jsx(Text,{style:[dn.title,{color:a.titleColor,fontFamily:o.medium}],children:m}),jsx(Text,{style:[dn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:u})]}),jsxs(View,{style:dn.rightContainer,children:[jsx(Text,{style:[dn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:y}),jsx(xr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var dn=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 Fm(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 Om(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 _y(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var Dm=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Vm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Ry(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 Iy({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,a=t.cardHover;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:Ri.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[Ri.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[Ri.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:Ri.textBlock,children:[jsx(Animated.View,{style:[Ri.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[Ri.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[Ri.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var Ri=StyleSheet.create({list:{paddingTop:16,paddingHorizontal:16,gap:12},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},icon:{width:40,height:40,borderRadius:20,marginRight:12},textBlock:{flex:1,gap:6},titleBar:{height:14,width:"65%",borderRadius:7},subtitleBar:{height:11,width:"45%",borderRadius:5.5},amountBar:{height:14,width:50,borderRadius:7,marginLeft:12}});function Nd({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=F(),[l,m]=useState(r),[u,y]=useState(false),[S,g]=useState(null),[b,w]=useState(false),h=useRef(null);useEffect(()=>{if(!e||!o)return;let T=async()=>{y(true);try{let W=[...(await Jo(o,n)).data].sort((V,O)=>{let P=V.created_at?new Date(V.created_at).getTime():0;return (O.created_at?new Date(O.created_at).getTime():0)-P});m(W);}catch(x){console.error("Failed to fetch executions:",x),m(r);}finally{y(false);}};T();let C=setInterval(T,1e4);return ()=>clearInterval(C)},[e,o,n,r]),useEffect(()=>{r.length>0&&m(T=>{let C=new Set(T.map(W=>W.id)),x=r.filter(W=>!C.has(W.id));return x.length>0?[...x,...T]:T});},[r]),useEffect(()=>{e||g(null);},[e]);let k=T=>{g(T);},c=()=>{g(null),w(false);},d=()=>{g(null),t();},f=()=>{if(!S)return null;let T=S,C=T.status==="pending"||T.status==="waiting"||T.status==="delayed",x=T.status==="succeeded",W=te(ke(T.destination_token_metadata,"png")||Kt("/icons/tokens/png/usdc.png")),V=T.provider_metadata?.details,O=V?.currencyIn,P=V?.currencyOut;O?.currency?.symbol||"USDC";P?.currency?.symbol||"USDC";let ue=Om(T.source_amount_base_unit,T.source_token_metadata?.decimals),Le=Om(T.destination_amount_base_unit,T.destination_token_metadata?.decimals),ve=_y(T.source_amount_usd),ee=Fm(T.source_chain_type,T.source_chain_id),Oe=Fm(T.destination_chain_type,T.destination_chain_id),fe=()=>{T.explorer_url&&Linking.openURL(T.explorer_url);},Re=()=>{T.destination_explorer_url&&Linking.openURL(T.destination_explorer_url);};return jsxs(it,{ref:h,style:me.scrollContainer,contentContainerStyle:me.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:me.iconSection,children:[jsxs(View,{style:me.iconWrapper,children:[jsx(Image,{source:{uri:W},style:me.tokenIcon}),jsx(View,{style:[me.statusBadge,{backgroundColor:C?a.warning:a.success,borderColor:a.background}],children:C?jsx(Dt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(ze,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:me.statusRow,children:[jsx(View,{style:[me.statusDot,{backgroundColor:C?a.warning:a.success}]}),jsx(Text,{style:[me.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:C?"Processing":"Completed"})]}),jsx(Text,{style:[me.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:Ry(T.created_at||new Date().toISOString())})]}),jsxs(View,{style:[me.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ue," ",Vm(T.source_currency)]})]}),jsx(View,{style:[me.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[Le," ",Vm(T.destination_currency)]})]}),jsx(View,{style:[me.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:ve})]}),jsx(View,{style:[me.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:ee})]}),jsx(View,{style:[me.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Oe})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let We=!b;w(We),We?setTimeout(()=>{h.current?.scrollToEnd({animated:true});},100):h.current?.scrollTo({y:0,animated:true});},style:me.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[me.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:b?"See less":"See more details"}),b?jsx(_o,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(Dt,{size:14,color:s.container.actionColor,strokeWidth:2})]}),b&&jsxs(View,{style:[me.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[T.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:fe,style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:me.cardRowRight,children:[jsx(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Dm(T.transaction_hash)}),jsx(xo,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[me.cardDivider,{backgroundColor:a.border}]})]}),T.destination_explorer_url&&x&&jsxs(TouchableOpacity,{onPress:Re,style:me.cardRow,children:[jsx(Text,{style:[me.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:me.cardRowRight,children:[jsx(Text,{style:[me.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Dm(T.destination_transaction_hashes[0])}),jsx(xo,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},R=u&&l.length===0;return jsxs(Fragment,{children:[jsx(vr,{title:S?"Deposit Details":"Deposit Tracker",onClose:d,showClose:!S,showBack:!!S,onBack:c}),S?f():R?jsx(Iy,{}):jsx(it,{style:me.scrollContainer,contentContainerStyle:me.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:me.emptyContainer,children:[jsx(Text,{style:[me.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[me.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:me.executionsList,children:l.map(T=>jsx(Al,{execution:T,onPress:()=>k(T)},T.id))})})]})}var me=StyleSheet.create({scrollContainer:{flex:1,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:40},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 ba(e,t=true){let[r,o]=useState(null),[n,a]=useState(null),[i,s]=useState(false),[l,m]=useState(false),[u,y]=useState(null),[S,g]=useState(null);useEffect(()=>{!t||r||(s(true),zs().then(k=>{o(k),y(null);}).catch(k=>{y(k instanceof Error?k:new Error(String(k)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(m(true),Ms(e).then(k=>{a(k),g(null);}).catch(k=>{g(k instanceof Error?k:new Error(String(k)));}).finally(()=>{m(false);}));},[t,e,n]);let b=i||l,w=u||S||null,h=null;if(r&&n){let k=n.blocked_country_codes||[],c=r.alpha2.toUpperCase();h=!k.some(d=>d.toUpperCase()===c);}return {isAllowed:h,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:b,error:w}}var qd="unifold_recent_tokens",Dy=5,Mm=[{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 Ul(){try{let e=await qc.getItem(qd);return e?JSON.parse(e):[]}catch{return []}}async function Vy(e){try{let r=(await Ul()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,Dy);await qc.setItem(qd,JSON.stringify(o));}catch{}}async function Ly(e){try{let r=(await Ul()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await qc.setItem(qd,JSON.stringify(r)),r}catch{return []}}function Qd({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:u}=F(),[y,S]=useState(""),[g,b]=useState([]);useEffect(()=>{e&&Ul().then(b);},[e]),useEffect(()=>{e||S("");},[e]);let w=useMemo(()=>{let R=[];return r.forEach(_=>{_.chains.forEach(T=>{R.push({token:_,chain:T});});}),R},[r]),h=useMemo(()=>{let R=[],_=new Set,T=(C,x,W,V)=>{let O=`${C}-${x}:${W}`;if(_.has(O))return;let P=r.find(N=>N.symbol===C);if(!P)return;let q=P.chains.find(N=>N.chain_type===x&&N.chain_id===W);q&&(_.add(O),R.push({token:P,chain:q,isRecent:V}));};return g.forEach(C=>{T(C.symbol,C.chainType,C.chainId,true);}),Mm.forEach(C=>{T(C.symbol,C.chainType,C.chainId,false);}),R},[r,g]),k=useMemo(()=>{if(!y.trim())return w;let R=y.toLowerCase();return w.filter(({token:_,chain:T})=>_.symbol.toLowerCase().includes(R)||_.name.toLowerCase().includes(R)||T.chain_name.toLowerCase().includes(R))},[w,y]),c=(R,_,T)=>Mm.some(C=>C.symbol===R&&C.chainType===_&&C.chainId===T),d=async(R,_)=>{let T=`${_.chain_type}:${_.chain_id}`;if(!c(R.symbol,_.chain_type,_.chain_id)){await Vy({symbol:R.symbol,chainType:_.chain_type,chainId:_.chain_id});let C=await Ul();b(C);}S(""),a(R.symbol,T),t();},f=async(R,_)=>{let T=await Ly({symbol:R.symbol,chainType:_.chain_type,chainId:_.chain_id});b(T);};return jsxs(pt,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:ct.header,children:[jsx(View,{style:ct.headerSpacer}),jsx(Text,{style:[ct.headerTitle,{color:u.header.titleColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:ct.closeButton,children:jsx(Ze,{size:20,color:u.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:ct.searchContainer,children:jsx(TextInput,{style:[ct.searchInput,{backgroundColor:u.search.backgroundColor,color:u.search.inputColor,fontFamily:m.regular,borderRadius:u.input.borderRadius,borderWidth:u.input.borderWidth,borderColor:u.input.borderColor}],placeholder:"Search",placeholderTextColor:u.search.placeholderColor,value:y,onChangeText:S,autoCapitalize:"none",autoCorrect:false})}),h.length>0&&!y&&jsxs(View,{style:ct.quickSelectSection,children:[jsx(Text,{style:[ct.sectionLabel,{color:u.list.titleSectionColor,fontFamily:m.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:ct.quickSelectScroll,children:h.map(({token:R,chain:_,isRecent:T})=>{let C=`${_.chain_type}:${_.chain_id}`;R.symbol===o&&C===n;return jsxs(View,{children:[T&&jsx(TouchableOpacity$1,{onPress:()=>f(R,_),style:ct.removeButton,children:jsx(Ze,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>d(R,_),activeOpacity:.7,style:[ct.quickSelectItem,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[jsxs(View,{style:ct.tokenIconContainer,children:[jsx(Image,{source:{uri:te(ke(R,"png"))},style:ct.quickSelectIcon}),jsx(Image,{source:{uri:te(ke(_,"png"))},style:[ct.quickSelectChainBadge,{borderColor:u.card.backgroundColor,borderRadius:u.badge.borderRadius}]})]}),jsxs(View,{style:ct.quickSelectText,children:[jsx(Text,{style:[ct.quickSelectSymbol,{color:u.card.titleColor,fontFamily:m.medium}],children:R.symbol}),jsx(Text,{style:[ct.quickSelectChain,{color:u.card.subtitleColor,fontFamily:m.regular}],children:_.chain_name})]})]})]},`quick-${R.symbol}-${C}`)})})]}),jsx(Text,{style:[ct.sectionLabel,{color:u.list.titleSectionColor,fontFamily:m.regular}],children:"All supported tokens"}),jsx(it,{style:ct.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:ct.tokenListContent,children:k.length===0?jsx(View,{style:ct.emptyState,children:jsx(Text,{style:[ct.emptyText,{color:l.foregroundMuted,fontFamily:m.regular}],children:"No tokens found"})}):k.map(({token:R,chain:_})=>{let T=`${_.chain_type}:${_.chain_id}`,C=R.symbol===o&&T===n;return jsxs(TouchableOpacity$1,{onPress:()=>d(R,_),activeOpacity:.7,style:[ct.tokenItem,{backgroundColor:C?u.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:ct.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:te(ke(R,"png"))},style:ct.tokenIcon}),jsx(Image,{source:{uri:te(ke(_,"png"))},style:[ct.tokenChainBadge,{borderColor:u.card.backgroundColor,borderRadius:u.badge.borderRadius}]})]}),jsxs(View,{style:ct.tokenInfo,children:[jsx(Text,{style:[ct.tokenSymbol,{color:u.card.titleColor,fontFamily:m.medium}],children:R.symbol}),jsx(Text,{style:[ct.tokenChainName,{color:u.card.subtitleColor,fontFamily:m.regular}],children:_.chain_name})]}),jsxs(Text,{style:[ct.minDeposit,{color:u.card.labelColor,fontFamily:m.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:u.card.labelHighlightRightColor,fontFamily:m.regular},children:["$",_.minimum_deposit_amount_usd]})]})]},`${R.symbol}-${T}`)})})]})}var ct=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:72,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 Nl=(e,t)=>`${t}:${e}`,My=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Kd({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:u="auto_ui",onExecutionsChange:y,onDepositSuccess:S,onDepositError:g,wallets:b,borderTopLeftRadius:w,borderTopRightRadius:h,sheetBorderRadius:k}){let{colors:c,fonts:d,components:f}=F(),R=s&&l?`${s}:${l}`:"solana:mainnet",[_,T]=useState("USDC"),[C,x]=useState(R),[W,V]=useState([]),[O,P]=useState(!b?.length),q=b?.length?b:W,[N,ue]=useState([]),[Le,ve]=useState(true),[ee,Oe]=useState(false),[fe,Re]=useState(false),[We,be]=useState(false),[oe,De]=useState([]),[dt,Ue]=useState(new Map),[Qe]=useState(()=>new Date),[Ke,Ee]=useState(null),[Je,Ce]=useState(false),[re,ae]=useState(null),[tt,rt]=useState(false),Me=new Map;N.forEach(B=>{B.chains.forEach(Se=>{let M=`${Se.chain_type}:${Se.chain_id}`;Me.has(M)||Me.set(M,Se);});});let he=Array.from(Me.values()),ne=My(C),le=he.find(B=>B.chain_type===ne.chainType&&B.chain_id===ne.chainId),qt=le?.chain_type||"ethereum",pe=Yo(q,qt),se=pe?.address||"",we=useRef(false);useEffect(()=>{async function B(){try{ve(!0),Ee(null);let M=await ei(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(ue(M.data),M.data.length>0&&!we.current){we.current=!0;let Z,ye;if(s&&l)if(m)for(let de of M.data){let mt=de.chains.find(D=>D.chain_type===s&&D.chain_id===l&&D.token_address.toLowerCase()===m.toLowerCase());if(mt){Z=de,ye=mt;break}}else for(let de of M.data){let mt=de.chains.find(D=>D.chain_type===s&&D.chain_id===l);if(mt){Z=de,ye=mt;break}}if(!Z&&a)for(let de of M.data){let mt=de.chains.find(D=>D.token_address.toLowerCase()===a.toLowerCase());if(mt){Z=de,ye=mt;break}}Z||(Z=M.data.find(de=>de.symbol==="USDC"),Z&&Z.chains.length>0&&(ye=Z.chains[0])),Z||(Z=M.data.find(de=>de.symbol==="USDT"),Z&&Z.chains.length>0&&(ye=Z.chains[0])),Z||(Z=M.data[0],Z.chains.length>0&&(ye=Z.chains[0])),Z&&T(Z.symbol),ye&&x(Nl(ye.chain_id,ye.chain_type));}}catch(Se){console.error("Error fetching supported tokens:",Se),Ee("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:Se});}finally{ve(false);}}B();},[t,a,n,o,s,l,m,g]),useEffect(()=>{y&&y(oe);},[oe,y]),useEffect(()=>{if(b?.length){P(false);return}if(W.length>0){P(false);return}let B=null,Se=false,M=async()=>{if(!Se){P(true);try{let Z=await Go({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);Se||(V(Z.data),Ee(null),P(!1));}catch(Z){console.error("Error fetching wallets, retrying in 5s:",Z),Se||(Ee(Z instanceof Error?Z.message:"Failed to load wallets"),P(false),B=setTimeout(M,5e3));}}};return M(),()=>{Se=true,B&&clearTimeout(B);}},[e,r,o,n,a,t,b,W.length]);let yt=pe?.id??"",{showWaitingUi:ot,handleIveDeposited:ce}=fa({depositConfirmationMode:u,depositAddress:se,chain:C,externalUserId:e,publishableKey:t,modalOpenedAt:Qe,depositWalletId:yt,depositExecutions:oe,trackedExecutions:dt,setDepositExecutions:De,setTrackedExecutions:Ue,setLatestExecution:ae,setShowStatusSheet:Ce,onDepositSuccess:S,onExecutionsChange:y,onDepositError:g});useEffect(()=>{if(!N.length)return;let B=N.find(M=>M.symbol===_);if(!B||B.chains.length===0)return;if(!B.chains.some(M=>Nl(M.chain_id,M.chain_type)===C)){let M=B.chains[0];x(Nl(M.chain_id,M.chain_type));}},[_,N,C]);let Ye=N.find(B=>B.symbol===_),ut=(Ye?.chains||[]).find(B=>Nl(B.chain_id,B.chain_type)===C),Fr=async()=>{if(se)try{Clipboard.setString(se),Oe(!0),setTimeout(()=>Oe(!1),2e3);}catch(B){console.error("Failed to copy:",B);}},zr=ut?.estimated_price_impact_percent??0,ar=ut?.max_slippage_percent??.25,E=ut?.minimum_deposit_amount_usd??3;return Le?jsxs(View,{style:H.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:c.primary}),jsx(Text,{style:[H.loadingText,{color:c.foregroundMuted,fontFamily:d.regular}],children:"Loading currencies..."})]}):Ke&&N.length===0?jsxs(View,{style:H.errorContainer,children:[jsx(Text,{style:[H.errorText,{color:c.error,fontFamily:d.regular}],children:Ke}),jsx(Text,{style:[H.errorHint,{color:c.foregroundMuted,fontFamily:d.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:d.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>be(true),disabled:Le||N.length===0,style:[H.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:Le?jsxs(View,{style:H.tokenSelectorLoading,children:[jsx(View,{style:[H.loadingIcon,{backgroundColor:c.cardHover}]}),jsxs(View,{style:H.loadingTextContainer,children:[jsx(View,{style:[H.loadingLine,{backgroundColor:c.cardHover,width:60}]}),jsx(View,{style:[H.loadingLine,{backgroundColor:c.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:H.tokenIconWrapper,children:[Ye&&jsx(Image,{source:{uri:te(ke(Ye,"png"))},style:H.tokenMainIcon}),(ut||le)&&jsx(Image,{source:{uri:te(ke(ut||le,"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:d.semibold}],children:Ye?.symbol||_}),jsx(Text,{style:[H.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:d.regular}],numberOfLines:1,children:ut?.chain_name||le?.chain_name||"Select network"})]}),jsxs(View,{style:H.tokenSelectorRight,children:[jsxs(Text,{style:[H.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:d.medium}],children:["$",E," min"]}),jsx(xr,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Qd,{visible:We,onClose:()=>be(false),tokens:N,selectedToken:_,selectedChainKey:C,onSelect:(B,Se)=>{T(B),x(Se);},borderTopLeftRadius:k?.tokenSelector?.borderTopLeftRadius??w,borderTopRightRadius:k?.tokenSelector?.borderTopRightRadius??h}),jsx(View,{style:H.qrContainer,children:jsx(View,{style:[H.qrWrapper,{backgroundColor:c.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:c.primary}),jsx(Text,{style:[H.loadingText,{color:c.foregroundMuted,fontFamily:d.regular}],children:"Loading..."})]}):se?jsx(ys,{value:se,size:180,logoUri:te(ke(ut,"png")||Kt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:H.qrLoading,children:jsx(Text,{style:[H.errorText,{color:c.error,fontFamily:d.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:d.medium}],children:"Deposit Address"}),ee&&jsxs(View,{style:H.copiedIndicator,children:[jsx(ze,{size:14,color:c.success,strokeWidth:2}),jsx(Text,{style:[H.copiedText,{color:c.success,fontFamily:d.regular}],children:"Copied"})]})]}),jsxs(or,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!O&&se?Fr:void 0,contentStyle:H.addressBox,children:[jsx(Text,{style:[H.addressText,{color:f.card.titleColor,fontFamily:d.regular}],numberOfLines:2,children:O?"Loading...":se||"No address available"}),jsx(View,{style:H.addressCopyIcon,children:jsx(Qo,{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:()=>Re(!fe),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(Dr,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:H.chevronContainer,children:fe?jsx(_o,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Dt,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),fe&&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(wn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Price impact: ",zr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>rt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Bi,{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(Sn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Slippage: Auto \u2022 ",ar.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>rt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Bi,{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:d.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(_l,{depositConfirmationMode:u,depositAddress:se,showWaitingUi:ot,latestExecution:re,onIveDeposited:ce}),jsx(TouchableOpacity$1,{style:H.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[H.termsText,{color:c.primary,fontFamily:d.regular}],children:"Terms apply"})}),jsxs(pt,{visible:tt,onClose:()=>rt(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:k?.infoSheet?.borderTopLeftRadius??w,borderTopRightRadius:k?.infoSheet?.borderTopRightRadius??h,children:[jsxs(View,{style:[H.sheetHeader,{borderBottomColor:c.border}],children:[jsx(View,{style:H.sheetHeaderSpacer}),jsx(Text,{style:[H.sheetTitle,{color:f.header.titleColor,fontFamily:d.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>rt(false),style:H.sheetCloseButton,children:jsx(Ze,{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(wn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Price Impact"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[zr.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:d.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(Sn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Max Slippage"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[ar.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:d.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."})]})]})]}),re&&jsx(bs,{visible:Je,status:re.status,tokenIconUrl:re.destination_token_metadata?.icon_urls?.find(B=>B.format==="png")?.url||re.destination_token_metadata?.icon_url||ke(Ye,"png"),explorerUrl:re.explorer_url,completionExplorerUrl:re.destination_explorer_url,date:re.created_at?new Date(re.created_at):void 0,amountUsd:re.source_amount_usd?parseFloat(re.source_amount_usd):void 0,onClose:()=>Ce(false),borderTopLeftRadius:k?.depositStatus?.borderTopLeftRadius??w,borderTopRightRadius:k?.depositStatus?.borderTopRightRadius??h})]})}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 mn={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 jy(){let{colors:e,components:t}=F(),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:[Yn.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[Yn.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:Yn.textBlock,children:[jsx(Animated.View,{style:[Yn.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[Yn.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:Yn.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[Yn.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:Yn.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var Yn=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 $y({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,defaultChainType:u,defaultChainId:y,defaultTokenAddress:S,showBalance:g=false,hideDepositTracker:b=false,enableStripeLinkPay:w=false,StripeOnrampComponent:h,stripeOnrampEmail:k,stripeOnrampPhone:c,stripeMerchantIdentifier:d,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:R,stripeTheme:_,depositConfirmationMode:T="auto_ui",transferInputVariant:C="double_input",initialScreen:x="main",onDepositSuccess:W,onDepositError:V,sheetBorderRadius:O}){let P=O?.globalBorderTopLeftRadius,q=O?.globalBorderTopRightRadius,{colors:N,fonts:ue}=F(),[Le,ve]=useState([]),[ee,Oe]=useState(null),[fe,Re]=useState("amount"),We=x==="tracker"&&!b?"tracker":x==="transfer"?"transfer":x==="card"?"card":"main",be=We==="main",[oe,De]=useState(We),{isAllowed:dt,isLoading:Ue}=ba(o,e);useEffect(()=>{if(!e||ee)return;let pe=false;return Ms(o).then(async se=>{if(pe)return;let we=[];for(let yt of se?.transfer_crypto?.networks??[]){let ot=yt.icon_urls.find(ce=>ce.format==="png")?.url||yt.icon_urls.find(ce=>ce.format==="svg")?.url;ot&&we.push(te(ot));}for(let yt of se?.payment_networks?.networks??[]){let ot=yt.icon_urls.find(ce=>ce.format==="png")?.url||yt.icon_urls.find(ce=>ce.format==="svg")?.url;ot&&we.push(te(ot));}we.length>0&&await Cd(we),pe||Oe(se);}).catch(console.error),()=>{pe=true;}},[e,ee,o]);let Qe=()=>{t();};useEffect(()=>{e&&(De(We),Re("amount"));},[e,We]);let Ke=useCallback(()=>{be?(De("main"),Re("amount")):Qe();},[be,Qe]),Ee=Le.filter(pe=>pe.status==="pending"||pe.status==="waiting").length,Ce=!!(i&&s&&l&&m&&o)&&g!==false&&!!ee,re=Ue||e&&!ee,ae=dt===false,tt=null;if(oe==="stripe"&&h){let pe=jsx(h,{publishableKey:o,email:k,phone:c,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,merchantIdentifier:d,paymentSelectorPosition:f,skipSuccessConfirmation:R,onClose:Ke});tt=_?jsx(Ai,{..._,children:pe}):pe;}let rt=oe==="stripe"?.9:oe==="transfer"||oe==="card"?.94:oe==="tracker"?.6:oe==="main"?.5:void 0,Me=oe==="tracker"||oe==="main"?.9:void 0,ne={main:O?.main,transfer:O?.transferCrypto,card:O?.buyWithCard,stripe:O?.stripeLinkPay,tracker:O?.depositsTracker}[oe],le=ne?.borderTopLeftRadius??P,qt=ne?.borderTopRightRadius??q;return jsxs(pt,{visible:e,onClose:oe==="main"?Qe:Ke,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:rt,maxHeightPercent:Me,borderTopLeftRadius:le,borderTopRightRadius:qt,children:[oe==="main"&&jsxs(Fragment,{children:[jsx(vr,{title:n,showBack:false,onClose:Qe,showBalance:Ce,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:ee?.project_name}),re&&jsx(jy,{}),!re&&ae&&jsxs(View,{style:Tr.centeredContainer,children:[jsx(View,{style:[Tr.iconContainer,{backgroundColor:N.cardHover}],children:jsx(Vs,{size:32,color:N.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Tr.blockedTitle,{color:N.foreground,fontFamily:ue.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tr.blockedDescription,{color:N.foreground,opacity:.7,fontFamily:ue.regular}],children:"There are no supported tokens available from your current location."})]}),!re&&!ae&&jsxs(View,{style:Tr.optionsContainer,children:[jsx(la,{onPress:()=>De("transfer"),title:mn.transferCrypto.title,subtitle:mn.transferCrypto.subtitle,featuredTokens:ee?.transfer_crypto?.networks}),jsx(da,{onPress:()=>De("card"),title:mn.depositWithCard.title,subtitle:mn.depositWithCard.subtitle,paymentNetworks:ee?.payment_networks?.networks}),w&&h&&jsx(ma,{onPress:()=>De("stripe"),title:mn.stripeLinkPay.title,subtitle:mn.stripeLinkPay.subtitle}),!b&&jsx(ua,{onPress:()=>De("tracker"),title:mn.depositTracker.title,subtitle:mn.depositTracker.subtitle,badge:Ee>0?Ee:void 0})]})]}),oe==="transfer"&&jsxs(Fragment,{children:[jsx(vr,{title:mn.transferCrypto.title,showBack:false,onClose:Ke,showBalance:Ce,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:ee?.project_name}),Ue&&jsx(View,{style:[Tr.centeredContainer,Tr.centeredFlex],children:jsx(ActivityIndicator,{color:N.primary})}),!Ue&&ae&&jsxs(View,{style:[Tr.centeredContainer,Tr.centeredFlex],children:[jsx(View,{style:[Tr.iconContainer,{backgroundColor:N.cardHover}],children:jsx(Vs,{size:32,color:N.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Tr.blockedTitle,{color:N.foreground,fontFamily:ue.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tr.blockedDescription,{color:N.foreground,opacity:.7,fontFamily:ue.regular}],children:"There are no supported tokens available from your current location."})]}),!Ue&&!ae&&jsx(it,{style:Tr.transferScrollContainer,contentContainerStyle:Tr.scrollContent,showsVerticalScrollIndicator:false,children:C==="single_input"?jsx(Kd,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:u,defaultChainId:y,defaultTokenAddress:S,depositConfirmationMode:T,onExecutionsChange:ve,onDepositSuccess:W,onDepositError:V,borderTopLeftRadius:P,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(Il,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:u,defaultChainId:y,defaultTokenAddress:S,depositConfirmationMode:T,onExecutionsChange:ve,onDepositSuccess:W,onDepositError:V,borderTopLeftRadius:P,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),oe==="card"&&jsxs(Fragment,{children:[jsx(vr,{title:`Deposit ${a||"USDC"}`,showBack:fe==="onramp",onBack:()=>Re("amount"),onClose:Ke,showBalance:Ce,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:ee?.project_name}),jsx(View,{style:Tr.buyWithCardContainer,children:jsx(Vl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,onDepositSuccess:W,onDepositError:V,view:fe,onViewChange:pe=>Re(pe),borderTopLeftRadius:P,borderTopRightRadius:q,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),oe==="stripe"&&tt&&jsx(View,{style:Tr.stripeLinkPayContainer,children:tt}),oe==="tracker"&&jsx(Nd,{active:oe==="tracker",onClose:Ke,executions:Le,externalUserId:r,publishableKey:o})]})}function ql({theme:e="auto",...t}){return jsx($y,{...t})}var Tr=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 Ql(e,t=true){return on({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Ea(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Jd(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return on({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await ei(a),m=null,u=null,y=null,S=null,g,b,w,h=l.data.some(k=>k.chains.some(c=>{let d=c.chain_type===t&&c.chain_id===r&&c.token_address.toLowerCase()===o.toLowerCase();return d&&(m=c.minimum_deposit_amount_usd,u=c.estimated_processing_time,y=c.max_slippage_percent,S=c.estimated_price_impact_percent,w=c.chain_name,b=k),d}));if(b){let k=ke(b,"png");k&&(g=te(k));}return {isSupported:h,minimumAmountUsd:m,estimatedProcessingTime:u,maxSlippagePercent:y,priceImpactPercent:S,errorMessage:h?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:g,chainName:w}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Zd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return on({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await Ma(t,r,o,n,a);if(l.balance){let m=l.balance.token?.decimals??6,u=l.balance.token?.symbol??"",y=l.balance.amount,S=BigInt(y),g=BigInt(10**m),b=S/g,h=(S%g).toString().padStart(m,"0").replace(/0+$/,""),k=h?`${b}.${h}`:b.toString();return {balanceBaseUnit:y,balanceHuman:k,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:m,symbol:u}}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 Qy=2500,Ky=3e3,Gy=6e4;function Xd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,m]=useState(false),u=useRef(new Date),y=useRef(new Map),S=useRef(false),g=useRef(n),b=useRef(a);return useEffect(()=>{g.current=n;},[n]),useEffect(()=>{b.current=a;},[a]),useEffect(()=>{o&&!S.current&&(u.current=new Date,y.current.clear()),o||y.current.clear(),S.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let w=u.current,h=async()=>{try{let c=await Jo(e,t,"withdraw"),d=new Date(w.getTime()-Gy),f=[...c.data].sort((C,x)=>{let W=C.created_at?new Date(C.created_at).getTime():0;return (x.created_at?new Date(x.created_at).getTime():0)-W}),R=["pending","waiting","delayed"],_=["succeeded","failed"],T=null;for(let C of f){let x=C.created_at?new Date(C.created_at):null;if(!x||x<d)continue;let W=y.current.get(C.id);if(!W){T=C;break}if(R.includes(W)&&_.includes(C.status)){T=C;break}}if(T){let C=T,x=C.created_at?new Date(C.created_at):null;if(!x||x<u.current)return;let W=y.current.get(C.id);y.current.set(C.id,C.status),s(V=>{let O=V.findIndex(P=>P.id===C.id);if(O>=0){let P=[...V];return P[O]=C,P}return [...V,C]}),C.status==="succeeded"&&(!W||R.includes(W))?g.current?.({message:"Withdrawal completed successfully",transaction:C}):C.status==="failed"&&W!=="failed"&&b.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:C});}}catch(c){console.error("Failed to fetch withdraw executions:",c),b.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:c});}};h();let k=setInterval(h,Qy);return m(true),()=>{clearInterval(k),m(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let w=async()=>{try{await Rc({deposit_wallet_id:r},t);}catch{}};w();let h=setInterval(w,Ky);return ()=>clearInterval(h)},[o,r,t]),{executions:i,isPolling:l}}var eu=(e,t)=>`${t}:${e}`;function Sa({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:a=false,tokenLabel:i="Receive token",chainLabel:s="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:m,chainPickerBorderTopLeftRadius:u,chainPickerBorderTopRightRadius:y}){let{colors:S,fonts:g,components:b}=F(),[w,h]=useState(false),[k,c]=useState(false),d=b.card,f=t?e.find(C=>C.symbol===t):void 0,R=f?.chains||[],_=r?R.find(C=>eu(C.chain_id,C.chain_type)===r):void 0,T={backgroundColor:d.backgroundColor,borderRadius:d.borderRadius,borderWidth:d.borderWidth||1,borderColor:d.borderColor};return jsxs(View,{style:Ge.row,children:[jsxs(View,{style:Ge.col,children:[jsx(Text,{style:[Ge.label,{color:d.labelColor,fontFamily:g.medium}],children:i}),jsxs(TouchableOpacity,{style:[Ge.selectButton,T],onPress:()=>!a&&e.length>0&&h(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Ge.placeholder,{color:d.subtitleColor,fontFamily:g.regular}],children:"Loading..."}):f?jsxs(View,{style:Ge.selectedItem,children:[jsx(Image,{source:{uri:te(ke(f,"png"))},style:Ge.icon}),jsx(Text,{style:[Ge.selectedText,{color:d.titleColor,fontFamily:g.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Ge.placeholder,{color:d.subtitleColor,fontFamily:g.regular}],children:"Select receive token"}),jsx(Dt,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Ge.col,children:[jsx(Text,{style:[Ge.label,{color:d.labelColor,fontFamily:g.medium}],children:s}),jsxs(TouchableOpacity,{style:[Ge.selectButton,T,(!f||R.length===0)&&Ge.disabled],onPress:()=>!a&&f&&R.length>0&&c(true),activeOpacity:.7,disabled:a||!f||R.length===0,children:[_?jsxs(View,{style:Ge.selectedItem,children:[jsx(Image,{source:{uri:te(ke(_,"png"))},style:Ge.icon}),jsx(Text,{style:[Ge.selectedText,{color:d.titleColor,fontFamily:g.medium}],numberOfLines:1,children:_.chain_name})]}):jsx(Text,{style:[Ge.placeholder,{color:d.subtitleColor,fontFamily:g.regular}],children:"Chain"}),jsx(Dt,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(pt,{visible:w,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:m,children:[jsxs(View,{style:Ge.pickerHeader,children:[jsx(View,{style:Ge.pickerHeaderSpacer}),jsx(Text,{style:[Ge.pickerTitle,{color:S.foreground,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Ge.pickerHeaderClose,onPress:()=>h(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ze,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(Wi,{data:e,keyExtractor:C=>C.symbol,contentContainerStyle:Ge.listContent,showsVerticalScrollIndicator:false,renderItem:({item:C})=>jsxs(TouchableOpacity,{style:[Ge.pickerItem,{backgroundColor:C.symbol===t?S.cardHover:"transparent"}],onPress:()=>{o(C.symbol),h(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:te(ke(C,"png"))},style:Ge.pickerIcon}),jsx(Text,{style:[Ge.pickerItemText,{color:S.foreground,fontFamily:g.medium}],children:C.symbol}),jsx(Text,{style:[Ge.pickerItemSub,{color:S.foregroundMuted,fontFamily:g.regular}],children:C.name}),C.symbol===t&&jsx(ze,{size:18,color:S.primary,strokeWidth:2.5})]})})]}),jsxs(pt,{visible:k,onClose:()=>c(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:u,borderTopRightRadius:y,children:[jsxs(View,{style:Ge.pickerHeader,children:[jsx(View,{style:Ge.pickerHeaderSpacer}),jsx(Text,{style:[Ge.pickerTitle,{color:S.foreground,fontFamily:g.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Ge.pickerHeaderClose,onPress:()=>c(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ze,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(Wi,{data:R,keyExtractor:C=>eu(C.chain_id,C.chain_type),contentContainerStyle:Ge.listContent,showsVerticalScrollIndicator:false,renderItem:({item:C})=>{let x=eu(C.chain_id,C.chain_type);return jsxs(TouchableOpacity,{style:[Ge.pickerItem,{backgroundColor:x===r?S.cardHover:"transparent"}],onPress:()=>{n(x),c(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:te(ke(C,"png"))},style:Ge.pickerIcon}),jsx(Text,{style:[Ge.pickerItemText,{color:S.foreground,fontFamily:g.medium}],children:C.chain_name}),x===r&&jsx(ze,{size:18,color:S.primary,strokeWidth:2.5})]})}})]})]})}var Ge=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 tu(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 on({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>_c({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 Xy(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function eb(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 tb(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Gl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:m,balanceData:u,isLoadingBalance:y,minimumWithdrawAmountUsd:S,estimatedProcessingTime:g,maxSlippagePercent:b,priceImpactPercent:w,canWithdraw:h,onDepositWalletCreation:k,onWithdraw:c,onWithdrawError:d,onWithdrawSubmitted:f,onViewTracker:R}){let _="https://unifold.io/terms",T="https://unifold.io/support",{colors:C,fonts:x,components:W}=F(),[V,O]=useState(s||""),[P,q]=useState(""),[N,ue]=useState(false),[Le,ve]=useState(null),[ee,Oe]=useState(false),[fe,Re]=useState(""),We=useRef(null);useEffect(()=>{O(s||""),q(""),ve(null);},[s]);let be=V.trim();useEffect(()=>{let ce=setTimeout(()=>Re(be),500);return ()=>clearTimeout(ce)},[be]);let{data:oe,isLoading:De,error:dt}=tu({chainType:m?.chain_type,chainId:m?.chain_id,tokenAddress:m?.token_address,recipientAddress:fe,publishableKey:e,enabled:fe.length>5&&!!m}),Ue=be!==fe,Qe=useMemo(()=>!be||be.length<=5||Ue||De?null:dt?"Invalid address":oe&&!oe.valid?oe.failure_code==="account_not_found"?`Account not found on ${m?.chain_name}`:oe.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${m?.chain_name}`:"Invalid address":null,[be,Ue,De,dt,oe,m,l]),Ke=!Ue&&!!oe?.valid&&!Qe,Ee=useMemo(()=>u?.exchangeRate?parseFloat(u.exchangeRate):0,[u]),Je=useMemo(()=>u?.balanceHuman?parseFloat(u.balanceHuman):0,[u]),Ce=n||u?.symbol||"TOKEN",re=u?.decimals??6,ae=useMemo(()=>{let ce=parseFloat(P);return !ce||ce<=0?0:ce},[P]),tt=useMemo(()=>{let ce=parseFloat(P);return !ce||ce<=0?0:ce*Ee},[P,Ee]),rt=useCallback(async()=>{try{let Ye=await ff("expo-clipboard").getStringAsync();Ye&&(O(Ye.trim()),ve(null));}catch{}},[]),Me=useCallback(()=>{Je<=0||q(u?.balanceHuman??"0");},[Je,u]),he=S!==null&&tt>0&&tt<S,ne=ae>0&&Je>0&&ae>Je,le=be.length>0&&P.trim().length>0&&ae>0&&Ke&&!he&&!ne&&!!u,qt=useCallback(async()=>{if(!(!l||!m||!le||!h)){ue(true),ve(null);try{let ce=await k({destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,recipientAddress:be}),Ye=eb(ae,re),nr=tb(ae,re),ut={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:Ce,sourceTokenIconUrl:i,destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,destinationTokenSymbol:l.symbol,destinationChainName:m.chain_name,destinationTokenIconUrl:l?te(ke(l,"png")):void 0,amount:nr,amountBaseUnit:Ye,submittedAt:new Date,withdrawIntentAddress:ce.address,recipientAddress:be};await c(ut),f(ut);}catch(ce){let Ye=ce instanceof Error?ce.message:"Withdrawal failed. Please try again.",nr=Ye.length>120?"Withdrawal failed. Please try again.":Ye;ve(nr),d?.({message:Ye,error:ce,code:"WITHDRAW_FAILED"});}finally{ue(false);}}},[l,m,le,h,be,t,r,o,Ce,i,P,Je,u,ae,re,tt,k,c,d,f]),pe=W.input,se=W.card,we=W.button,yt=Qe?C.error:pe.borderColor,ot=useMemo(()=>N?"Processing...":ne?"Insufficient balance":he?`Minimum $${S?.toFixed(2)}`:Le?"Withdrawal failed \u2014 try again":"Withdraw",[N,ne,he,S,Le]);return jsxs(View,{style:qe.container,children:[jsxs(View,{children:[jsxs(View,{style:qe.labelRow,children:[jsx(Text,{style:[qe.label,{color:se.labelColor,fontFamily:x.medium}],children:"Recipient address"}),(Ue||De)&&be.length>5?jsx(ActivityIndicator,{size:"small",color:C.primary}):jsx(TouchableOpacity,{onPress:rt,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(fu,{size:16,color:C.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[qe.inputRow,{backgroundColor:pe.backgroundColor,borderRadius:pe.borderRadius,borderWidth:pe.borderWidth,borderColor:yt}],children:jsx(TextInput,{style:[qe.textInput,{color:pe.textColor,fontFamily:x.regular}],placeholder:"Enter wallet address",placeholderTextColor:pe.placeholderColor,value:V,onChangeText:ce=>{O(ce),ve(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>We.current?.focus()})}),Qe?jsx(Text,{style:[qe.errorText,{color:C.error,fontFamily:x.regular}],children:Qe}):null]}),jsxs(View,{children:[jsxs(Text,{style:[qe.label,{color:se.labelColor,fontFamily:x.medium,paddingBottom:8}],children:["Amount",S!=null&&S>0&&jsx(Text,{style:{color:C.warning,fontFamily:x.regular},children:` ($${S.toFixed(2)} min)`})]}),jsxs(View,{style:[qe.amountRow,{backgroundColor:pe.backgroundColor,borderRadius:pe.borderRadius,borderWidth:pe.borderWidth,borderColor:pe.borderColor}],children:[jsx(TextInput,{ref:We,style:[qe.amountInput,{color:pe.textColor,fontFamily:x.regular}],placeholder:"0.00",placeholderTextColor:pe.placeholderColor,value:P,onChangeText:ce=>{(ce===""||/^\d*\.?\d*$/.test(ce))&&(q(ce),ve(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[qe.unitLabel,{color:C.foregroundMuted,fontFamily:x.medium}],children:Ce}),jsx(TouchableOpacity,{style:[qe.maxButton,{backgroundColor:`${C.primary}20`}],onPress:Me,activeOpacity:.7,children:jsx(Text,{style:[qe.maxText,{color:C.primary,fontFamily:x.medium}],children:"Max"})})]})]}),jsxs(View,{style:[qe.detailsCard,{marginTop:24,backgroundColor:se.backgroundColor,borderRadius:se.borderRadius,borderWidth:se.borderWidth||1,borderColor:se.borderColor}],children:[jsx(TouchableOpacity,{style:qe.detailsToggle,onPress:()=>Oe(!ee),activeOpacity:.7,children:jsxs(View,{style:qe.detailsRow,children:[jsx(View,{style:[qe.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(Dr,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[qe.detailsLabel,{color:se.titleColor,fontFamily:x.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:x.medium},children:Xy(g)})]}),jsx(View,{style:{transform:[{rotate:ee?"180deg":"0deg"}]},children:jsx(Dt,{size:16,color:se.actionColor,strokeWidth:2})})]})}),ee&&jsxs(View,{style:qe.detailsExpanded,children:[jsxs(View,{style:qe.detailsRow,children:[jsx(View,{style:[qe.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(Sn,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[qe.detailsLabel,{color:se.titleColor,fontFamily:x.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:["Auto \u2022 ",(b??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:qe.detailsRow,children:[jsx(View,{style:[qe.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(wn,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[qe.detailsLabel,{color:se.titleColor,fontFamily:x.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:[(w??0).toFixed(2),"%"]})]})]})]})]}),Le&&jsx(Text,{style:[qe.errorText,{color:C.error,fontFamily:x.regular,textAlign:"center"}],children:Le}),jsxs(View,{style:qe.withdrawRow,children:[jsxs(TouchableOpacity,{style:[qe.withdrawButton,{backgroundColor:we.primaryBackground,borderRadius:we.borderRadius,borderWidth:we.borderWidth,borderColor:we.borderColor,opacity:!le||!h||N?.5:1}],onPress:qt,disabled:!le||!h||N,activeOpacity:.8,children:[N&&jsx(ActivityIndicator,{size:"small",color:we.primaryText}),jsx(Text,{style:[qe.withdrawButtonText,{color:we.primaryText,fontFamily:x.medium}],children:ot})]}),jsxs(View,{style:qe.footerRow,children:[jsxs(TouchableOpacity,{style:qe.historyLink,onPress:R,activeOpacity:.7,children:[jsx(Dr,{size:14,color:C.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[qe.historyText,{color:C.foregroundMuted,fontFamily:x.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:qe.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[qe.legalText,{color:C.foregroundMuted,fontFamily:x.regular}],children:"Terms"})}),jsx(Text,{style:[qe.legalSeparator,{color:C.foregroundMuted,fontFamily:x.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(T),activeOpacity:.7,children:jsx(Text,{style:[qe.legalText,{color:C.foregroundMuted,fontFamily:x.regular}],children:"Help"})})]})]})]})]})}var qe=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:6,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,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"},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 nb(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 ib(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Zl({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=F(),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,m=te(ke(e.destination_token_metadata,"png")||Kt("/icons/tokens/png/usdc.png")),u=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",y=nb(e.created_at||new Date().toISOString()),S=ib(e.source_amount_usd);return jsxs(or,{cardTokens:a,onPress:t,contentStyle:hn.container,children:[jsxs(View,{style:hn.iconContainer,children:[jsx(Image,{source:{uri:m},style:hn.tokenIcon}),jsx(View,{style:[hn.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Ds,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(Fa,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(ze,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:hn.textContainer,children:[jsx(Text,{style:[hn.title,{color:a.titleColor,fontFamily:o.medium}],children:u}),jsx(Text,{style:[hn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:y})]}),jsxs(View,{style:hn.rightContainer,children:[jsx(Text,{style:[hn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:S}),jsx(xr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var hn=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 nu(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 m=s<10?`0${s}`:`${s}`;return `${o} ${n}, ${a} at ${i}:${m} ${l}`}catch{return e}}function ef(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 ab(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 tf(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function rf(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function ka({label:e,value:t,isLast:r}){let{fonts:o,components:n}=F(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Ae.detailRow,children:[jsx(Text,{style:[Ae.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Ae.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Ae.divider,{backgroundColor:a.borderColor}]})]})}function su({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=F(),[m,u]=useState([]),[y,S]=useState(!!n),g=l.card,b=l.button,w=l.header,h=l.container;useEffect(()=>{xc().then(ue=>u(ue.data)).catch(()=>{});},[]),useEffect(()=>{S(!!n);},[e?.id]);let k=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,c=e?e.status==="failed"||e.status==="refunded":false,d=c?i.error:k?i.warning:i.success,f=c?"Failed":k?"Processing":"Completed",R=e?.destination_token_metadata?te(ke(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?te(t.destinationTokenIconUrl):te(Kt("/icons/tokens/png/usdc.png")),_=e?.created_at?nu(e.created_at):t.submittedAt?nu(t.submittedAt.toISOString()):nu(new Date().toISOString()),T=e?`${ef(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${tf(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,C=e?`${ef(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${tf(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,x=e?ab(e.source_amount_usd,e.source_amount_base_unit):"$0.00",W=e?Wa(m,e.source_chain_type,e.source_chain_id):t.sourceChainId,V=e?Wa(m,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,P=e?.explorer_url,q=e?.destination_transaction_hashes?.[0],N=e?.destination_explorer_url;return jsxs(it,{style:Ae.scroll,contentContainerStyle:Ae.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Ae.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Li,{size:22,color:w.buttonColor,strokeWidth:2})}):jsx(View,{style:Ae.headerSpacer}),jsx(Text,{style:[Ae.headerTitle,{color:w.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Ae.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ze,{size:20,color:w.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Ae.iconContainer,children:[jsx(Image,{source:{uri:R},style:Ae.tokenIcon}),jsx(View,{style:[Ae.statusBadge,{backgroundColor:d}],children:c?jsx(Ds,{size:10,color:"#FFFFFF",strokeWidth:3}):k?jsx(View,{style:Ae.spinnerDot}):jsx(ze,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Ae.statusRow,children:[jsx(View,{style:[Ae.statusDot,{backgroundColor:d}]}),jsx(Text,{style:[Ae.statusText,{color:d,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Ae.dateText,{color:h.subtitleColor,fontFamily:s.regular}],children:_}),jsxs(View,{style:[Ae.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:[jsx(ka,{label:"Amount Sent",value:T}),jsx(ka,{label:"Amount Received",value:C}),jsx(ka,{label:"USD Value",value:x}),jsx(ka,{label:"Source Network",value:W}),jsx(ka,{label:"Destination Network",value:V,isLast:true})]}),jsxs(TouchableOpacity,{style:Ae.moreDetailsRow,onPress:()=>S(ue=>!ue),activeOpacity:.7,children:[jsx(Text,{style:[Ae.moreDetailsText,{color:h.actionTitle,fontFamily:s.regular}],children:y?"See less":n?"See more":"See more details"}),y?jsx(_o,{size:16,color:h.actionColor,strokeWidth:2}):jsx(Dt,{size:16,color:h.actionColor,strokeWidth:2})]}),y&&jsx(View,{style:[Ae.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:O&&P?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Ae.txRow,onPress:()=>Linking.openURL(P),activeOpacity:.7,children:[jsx(Text,{style:[Ae.txLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Ae.txHash,{color:g.titleColor,fontFamily:s.regular}],children:rf(O)}),jsx(xo,{size:14,color:g.actionColor,strokeWidth:2})]}),!k&&q&&N&&jsxs(Fragment,{children:[jsx(View,{style:[Ae.divider,{backgroundColor:g.borderColor}]}),jsxs(TouchableOpacity,{style:Ae.txRow,onPress:()=>Linking.openURL(N),activeOpacity:.7,children:[jsx(Text,{style:[Ae.txLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Ae.txHash,{color:g.titleColor,fontFamily:s.regular}],children:rf(q)}),jsx(xo,{size:14,color:g.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Ae.detailRow,children:jsx(Text,{style:[Ae.detailLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Ae.buttonRow,children:[jsx(TouchableOpacity,{style:[Ae.button,Ae.halfButton,{backgroundColor:b.secondaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ae.buttonText,{color:b.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Ae.button,Ae.halfButton,{backgroundColor:b.primaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ae.buttonText,{color:b.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Ae=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 of(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Xl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=F(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",m=s?.status==="failed",u={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:kt.container,children:[jsx(TouchableOpacity,{style:kt.closeButton,onPress:r,children:jsx(Ze,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[kt.iconRing,{backgroundColor:n.successBackground}],children:jsx(ze,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[kt.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[kt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",of(e.recipientAddress)]}),jsxs(View,{style:kt.buttonRow,children:[jsx(TouchableOpacity,{style:[kt.button,kt.halfButton,u,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[kt.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[kt.button,kt.halfButton,u,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[kt.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):m?jsxs(View,{style:kt.container,children:[jsx(TouchableOpacity,{style:kt.closeButton,onPress:r,children:jsx(Ze,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[kt.iconRing,{backgroundColor:n.errorBackground}],children:jsx(Ze,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[kt.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[kt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[kt.button,kt.fullButton,u,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[kt.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:kt.container,children:[jsx(TouchableOpacity,{style:kt.closeButton,onPress:r,children:jsx(Ze,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(Ct,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:te(e.sourceTokenIconUrl)},style:kt.tokenIconFill}):jsx(View,{style:[kt.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[kt.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[kt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",of(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 mb(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:te(ke(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:te(ke(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 nf=(e,t)=>`${t}:${e}`;function fb(){let{colors:e}=F(),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 rc({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,defaultDestinationChainType:i,defaultDestinationChainId:s,defaultDestinationTokenAddress:l,modalTitle:m="Withdraw Crypto",onWithdraw:u,onWithdrawSuccess:y,onWithdrawError:S,heightPercent:g=.94,sheetBorderRadius:b,sourceChainType:w,sourceChainId:h,sourceTokenAddress:k,sourceTokenSymbol:c,sourceChainName:d,sourceTokenIconUrl:f}){let{colors:R,fonts:_}=F(),[T,C]=useState("form"),[x,W]=useState(w),[V,O]=useState(h),[P,q]=useState(k),[N,ue]=useState(c),[Le,ve]=useState(d),[ee,Oe]=useState(f),[fe,Re]=useState(null),[We,be]=useState(null),[oe,De]=useState(null),[dt,Ue]=useState(),[Qe,Ke]=useState([]),[Ee,Je]=useState(null),[Ce,re]=useState("form"),ae=useRef(new Animated.Value(Dimensions.get("window").width)).current,tt=useRef(null),rt=!!x&&!!V&&!!P,{data:Me,isLoading:he}=Ql(r,e&&T==="form"),ne=Me?.data??[],{data:le,isLoading:qt}=Jd({sourceChainType:x,sourceChainId:V,sourceTokenAddress:P,sourceTokenSymbol:N,publishableKey:r,enabled:e&&rt&&T==="form"}),{data:pe,isLoading:se}=Zd({address:n,chainType:x,chainId:V,tokenAddress:P,publishableKey:r,enabled:e&&rt}),{executions:we}=Xd({userId:o,publishableKey:r,depositWalletId:dt,enabled:!!dt&&e,onWithdrawSuccess:y,onWithdrawError:S});useEffect(()=>{if(!e||T!=="tracker")return;let U=false;return Jo(o,r,"withdraw").then(Rt=>{U||Ke(Rt.data);}).catch(console.error),()=>{U=true;}},[e,T,o,r]),useEffect(()=>{e&&(tt.current&&(clearTimeout(tt.current),tt.current=null),C("form"),W(w),O(h),q(k),ue(c),ve(d),Oe(f),Re(null),be(null),De(null),Ue(void 0),Ke([]),Je(null),re("form"),ae.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{tt.current&&clearTimeout(tt.current);},[]),useEffect(()=>{ee||le?.iconUrl&&Oe(le.iconUrl);},[le?.iconUrl,ee]),useEffect(()=>{Le||le?.chainName&&ve(le.chainName);},[le?.chainName,Le]),useEffect(()=>{if(!ne.length||fe)return;let U,Rt;if(i&&s)if(l)for(let bt of ne){let Ur=bt.chains.find(Zt=>Zt.chain_type===i&&Zt.chain_id===s&&Zt.token_address.toLowerCase()===l.toLowerCase());if(Ur){U=bt,Rt=Ur;break}}else for(let bt of ne){let Ur=bt.chains.find(Zt=>Zt.chain_type===i&&Zt.chain_id===s);if(Ur){U=bt,Rt=Ur;break}}U||(U=ne[0]),U&&(Re(U),be(Rt??U.chains[0]??null));},[ne,fe,i,s,l]),useEffect(()=>{T==="confirming"&&we.length>0&&C("details");},[T,we]);let yt=useCallback(()=>{t(),tt.current=setTimeout(()=>{C("form"),W(w),O(h),q(k),ue(c),ve(d),Oe(f),Re(null),be(null),De(null),Ue(void 0),Ke([]),Je(null),re("form"),tt.current=null;},300);},[t,w,h,k,c,d,f]),ot=useCallback(U=>{let Rt=ne.find(bt=>bt.symbol===U);Rt&&(Re(Rt),Rt.chains.length>0&&be(Rt.chains[0]));},[ne]),ce=useCallback(U=>{if(!fe)return;let Rt=fe.chains.find(bt=>nf(bt.chain_id,bt.chain_type)===U);Rt&&be(Rt);},[fe]),Ye=useCallback(async U=>{let Rt=await Go({external_user_id:o,destination_chain_type:U.destinationChainType,destination_chain_id:U.destinationChainId,destination_token_address:U.destinationTokenAddress,recipient_address:U.recipientAddress,action_type:"withdraw"},r),bt=Yo(Rt.data,x??"");if(!bt)throw new Error(`No deposit wallet found for chain type: ${x}`);return Ue(bt.id),{id:bt.id,address:bt.address}},[o,r,x]),nr=useCallback(U=>{De(U),C("confirming");},[]),ut=useCallback(U=>{Je(U),ae.setValue(Dimensions.get("window").width),Animated.timing(ae,{toValue:0,duration:280,useNativeDriver:true}).start();},[ae]),Fr=useCallback(()=>{Animated.timing(ae,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>Je(null));},[ae]),zr=he||qt,ar=le?.isSupported??null,E=T==="confirming"?"Withdrawal Status":m,B=b?.globalBorderTopLeftRadius,Se=b?.globalBorderTopRightRadius,M=b?.main?.borderTopLeftRadius??B,Z=b?.main?.borderTopRightRadius??Se,ye=b?.tokenSelector?.borderTopLeftRadius??B,de=b?.tokenSelector?.borderTopRightRadius??Se,mt=b?.chainSelector?.borderTopLeftRadius??B,D=b?.chainSelector?.borderTopRightRadius??Se,Or=(()=>{if(T!=="form"||!rt||se||!pe)return;let U=N||pe.symbol,Rt=pe.balanceUsd;if(Rt!=null){let Zt=`$${parseFloat(Rt).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return U?`Balance: ${Zt} ${U}`:`Balance: ${Zt}`}let bt=pe.balanceHuman;if(!(!bt||bt==="0"))return U?`Balance: ${bt} ${U}`:`Balance: ${bt}`})();return jsx(pt,{visible:e,onClose:yt,closeOnBackdropPress:false,enablePanDownToClose:T==="tracker"||T==="form",showHandle:T==="tracker"||T==="form",heightPercent:T==="confirming"?.3:T==="details"?.7:T==="tracker"?.6:g,maxHeightPercent:T==="tracker"?.9:void 0,borderTopLeftRadius:M,borderTopRightRadius:Z,children:T==="confirming"&&oe?jsx(Xl,{txInfo:oe,executions:we,onClose:yt,onViewTracker:()=>{re("confirming"),C("tracker");}}):T==="details"&&oe?jsx(su,{execution:we.length>0?we[we.length-1]:null,txInfo:oe,onClose:yt,onViewHistory:()=>{re("details"),C("tracker");},onHeaderClose:()=>C("form")}):T==="tracker"?jsxs(View,{style:jo.trackerContainer,children:[jsx(vr,{title:"Withdrawal History",onClose:()=>C(Ce)}),Qe.length===0?jsx(View,{style:jo.emptyState,children:jsx(Text,{style:[jo.emptyText,{color:R.foregroundMuted,fontFamily:_.regular}],children:"No withdrawals to track yet"})}):jsx(Wi,{data:Qe,keyExtractor:U=>U.id,contentContainerStyle:jo.listContent,showsVerticalScrollIndicator:false,renderItem:({item:U})=>jsx(Zl,{execution:U,onPress:()=>ut(U)})}),Ee&&jsx(Animated.View,{style:[jo.historyDetailOverlay,{backgroundColor:R.background,transform:[{translateX:ae}]}],children:jsx(su,{execution:Ee,txInfo:mb(Ee),onClose:yt,onBack:Fr,onViewHistory:Fr})})]}):jsxs(Fragment,{children:[jsx(vr,{title:E,subtitle:Or,onClose:yt}),zr?jsx(fb,{}):ar===false?jsxs(View,{style:jo.unsupportedContainer,children:[jsx(Text,{style:[jo.unsupportedTitle,{color:R.foreground,fontFamily:_.medium}],children:"Unsupported Token"}),jsx(Text,{style:[jo.unsupportedMessage,{color:R.foregroundMuted,fontFamily:_.regular}],children:le?.errorMessage})]}):jsx(hb,{publishableKey:r,sourceChainType:x??"",sourceChainId:V??"",sourceTokenAddress:P??"",sourceTokenSymbol:N,sourceChainName:Le,sourceTokenIconUrl:ee,recipientAddressProp:a,destinationTokens:ne,selectedToken:fe,selectedChain:We,selectedChainKey:We?nf(We.chain_id,We.chain_type):null,onTokenChange:ot,onChainChange:ce,tokensLoading:he,balanceData:pe??null,isLoadingBalance:se,sourceValidation:le??null,onDepositWalletCreation:Ye,onWithdraw:u,onWithdrawError:S,onWithdrawSubmitted:nr,onViewTracker:()=>{re("form"),C("tracker");},tokenSelectorLeft:ye,tokenSelectorRight:de,chainSelectorLeft:mt,chainSelectorRight:D})]})})}function hb({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:m,selectedChain:u,selectedChainKey:y,onTokenChange:S,onChainChange:g,tokensLoading:b,balanceData:w,isLoadingBalance:h,sourceValidation:k,onDepositWalletCreation:c,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:R,onViewTracker:_,tokenSelectorLeft:T,tokenSelectorRight:C,chainSelectorLeft:x,chainSelectorRight:W}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(it,{style:{flex:1,paddingTop:16},contentContainerStyle:jo.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:jo.doubleInputWrapper,children:jsx(Sa,{tokens:l,selectedTokenSymbol:m?.symbol??null,selectedChainKey:y,onTokenChange:S,onChainChange:g,isLoading:b,tokenPickerBorderTopLeftRadius:T,tokenPickerBorderTopRightRadius:C,chainPickerBorderTopLeftRadius:x,chainPickerBorderTopRightRadius:W})}),jsx(Gl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:m,selectedChain:u,balanceData:w,isLoadingBalance:h,minimumWithdrawAmountUsd:k?.minimumAmountUsd??null,estimatedProcessingTime:k?.estimatedProcessingTime??null,maxSlippagePercent:k?.maxSlippagePercent??null,priceImpactPercent:k?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:c,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:R,onViewTracker:_})]})})}var jo=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 lf=createContext(null);function _b({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new pd({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,m]=useState(false),[u,y]=useState(null),S=useColorScheme(),g=useRef(false);g.current||(Va({publishableKey:t}),g.current=true);let b=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.'),Va({publishableKey:t});},[t]),useEffect(()=>()=>{h.current&&clearTimeout(h.current),_.current&&clearTimeout(_.current);},[]);let w=useRef(null),h=useRef(null),k=useCallback(P=>{h.current&&(clearTimeout(h.current),h.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 q=new Promise((N,ue)=>{w.current={resolve:N,reject:ue};});return s(P),a(true),q},[]),c=useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),a(false),h.current=setTimeout(()=>{s(null),h.current=null;},200);},[]),d=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]),R=useRef(null),_=useRef(null),T=useRef(void 0),C=useCallback(P=>{_.current&&(clearTimeout(_.current),_.current=null),R.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),R.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),R.current=null);let q=new Promise((N,ue)=>{R.current={resolve:N,reject:ue};});return T.current=P.onClose,y(P),m(true),q},[]),x=useCallback(()=>{R.current&&(R.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),R.current=null),T.current?.(),T.current=void 0,m(false),_.current=setTimeout(()=>{y(null),_.current=null;},200);},[]),W=useCallback(P=>{u?.onSuccess&&u.onSuccess(P),R.current&&(R.current.resolve(P),R.current=null);},[u]),V=useCallback(P=>{console.error("[UnifoldProvider] Withdraw error:",P),u?.onError&&u.onError(P),R.current&&(R.current.reject(P),R.current=null);},[u]),O=useMemo(()=>({publishableKey:t,beginDeposit:k,closeDeposit:c,beginWithdraw:C,closeWithdraw:x}),[t,k,c,C,x]);return jsx(hd,{client:o,children:jsx(lf.Provider,{value:O,children:jsxs(Ai,{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(ql,{visible:n,onClose:c,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:b,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?bp():void 0,onDepositSuccess:d,onDepositError:f,theme:b,sheetBorderRadius:r?.sheetBorderRadius}),u&&jsx(rc,{visible:l,onClose:x,publishableKey:t,externalUserId:u.externalUserId,senderAddress:u.senderAddress,recipientAddress:u.recipientAddress,sourceChainType:u.sourceChainType,sourceChainId:u.sourceChainId,sourceTokenAddress:u.sourceTokenAddress,sourceTokenSymbol:u.sourceTokenSymbol,defaultDestinationChainType:u.defaultDestinationChainType,defaultDestinationChainId:u.defaultDestinationChainId,defaultDestinationTokenAddress:u.defaultDestinationTokenAddress,onWithdraw:u.withdraw,onWithdrawSuccess:W,onWithdrawError:V,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function Rb(){let e=useContext(lf);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
+ export{Za as AmountScreen,pt as BottomSheet,Xa as KYCWizardScreen,il as OnrampScreen,sl as StripeOnramp,gp as StripeOnrampPreconfigure,_b as UnifoldProvider,ke as getPreferredIcon,Ka as getStripePublishableKey,Ea as getSupportedDestinationTokens,te as normalizeIconUrl,al as registerStripeOnramp,bu as setDevApiUrl,Qa as setStripeOnrampApiUrl,qa as setStripeOnrampPublishableKey,ba as useAllowedCountry,el as useStripeOnramp,F as useTheme,Rb as useUnifold};