@unifold/connect-react-native 0.1.43 → 0.1.44-beta.1

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 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};
1
+ import*as ni from'react';import ni__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,Linking,Dimensions,Clipboard,FlatList}from'react-native';import Pt,{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 ap,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Fd from'@react-native-async-storage/async-storage';import Py from'expo-constants';import db from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Zu=e=>{throw TypeError(e)};var hh=(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 Nc=(e,t,r)=>t.has(e)||Zu("Cannot "+r);var f=(e,t,r)=>(Nc(e,t,"read from private field"),r?r.call(e):t.get(e)),te=(e,t,r)=>t.has(e)?Zu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(Nc(e,t,"write to private field"),t.set(e,r),r),Ue=(e,t,r)=>(Nc(e,t,"access private method"),r);var Js=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return f(e,t,o)}});var jc={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)"}},$c=jc;function ol(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function Zs(e,t,r){let o=r?t?.[r]:void 0,n=(c,y,T)=>{let w=o?.[c]?.[y];if(w!==void 0)return w;let m=t?.[c]?.[y];return m!==void 0?m:T},i={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},s=(o?.depositMenu??t?.depositMenu)?.card,a=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,l=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,u=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:i,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:ol(i,s)},transferCrypto:{depositAddress:{card:ol(i,a)}},depositCard:{quoteProvider:{card:ol(i,l)}},depositTracker:{executionRow:{card:ol(i,u)}}}}function qc(e,t,r){let n={...jc[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var Kc=createContext(null);function V(){let e=useContext(Kc);if(!e){let t=$c.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:Zs(t,void 0,"dark"),isDark:true}}return e}function nt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:i,gradientTo:s}){let{colors:a}=V(),l=i??a.warning,u=s??"#FBBF24",c=useRef(new Animated.Value(0)).current,y=useId(),T=useMemo(()=>`circularProgressGrad_${y.replace(/[^a-zA-Z0-9_-]/g,"")}`,[y]),w=(e-t)/2,m=2*Math.PI*w,g=e/2,h=o??Math.max(0,Math.round(e-t*2-8)),S=(e-h)/2;useEffect(()=>{let p=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true})),d=requestAnimationFrame(()=>p.start());return ()=>{cancelAnimationFrame(d),p.stop();}},[c]);let b=c.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},n],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:b}]},children:jsxs(Pt,{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:u})]})}),jsx(Circle,{cx:g,cy:g,r:w,stroke:`url(#${T})`,strokeWidth:t,fill:"none",strokeDasharray:`${m*.75} ${m*.25}`,strokeLinecap:"round",rotation:-90,origin:`${g}, ${g}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:S+1.5,left:S,width:h,height:h},children:r}):null]})}function Yc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{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 Ji({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 Nr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 Xs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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(Pt,{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 _r({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{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 Zi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{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 Gt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{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 ln({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 Le({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{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 ea({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 Gc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 Do({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 An({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 il({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 Vo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{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 Xi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 es({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 jr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 sl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M3 7V5a2 2 0 0 1 2-2h2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 3h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M21 17v2a2 2 0 0 1-2 2h-2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M7 21H5a2 2 0 0 1-2-2v-2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 14s1.5 2 4 2 4-2 4-2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 9h.01",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M15 9h.01",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function al({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 ta({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 rp({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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 op({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:12,cy:5,r:1,stroke:t,strokeWidth:r,fill:t}),jsx(Circle,{cx:12,cy:12,r:1,stroke:t,strokeWidth:r,fill:t}),jsx(Circle,{cx:12,cy:19,r:1,stroke:t,strokeWidth:r,fill:t})]})}function np({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"16 17 21 12 16 7",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:21,y1:12,x2:9,y2:12,stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ip({height:e=24,color:t="#011e0f"}){let o=e*2.985416666666667;return jsxs(Pt,{width:o,height:e,viewBox:"0 0 71.65 24",fill:"none",children:[jsx(Path,{d:"M36.12,3.68c0-1.13.95-2.04,2.07-2.04s2.07.92,2.07,2.04-.92,2.07-2.07,2.07-2.07-.92-2.07-2.07ZM29.98,1.92h3.6v20.16h-3.6s0-20.16,0-20.16ZM40.01,7.68h-3.63v14.4h3.63V7.68ZM66.1,14.39c2.73-1.68,4.59-4.18,5.32-6.72h-3.63c-.95,2.42-3.12,4.24-5.5,5.01V1.92h-3.63v20.16h3.63v-6c2.77.69,4.96,3.09,5.71,6h3.65c-.56-3.05-2.64-5.91-5.55-7.68ZM46.44,9.29c.95-1.26,2.8-2,4.31-2,2.8,0,5.12,2.05,5.13,5.15v9.63h-3.63v-8.83c0-1.27-.57-2.74-2.4-2.74-2.16,0-3.4,1.92-3.4,4.16v7.43h-3.63V7.69h3.63v1.6Z",fill:t}),jsx(Circle,{cx:12,cy:12,r:12,fill:"#00d66f"}),jsx(Path,{d:"M11.45,4.8h-3.7c.72,3.01,2.82,5.58,5.45,7.2-2.64,1.62-4.73,4.19-5.45,7.2h3.7c.92-2.78,3.46-5.2,6.58-5.7v-3.01c-3.12-.49-5.66-2.91-6.58-5.69Z",fill:"#011e0f"})]})}function ts({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:i,components:s}){let a=useColorScheme(),l=useMemo(()=>t==="auto"?a==="dark"?"dark":"light":t,[t,a]),u=useMemo(()=>{let w=o?.[l];return qc(l,w,r)},[l,o,r]),c=useMemo(()=>Zs(u,s,l),[u,s,l]),y=useMemo(()=>i?{regular:i.regular||n,medium:i.medium||n,semibold:i.semibold||n,bold:i.bold||n}:n?{regular:n,medium:n,semibold:n,bold:n}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[n,i]),T=useMemo(()=>({mode:l,colors:u,fonts:y,components:c,isDark:l==="dark"}),[l,u,y,c]);return jsx(Kc.Provider,{value:T,children:e})}var ia={damping:28,stiffness:300,mass:.8},$h=80,qh=500;function bt({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:i=true,heightPercent:s,maxHeightPercent:a,startExpanded:l=false,noPadding:u=false,borderTopLeftRadius:c=24,borderTopRightRadius:y=24}){let{colors:T}=V(),{height:w}=useWindowDimensions(),[m,g]=useState(false),h=useRef(e);h.current=e;let S=useRef(0),b=s!=null&&s>=1,p=b||u?0:Platform.OS==="ios"?34:24,d=a!=null&&s!=null&&a>s,C=s!=null?(d?a:s)*w:void 0,x=d?(a-s)*w:0,_=l?0:x,k=useSharedValue(w),v=useRef(null),M=useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),h.current||g(false);},[]);useEffect(()=>{e?(v.current&&(clearTimeout(v.current),v.current=null),g(true),k.value=withSpring(_,ia)):m&&(k.value=withTiming(w,{duration:250},j=>{j&&runOnJS(M)();}),v.current=setTimeout(()=>{v.current=null,M();},350));},[e]),useEffect(()=>()=>{v.current&&clearTimeout(v.current);},[]),useEffect(()=>{m&&e&&(k.value=withSpring(_,ia));},[_]);let W=useCallback(()=>{o&&t();},[o,t]),O=useMemo(()=>{if(!(!n&&!d))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{S.current=k.value;},onPanResponderMove:(j,le)=>{if(Math.abs(le.dy)<4)return;let Ye=S.current+le.dy;k.value=Math.max(0,Ye);},onPanResponderRelease:(j,le)=>{if(!(Math.abs(le.dy)<4)){if(n&&(le.dy>$h||le.vy>qh)){t();return}if(d){let Ye=x/2,_e=k.value<Ye?0:x;k.value=withSpring(_e,ia);}else k.value=withSpring(_,ia);}},onPanResponderTerminate:()=>{k.value=withSpring(_,ia);}}).panHandlers},[n,d,x,_,k,t]),F=useAnimatedStyle(()=>({transform:[{translateY:k.value}]})),U=useAnimatedStyle(()=>({opacity:interpolate(k.value,[0,w*.5,w],[.5,.25,0],Extrapolation.CLAMP)}));return m?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:bi.root,pointerEvents:e?"auto":"none",children:[jsx(ap.View,{style:[bi.backdrop,U],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:W})}),jsxs(ap.View,{style:[bi.sheet,F,{height:C,backgroundColor:T.background,borderTopLeftRadius:b?0:c,borderTopRightRadius:b?0:y}],children:[jsxs(GestureHandlerRootView,{style:bi.gestureRoot,children:[i&&jsx(View,{style:bi.handleContainer,pointerEvents:"none",children:jsx(View,{style:[bi.handle,{backgroundColor:T.foreground+"33"}]})}),r,p>0&&jsx(View,{style:{height:p}})]}),O&&jsx(View,{...O,style:bi.dragOverlay})]})]})}):null}var bi=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}}),at=ni__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));at.displayName="BottomSheetScrollView";function rs(e){return jsx(FlatList,{...e})}var Kh="https://api.unifold.io",td="__UnifoldDevApiBaseUrl__",Er="pk_test_123",ll={};function Qh(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[td];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function fr(){return Qh()??Kh}function cl(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.'),Er=e.publishableKey;}e.defaultConfig&&(ll=e.defaultConfig);}function cp(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[td]=t:delete globalThis[td];}function sa(){return fr()}function dl(){return Er}function to(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 cr(e){let t=e.startsWith("/")?e:`/${e}`;return `${fr()}/api/public${t}`}function oe(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,fr()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${fr()}${e}`:`${fr()}/api/public${e}`:""}async function dn(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||ll.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||ll.destinationChainId||"8453",destination_token_address:e?.destination_token_address||ll.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||Er;to(n);let i=await fetch(`${fr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to create deposit address: ${i.statusText}`);return await i.json()}function un(e,t){return e.find(r=>r.chain_type===t)}async function pn(e,t,r){let o=t||Er;to(o);let n=await fetch(`${fr()}/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 ul(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/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 Te(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 Ci(e,t){let r=e||Er;to(r);let o=`${fr()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let i=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});o=`${o}?${i.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 rd(e,t){let r=t||Er;to(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${fr()}/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 pl(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function od(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/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 nd(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/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 id(e,t){let r=t||Er;to(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(`${fr()}/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 aa(e){let t=e||Er;to(t);let r=await fetch(`${fr()}/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 os(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 la(e){let t=e||Er;to(t);let r=await fetch(`${fr()}/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 sd(){let e=await fetch(`${fr()}/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 ml(e,t,r){let o=e.find(i=>i.chain_id===r);if(o)return o.chain_name;let n=e.find(i=>i.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function ca(){let e=await fetch(`${fr()}/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 fl(e){let t=e||Er;to(t);let r=await fetch(`${fr()}/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 ad(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/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 ld(e,t){return ul(e.deposit_wallet_id,t)}async function hl(e,t,r,o,n){let i=n||Er;to(i);let s=await fetch(`${fr()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":i},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!s.ok)throw new Error(`Failed to fetch address balance: ${s.statusText}`);return s.json()}function up({size:e=28}){return jsx(Pt,{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 mp({size:e=28}){return jsxs(Pt,{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 gp({size:e=28}){return jsxs(Pt,{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 yp({size:e=28}){return jsxs(Pt,{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 bp({size:e=28}){return jsx(Pt,{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 gl=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:up},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:mp},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:gp},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:yp},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:bp}];function yl(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function bl(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 ss(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=gl.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=gl.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function St({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:i}=V(),s=r==="back",a=s?jsx(Zi,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(st,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:En.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:s?"Back":"Close",children:a});return t?jsxs(View,{style:En.headerWithTitle,children:[s?l:o??jsx(View,{style:En.headerSide}),jsx(Text,{style:[En.headerTitleText,{color:n.header.titleColor},...i.bold?[{fontFamily:i.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),s?jsx(View,{style:En.headerSide}):l]}):jsxs(View,{style:s?En.headerWithTitle:En.header,children:[s?l:jsx(View,{style:En.headerSpacer}),!s&&l]})}var Cl={paddingTop:8,paddingBottom:8},En=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Cl},headerWithTitle:{flexDirection:"row",alignItems:"center",...Cl,zIndex:9999,overflow:"visible"},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 Mr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=V();return e?jsx(Text,{style:[Cp.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[Cp.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var Cp=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function To({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 fd({quote:e,label:t,address:r,last:o,hideDivider:n}){let[i,s]=useState(false),{colors:a,components:l}=V(),u=()=>{Clipboard.setString(r),s(true),setTimeout(()=>s(false),2e3);},c=yl(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:u,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:i?jsx(Le,{size:14,color:a.success,strokeWidth:2.5}):jsx(ln,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var wl={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function as({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=V(),i=e.toLowerCase(),s=wl[i]??n.primary,a=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:s,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:a,height:a,borderRadius:a/2,borderWidth:2,borderColor:n.background}}):null]})}function Sl({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:i}){let{colors:s,components:a,fonts:l}=V(),u=cr(`/icons/currencies/png/${e.toLowerCase()}.png`),c=ss(r);return jsxs(View,{style:[mo.diagram,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor},i],children:[jsxs(View,{style:mo.step,children:[jsx(Image,{source:{uri:u},style:mo.iconImage}),jsx(Text,{style:[mo.label,{color:a.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[mo.value,{color:a.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(_r,{size:16,color:s.foregroundMuted,strokeWidth:2}),jsxs(View,{style:mo.step,children:[jsxs(View,{style:mo.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:mo.tokenIcon}):jsx(View,{style:[mo.tokenIcon,{backgroundColor:wl[t.toLowerCase()]??s.primary}]}),n?jsx(Image,{source:{uri:n},style:[mo.networkBadge,{borderColor:s.background}]}):null]}),jsx(Text,{style:[mo.label,{color:a.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[mo.value,{color:a.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var mo=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 Wo(){let{colors:e,fonts:t,components:r}=V(),o=r.input,n=r.button,i=r.container,s=r.card,a=r.header;return useMemo(()=>{let l=s.borderRadius,u={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},content:{flex:1,paddingTop:16},title:{fontSize:18,color:a.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:14,color:e.foregroundSubtle,marginBottom:8,...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:i.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:i.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}:{}},minAmountText:{fontSize:13,textAlign:"center",marginTop:8,...t.regular?{fontFamily:t.regular}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:s.borderRadius,backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:s.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:s.borderRadius,backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:s.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:s.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:s.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:s.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:s.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},y={heroBox:{backgroundColor:s.backgroundColor,borderRadius:l,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:s.borderWidth,borderColor:s.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:s.backgroundColor,borderRadius:l,borderWidth:s.borderWidth,borderColor:s.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:s.rowLeftLabel,...t.regular?{fontFamily:t.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:s.rowRightLabel,...t.medium?{fontFamily:t.medium}:{}}},T=Math.max(16,Math.min(l,22)),w={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:s.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:s.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}:{}}},m={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:s.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"}},g={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:e.successBackground,borderWidth:2,borderColor:e.success,alignItems:"center",justifyContent:"center",marginBottom:28},heading:{fontSize:28,color:a.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:u,quote:y,pm:w,wallet:m,flow:g,amount:c}},[e,t,o,n,i,s,a])}var kp="",Tp;function kl(e){kp=e;}function Tl(e){Tp=e;}function $r(){let e=kp||dl();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function qr(){return Tp??sa()}async function xl(){let e=`${qr()}/v1/public/onramps/headless/stripe/config`,t=$r(),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 hd(e){let t=await fetch(`${qr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":$r(),"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 xp(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":$r(),"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 gd(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":$r(),"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 _p(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(`${qr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":$r(),"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 Rp(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":$r(),"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 Mn(e,t){let r=`${qr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":$r(),"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 vp(e){let t=`${qr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":$r(),"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 Ip(e,t){let r=`${qr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":$r(),"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 yd(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":$r(),"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 bd(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(`${qr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":$r(),"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 Cd(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":$r(),"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 Pp(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(`${qr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":$r(),"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 zn(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 Op(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":$r()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function Sg({size:e=24}){let t=e,r=e*(471/750);return jsxs(Pt,{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 kg({size:e=24}){return jsx(Pt,{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 Tg({size:e=24}){return jsx(Pt,{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 Sd({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Ji,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(Sg,{size:t}):o.includes("mastercard")?jsx(kg,{size:t}):o.includes("amex")||o.includes("american express")?jsx(Tg,{size:t}):jsx(Ji,{size:t*.75,color:r,strokeWidth:1.75})}function _l(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 Td={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function xd(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 Bp({status:e,colors:t,fontFamily:r}){let o=xd(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:Td[e]??e})})}function Wp({count:e=4}){let{colors:t,components:r}=V(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,i=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[o]),jsx(View,{style:ls.list,children:Array.from({length:e}).map((s,a)=>jsxs(View,{style:[ls.row,{backgroundColor:t.card,borderRadius:i,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:ls.left,children:[jsx(Animated.View,{style:[ls.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[ls.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[ls.badgeBar,{backgroundColor:n,opacity:o}]})]},a))})}var ls=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 Ap({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:i})=>{i&&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 Ep({session:e,onBack:t}){let{colors:r,components:o,fonts:n}=V(),[i,s]=useState(false),a=()=>{Clipboard.setString(e.id),s(true),setTimeout(()=>s(false),2e3);},l=e.transaction_details,u=e.status!=="fulfillment_complete"&&e.status!=="rejected",c=xd(e.status,r),y=l?.source_amount?`$${parseFloat(l.source_amount).toFixed(2)}`:"\u2014",T=l?.destination_amount?parseFloat(l.destination_amount).toFixed(2):"\u2014",w=(l?.destination_currency??"").toUpperCase(),m=e.destination_token_metadata,g=zn(m?.icon_urls,m?.icon_url),h=ss(l?.destination_network??""),S=l?.wallet_address?yl(l.wallet_address):null,b=l?.fees?.network_fee_amount?`$${parseFloat(l.fees.network_fee_amount).toFixed(2)}`:null,p=l?.fees?.transaction_fee_amount?`$${parseFloat(l.fees.transaction_fee_amount).toFixed(2)}`:null,d=e.payment_method?e.payment_method.replace(/_/g," ").replace(/\b\w/g,x=>x.toUpperCase()):null,C=[{label:"Amount",value:y},{label:"Received",value:`${T} ${w}`},...d?[{label:"Payment",value:d}]:[],{label:"Network",value:h},...S?[{label:"Wallet",value:S}]:[],...b?[{label:"Network Fee",value:b}]:[],...p?[{label:"Transaction Fee",value:p}]:[]];return jsxs(Fragment,{children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(St,{onPress:t,title:"Purchase Details",variant:"back"})}),jsxs(at,{style:wr.scroll,contentContainerStyle:wr.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:wr.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(as,{currency:w||"USD",tokenIconUrl:g,size:64}),jsx(View,{style:[wr.statusBadge,{backgroundColor:c,borderColor:o.card.backgroundColor??r.background}],children:u?jsx(Nr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):e.status==="rejected"?jsx(st,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx(Le,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:wr.statusRow,children:[jsx(View,{style:[wr.statusDot,{backgroundColor:c}]}),jsx(Text,{style:[wr.statusText,{color:o.container.titleColor,fontFamily:n.semibold}],children:Td[e.status]??e.status})]}),e.created?jsx(Text,{style:[wr.dateText,{color:o.container.subtitleColor,fontFamily:n.regular}],children:_l(e.created)}):null]}),jsxs(View,{style:[wr.card,{backgroundColor:o.card.backgroundColor,borderRadius:o.card.borderRadius,borderWidth:o.card.borderWidth,borderColor:o.card.borderColor}],children:[jsxs(View,{style:wr.cardRow,children:[jsx(Text,{style:[wr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:"ID"}),jsxs(TouchableOpacity$1,{onPress:a,activeOpacity:.7,style:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},children:[jsx(Text,{style:[wr.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}),i?jsx(Le,{size:14,color:r.primary,strokeWidth:2}):jsx(ln,{size:14,color:r.foregroundMuted,strokeWidth:2})]})]}),C.map(x=>jsx(ni__default.Fragment,{children:jsxs(View,{style:wr.cardRow,children:[jsx(Text,{style:[wr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:x.label}),jsx(Text,{style:[wr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium}],selectable:true,children:x.value})]})},x.label))]}),l?.last_error?jsx(View,{style:[wr.card,{backgroundColor:r.errorBackground,borderRadius:o.card.borderRadius}],children:jsxs(View,{style:wr.cardRow,children:[jsx(Text,{style:[wr.cardLabel,{color:r.error,fontFamily:n.regular}],children:"Error"}),jsx(Text,{style:[wr.cardValue,{color:r.error,fontFamily:n.medium,flex:1,textAlign:"right"}],selectable:true,children:l.last_error})]})}):null]})]})}var wr=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"}});function zp({onSelect:e,showKycOption:t=true}){let{colors:r,fonts:o,components:n}=V(),[i,s]=useState(false),a=l=>{s(false),e(l);};return jsxs(View,{style:Eo.wrapper,children:[jsx(TouchableOpacity,{style:Eo.trigger,onPress:()=>s(l=>!l),hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"More options",children:jsx(op,{size:20,color:r.foreground,strokeWidth:2})}),i&&jsxs(Fragment,{children:[jsx(Pressable,{style:Eo.backdrop,onPress:()=>s(false)}),jsxs(View,{style:[Eo.menu,{backgroundColor:n.card.backgroundColor,borderRadius:n.card.borderRadius??12,borderWidth:n.card.borderWidth,borderColor:n.card.borderColor,...Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.15,shadowRadius:12},android:{elevation:8}})}],children:[jsxs(TouchableOpacity,{style:Eo.menuItem,onPress:()=>a("history"),activeOpacity:.6,children:[jsx(Nr,{size:18,color:r.foreground,strokeWidth:1.8}),jsx(Text,{style:[Eo.menuLabel,{color:r.foreground,fontFamily:o.regular}],children:"Purchase History"})]}),t&&jsxs(TouchableOpacity,{style:Eo.menuItem,onPress:()=>a("kyc"),activeOpacity:.6,children:[jsx(jr,{size:18,color:r.foreground,strokeWidth:1.8}),jsx(Text,{style:[Eo.menuLabel,{color:r.foreground,fontFamily:o.regular}],children:"Increase Limits (KYC)"})]}),jsxs(TouchableOpacity,{style:Eo.menuItem,onPress:()=>a("logout"),activeOpacity:.6,children:[jsx(np,{size:18,color:r.error,strokeWidth:1.8}),jsx(Text,{style:[Eo.menuLabel,{color:r.error,fontFamily:o.regular}],children:"Disconnect Stripe Link"})]})]})]})]})}var Eo=StyleSheet.create({wrapper:{zIndex:9999},trigger:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},backdrop:{position:"absolute",top:-500,left:-500,width:2e3,height:2e3,zIndex:9998},menu:{position:"absolute",top:32,left:0,minWidth:200,paddingVertical:6,zIndex:9999},menuItem:{flexDirection:"row",alignItems:"center",paddingHorizontal:14,paddingVertical:12,gap:12},menuLabel:{fontSize:15}});var Ag=[50,100,500],Eg=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Hp(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Mg(e){return e.card?`${Hp(e.card.brand)} ${Hp(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Pl({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,minAmount:n,maxAmount:i,paymentSelectorPosition:s="inline",onCollectPayment:a,paymentLoading:l=false,paymentStatus:u,paymentError:c,paymentTokens:y=[],onAddPaymentMethod:T,onConfirm:w,onCancel:m,sheetBorderTopLeftRadius:g,sheetBorderTopRightRadius:h,accessToken:S,showHistoryProgressBar:b=true,onLogout:p,onRequestKYC:d}){let C=Wo(),{colors:x,components:_,fonts:k}=V(),v=g??_.card.borderRadius,M=h??_.card.borderRadius,[W,O]=useState(e),[F,U]=useState(r?"apple_pay":y.length>0?y[0].id:null),j=useRef(false),le=I=>{j.current=true,U(I);};useEffect(()=>{j.current||r||y.length>0&&U(y[0].id);},[y,r]);let[Ye,_e]=useState(false),[ne,we]=useState("select"),[fe,Pe]=useState(null),$e=useRef(false);useEffect(()=>{l&&u&&/saving/i.test(u)&&we("card");},[l,u]);let ue=i,J=ue!=null&&ue>0,be=useMemo(()=>{if(o)return [];let I=Ag.map(D=>({label:`$${D}`,amount:String(D),disabled:false}));return I.push({label:"MAX",amount:J?String(ue):"0",disabled:!J}),I},[o,J,ue]),vt=I=>{if(I==="\u232B"){O(D=>D.slice(0,-1));return}if(I==="."){if(W.includes("."))return;O(D=>D===""?"0.":D+".");return}O(D=>{let q=D.indexOf(".");return q!==-1&&D.length-q>2?D:D==="0"&&I!=="."?I:D+I});},ve=W===""?"0":W,qe=parseFloat(W),Ne=n!=null&&!isNaN(qe)&&qe>0&&qe<n,Ve=ue!=null&&ue>0&&!isNaN(qe)&&qe>ue,ze=W!==""&&!isNaN(qe)&&qe>0&&!Ne&&!Ve,it=r||y.length>0,ie=s==="header",pe=useMemo(()=>{let I=[];r&&I.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let D of y)I.push({id:D.id,label:Mg(D),hint:D.card?`Expires ${D.card.exp_month}/${D.card.exp_year}`:D.type,brand:D.card?.brand,isApplePay:false});return I},[r,y]),et=pe.find(I=>I.id===F),Ke=F!=null&&F!=="apple_pay",$t=et?et.label:Ke&&fe?fe:Ke?"Card":"Pay With",Ee=et?!et.isApplePay:Ke,Oe=et?.brand??fe??void 0,[ar,he]=useState(false),[X,Ce]=useState([]),[pt,It]=useState(false),[me,je]=useState(null),[Vt,ot]=useState(null),Lt=useRef(null);Lt.current=Vt;let Bt=useRef(false);Bt.current=ar;let yt=useCallback(async(I=false)=>{if(S){I||(It(true),je(null));try{let D=await vp(S);if(!Bt.current)return;let q=Array.isArray(D.data)?D.data:Array.isArray(D)?D:[];Ce(q),I||je(null);let Fe=Lt.current?.id;if(Fe){let ke=q.find(pr=>pr.id===Fe);ke&&ot(ke);}}catch(D){if(!Bt.current)return;I||je(D?.message??"Failed to load history");}finally{!I&&Bt.current&&It(false);}}},[S]),Se=useCallback(()=>{he(true),yt();},[yt]);useEffect(()=>{if(!ar||!S)return;let I=setInterval(()=>yt(true),15e3);return ()=>clearInterval(I)},[ar,S,yt]);let Z=useCallback(I=>{switch(I){case "history":Se();break;case "kyc":d?.();break;case "logout":p?.();break}},[Se,d,p]),Q=S?jsx(zp,{onSelect:Z,showKycOption:!!d}):void 0,L=it?jsx(TouchableOpacity,{style:[ie?C.amount.paymentRowHeader:C.amount.paymentRow,l&&{opacity:.5}],onPress:()=>{l||(we("select"),_e(true));},activeOpacity:.7,disabled:l,children:jsxs(View,{style:C.amount.paymentLeft,children:[et?.isApplePay?jsx(Text,{style:C.amount.applePayIcon,children:"\uF8FF"}):Ee?jsx(Sd,{sublabel:Oe,size:20}):null,jsx(Text,{style:C.amount.paymentLabel,children:$t}),jsx(Gt,{size:12,color:C.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:C.form.screen,children:[jsx(St,{onPress:m,title:"Enter amount",leftAction:Q}),ie&&L,jsxs(View,{style:C.form.content,children:[jsxs(View,{style:C.amount.amountContainer,children:[jsxs(Text,{style:[C.amount.amountText,ve==="0"&&C.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",ve]}),jsx(Text,{style:C.amount.currencyLabel,children:t.toUpperCase()}),Ne&&n!=null&&jsxs(Text,{style:[C.amount.minAmountText,{color:x.warning}],children:["Minimum amount is $",n.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})," ",t.toUpperCase()]}),Ve&&ue!=null&&jsxs(Text,{style:[C.amount.minAmountText,{color:x.warning}],children:["Maximum amount is $",ue.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})," ",t.toUpperCase()]})]}),!ie&&L,be.length>0&&jsx(View,{style:C.amount.quickRow,children:be.map(I=>{let D=!I.disabled&&W===I.amount&&W!=="";return jsx(TouchableOpacity,{style:[C.amount.quickPill,D&&{backgroundColor:x.primary},I.disabled&&{opacity:.4}],activeOpacity:.7,disabled:I.disabled||l,onPress:()=>O(I.amount),children:jsx(Text,{style:[C.amount.quickPillText,D&&{color:x.primaryForeground}],children:I.label})},I.label)})}),jsx(View,{style:C.amount.numpad,children:Eg.map((I,D)=>jsx(View,{style:C.amount.numpadRow,children:I.map(q=>jsx(TouchableOpacity,{style:[C.amount.numpadKey,l&&{opacity:.3}],onPress:()=>vt(q),activeOpacity:.6,disabled:l,children:jsx(Text,{style:q==="\u232B"?C.amount.backspaceText:C.amount.numpadKeyText,children:q})},q))},D))}),jsx(TouchableOpacity,{style:[C.form.continueBtn,(!ze||l)&&C.form.continueBtnDisabled],onPress:()=>ze&&!l&&w(W,F),disabled:!ze||l,children:l?jsx(ActivityIndicator,{size:"small",color:x.primaryForeground}):jsx(Text,{style:[C.form.continueBtnText,!ze&&C.form.continueBtnTextDisabled],children:"Continue"})}),!Ye&&c?jsx(Text,{style:C.amount.inlineError,children:c}):!Ye&&l&&u&&__DEV__?jsx(Text,{style:C.amount.inlineStatus,children:u}):null]}),jsx(bt,{visible:Ye,onClose:()=>{l||(_e(false),we("select"));},closeOnBackdropPress:!l,enablePanDownToClose:!l,showHandle:!l,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:v,borderTopRightRadius:M,children:jsx(View,{style:C.amount.sheetContent,children:ne==="select"?jsxs(Fragment,{children:[jsxs(View,{style:C.amount.sheetTitleRow,children:[jsx(Text,{style:C.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>_e(false),activeOpacity:.7,style:C.amount.sheetCloseBtn,children:jsx(st,{size:16,color:x.foregroundMuted,strokeWidth:2.5})})]}),jsxs(at,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[pe.map(I=>{let D=F===I.id;return jsxs(TouchableOpacity$1,{style:[C.amount.sheetOption,D&&{borderColor:x.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{le(I.id),Pe(I.isApplePay?null:I.label),_e(false);},children:[jsxs(View,{style:C.amount.sheetOptionLeft,children:[jsx(View,{style:C.amount.sheetOptionIcon,children:I.isApplePay?jsx(Text,{style:C.amount.applePayIcon,children:"\uF8FF"}):jsx(Sd,{sublabel:I.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:C.amount.sheetOptionLabel,children:I.label}),jsx(Text,{style:C.amount.sheetOptionHint,children:I.hint})]})]}),D&&jsx(Le,{size:18,color:x.primary,strokeWidth:2.5})]},I.id)}),jsx(TouchableOpacity$1,{style:C.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!$e.current){$e.current=true;try{let I=await T?.();I&&(le(I.token),Pe(I.sublabel),_e(!1));}finally{$e.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:()=>{l||we("select");},activeOpacity:.7,style:C.amount.sheetBackBtn,children:jsx(Zi,{size:20,color:x.foreground,strokeWidth:2})}),jsx(Text,{style:C.amount.sheetTitle,children:"Pay With"})]}),l?jsxs(View,{style:C.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:x.primary}),__DEV__?jsx(Text,{style:C.amount.sheetStatusText,children:u||"Loading Stripe Link..."}):null]}):c?jsxs(Fragment,{children:[jsx(View,{style:C.amount.sheetError,children:jsx(Text,{style:C.amount.sheetErrorText,children:c})}),jsx(TouchableOpacity$1,{style:C.form.continueBtn,onPress:()=>{a&&ze&&a(false,W);},children:jsx(Text,{style:C.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:C.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:x.primary}),__DEV__?jsx(Text,{style:C.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(bt,{visible:ar,onClose:()=>{he(false),ot(null);},closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:v,borderTopRightRadius:M,children:Vt?jsx(Ep,{session:Vt,onBack:()=>ot(null)}):jsxs(View,{style:C.amount.sheetContent,children:[jsx(St,{onPress:()=>he(false),title:"Purchase History"}),b&&jsx(Ap,{active:ar&&!pt&&X.length>0,color:x.primary}),pt?jsx(Wp,{}):me?jsx(View,{style:C.amount.sheetError,children:jsx(Text,{style:C.amount.sheetErrorText,children:me})}):X.length===0?jsx(View,{style:C.amount.sheetLoading,children:jsx(Text,{style:[C.amount.sheetStatusText,{color:x.foregroundMuted}],children:"No purchases yet"})}):jsx(at,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:X.map(I=>{let D=I.transaction_details,q=D?.source_amount?`$${parseFloat(D.source_amount).toFixed(2)}`:"\u2014",Fe=(D?.destination_currency??"").toUpperCase(),ke=D?.destination_amount?`${parseFloat(D.destination_amount).toFixed(2)} ${Fe}`:"",pr=_l(I.created),ce=I.destination_token_metadata,xt=zn(ce?.icon_urls,ce?.icon_url),Ct=zn(ce?.chain?.icon_urls,ce?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:C.amount.sheetOption,activeOpacity:.7,onPress:()=>ot(I),children:[jsx(as,{currency:Fe||"USD",tokenIconUrl:xt,networkIconUrl:Ct,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:C.amount.sheetOptionLabel,children:q}),ke?jsx(Text,{style:C.amount.sheetOptionHint,children:ke}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx(Bp,{status:I.status,colors:x,fontFamily:k.regular}),pr?jsx(Text,{style:{fontSize:11,color:x.foregroundMuted,fontFamily:k.regular},children:pr}):null]}),jsx(_r,{size:14,color:x.foregroundMuted,strokeWidth:2})]})]},I.id)})})]})})]})}function Ol({initialData:e={},loading:t=false,level:r="L0",onComplete:o,onCancel:n}){let i=Wo(),{colors:s,fonts:a,components:l}=V(),u=l.input.placeholderColor,c=r==="L0"?["name","address"]:["name","dob","address","ssn"],y=c.length,[T,w]=useState(1),[m,g]=useState(e.firstName??""),[h,S]=useState(e.lastName??""),[b,p]=useState(e.dobMonth??""),[d,C]=useState(e.dobDay??""),[x,_]=useState(e.dobYear??""),[k,v]=useState(e.addressLine1??""),[M,W]=useState(e.addressLine2??""),[O,F]=useState(e.city??""),[U,j]=useState(e.state??""),[le,Ye]=useState(e.postalCode??""),[_e,ne]=useState(e.country??"US"),[we,fe]=useState(e.idNumber??""),Pe=useRef(null),$e=useRef(null),ue=useRef(null),J=useRef(null),be=useRef(null),vt=useRef(null),ve=useRef(null),qe=useRef(null),Ne=c[T-1],Ve=()=>{switch(Ne){case "name":return m.trim().length>0&&h.trim().length>0;case "dob":return b.length===2&&d.length===2&&x.length===4;case "address":return k.trim().length>0&&O.trim().length>0&&U.trim().length>0&&le.trim().length>0;case "ssn":return we.trim().length>0;default:return false}},ze=()=>{Ve()&&(T<y?w(Ae=>Ae+1):o({firstName:m,lastName:h,idNumber:we,dobMonth:b,dobDay:d,dobYear:x,addressLine1:k,addressLine2:M,city:O,state:U,postalCode:le,country:_e}));},it=()=>{T>1?w(Ae=>Ae-1):n();},ie={name:{title:"Enter your name",subtitle:"Use your full legal name as it appears on your ID."},dob:{title:"Enter your date of birth",subtitle:"We use this to verify your identity."},address:{title:"Enter your address",subtitle:"Enter the address associated with your ID."},ssn:{title:"Enter your SSN",subtitle:"Your SSN is encrypted and used only for identity verification."}},{subtitle:pe}=ie[Ne],et=[or.stepCounter,{color:s.foregroundMuted},...a.semibold?[{fontFamily:a.semibold}]:[]];return jsx(KeyboardAvoidingView,{style:i.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:i.form.screen,children:[jsxs(View,{style:or.header,children:[jsx(View,{style:or.headerSide,children:!t&&jsx(TouchableOpacity,{style:or.iconButton,onPress:it,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:T>1?"Back":"Cancel",children:jsx(Xs,{size:20,color:l.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:or.headerCenter,children:jsxs(Text,{style:et,children:[T," of ",y]})}),jsx(View,{style:or.headerSide,children:jsx(TouchableOpacity,{style:or.iconButton,onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(st,{size:20,color:l.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:or.progressTrack,children:Array.from({length:y}).map((Ae,Ke)=>jsx(View,{style:[or.progressSegment,{backgroundColor:Ke<T||Ke+1===T?s.primary:s.border}]},Ke))}),jsx(at,{style:i.form.flex,contentContainerStyle:or.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:jsxs(View,{pointerEvents:t?"none":"auto",style:[i.form.flex,t&&{opacity:.5}],children:[jsx(Text,{style:i.form.subtitle,children:pe}),Ne==="name"&&jsxs(Fragment,{children:[jsx(fn,{form:i.form,label:"First name",children:jsx(TextInput,{style:i.form.input,placeholder:"Jane",placeholderTextColor:u,value:m,onChangeText:g,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Pe.current?.focus()})}),jsx(fn,{form:i.form,label:"Last name",children:jsx(TextInput,{ref:Pe,style:i.form.input,placeholder:"Doe",placeholderTextColor:u,value:h,onChangeText:S,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:ze})})]}),Ne==="dob"&&jsxs(View,{style:or.dobRow,children:[jsxs(View,{style:or.dobCol,children:[jsx(Text,{style:[i.form.fieldLabel,or.dobLabel],children:"Month"}),jsx(TextInput,{style:[i.form.input,or.dobInput],placeholder:"MM",placeholderTextColor:u,value:b,onChangeText:Ae=>{let Ke=Ae.replace(/\D/g,"").slice(0,2);p(Ke),Ke.length===2&&$e.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:or.dobCol,children:[jsx(Text,{style:[i.form.fieldLabel,or.dobLabel],children:"Day"}),jsx(TextInput,{ref:$e,style:[i.form.input,or.dobInput],placeholder:"DD",placeholderTextColor:u,value:d,onChangeText:Ae=>{let Ke=Ae.replace(/\D/g,"").slice(0,2);C(Ke),Ke.length===2&&ue.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:or.dobColWide,children:[jsx(Text,{style:[i.form.fieldLabel,or.dobLabel],children:"Year"}),jsx(TextInput,{ref:ue,style:[i.form.input,or.dobInput],placeholder:"YYYY",placeholderTextColor:u,value:x,onChangeText:Ae=>{let Ke=Ae.replace(/\D/g,"").slice(0,4);_(Ke);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:ze})]})]}),Ne==="address"&&jsxs(Fragment,{children:[jsx(fn,{form:i.form,label:"Street address",children:jsx(TextInput,{style:i.form.input,placeholder:"123 Main St",placeholderTextColor:u,value:k,onChangeText:v,returnKeyType:"next",onSubmitEditing:()=>J.current?.focus()})}),jsx(fn,{form:i.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:J,style:i.form.input,placeholder:"Apt 2",placeholderTextColor:u,value:M,onChangeText:W,returnKeyType:"next",onSubmitEditing:()=>be.current?.focus()})}),jsx(fn,{form:i.form,label:"City",children:jsx(TextInput,{ref:be,style:i.form.input,placeholder:"San Francisco",placeholderTextColor:u,value:O,onChangeText:F,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>vt.current?.focus()})}),jsxs(View,{style:or.row,children:[jsx(View,{style:[i.form.flex,{marginRight:8}],children:jsx(fn,{form:i.form,label:"State",children:jsx(TextInput,{ref:vt,style:i.form.input,placeholder:"CA",placeholderTextColor:u,value:U,onChangeText:Ae=>j(Ae.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>ve.current?.focus()})})}),jsx(View,{style:i.form.flex,children:jsx(fn,{form:i.form,label:"ZIP code",children:jsx(TextInput,{ref:ve,style:i.form.input,placeholder:"94001",placeholderTextColor:u,value:le,onChangeText:Ye,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>qe.current?.focus()})})})]}),jsx(fn,{form:i.form,label:"Country",children:jsx(TextInput,{ref:qe,style:i.form.input,placeholder:"US",placeholderTextColor:u,value:_e,onChangeText:Ae=>ne(Ae.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:ze})})]}),Ne==="ssn"&&jsxs(fn,{form:i.form,label:"Social Security Number",children:[jsx(TextInput,{style:i.form.input,placeholder:"123-45-6789",placeholderTextColor:u,value:we,onChangeText:fe,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:ze}),jsx(Text,{style:[i.form.hint,or.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]})}),jsx(View,{style:i.form.footer,children:t&&T>=y?jsx(View,{style:[i.form.continueBtn,i.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:s.primaryForeground,gradientTo:s.primaryForeground})}):jsx(TouchableOpacity,{style:[i.form.continueBtn,!Ve()&&i.form.continueBtnDisabled],onPress:ze,disabled:!Ve(),children:jsx(Text,{style:[i.form.continueBtnText,!Ve()&&i.form.continueBtnTextDisabled],children:T>=y?"Submit":"Continue"})})})]})})}function fn({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var or=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:16,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:12},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:4},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 Dd="@unifold/stripe_oauth";async function jp(){try{let e=await Fd.getItem(Dd);return e?JSON.parse(e):null}catch{return null}}async function Vd(e){try{await Fd.setItem(Dd,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function hn(){try{await Fd.removeItem(Dd);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Kg=5,Kn=null,$p={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Fl(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:i,authorize:s,attachKycInfo:a,presentKycInfoVerification:l,verifyIdentity:u,registerWalletAddress:c,collectPaymentMethod:y,createCryptoPaymentToken:T}=useOnramp(),[w,m]=useState(r),[g,h]=useState(!!e?.externalUserId),[S,b]=useState(false),[p,d]=useState(""),[C,x]=useState(null),[_,k]=useState(e?.email??""),[v,M]=useState(e?.phone??""),[W,O]=useState(""),[F,U]=useState("US"),[j,le]=useState(""),[Ye,_e]=useState(""),ne=useRef(""),we=useRef(""),fe=useRef(""),[Pe,$e]=useState(false),[ue,J]=useState(false),be=useRef(0),vt=useRef(false),ve=useRef(false),qe=useRef(false),Ne=useRef(e?.email??""),Ve=useRef(false),ze=useRef(null),it=useRef(""),ie=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),pe=useRef(null),[et,Ae]=useState(0),[Ke,$t]=useState($p),[Ee,Oe]=useState(e?.defaultWalletAddress??""),[ar,he]=useState(""),[X,Ce]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[pt,It]=useState(e?.defaultSourceAmount??"100"),[me,je]=useState(e?.defaultSourceCurrency??"usd"),[Vt,ot]=useState(e?.defaultDestinationCurrency??"usdc"),[Lt,Bt]=useState(null),[yt,Se]=useState(),[Z,Q]=useState(),[L,I]=useState(false),D=useRef(null),q=useRef(false),Fe=useRef(0),ke=useRef(e?.onComplete),pr=useRef(e?.onError),ce=useRef(e?.onStepChange),xt=useRef(r);useEffect(()=>{ke.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{pr.current=e?.onError;},[e?.onError]),useEffect(()=>{ce.current=e?.onStepChange;},[e?.onStepChange]);let Ct=useRef(r);useEffect(()=>{w!==Ct.current&&(ce.current?.(w,Ct.current),Ct.current=w),xt.current=w;},[w]),useEffect(()=>{g&&w!==r&&h(false);},[g,w,r]);let z=useCallback((R,P,$)=>{let G={code:R,message:P,step:xt.current,stripeErrorCode:$};x(G),d(""),pr.current?.(G);},[]),Xr=useCallback(R=>{let P={sessionId:R.id,status:R.status,sourceAmount:R.transaction_details.source_amount,sourceCurrency:R.transaction_details.source_currency,destinationAmount:R.transaction_details.destination_amount,destinationCurrency:R.transaction_details.destination_currency,destinationNetwork:R.transaction_details.destination_network,walletAddress:R.transaction_details.wallet_address,fees:{networkFee:R.transaction_details.fees.network_fee_amount,transactionFee:R.transaction_details.fees.transaction_fee_amount}};return ke.current?.(P),P},[]),dt=useCallback(()=>x(null),[]),Ga=R=>R.refresh_token??R.refresh?.refresh_token??"",Yi=useCallback((R,P,$,G,de)=>{we.current=P,ne.current=$,e?.externalUserId&&Vd({accessToken:P,refreshToken:$,customerId:R,externalUserId:e.externalUserId,email:de||_,expiresAt:Date.now()+G*1e3});},[e?.externalUserId,_]),Y=useCallback(async()=>{let R=ne.current;if(!R)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let P=await gd(R,fe.current??void 0),$=P.access_token,G=Ga(P)||R;return _e($),Yi(fe.current,$,G,P.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),$}catch(P){return console.error("[tryRefreshAccessToken] refresh failed:",P?.message),await hn(),Kn=null,we.current="",ne.current="",fe.current="",_e(""),le(""),null}},[Yi]),ae=useCallback(async R=>{try{return await R(we.current)}catch(P){let $=P?.message??"";if($.includes("stripe_onramp_forbidden")||$.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let G=await Y();if(!G)throw z("authorization_error","Session expired. Please sign in again."),m("email"),P;return await R(G)}throw P}},[Y,z]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){I(false);return}let P=false;return isPlatformPaySupported().then($=>{P||I($);}),()=>{P=true;}},[e?.merchantIdentifier]),useEffect(()=>(q.current=false,()=>{q.current=true,D.current&&clearTimeout(D.current);}),[]);let qt=useRef(false);useEffect(()=>{if(qt.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),hn(),Kn=null,h(false);return}let R=false;return (async()=>{try{let P=await jp();if(R||!P){R||h(!1);return}if(P.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",P.externalUserId,"current:",e.externalUserId),await hn(),Kn=null,R||h(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",P.customerId);let $=Date.now()>=P.expiresAt,G=P.accessToken,de=P.refreshToken;if($){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let ye=await gd(P.refreshToken,P.customerId);if(R)return;G=ye.access_token,de=ye.refresh_token??ye.refresh?.refresh_token??P.refreshToken,await Vd({accessToken:G,refreshToken:de,customerId:P.customerId,externalUserId:e.externalUserId,email:P.email,expiresAt:Date.now()+(ye.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(ye){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",ye?.message),await hn(),Kn=null,R||h(!1);return}}if(R)return;if(qt.current=!0,le(P.customerId),fe.current=P.customerId,_e(G),we.current=G,ne.current=de,console.log("[useStripeOnramp] restore email from storage:",P.email??"(not stored)"),P.email&&(k(P.email),Ne.current=P.email),Kn===P.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",P.customerId,"\u2014 skipping configure()"),pe.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",P.customerId);let ye=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:P.customerId});ye.error?console.error("[useStripeOnramp] restore configureSDK error:",ye.error.message):Kn=P.customerId,pe.current=Promise.resolve(ye);}if(R)return;let _t=()=>new Promise(ye=>{let tt=()=>{Ve.current&&it.current?ye():setTimeout(tt,200);};tt();});try{if(await Promise.race([_t(),new Promise((tt,Wt)=>setTimeout(()=>Wt(new Error("timeout")),1e4))]),R)return;let ye=it.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",ye,"network:",ie.current),await c(ye,ie.current);}catch(ye){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",ye?.message);}if(R)return;try{(await Mn(fe.current,we.current)).verifications.find(Wt=>Wt.name==="kyc_verified")?.status!=="verified"?(console.log("[useStripeOnramp] credentials restored but KYC not verified \u2014 going to kyc"),m("kyc")):(console.log("[useStripeOnramp] credentials restored, KYC verified \u2014 skipping to session_params"),m("session_params"));}catch{console.log("[useStripeOnramp] credentials restored, could not check KYC \u2014 defaulting to kyc"),m("kyc");}}finally{R||h(false);}})(),()=>{R=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress){console.log("[resolveWallet] skipping \u2014 missing:",e?.publishableKey?"":"publishableKey",e?.externalUserId?"":"externalUserId",e?.recipientAddress?"":"recipientAddress");return}if(Pe)return;let R=false;J(true);async function P(){try{console.log("[resolveWallet] fetching deposit address for:",e.externalUserId,e.recipientAddress);let[$,G]=await Promise.all([Pp({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?Op({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Et=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Et?.message),null)):Promise.resolve(null)]);if(R){console.log("[resolveWallet] cancelled after fetch \u2014 discarding stale result");return}let de=e?.destinationChainType??"ethereum",_t=$.data.find(Et=>Et.chain_type===de);if(_t?.address){let Et=_t.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Et,"recipient:",_t.recipient_address),Oe(Et),it.current=Et,_t.recipient_address&&he(_t.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",de,"in",$.data?.length,"wallets");let ye={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},tt={8453:"base",1:"ethereum",137:"polygon"},Wt=G?.destination_network,xr="none";if(Wt&&ye[Wt])Ce(ye[Wt]),ie.current=ye[Wt],xr=Wt+" (from default_token API)";else if(e?.destinationChainId&&tt[e.destinationChainId]){let Et=tt[e.destinationChainId];ye[Et]&&(Ce(ye[Et]),ie.current=ye[Et]),xr=Et+" (from chain_id "+e.destinationChainId+")";}else ye[de]&&(Ce(ye[de]),ie.current=ye[de],xr=de+" (from chain_type fallback)");G?.destination_currency&&ot(G.destination_currency.toLowerCase());let At=G?.destination_token_metadata,lr=zn(At?.icon_urls,At?.icon_url),Vr=zn(At?.chain?.icon_urls,At?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",lr,"network:",Vr),lr&&Se(lr),Vr&&Q(Vr),console.log("[resolveWallet] \u2705 setting walletReady = true"),$e(!0),Ve.current=!0;}catch($){if(R)return;console.error("[resolveWallet] Failed to resolve wallet:",$?.message),$e(true),Ve.current=true;}finally{R||J(false);}}return ze.current=P(),()=>{R=true;}},[e?.publishableKey,e?.externalUserId,et]);let Tr=useCallback(async()=>{if(pe.current)return pe.current;let R=o({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(P=>(P.error&&(console.error("[useStripeOnramp] configureSDK error:",P.error.message,P.error.code),pe.current=null),P)).catch(P=>{throw console.error("[useStripeOnramp] configureSDK threw:",P?.message??P),pe.current=null,P});return pe.current=R,R},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||Tr();},[]);let an=useCallback(async R=>{if(!vt.current){vt.current=true,b(true),dt(),d("Creating auth intent...");try{let P=await hd(R);d("Waiting for authorization...");let $=await s(P);if($?.error){console.log("[proceedToAuthorize] authorize error:",$.error.message),z("authorization_error","Something went wrong during authorization. Please try again."),m("email");return}if($?.status==="Denied"){z("authorization_error","Authorization denied by user."),m("email");return}if($?.status!=="Consented"||!$.customerId){z("authorization_error","Authorization was canceled."),m("email");return}d("Exchanging tokens...");let G=$.customerId,de=await xp(P,G),_t=de.access_token,ye=Ga(de);console.log("[useStripeOnramp] customerId:",G),console.log("[useStripeOnramp] accessToken acquired, length:",_t.length),k(R),Ne.current=R,le(G),fe.current=G,Kn=G,_e(_t),Yi(G,_t,ye,de.expires_in??3600,R),d("Checking verification status...");try{let tt=await Mn(G,_t),Wt=tt.verifications.find(Vr=>Vr.name==="kyc_verified"),xr=Wt?.status==="verified",At=Wt?.status==="rejected",lr=tt.provided_fields.includes("first_name");if(d(""),At&&!lr)z("kyc_error","KYC was previously rejected. Please submit with correct info."),m("kyc");else if(!xr)m("kyc");else {ze.current&&(d("Resolving wallet..."),await ze.current,d(""));let Vr=it.current;if(Vr)try{let Et=Vr.toLowerCase(),Gs=ie.current;console.log("[proceedToAuthorize] registering wallet:",Et,"network:",Gs);let gi=await c(Et,Gs);gi?.error?(console.warn("[proceedToAuthorize] wallet registration error:",gi.error.message),z("wallet_error",gi.error.message,gi.error.code),m("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),m("kyc_offer"));}catch(Et){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Et?.message),m("wallet");}else console.log("[proceedToAuthorize] no resolved deposit address available, going to wallet step"),m("wallet");}}catch(tt){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",tt?.message),d(""),m("kyc");}}catch(P){z("authorization_error",P?.message??String(P)),m("email");}finally{vt.current=false,b(false);}}},[s,dt,z,Yi,c,X]),Bn=useCallback(async()=>{if(Keyboard.dismiss(),!_){z("validation_error","Please enter an email address.");return}b(true),dt(),d("");try{d("Configuring...");let R=await Tr();if(R.error){z("configuration_error",R.error.message,R.error.code);return}d("Checking Link account...");let P=await n(_);if(P.error){z("authorization_error",P.error.message,P.error.code);return}console.log("[checkEmail] link.hasLinkAccount:",P.hasLinkAccount),P.hasLinkAccount?await an(_):(d(""),m("disclaimer"));}catch(R){z("unknown_error",R?.message??String(R));}finally{b(false);}},[dt,Tr,_,z,n,an]),Wn=useCallback(async()=>{if(!qe.current){if(!v){z("validation_error","Please enter your phone number.");return}qe.current=true,b(true),dt(),d("");try{d("Creating Link account...");let R=await i({email:_,phone:v,fullName:W||_,country:F||"US"});if(R.error){z("registration_error",R.error.message,R.error.code);return}await an(_);}catch(R){z("registration_error",R?.message??String(R));}finally{qe.current=false,b(false);}}},[dt,F,_,z,W,v,i,an]);useEffect(()=>{if(w!=="email"||!e?.email||g)return;let R=++be.current,P=false,$=()=>P||be.current!==R;return e?.phone?(async()=>{b(true),dt();try{d("Configuring...");let G=await Tr();if($())return;if(G.error){z("configuration_error",G.error.message,G.error.code);return}d("Checking Link account...");let de=await n(e.email);if($())return;if(de.error){z("authorization_error",de.error.message,de.error.code);return}if(de.hasLinkAccount){if($())return;await an(e.email);}else {if($())return;d(""),m("disclaimer");}}catch(G){$()||z("unknown_error",G?.message??String(G));}finally{b(false);}})():(async()=>{b(true),dt();try{d("Configuring...");let G=await Tr();if($())return;if(G.error){z("configuration_error",G.error.message,G.error.code);return}d("Checking Link account...");let de=await n(e.email);if($())return;if(de.error){z("authorization_error",de.error.message,de.error.code);return}if(de.hasLinkAccount){if($())return;await an(e.email);}else {if($())return;d(""),m("disclaimer");}}catch(G){$()||z("unknown_error",G?.message??String(G));}finally{b(false);}})(),()=>{P=true;}},[w,e?.email,e?.phone,g]);let Ja=useCallback(async()=>{ze.current&&(d("Resolving wallet..."),await ze.current);let R=it.current;if(R)try{d("Registering wallet...");let P=R.toLowerCase(),$=ie.current;console.log("[resolveAndRegisterWallet] registering wallet:",P,"network:",$),await c(P,$);}catch(P){console.warn("[resolveAndRegisterWallet] wallet registration failed (non-fatal):",P?.message);}else console.warn("[resolveAndRegisterWallet] no resolved deposit address \u2014 skipping registration");},[c]),sh=useCallback(async(R,P)=>{b(true),dt(),d(""),$t(de=>({...de,...R}));let $=P??"kyc_offer",G=P?"kyc_l1":"kyc";try{let de=R.dobDay&&R.dobMonth&&R.dobYear,_t=R.firstName&&R.lastName,ye={};_t&&(ye.firstName=R.firstName,ye.lastName=R.lastName),R.addressLine1&&(ye.address={line1:R.addressLine1,line2:R.addressLine2||void 0,city:R.city,state:R.state,postalCode:R.postalCode,country:R.country}),R.idNumber&&(ye.idNumber=R.idNumber),de&&(ye.dateOfBirth={day:parseInt(R.dobDay,10),month:parseInt(R.dobMonth,10),year:parseInt(R.dobYear,10)}),console.log("[attachKyc] sending kycInfo:",JSON.stringify(ye,null,2));let tt=await a(ye);if(console.log("[attachKyc] attachKycInfo result:",JSON.stringify(tt,null,2)),tt?.error?.message&&(/no active link consumer/i.test(tt.error.message)||/not be verified/i.test(tt.error.message))){if(console.log("[attachKyc] Link session invalid \u2014 re-establishing session"),d("Verifying identity..."),!await Ys()){z("kyc_error","Please verify your identity to continue."),m(G);return}tt=await a(ye),console.log("[attachKyc] retry attachKycInfo result:",JSON.stringify(tt,null,2));}if(tt?.error){if(tt.error.stripeErrorCode==="consumer_person_already_verified"){console.log("[attachKyc] already verified, resolving wallet before",$),await Ja(),d(""),m($);return}z("kyc_error",tt.error.message,tt.error.stripeErrorCode??tt.error.code),m(G);return}if(!(tt&&Object.keys(tt).length>0&&!tt.error)){let lr=P?"l1":"l0";if(console.log(`[attachKyc] success (no verification needed), waiting for ${lr} verified...`),d("Verifying identity..."),!fe.current||!we.current){console.warn(`[attachKyc] \u274C cannot poll ${lr} \u2014 missing customerIdRef or accessTokenRef`),z("kyc_error","Unable to verify identity. Please try again."),m(G);return}let Vr=fe.current,Et=we.current,Gs=10,gi=!1;for(let Hc=0;Hc<Gs;Hc++){try{let rl=(await Mn(Vr,Et)).kyc_tiers?.find(fh=>fh.tier===lr);if(console.log(`[attachKyc] ${lr} poll #${Hc+1}: verification_status=${rl?.verification_status}`),rl?.verification_status==="verified"){console.log(`[attachKyc] \u2705 ${lr} verified!`),gi=!0;break}if(rl?.verification_status==="rejected"){console.warn(`[attachKyc] \u274C ${lr} rejected:`,rl?.verification_errors),z("kyc_error","KYC verification was rejected. Please try again."),m(G);return}}catch(tl){console.warn(`[attachKyc] ${lr} poll error:`,tl?.message);}await new Promise(tl=>setTimeout(tl,2e3));}if(!gi){console.warn(`[attachKyc] \u274C ${lr} verification timed out after`,Gs,"attempts"),z("kyc_error","Identity verification is taking longer than expected. Please try again."),m(G);return}await Ja(),d(""),m($);return}console.log("[attachKyc] calling presentKycInfoVerification..."),d("Please review your KYC information...");let At=await l(null);if(console.log("[attachKyc] presentKycInfoVerification result:",JSON.stringify(At,null,2)),At?.error){z("kyc_error",At.error.message,At.error.stripeErrorCode??At.error.code),m(G);return}if(At?.status==="UpdateAddress"){z("kyc_error","Please update your address and resubmit."),m(G);return}await Ja(),d(""),console.log("[attachKyc] success, navigating to:",$),m($);}catch(de){z("kyc_error",de?.message??String(de)),m(G);}finally{b(false);}},[a,dt,z,l,Ja]),Ys=useCallback(async()=>{let R=Ne.current||e?.email;if(!R)return console.warn("[reestablishLinkSession] no email available \u2014 emailRef:",JSON.stringify(Ne.current),"config.email:",e?.email),false;try{console.log("[reestablishLinkSession] re-establishing Link session for:",R);let P=await hd(R),$=await s(P);return $?.status==="Consented"&&$.customerId?(console.log("[reestablishLinkSession] success, customerId:",$.customerId),fe.current=$.customerId,le($.customerId),!0):(console.warn("[reestablishLinkSession] authorize did not consent:",$?.status),!1)}catch(P){return console.warn("[reestablishLinkSession] failed:",P?.message),false}},[s,e?.email]),Gu=useCallback(async()=>{if(!ve.current){ve.current=true,b(true),dt(),d("Launching identity verification...");try{let R=await u();if(R?.error?.message&&(/no active link consumer/i.test(R.error.message)||/not be verified/i.test(R.error.message))){if(console.log("[verifyIdentity] Link session invalid \u2014 re-establishing session"),d("Verifying identity..."),!await Ys()){z("identity_error","Please verify your identity to continue.");return}R=await u();}if(R?.error){let $=R.error.message??"";if(/cancel/i.test($)){console.log("[verifyIdentity] cancelled by user, returning silently"),d("");return}z("identity_error",$,R.error.code);return}d(""),Za.current?(Za.current=!1,m("session_params")):m("wallet");}catch(R){z("identity_error",R?.message??String(R));}finally{ve.current=false,b(false);}}},[dt,z,Ys,u]),Za=useRef(false);useEffect(()=>{w==="identity"&&!S&&Gu();},[w]);let Ju=useCallback(async()=>{if(console.log("[registerWallet] called. walletAddress:",Ee,"walletNetwork:",X),!Ee){z("validation_error","Please enter a wallet address.");return}b(true),dt(),d("");try{let R=Ee.toLowerCase();console.log("[registerWallet] registering wallet:",R,"network:",X);let P=await c(R,X);if(console.log("[registerWallet] result:",JSON.stringify(P,null,2)),P?.error){console.warn("[registerWallet] error:",P.error.message),z("wallet_error",P.error.message,P.error.code);return}console.log("[registerWallet] wallet registered successfully \u2192 kyc_offer"),d(""),m("kyc_offer");}catch(R){console.error("[registerWallet] exception:",R?.message??String(R)),z("wallet_error",R?.message??String(R));}finally{b(false);}},[dt,z,Ee,X,c]);useEffect(()=>{console.log("[auto-register] step:",w,"walletReady:",Pe,"walletAddress:",Ee||"(empty)"),w==="wallet"&&Pe&&Ee&&(console.log("[auto-register] triggering registerWallet() with address:",Ee),Ju());},[w,Pe,Ee]);let Xa=useCallback(R=>{q.current=false,Fe.current=0;let P=0,$=async()=>{P+=1;let G=we.current;try{let de=await Ip(R,G);if(console.log(`[pollSessionStatus] poll #${P} session=${R} status="${de.status}"`),q.current)return;Fe.current=0,de.status==="fulfillment_complete"?(Bt(de),m("success")):D.current=setTimeout($,3e3);}catch(de){if(q.current)return;let _t=de?.message??"";if((_t.includes("stripe_onramp_forbidden")||_t.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Y()&&!q.current)){D.current=setTimeout($,1e3);return}if(Fe.current+=1,console.error(`[pollSessionStatus] poll #${P} error:`,_t),Fe.current>=Kg){z("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}D.current=setTimeout($,5e3);}};D.current=setTimeout($,3e3);},[z,Y]),ah=useCallback(()=>{if(xt.current==="processing"&&Lt?.id){if(!we.current){z("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}dt(),Fe.current=0,D.current&&(clearTimeout(D.current),D.current=null),Xa(Lt.id);}},[dt,z,Xa,Lt?.id]),el=useCallback(async R=>{b(true),dt(),d("");try{d("Confirming purchase...");let P=await ae($=>Rp(R,$));console.log("[finalizeOnrampSession] confirmed session:",P.id,"status:",P.status),Bt(P),m("processing"),d(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",P.id),Xa(P.id);}finally{b(false);}},[dt,Xa,ae]),zc=useRef(false),lh=useCallback(async()=>{if(!(!Lt||zc.current)){zc.current=true;try{b(!0),dt(),d("Refreshing quote...");let R=await ae(P=>yd(Lt.id,P));Bt(R),await el(R.id);}catch(R){console.log("[confirmCheckout] error:",R?.message),z("session_error","Something went wrong. Please try again."),m("quote");}finally{b(false),zc.current=false;}}},[dt,z,el,Lt,ae]),ch=useCallback(async(R=false,P,$)=>{let G=P??pt;if(console.log("[collectPaymentMethod] called:",{useApplePay:R,amt:G,amountOverride:P,sourceAmount:pt,hasSavedToken:!!$}),!G||isNaN(Number(G))||Number(G)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),z("validation_error","Please enter a valid amount.");return}P&&It(P),b(true),dt(),d("");try{let de=await Tr();if(de.error){z("configuration_error",de.error.message,de.error.code);return}let _t;if($)console.log("[collectPaymentMethod] using saved payment token"),_t=$;else if(R){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),z("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),m("session_params");return}d("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Wt={applePay:{merchantCountryCode:"US",currencyCode:me.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${Vt.toUpperCase()} purchase + fees`,amount:G}]}},xr=await y("PlatformPay",Wt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!xr?.error),xr?.error){let lr=xr.error.message??"",Vr=xr.error.code??"",Et=/cancel/i.test(lr)||/cancel/i.test(Vr);console.log("[collectPaymentMethod] pmResult error:",xr.error,"isCancellation:",Et),Et||(z("payment_error",lr,Vr),m("session_params"));return}if(!xr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}d("Creating payment token...");let At=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!At?.error),At?.error){z("payment_error",At.error.message,At.error.code),m("session_params");return}_t=At.cryptoPaymentToken;}else {d("Select a payment method...");let Wt=await y("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Wt?.error),Wt?.error){let lr=Wt.error.message??"",Vr=Wt.error.code??"",Et=/cancel/i.test(lr)||/cancel/i.test(Vr);console.log("[collectPaymentMethod] pmResult error:",Wt.error,"isCancellation:",Et),Et||(z("payment_error",lr,Vr),m("session_params"));return}if(!Wt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let xr=Wt.displayData;console.log("[collectPaymentMethod] displayData:",{type:xr.type,label:xr.label,sublabel:xr.sublabel,hasIcon:!!xr.icon}),d("Creating payment token...");let At=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!At?.error),At?.error){z("payment_error",At.error.message,At.error.code),m("session_params");return}_t=At.cryptoPaymentToken;}d("Creating onramp session...");let ye=it.current||Ee;if(console.log("[collectPaymentMethod] creating onramp session, sessionWalletAddress:",ye),!ye){z("wallet_error","No wallet address available. Please go back and enter a wallet address.");return}let tt=await ae(Wt=>_p({cryptoCustomerId:fe.current,paymentToken:_t,sourceAmount:Number(G),sourceCurrency:me,destinationCurrency:Vt,walletAddress:ye,destinationNetwork:X},Wt));console.log("[collectPaymentMethod] session created:",tt?.id,"useApplePay:",R),Bt(tt),d(""),R?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await el(tt.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):m("quote");}catch(de){console.log("[collectPaymentMethod] error caught:",de?.message),z("session_error","Something went wrong. Please try again."),m("session_params");}finally{b(false),d("");}},[dt,Tr,y,T,Vt,z,el,It,pt,me,Ee,X,ae,e?.merchantIdentifier]),dh=useCallback(async()=>{b(true),dt(),d("Select a payment method...");try{let R=await Tr();if(R.error)return z("configuration_error",R.error.message,R.error.code),null;let P=await y("Card");if(console.log("[addPaymentMethod] Card result ok:",!P?.error),P?.error?.message&&(/no active link consumer/i.test(P.error.message)||/not be verified/i.test(P.error.message))){if(console.log("[addPaymentMethod] Link session invalid \u2014 re-establishing session"),!await Ys())return z("authorization_error","Please verify your identity to add a payment method."),null;P=await y("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!P?.error);}if(P?.error){let _t=P.error.message??"",ye=P.error.code??"",tt=/cancel/i.test(_t)||/cancel/i.test(ye);return console.log("[addPaymentMethod] pmResult error:",P.error,"isCancellation:",tt),tt||z("payment_error",_t,ye),null}if(!P?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let G=P.displayData;console.log("[addPaymentMethod] displayData:",{type:G.type,label:G.label,sublabel:G.sublabel,hasIcon:!!G.icon}),d("Saving payment method...");let de=await T();return console.log("[addPaymentMethod] tokenResult ok:",!de?.error),de?.error?(z("payment_error",de.error.message,de.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:de.cryptoPaymentToken,sublabel:G.sublabel??""})}catch(R){return console.log("[addPaymentMethod] error:",R?.message),z("session_error",R?.message??String(R)),null}finally{b(false),d("");}},[dt,Tr,y,T,z,Ys]),uh=useCallback(async()=>{if(Lt){b(true),dt(),d("");try{let R=await ae(P=>yd(Lt.id,P));Bt(R);}catch(R){console.log("[refreshQuote] error:",R?.message),z("session_error","Something went wrong. Please try again.");}finally{b(false);}}},[dt,z,Lt,ae]),Uc=useCallback(()=>{q.current=true,Fe.current=0,D.current&&(clearTimeout(D.current),D.current=null),m(r),b(false),d(""),x(null),k(e?.email??""),Ne.current=e?.email??"",M(e?.phone??""),O(""),U("US"),le(""),fe.current="",_e(""),we.current="",ne.current="",$e(false),J(false),ze.current=null,Ae(R=>R+1),$t($p),Oe(""),it.current="",Ve.current=false,Ce(Onramp.CryptoNetwork.ethereum),It(e?.defaultSourceAmount??"100"),je(e?.defaultSourceCurrency??"usd"),ot(e?.defaultDestinationCurrency??"usdc"),he(""),Se(void 0),Q(void 0),Bt(null),be.current+=1,vt.current=false,ve.current=false,qe.current=false;},[e,r]),ph=useCallback(()=>{Za.current=true,m("kyc_offer");},[]),mh=useCallback(async()=>{await hn(),Kn=null,Uc();},[Uc]);return {step:w,restoring:g,loading:S,status:p,error:C,email:_,phone:v,fullName:W,country:F,customerId:j,accessToken:Ye,session:Lt,kycData:Ke,walletAddress:Ee,resolvedRecipientAddress:ar,walletNetwork:X,sourceAmount:pt,sourceCurrency:me,destinationCurrency:Vt,tokenIconUrl:yt,networkIconUrl:Z,applePaySupported:L,walletReady:Pe,walletLoading:ue,setStep:m,setStatus:d,setEmail:k,setPhone:M,setFullName:O,setCountry:U,setWalletAddress:Oe,setWalletNetwork:Ce,setSourceAmount:It,setSourceCurrency:je,setDestinationCurrency:ot,checkEmail:Bn,register:Wn,attachKyc:sh,verifyIdentity:Gu,requestKYCUpgrade:ph,kycUpgradeMode:Za,logout:mh,registerWallet:Ju,collectPaymentMethod:ch,addPaymentMethod:dh,refreshQuote:uh,confirmCheckout:lh,reset:Uc,clearError:dt,emitComplete:Xr,resumeFulfillmentPolling:ah,amountFirst:t}}function qp({initialData:e={},loading:t=false,onComplete:r,onCancel:o,onClose:n}){let i=Wo(),{colors:s,fonts:a,components:l}=V(),u=l.input.placeholderColor,[c,y]=useState(e.dobMonth??""),[T,w]=useState(e.dobDay??""),[m,g]=useState(e.dobYear??""),[h,S]=useState(e.idNumber??""),b=useRef(null),p=useRef(null),d=useRef(null),C=c.length===2&&T.length===2&&m.length===4&&h.trim().length>0,x=()=>{console.log("[KYCL1Screen] handleSubmit \u2014 canSubmit:",C,"dobMonth:",c,"dobDay:",T,"dobYear:",m,"idNumber:",h?"set":"empty"),C&&r({dobMonth:c,dobDay:T,dobYear:m,idNumber:h});};return jsx(KeyboardAvoidingView,{style:i.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:i.form.screen,children:[jsx(St,{onPress:t?n??o:o,title:"Increase Your Limits",variant:t?"close":"back"}),jsx(at,{style:i.form.flex,contentContainerStyle:Uo.scrollContent,keyboardShouldPersistTaps:"handled",children:jsxs(View,{pointerEvents:t?"none":"auto",style:{opacity:t?.5:1},children:[jsx(Text,{style:i.form.title,children:"Date of birth & SSN"}),jsx(Text,{style:i.form.subtitle,children:"This information is used to verify your identity and increase your transaction limits."}),jsxs(View,{style:Uo.section,children:[jsx(Text,{style:[i.form.fieldLabel,{marginBottom:8}],children:"Date of birth"}),jsxs(View,{style:Uo.dobRow,children:[jsx(View,{style:Uo.dobCol,children:jsx(TextInput,{style:[i.form.input,Uo.dobInput],placeholder:"MM",placeholderTextColor:u,value:c,onChangeText:_=>{let k=_.replace(/\D/g,"").slice(0,2);y(k),k.length===2&&b.current?.focus();},keyboardType:"number-pad",maxLength:2,editable:!t})}),jsx(View,{style:Uo.dobCol,children:jsx(TextInput,{ref:b,style:[i.form.input,Uo.dobInput],placeholder:"DD",placeholderTextColor:u,value:T,onChangeText:_=>{let k=_.replace(/\D/g,"").slice(0,2);w(k),k.length===2&&p.current?.focus();},keyboardType:"number-pad",maxLength:2,editable:!t})}),jsx(View,{style:Uo.dobColWide,children:jsx(TextInput,{ref:p,style:[i.form.input,Uo.dobInput],placeholder:"YYYY",placeholderTextColor:u,value:m,onChangeText:_=>{let k=_.replace(/\D/g,"").slice(0,4);g(k),k.length===4&&d.current?.focus();},keyboardType:"number-pad",maxLength:4,editable:!t})})]})]}),jsxs(View,{style:Uo.section,children:[jsx(Text,{style:[i.form.fieldLabel,{marginBottom:8}],children:"Social Security Number"}),jsx(TextInput,{ref:d,style:i.form.input,placeholder:"123-45-6789",placeholderTextColor:u,value:h,onChangeText:S,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:x,editable:!t}),jsx(Text,{style:[i.form.hint,{marginTop:10,lineHeight:18}],children:"Your SSN is transmitted securely and never stored on this device."})]})]})}),jsx(View,{style:i.form.footer,children:t?jsx(View,{style:[i.form.continueBtn,i.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:s.primaryForeground,gradientTo:s.primaryForeground})}):jsx(TouchableOpacity,{style:[i.form.continueBtn,!C&&i.form.continueBtnDisabled],onPress:x,disabled:!C,children:jsx(Text,{style:[i.form.continueBtnText,!C&&i.form.continueBtnTextDisabled],children:"Submit"})})})]})})}var Uo=StyleSheet.create({scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},section:{marginTop:20},dobRow:{flexDirection:"row",gap:10},dobCol:{flex:1},dobColWide:{flex:1.5},dobInput:{textAlign:"center"}});function Bd({borderRadius:e,backgroundColor:t,borderColor:r,borderWidth:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[n]),jsxs(Animated.View,{style:[Ge.card,{backgroundColor:t,borderRadius:e,borderColor:r,borderWidth:o,opacity:n}],children:[jsx(View,{style:Ge.skeletonLine}),jsx(View,{style:[Ge.skeletonLine,{width:"60%"}]})]})}function Kp({onRefresh:e,colors:t,fonts:r}){let[o,n]=useState(10),i=useRef(null);useEffect(()=>(i.current=setInterval(()=>{n(a=>a<=1?(i.current&&clearInterval(i.current),0):a-1);},1e3),()=>{i.current&&clearInterval(i.current);}),[]);let s=useCallback(()=>{o>0||(e(),n(10),i.current=setInterval(()=>{n(a=>a<=1?(i.current&&clearInterval(i.current),0):a-1);},1e3));},[o,e]);return jsxs(TouchableOpacity,{onPress:s,disabled:o>0,style:[Ge.refreshBtn,{opacity:o>0?.4:1}],activeOpacity:.7,children:[jsx(Xi,{size:14,color:t.foregroundMuted,strokeWidth:2}),o>0?jsxs(Text,{style:[Ge.refreshText,{color:t.foregroundMuted,fontFamily:r.regular}],children:[o,"s"]}):null]})}function Jp({onSelectL1:e,onSelectL2:t,onSkip:r,onClose:o,onRefresh:n,loading:i=false,loadingTiers:s=false,error:a,l0Status:l="not_started",l1Status:u="not_started",l2Status:c="not_started",l1Completed:y=false,l2Completed:T=false,currentLimit:w}){let m=Wo(),{colors:g,fonts:h,components:S}=V(),b=[Ge.card,{backgroundColor:S.card.backgroundColor,borderRadius:S.card.borderRadius??12,borderWidth:S.card.borderWidth,borderColor:S.card.borderColor}],p=[...b,{opacity:.5}],d=l==="verified",C=u==="verified",x=c==="verified",_=u==="pending"||d&&y&&!C,k=c==="pending"||d&&T&&!x,v=x,M=d&&!C,W=d&&!x,O=!v,F=U=>`$${U.toLocaleString()}`;return jsxs(View,{style:m.form.screen,children:[jsx(St,{onPress:o,title:"Increase Your Limits"}),jsxs(View,{style:Ge.content,children:[w!==void 0?jsxs(View,{style:[Ge.limitBadge,{backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth,borderRadius:S.card.borderRadius??12}],children:[jsx(Text,{style:[Ge.limitLabel,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Current transaction limit"}),jsxs(Text,{style:[Ge.limitValue,{color:g.foreground,fontFamily:h.semibold}],children:[F(w)," USD"]})]}):jsx(Bd,{borderRadius:S.card.borderRadius??12,backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth}),jsx(Text,{style:[Ge.subtitle,{color:g.foregroundMuted,fontFamily:h.regular}],children:s?"Checking your verification status...":v?"All verification levels have been completed. Your limits are at the maximum available.":"Complete additional verification to increase your transaction limits."}),s?jsxs(Fragment,{children:[jsx(Bd,{borderRadius:S.card.borderRadius??12,backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth}),jsx(Bd,{borderRadius:S.card.borderRadius??12,backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth})]}):jsxs(Fragment,{children:[M&&(C?jsxs(View,{style:p,children:[jsxs(View,{style:Ge.completedRow,children:[jsx(jr,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Date of Birth & SSN"}),jsx(Le,{size:18,color:g.primary,strokeWidth:2.5})]}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular,marginLeft:28}],children:"Completed"})]}):_?jsxs(View,{style:b,children:[jsxs(View,{style:Ge.pendingHeader,children:[jsx(jr,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Date of Birth & SSN"}),n?jsx(Kp,{onRefresh:n,colors:g,fonts:h}):null]}),jsxs(View,{style:[Ge.pendingFooter,{marginLeft:28}],children:[jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Verification in progress..."}),jsx(nt,{size:18,strokeWidth:2,gradientFrom:g.primary,gradientTo:g.primary})]})]}):jsxs(TouchableOpacity,{style:[b,Ge.cardRow],onPress:e,activeOpacity:.7,children:[jsx(jr,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsxs(View,{style:Ge.cardContent,children:[jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold}],children:"Provide Date of Birth & SSN"}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Increases your per-transaction and weekly limits."})]}),jsx(_r,{size:18,color:g.foregroundMuted,strokeWidth:2})]})),W&&(x?jsxs(View,{style:p,children:[jsxs(View,{style:Ge.completedRow,children:[jsx(sl,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Photo ID & Selfie"}),jsx(Le,{size:18,color:g.primary,strokeWidth:2.5})]}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular,marginLeft:28}],children:"Completed"})]}):k?jsxs(View,{style:b,children:[jsxs(View,{style:Ge.pendingHeader,children:[jsx(sl,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Photo ID & Selfie"}),n?jsx(Kp,{onRefresh:n,colors:g,fonts:h}):null]}),jsxs(View,{style:[Ge.pendingFooter,{marginLeft:28}],children:[jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Verification in progress..."}),jsx(nt,{size:18,strokeWidth:2,gradientFrom:g.primary,gradientTo:g.primary})]})]}):jsxs(TouchableOpacity,{style:[b,Ge.cardRow],onPress:t,activeOpacity:.7,children:[jsx(sl,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsxs(View,{style:Ge.cardContent,children:[jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold}],children:"Provide Photo ID & Selfie"}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Unlocks the highest transaction limits available."})]}),jsx(_r,{size:18,color:g.foregroundMuted,strokeWidth:2})]}))]})]}),jsxs(View,{style:Ge.footer,children:[a?jsx(Text,{style:[m.form.subtitle,{marginBottom:12,textAlign:"center",color:"red"}],children:a}):null,i?jsxs(View,{style:Ge.loaderRow,children:[jsx(nt,{size:24,strokeWidth:2,gradientFrom:g.primary,gradientTo:g.primary}),jsx(Text,{style:[m.form.ghostBtnText,{marginLeft:8}],children:"Verifying..."})]}):O?jsx(TouchableOpacity,{style:m.form.ghostBtn,onPress:r,activeOpacity:.7,children:jsx(Text,{style:m.form.ghostBtnText,children:"Skip for now"})}):jsx(TouchableOpacity,{style:m.form.continueBtn,onPress:r,activeOpacity:.7,children:jsx(Text,{style:m.form.continueBtnText,children:"Done"})})]})]})}var Ge=StyleSheet.create({content:{flex:1,paddingTop:24,gap:16},limitBadge:{alignItems:"center",paddingVertical:24,paddingHorizontal:20,gap:4},limitLabel:{fontSize:13},limitValue:{fontSize:20,paddingTop:8},subtitle:{fontSize:15,lineHeight:22,textAlign:"center",paddingHorizontal:16,paddingVertical:24},card:{padding:20,gap:6},cardRow:{flexDirection:"row",alignItems:"center",gap:16},cardContent:{flex:1,gap:6},cardTitle:{fontSize:16},cardBody:{fontSize:14,lineHeight:20},completedRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8},skeletonLine:{height:14,borderRadius:7,backgroundColor:"rgba(128, 128, 128, 0.15)",width:"80%",marginBottom:6},pendingHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:4,gap:8},pendingFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},refreshBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:2,paddingHorizontal:4},refreshText:{fontSize:12},footer:{paddingTop:12,gap:4},loaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:12}});var Bl={linkOnrampTerms:"https://link.com/terms/crypto-onramp",bridgeTerms:"https://www.bridge.xyz/legal/us-terms/bridge-building-inc",linkPrivacy:"https://link.com/privacy",bridgePrivacy:"https://www.bridge.xyz/legal/us-privacy-policy/bridge-building-inc"};function Xp({styles:e,merchantDisplayName:t="This app",onContinue:r,onClose:o}){let{colors:n,fonts:i,components:s}=V(),a=[vo.link,{color:n.primary,fontFamily:i.medium}],l=s.card.borderRadius??12;return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:o,title:"Verify Your Identity"}),jsx(View,{style:vo.logoRow,children:jsx(ip,{height:20,color:n.foreground})}),jsxs(ScrollView,{style:vo.scroll,contentContainerStyle:vo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:[vo.card,{backgroundColor:s.card.backgroundColor,borderRadius:l,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsx(Text,{style:[vo.sectionTitle,{color:n.foreground,fontFamily:i.semibold}],children:"Description"}),jsxs(Text,{style:[vo.body,{color:n.foregroundMuted,fontFamily:i.regular}],children:["You must verify your identity using Link. ",t," will create or access your Link account on your behalf."]})]}),jsxs(View,{style:[vo.card,{backgroundColor:s.card.backgroundColor,borderRadius:l,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsx(Text,{style:[vo.sectionTitle,{color:n.foreground,fontFamily:i.semibold}],children:"Terms"}),jsxs(Text,{style:[vo.body,{color:n.foregroundMuted,fontFamily:i.regular}],children:["Your data will be encrypted and processed by our partner, Stripe. Funds transfer services are provided by Stripe Payments Company. Cryptocurrency conversion services are provided by Bridge. By continuing you agree to the"," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.linkOnrampTerms),children:"Link Onramp Terms"}),","," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.bridgeTerms),children:"Bridge Terms"})," ","and you acknowledge receipt of the"," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.linkPrivacy),children:"Link US Consumer Privacy Notice"})," ","and the"," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.bridgePrivacy),children:"Bridge Privacy Notice"}),"."]})]})]}),jsxs(View,{style:vo.footer,children:[jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:r,activeOpacity:.7,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue"})}),jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:o,activeOpacity:.7,children:jsx(Text,{style:e.form.ghostBtnText,children:"Cancel"})})]})]})}var vo=StyleSheet.create({logoRow:{paddingVertical:24,alignItems:"center"},scroll:{flex:1},scrollContent:{paddingTop:16,paddingBottom:16,gap:12},card:{padding:20,gap:10},sectionTitle:{fontSize:15},body:{fontSize:14,lineHeight:21},link:{textDecorationLine:"underline"},footer:{paddingTop:12,gap:4}});function em({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:i,email:s,setEmail:a,checkEmail:l,onClose:u}){let{colors:c}=V();return r?jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),jsxs(View,{style:e.flow.centered,children:[jsx(nt,{size:56,strokeWidth:3}),jsx(Mr,{error:n,progress:i,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your email"}),jsx(Text,{style:e.form.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Email address"}),jsx(TextInput,{style:[e.form.input,o&&{opacity:.5}],placeholder:"jane@example.com",placeholderTextColor:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:s,onChangeText:a,autoFocus:true,returnKeyType:"done",onSubmitEditing:l,editable:!o})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!s&&e.form.continueBtnDisabled],onPress:l,disabled:!s,children:jsx(Text,{style:[e.form.continueBtnText,!s&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Mr,{error:n,progress:i,loading:o})]})]})})}function rm({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:i}){return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:i}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(nt,{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(Mr,{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 nm({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:i,destinationNetwork:s,tokenIconUrl:a,networkIconUrl:l,onClose:u,onRetryStatusCheck:c}){let{colors:y}=V(),T=!!t;return jsxs(View,{style:e.form.screen,children:[T?jsx(St,{onPress:u}):jsx(View,{style:Cl}),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(nt,{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&&i&&s&&jsx(Sl,{sourceCurrency:n,destinationCurrency:i,destinationNetwork:s,tokenIconUrl:a,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(Mr,{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 im({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:i,tokenIconUrl:s,networkIconUrl:a,onClose:l,onBack:u}){let{colors:c}=V(),y=t.transaction_details,T=bl(y.destination_amount,y.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u??l,title:"Review your purchase",variant:u?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(as,{currency:y.destination_currency,tokenIconUrl:s,networkIconUrl:a,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(To,{quote:e.quote,label:"You pay",value:`${y.source_amount} ${y.source_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"You receive",value:`${T} ${y.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Network fee",value:`$${y.fees.network_fee_amount}`,hideDivider:true}),jsx(To,{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(nt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(Mr,{error:o,progress:n,loading:r})]})]})}function sm({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:i,phone:s,setPhone:a,register:l,onClose:u}){let c=V(),{colors:y,fonts:T,components:w}=c,[m,g]=useState("");useEffect(()=>{if(t)return;let b=m?`+1${m}`:"";a(b);},[m,a,t]);let h=useCallback(b=>{g(b.replace(/[^\d]/g,""));},[]);if(t)return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),jsxs(View,{style:e.flow.centered,children:[jsx(nt,{size:56,strokeWidth:3}),jsx(Mr,{error:o,progress:n,loading:r})]})]});let S=m.length>=4;return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your phone"}),jsx(Text,{style:e.form.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Phone number"}),jsxs(View,{style:Sa.phoneRow,children:[jsxs(View,{style:[Sa.countryPrefix,{backgroundColor:w.card.backgroundColor,borderColor:w.input.borderColor,borderRadius:w.input.borderRadius,borderWidth:w.card.borderWidth}],children:[jsx(Text,{style:Sa.flag,children:"\u{1F1FA}\u{1F1F8}"}),jsx(Text,{style:[Sa.dialCode,{color:y.foreground,fontFamily:T.medium}],children:"+1"})]}),jsx(TextInput,{style:[e.form.input,Sa.phoneInput,r&&{opacity:.5}],placeholder:"Phone number",placeholderTextColor:c.components.input.placeholderColor,keyboardType:"phone-pad",value:m,onChangeText:h,autoFocus:true,returnKeyType:"done",onSubmitEditing:()=>S&&l(),editable:!r})]})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:i})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:y.primaryForeground,gradientTo:y.primaryForeground})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!S&&e.form.continueBtnDisabled],onPress:l,disabled:!S,children:jsx(Text,{style:[e.form.continueBtnText,!S&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Mr,{error:o,progress:n,loading:r})]})]})})}var Sa=StyleSheet.create({phoneRow:{flexDirection:"row",gap:8,alignItems:"stretch"},countryPrefix:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,gap:8},flag:{fontSize:20},dialCode:{fontSize:16,fontWeight:"600"},phoneInput:{flex:1}});function ky({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=V(),n=e.toLowerCase(),i=wl[n]??o.primary,s=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:[$o.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:i}],children:jsx(Text,{style:[$o.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[$o.checkBadge,{width:s,height:s,borderRadius:s/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(Le,{size:s*.55,color:"#FFFFFF",strokeWidth:3})})]})}function am({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:i,onDone:s}){let {colors:a,components:l,fonts:u}=V(),c=t.transaction_details,y=bl(c.destination_amount,c.destination_currency),T=r||o||"";ss(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:s,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(at,{style:e.form.flex,contentContainerStyle:$o.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:$o.iconSection,children:[jsx(ky,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:$o.statusRow,children:[jsx(View,{style:[$o.statusDot,{backgroundColor:a.success}]}),jsx(Text,{style:[$o.statusText,{color:a.foreground,fontFamily:u.semibold}],children:"Completed"})]}),jsx(Text,{style:[$o.subtitle,{color:a.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(Sl,{sourceCurrency:c.source_currency,destinationCurrency:c.destination_currency,destinationNetwork:c.destination_network,tokenIconUrl:n,networkIconUrl:i,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor},$o.detailCard],children:[jsx(To,{quote:e.quote,label:"You Paid",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"You Received",value:`${y} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(fd,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),T?jsx(fd,{quote:e.quote,label:"Recipient Address",address:T,last:true}):jsx(To,{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:s,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var $o=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 lm({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:i,walletNetwork:s,setWalletAddress:a,setWalletNetwork:l,setDestinationCurrency:u,registerWallet:c,onClose:y}){let{colors:T,components:w}=V();if(t){let m=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:y}),jsxs(View,{style:e.flow.centered,children:[!m&&jsx(nt,{size:56,strokeWidth:3}),jsx(Mr,{error:o,progress:n,loading:r})]}),m&&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(St,{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:w.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:a})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:gl.map(m=>{let g=s===m.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,g&&e.wallet.rowSelected],onPress:()=>{l(m.value),u(m.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(m.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,g&&e.wallet.rowTextSelected],children:m.label}),g&&jsx(View,{style:e.wallet.checkCircle,children:jsx(Le,{size:14,color:w.container.buttonTitleColor,strokeWidth:2.5})})]},m.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:T.primaryForeground,gradientTo:T.primaryForeground})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:c,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Mr,{error:o,progress:n,loading:r})]})]})})}function Ul({config:e,onClose:t}){let r=V(),o=Wo(),{step:n,restoring:i,loading:s,status:a,error:l,email:u,phone:c,session:y,kycData:T,walletAddress:w,resolvedRecipientAddress:m,walletNetwork:g,sourceAmount:h,sourceCurrency:S,destinationCurrency:b,tokenIconUrl:p,networkIconUrl:d,applePaySupported:C,setStep:x,setEmail:_,setPhone:k,setWalletAddress:v,setWalletNetwork:M,setSourceAmount:W,setDestinationCurrency:O,checkEmail:F,register:U,attachKyc:j,verifyIdentity:le,registerWallet:Ye,collectPaymentMethod:_e,addPaymentMethod:ne,confirmCheckout:we,reset:fe,emitComplete:Pe,resumeFulfillmentPolling:$e,amountFirst:ue,customerId:J,accessToken:be,requestKYCUpgrade:vt,kycUpgradeMode:ve,logout:qe}=Fl(e),Ne=!!e?.email,Ve=!!e?.phone,ze=!!e?.publishableKey&&!!e?.externalUserId,[it,ie]=useState(void 0),[pe,et]=useState(void 0),[Ae,Ke]=useState([]),[$t,Ee]=useState(false),[Oe,ar]=useState(false),[he,X]=useState("not_started"),[Ce,pt]=useState("not_started"),[It,me]=useState("not_started"),[je,Vt]=useState(false);useEffect(()=>{n!=="kyc_offer"||!J||!be||(Vt(true),Mn(J,be).then(Se=>{let Z=Se.kyc_tiers??[],Q=Z.find(D=>D.tier==="l0"),L=Z.find(D=>D.tier==="l1"),I=Z.find(D=>D.tier==="l2");Q?.verification_status&&X(Q.verification_status),L?.verification_status&&pt(L.verification_status),I?.verification_status&&me(I.verification_status),console.log("[OnrampScreen] kyc_tiers \u2014 l0:",Q?.verification_status,"l1:",L?.verification_status,"l2:",I?.verification_status);}).catch(Se=>{console.warn("[OnrampScreen] kyc_offer customer fetch error:",Se?.message);}).finally(()=>Vt(false)),w&&bd({destinationNetwork:g||"ethereum",walletAddress:w,accessToken:be,cryptoCustomerId:J}).then(Se=>{let Z=Se.limits?.usd;if(Z?.card?.length){let Q=Math.max(...Z.card.map(L=>L.limit));ie(Q),console.log("[OnrampScreen] kyc_offer card max amount:",Q);}}).catch(Se=>{console.warn("[OnrampScreen] kyc_offer transaction_limits error:",Se?.message);}));},[n,J,be,w,g]),useEffect(()=>{if(i||n!=="session_params"||!J||!be)return;console.log("[OnrampScreen] customerId:",J);let Se=Q=>{let L=Q?.message??"";return L.includes("stripe_onramp_forbidden")||L.includes("403")},Z=Q=>{Se(Q)&&(hn(),fe());};Mn(J,be).then(Q=>{console.log("[OnrampScreen] customer:",JSON.stringify(Q,null,2));let L=Q.provided_fields??[],I=Q.verifications??[],D=L.includes("date_of_birth")||L.includes("id_number"),Fe=I.find(ke=>ke.name==="id_document_verified")?.status==="verified";Ee(D),ar(!!Fe);}).catch(Q=>{console.warn("[OnrampScreen] customer fetch error:",Q?.message),Z(Q);}),Cd(J,be).then(Q=>{console.log("[OnrampScreen] payment_tokens fetched, count:",Q.data?.length??0),Ke(Q.data??[]);}).catch(Q=>{console.warn("[OnrampScreen] payment_tokens error:",Q?.message),Z(Q);}),console.log("[OnrampScreen] walletAddress:",w,"walletNetwork:",g),w&&(console.log("[OnrampScreen] calling getTransactionLimits..."),bd({destinationNetwork:g||"ethereum",walletAddress:w,accessToken:be,cryptoCustomerId:J}).then(Q=>{console.log("[OnrampScreen] transaction_limits fetched");let L=Q.limits?.usd;if(L?.card?.length){let I=Math.max(...L.card.map(D=>D.limit));ie(I),console.log("[OnrampScreen] card max amount:",I);}}).catch(Q=>{console.warn("[OnrampScreen] transaction_limits error:",Q?.message),Z(Q);})),aa(e?.publishableKey).then(Q=>{let L=Q.data?.find(I=>I.currency_code==="usd");L&&(et(L.minimum_amount),console.log("[OnrampScreen] fiat min amount:",L.minimum_amount));}).catch(Q=>{console.warn("[OnrampScreen] fiat_currencies error:",Q?.message);});},[i,n,J,be,w,g,fe]);let ot=async()=>{if(!(!J||!be))try{let Se=await Cd(J,be);console.log("[OnrampScreen] payment_tokens refreshed, count:",Se.data?.length??0),Ke(Se.data??[]);}catch(Se){console.warn("[OnrampScreen] payment_tokens refresh error:",Se?.message);let Z=Se?.message??"";(Z.includes("stripe_onramp_forbidden")||Z.includes("403"))&&(hn(),fe());}},Lt=async()=>{let Se=await ne();return Se&&await ot(),Se},Bt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&Bt&&y&&(Pe(y),fe(),t?.());},[n,Bt,y,Pe,fe,t]),useEffect(()=>{n==="register"&&Ve&&U();},[n,Ve,U]);let yt=()=>{fe(),t?.();};if(i)return jsx(View,{style:[Iy.container,{backgroundColor:r.colors.background}],children:jsx(nt,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})});if(n==="disclaimer")return jsx(Xp,{styles:o,merchantDisplayName:e?.merchantDisplayName,onContinue:()=>x("register"),onClose:()=>x("email")});if(n==="email")return jsx(em,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:Ne,loading:s,error:l,status:a,email:u,setEmail:_,checkEmail:F,onClose:yt});if(n==="register")return jsx(sm,{styles:o,hasPrefilledPhone:Ve,loading:s,error:l,status:a,email:u,phone:c,setPhone:k,register:U,onClose:yt});if(n==="kyc")return jsx(Ol,{initialData:T,loading:s,onComplete:j,onCancel:yt});if(n==="kyc_offer"){let Se=()=>{ve.current&&(ve.current=false),x("session_params");};return jsx(Jp,{onSelectL1:()=>x("kyc_l1"),onSelectL2:()=>{ve.current=true,x("identity");},onSkip:Se,onClose:()=>{ve.current?(ve.current=false,x("session_params")):Se();},onRefresh:()=>{!J||!be||(Vt(true),Mn(J,be).then(L=>{let I=L.kyc_tiers??[],D=I.find(ke=>ke.tier==="l0"),q=I.find(ke=>ke.tier==="l1"),Fe=I.find(ke=>ke.tier==="l2");D?.verification_status&&X(D.verification_status),q?.verification_status&&pt(q.verification_status),Fe?.verification_status&&me(Fe.verification_status),console.log("[OnrampScreen] refresh kyc_tiers \u2014 l0:",D?.verification_status,"l1:",q?.verification_status,"l2:",Fe?.verification_status);}).catch(L=>{console.warn("[OnrampScreen] refresh customer fetch error:",L?.message);}).finally(()=>Vt(false)));},loading:s,loadingTiers:je,error:l?.message,l0Status:he,l1Status:Ce,l2Status:It,l1Completed:$t,l2Completed:Oe,currentLimit:it})}if(n==="kyc_l1"){let Se=ve.current?"session_params":"wallet";return jsx(qp,{initialData:T,loading:s,onComplete:Z=>{console.log("[KYCL1] onComplete called with:",JSON.stringify(Z)),ve.current&&(ve.current=false),j(Z,Se);},onCancel:()=>x("kyc_offer"),onClose:yt})}return n==="identity"?jsx(rm,{styles:o,loading:s,status:a,error:l,verifyIdentity:le,onClose:()=>{ve.current?(ve.current=false,x("session_params")):yt();}}):n==="wallet"?jsx(lm,{styles:o,hasAutoWallet:ze,loading:s,error:l,status:a,walletAddress:w,walletNetwork:g,setWalletAddress:v,setWalletNetwork:M,setDestinationCurrency:O,registerWallet:Ye,onClose:yt}):n==="session_params"?jsx(Pl,{initialAmount:h,currency:S,applePaySupported:C,paymentSelectorPosition:e?.paymentSelectorPosition??"header",minAmount:pe,maxAmount:it,paymentTokens:Ae,onAddPaymentMethod:Lt,onCollectPayment:(Se,Z)=>{_e(Se,Z);},paymentLoading:s,paymentStatus:a,paymentError:l?.message??null,onConfirm:(Se,Z)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:Se,selectedMethod:Z,amountFirst:ue}),ue&&!J)W(Se),x("email");else {let Q=Z==="apple_pay",L=!Q&&Z?Z:void 0;console.log("[OnrampScreen] isApplePay:",Q,"hasSavedToken:",!!L),_e(Q,Se,L);}},onCancel:yt,accessToken:be,showHistoryProgressBar:e?.showHistoryProgressBar,onLogout:qe,onRequestKYC:vt}):n==="quote"&&y?jsx(im,{styles:o,session:y,loading:s,error:l,status:a,confirmCheckout:we,tokenIconUrl:p,networkIconUrl:d,onClose:yt,onBack:()=>x("session_params")}):n==="processing"?jsx(nm,{styles:o,error:l,status:a,loading:s,sourceCurrency:y?.transaction_details.source_currency,destinationCurrency:y?.transaction_details.destination_currency??b,destinationNetwork:y?.transaction_details.destination_network??"base",tokenIconUrl:p,networkIconUrl:d,onClose:yt,onRetryStatusCheck:$e}):n==="success"&&y&&!Bt?jsx(am,{styles:o,session:y,resolvedRecipientAddress:m,recipientFromConfig:e?.recipientAddress,tokenIconUrl:p,networkIconUrl:d,onDone:()=>{Pe(y),fe(),t?.();}}):null}var Iy=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function cm(){try{let e=Py.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 i=n.trim();if(i.length>0)return i}}}catch{}}function Hl({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:i="ethereum",destinationChainId:s="8453",destinationTokenAddress:a,recipientAddress:l,onComplete:u,onError:c,onStepChange:y,onClose:T,merchantIdentifier:w="",urlScheme:m="unifoldOnramp",paymentSelectorPosition:g,skipSuccessConfirmation:h=false,appName:S}){let{colors:b,fonts:p,components:d}=V(),C=e||dl(),x=useMemo(()=>{let O=w.trim();return O.length>0?O:cm()??""},[w]),[_,k]=useState("loading"),[v,M]=useState(null);useEffect(()=>{let O=false;async function F(){try{C&&(kl(C),Tl(sa()));let U=await xl();if(O)return;let j=x.trim();if(await initStripe({publishableKey:U,urlScheme:m,...j?{merchantIdentifier:j}:{}}),O)return;k("ready");}catch(U){if(O)return;console.error("[StripeOnramp] Init failed:",U),M(U?.message??"Failed to load Stripe configuration"),k("error");}}return F(),()=>{O=true;}},[C,x,m]);let W=useMemo(()=>{let O={publishableKey:C,externalUserId:o,destinationChainType:i,destinationChainId:s,onComplete:u,onError:c,onStepChange:y};return a&&(O.destinationTokenAddress=a),l&&(O.recipientAddress=l),t&&(O.email=t),r&&(O.phone=r),n&&(O.flowOrder=n),g&&(O.paymentSelectorPosition=g),O.skipSuccessConfirmation=h,O.merchantIdentifier=x,S&&(O.merchantDisplayName=S),O},[C,o,i,s,a,l,t,r,n,g,h,x,S,u,c,y]);return _==="error"?jsxs(View,{style:[ys.centered,{backgroundColor:b.background}],children:[jsx(Text,{style:[ys.errorText,{color:b.error,fontFamily:p.medium}],children:"Unable to initialize"}),jsx(Text,{style:[ys.errorDetail,{color:b.foregroundMuted,fontFamily:p.regular}],children:v}),T&&jsx(TouchableOpacity,{style:[ys.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:T,children:jsx(Text,{style:[ys.retryBtnText,{color:d.button.primaryText,fontFamily:p.medium}],children:"Go Back"})})]}):_==="loading"?jsx(View,{style:[ys.centered,{backgroundColor:b.background}],children:jsx(nt,{size:56,strokeWidth:3,gradientFrom:b.primary,gradientTo:b.primary})}):jsx(Ul,{config:W,onClose:T})}var ys=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 mm(){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 fm="__unifold_stripe_onramp__";function Nl(e){globalThis[fm]=e;}function hm(){return globalThis[fm]}Nl(Hl);var qo=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 _i,Gn,bs,gm,Ey=(gm=class extends qo{constructor(){super();te(this,_i);te(this,Gn);te(this,bs);A(this,bs,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){f(this,Gn)||this.setEventListener(f(this,bs));}onUnsubscribe(){var t;this.hasListeners()||((t=f(this,Gn))==null||t.call(this),A(this,Gn,void 0));}setEventListener(t){var r;A(this,bs,t),(r=f(this,Gn))==null||r.call(this),A(this,Gn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){f(this,_i)!==t&&(A(this,_i,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof f(this,_i)=="boolean"?f(this,_i):globalThis.document?.visibilityState!=="hidden"}},_i=new WeakMap,Gn=new WeakMap,bs=new WeakMap,gm),Cs=new Ey;var My={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ko,Ri,ym,zy=(ym=class{constructor(){te(this,Ko,My);te(this,Ri,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&f(this,Ri)&&e!==f(this,Ko)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:f(this,Ko),provider:e}),A(this,Ko,e),process.env.NODE_ENV!=="production"&&A(this,Ri,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,Ri,true),f(this,Ko).setTimeout(e,t)}clearTimeout(e){f(this,Ko).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,Ri,true),f(this,Ko).setInterval(e,t)}clearInterval(e){f(this,Ko).clearInterval(e);}},Ko=new WeakMap,Ri=new WeakMap,ym),Qo=new zy;function bm(e){setTimeout(e,0);}var Md=typeof window>"u"||"Deno"in globalThis;function br(){}function Sm(e,t){return typeof e=="function"?e(t):e}function ka(e){return typeof e=="number"&&e>=0&&e!==1/0}function $l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Io(e,t){return typeof e=="function"?e(t):e}function Yr(e,t){return typeof e=="function"?e(t):e}function ql(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:i,queryKey:s,stale:a}=e;if(s){if(o){if(t.queryHash!==Ta(s,t.options))return false}else if(!Pi(t.queryKey,s))return false}if(r!=="all"){let l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return false}return !(typeof a=="boolean"&&t.isStale()!==a||n&&n!==t.state.fetchStatus||i&&!i(t))}function Kl(e,t){let{exact:r,status:o,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return false;if(r){if(vi(t.options.mutationKey)!==vi(i))return false}else if(!Pi(t.options.mutationKey,i))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Ta(e,t){return (t?.queryKeyHashFn||vi)(e)}function vi(e){return JSON.stringify(e,(t,r)=>Ed(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function Pi(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Pi(e[r],t[r])):false}var Uy=Object.prototype.hasOwnProperty;function jl(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=Cm(e)&&Cm(t);if(!o&&!(Ed(e)&&Ed(t)))return t;let i=(o?e:Object.keys(e)).length,s=o?t:Object.keys(t),a=s.length,l=o?new Array(a):{},u=0;for(let c=0;c<a;c++){let y=o?c:s[c],T=e[y],w=t[y];if(T===w){l[y]=T,(o?c<i:Uy.call(e,y))&&u++;continue}if(T===null||w===null||typeof T!="object"||typeof w!="object"){l[y]=w;continue}let m=jl(T,w,r+1);l[y]=m,m===T&&u++;}return i===a&&u===i?e:l}function Ql(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 Cm(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ed(e){if(!wm(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!wm(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function wm(e){return Object.prototype.toString.call(e)==="[object Object]"}function km(e){return new Promise(t=>{Qo.setTimeout(t,e);})}function xa(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 jl(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 jl(e,t)}return t}function Tm(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function xm(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Ii=Symbol();function Yl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ii&&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===Ii?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Gl(e,t){return typeof e=="function"?e(...t):!!e}function _m(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 Yo=(()=>{let e=()=>Md;return {isServer(){return e()},setIsServer(t){e=t;}}})();function _a(){let e,t,r=new Promise((n,i)=>{e=n,t=i;});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 Rm=bm;function Hy(){let e=[],t=0,r=a=>{a();},o=a=>{a();},n=Rm,i=a=>{t?e.push(a):n(()=>{r(a);});},s=()=>{let a=e;e=[],a.length&&n(()=>{o(()=>{a.forEach(l=>{r(l);});});});};return {batch:a=>{let l;t++;try{l=a();}finally{t--,t||s();}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l);});},schedule:i,setNotifyFunction:a=>{r=a;},setBatchNotifyFunction:a=>{o=a;},setScheduler:a=>{n=a;}}}var Ht=Hy();var ws,Jn,Ss,vm,Ny=(vm=class extends qo{constructor(){super();te(this,ws,true);te(this,Jn);te(this,Ss);A(this,Ss,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(){f(this,Jn)||this.setEventListener(f(this,Ss));}onUnsubscribe(){var t;this.hasListeners()||((t=f(this,Jn))==null||t.call(this),A(this,Jn,void 0));}setEventListener(t){var r;A(this,Ss,t),(r=f(this,Jn))==null||r.call(this),A(this,Jn,t(this.setOnline.bind(this)));}setOnline(t){f(this,ws)!==t&&(A(this,ws,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return f(this,ws)}},ws=new WeakMap,Jn=new WeakMap,Ss=new WeakMap,vm),ks=new Ny;function jy(e){return Math.min(1e3*2**e,3e4)}function zd(e){return (e??"online")==="online"?ks.isOnline():true}var Jl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function Zl(e){let t=false,r=0,o,n=_a(),i=()=>n.status!=="pending",s=g=>{if(!i()){let h=new Jl(g);T(h),e.onCancel?.(h);}},a=()=>{t=true;},l=()=>{t=false;},u=()=>Cs.isFocused()&&(e.networkMode==="always"||ks.isOnline())&&e.canRun(),c=()=>zd(e.networkMode)&&e.canRun(),y=g=>{i()||(o?.(),n.resolve(g));},T=g=>{i()||(o?.(),n.reject(g));},w=()=>new Promise(g=>{o=h=>{(i()||u())&&g(h);},e.onPause?.();}).then(()=>{o=void 0,i()||e.onContinue?.();}),m=()=>{if(i())return;let g,h=r===0?e.initialPromise:void 0;try{g=h??e.fn();}catch(S){g=Promise.reject(S);}Promise.resolve(g).then(y).catch(S=>{if(i())return;let b=e.retry??(Yo.isServer()?0:3),p=e.retryDelay??jy,d=typeof p=="function"?p(r,S):p,C=b===true||typeof b=="number"&&r<b||typeof b=="function"&&b(r,S);if(t||!C){T(S);return}r++,e.onFail?.(r,S),km(d).then(()=>u()?void 0:w()).then(()=>{t?T(S):m();});});};return {promise:n,status:()=>n.status,cancel:s,continue:()=>(o?.(),n),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?m():w().then(m),n)}}var Oi,Im,Xl=(Im=class{constructor(){te(this,Oi);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),ka(this.gcTime)&&A(this,Oi,Qo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Yo.isServer()?1/0:300*1e3));}clearGcTimeout(){f(this,Oi)!==void 0&&(Qo.clearTimeout(f(this,Oi)),A(this,Oi,void 0));}},Oi=new WeakMap,Im);var Fi,Ts,Co,Di,Ir,Ra,Vi,lo,Vm,bn,Fm,Dm=(Fm=class extends Xl{constructor(t){super();te(this,lo);te(this,Fi);te(this,Ts);te(this,Co);te(this,Di);te(this,Ir);te(this,Ra);te(this,Vi);A(this,Vi,false),A(this,Ra,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,Di,t.client),A(this,Co,f(this,Di).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,Fi,Om(this.options)),this.state=t.state??f(this,Fi),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return f(this,Ir)?.promise}setOptions(t){if(this.options={...f(this,Ra),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Om(this.options);r.data!==void 0&&(this.setState(Pm(r.data,r.dataUpdatedAt)),A(this,Fi,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&f(this,Co).remove(this);}setData(t,r){let o=xa(this.state.data,t,this.options);return Ue(this,lo,bn).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Ue(this,lo,bn).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=f(this,Ir)?.promise;return f(this,Ir)?.cancel(t),r?r.then(br).catch(br):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return f(this,Fi)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Yr(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ii||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Io(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:!$l(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),f(this,Ir)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),f(this,Ir)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),f(this,Co).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(f(this,Ir)&&(f(this,Vi)||Ue(this,lo,Vm).call(this)?f(this,Ir).cancel({revert:true}):f(this,Ir).cancelRetry()),this.scheduleGc()),f(this,Co).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ue(this,lo,bn).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&f(this,Ir)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(f(this,Ir))return f(this,Ir).continueRetry(),f(this,Ir).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(u=>u.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,Vi,true),o.signal)});},i=()=>{let l=Yl(this.options,r),c=(()=>{let y={client:f(this,Di),queryKey:this.queryKey,meta:this.meta};return n(y),y})();return A(this,Vi,false),this.options.persister?this.options.persister(l,c,this):l(c)},a=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:f(this,Di),state:this.state,fetchFn:i};return n(l),l})();this.options.behavior?.onFetch(a,this),A(this,Ts,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&Ue(this,lo,bn).call(this,{type:"fetch",meta:a.fetchOptions?.meta}),A(this,Ir,Zl({initialPromise:r?.initialPromise,fn:a.fetchFn,onCancel:l=>{l instanceof Jl&&l.revert&&this.setState({...f(this,Ts),fetchStatus:"idle"}),o.abort();},onFail:(l,u)=>{Ue(this,lo,bn).call(this,{type:"failed",failureCount:l,error:u});},onPause:()=>{Ue(this,lo,bn).call(this,{type:"pause"});},onContinue:()=>{Ue(this,lo,bn).call(this,{type:"continue"});},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>true}));try{let l=await f(this,Ir).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),f(this,Co).config.onSuccess?.(l,this),f(this,Co).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Jl){if(l.silent)return f(this,Ir).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Ue(this,lo,bn).call(this,{type:"error",error:l}),f(this,Co).config.onError?.(l,this),f(this,Co).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},Fi=new WeakMap,Ts=new WeakMap,Co=new WeakMap,Di=new WeakMap,Ir=new WeakMap,Ra=new WeakMap,Vi=new WeakMap,lo=new WeakSet,Vm=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},bn=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,...Ud(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...Pm(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,Ts,t.manual?n:void 0),n;case "error":let i=t.error;return {...o,error:i,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:true};case "invalidate":return {...o,isInvalidated:true};case "setState":return {...o,...t.state}}};this.state=r(this.state),Ht.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),f(this,Co).notify({query:this,type:"updated",action:t});});},Fm);function Ud(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:zd(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Pm(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Om(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 Gr,Je,Ia,zr,Li,xs,Cn,Zn,Pa,_s,Rs,Bi,Wi,Xn,vs,ft,va,Hd,Nd,jd,$d,qd,Kd,Qd,Am,Wm,Gd=(Wm=class extends qo{constructor(t,r){super();te(this,ft);te(this,Gr);te(this,Je);te(this,Ia);te(this,zr);te(this,Li);te(this,xs);te(this,Cn);te(this,Zn);te(this,Pa);te(this,_s);te(this,Rs);te(this,Bi);te(this,Wi);te(this,Xn);te(this,vs,new Set);this.options=r,A(this,Gr,t),A(this,Zn,null),A(this,Cn,_a()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(f(this,Je).addObserver(this),Lm(f(this,Je),this.options)?Ue(this,ft,va).call(this):this.updateResult(),Ue(this,ft,$d).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Yd(f(this,Je),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Yd(f(this,Je),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ue(this,ft,qd).call(this),Ue(this,ft,Kd).call(this),f(this,Je).removeObserver(this);}setOptions(t){let r=this.options,o=f(this,Je);if(this.options=f(this,Gr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Yr(this.options.enabled,f(this,Je))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ue(this,ft,Qd).call(this),f(this,Je).setOptions(this.options),r._defaulted&&!Ql(this.options,r)&&f(this,Gr).getQueryCache().notify({type:"observerOptionsUpdated",query:f(this,Je),observer:this});let n=this.hasListeners();n&&Bm(f(this,Je),o,this.options,r)&&Ue(this,ft,va).call(this),this.updateResult(),n&&(f(this,Je)!==o||Yr(this.options.enabled,f(this,Je))!==Yr(r.enabled,f(this,Je))||Io(this.options.staleTime,f(this,Je))!==Io(r.staleTime,f(this,Je)))&&Ue(this,ft,Hd).call(this);let i=Ue(this,ft,Nd).call(this);n&&(f(this,Je)!==o||Yr(this.options.enabled,f(this,Je))!==Yr(r.enabled,f(this,Je))||i!==f(this,Xn))&&Ue(this,ft,jd).call(this,i);}getOptimisticResult(t){let r=f(this,Gr).getQueryCache().build(f(this,Gr),t),o=this.createResult(r,t);return qy(this,o)&&(A(this,zr,o),A(this,xs,this.options),A(this,Li,f(this,Je).state)),o}getCurrentResult(){return f(this,zr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&f(this,Cn).status==="pending"&&f(this,Cn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){f(this,vs).add(t);}getCurrentQuery(){return f(this,Je)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=f(this,Gr).defaultQueryOptions(t),o=f(this,Gr).getQueryCache().build(f(this,Gr),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Ue(this,ft,va).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),f(this,zr)))}createResult(t,r){let o=f(this,Je),n=this.options,i=f(this,zr),s=f(this,Li),a=f(this,xs),u=t!==o?t.state:f(this,Ia),{state:c}=t,y={...c},T=false,w;if(r._optimisticResults){let v=this.hasListeners(),M=!v&&Lm(t,r),W=v&&Bm(t,o,r,n);(M||W)&&(y={...y,...Ud(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(y.fetchStatus="idle");}let{error:m,errorUpdatedAt:g,status:h}=y;w=y.data;let S=false;if(r.placeholderData!==void 0&&w===void 0&&h==="pending"){let v;i?.isPlaceholderData&&r.placeholderData===a?.placeholderData?(v=i.data,S=true):v=typeof r.placeholderData=="function"?r.placeholderData(f(this,Rs)?.state.data,f(this,Rs)):r.placeholderData,v!==void 0&&(h="success",w=xa(i?.data,v,r),T=true);}if(r.select&&w!==void 0&&!S)if(i&&w===s?.data&&r.select===f(this,Pa))w=f(this,_s);else try{A(this,Pa,r.select),w=r.select(w),w=xa(i?.data,w,r),A(this,_s,w),A(this,Zn,null);}catch(v){A(this,Zn,v);}f(this,Zn)&&(m=f(this,Zn),w=f(this,_s),g=Date.now(),h="error");let b=y.fetchStatus==="fetching",p=h==="pending",d=h==="error",C=p&&b,x=w!==void 0,k={status:h,fetchStatus:y.fetchStatus,isPending:p,isSuccess:h==="success",isError:d,isInitialLoading:C,isLoading:C,data:w,dataUpdatedAt:y.dataUpdatedAt,error:m,errorUpdatedAt:g,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:y.dataUpdateCount>u.dataUpdateCount||y.errorUpdateCount>u.errorUpdateCount,isFetching:b,isRefetching:b&&!p,isLoadingError:d&&!x,isPaused:y.fetchStatus==="paused",isPlaceholderData:T,isRefetchError:d&&x,isStale:Jd(t,r),refetch:this.refetch,promise:f(this,Cn),isEnabled:Yr(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let v=k.data!==void 0,M=k.status==="error"&&!v,W=U=>{M?U.reject(k.error):v&&U.resolve(k.data);},O=()=>{let U=A(this,Cn,k.promise=_a());W(U);},F=f(this,Cn);switch(F.status){case "pending":t.queryHash===o.queryHash&&W(F);break;case "fulfilled":(M||k.data!==F.value)&&O();break;case "rejected":(!M||k.error!==F.reason)&&O();break}}return k}updateResult(){let t=f(this,zr),r=this.createResult(f(this,Je),this.options);if(A(this,Li,f(this,Je).state),A(this,xs,this.options),f(this,Li).data!==void 0&&A(this,Rs,f(this,Je)),Ql(r,t))return;A(this,zr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!f(this,vs).size)return true;let s=new Set(i??f(this,vs));return this.options.throwOnError&&s.add("error"),Object.keys(f(this,zr)).some(a=>{let l=a;return f(this,zr)[l]!==t[l]&&s.has(l)})};Ue(this,ft,Am).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ue(this,ft,$d).call(this);}},Gr=new WeakMap,Je=new WeakMap,Ia=new WeakMap,zr=new WeakMap,Li=new WeakMap,xs=new WeakMap,Cn=new WeakMap,Zn=new WeakMap,Pa=new WeakMap,_s=new WeakMap,Rs=new WeakMap,Bi=new WeakMap,Wi=new WeakMap,Xn=new WeakMap,vs=new WeakMap,ft=new WeakSet,va=function(t){Ue(this,ft,Qd).call(this);let r=f(this,Je).fetch(this.options,t);return t?.throwOnError||(r=r.catch(br)),r},Hd=function(){Ue(this,ft,qd).call(this);let t=Io(this.options.staleTime,f(this,Je));if(Yo.isServer()||f(this,zr).isStale||!ka(t))return;let o=$l(f(this,zr).dataUpdatedAt,t)+1;A(this,Bi,Qo.setTimeout(()=>{f(this,zr).isStale||this.updateResult();},o));},Nd=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(f(this,Je)):this.options.refetchInterval)??false},jd=function(t){Ue(this,ft,Kd).call(this),A(this,Xn,t),!(Yo.isServer()||Yr(this.options.enabled,f(this,Je))===false||!ka(f(this,Xn))||f(this,Xn)===0)&&A(this,Wi,Qo.setInterval(()=>{(this.options.refetchIntervalInBackground||Cs.isFocused())&&Ue(this,ft,va).call(this);},f(this,Xn)));},$d=function(){Ue(this,ft,Hd).call(this),Ue(this,ft,jd).call(this,Ue(this,ft,Nd).call(this));},qd=function(){f(this,Bi)!==void 0&&(Qo.clearTimeout(f(this,Bi)),A(this,Bi,void 0));},Kd=function(){f(this,Wi)!==void 0&&(Qo.clearInterval(f(this,Wi)),A(this,Wi,void 0));},Qd=function(){let t=f(this,Gr).getQueryCache().build(f(this,Gr),this.options);if(t===f(this,Je))return;let r=f(this,Je);A(this,Je,t),A(this,Ia,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},Am=function(t){Ht.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(f(this,zr));}),f(this,Gr).getQueryCache().notify({query:f(this,Je),type:"observerResultsUpdated"});});},Wm);function $y(e,t){return Yr(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function Lm(e,t){return $y(e,t)||e.state.data!==void 0&&Yd(e,t,t.refetchOnMount)}function Yd(e,t,r){if(Yr(t.enabled,e)!==false&&Io(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&Jd(e,t)}return false}function Bm(e,t,r,o){return (e!==t||Yr(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&Jd(e,r)}function Jd(e,t){return Yr(t.enabled,e)!==false&&e.isStaleByTime(Io(t.staleTime,e))}function qy(e,t){return !Ql(e.getCurrentResult(),t)}function Zd(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],s=t.state.data?.pageParams||[],a={pages:[],pageParams:[]},l=0,u=async()=>{let c=false,y=m=>{_m(m,()=>t.signal,()=>c=true);},T=Yl(t.options,t.fetchOptions),w=async(m,g,h)=>{if(c)return Promise.reject();if(g==null&&m.pages.length)return Promise.resolve(m);let b=(()=>{let x={client:t.client,queryKey:t.queryKey,pageParam:g,direction:h?"backward":"forward",meta:t.options.meta};return y(x),x})(),p=await T(b),{maxPages:d}=t.options,C=h?xm:Tm;return {pages:C(m.pages,p,d),pageParams:C(m.pageParams,g,d)}};if(n&&i.length){let m=n==="backward",g=m?Ky:Em,h={pages:i,pageParams:s},S=g(o,h);a=await w(h,S,m);}else {let m=e??i.length;do{let g=l===0?s[0]??o.initialPageParam:Em(o,a);if(l>0&&g==null)break;a=await w(a,g),l++;}while(l<m)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u;}}}function Em(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 Ky(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var Oa,Go,Lr,Ai,Jo,ei,Mm,zm=(Mm=class extends Xl{constructor(t){super();te(this,Jo);te(this,Oa);te(this,Go);te(this,Lr);te(this,Ai);A(this,Oa,t.client),this.mutationId=t.mutationId,A(this,Lr,t.mutationCache),A(this,Go,[]),this.state=t.state||Qy(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){f(this,Go).includes(t)||(f(this,Go).push(t),this.clearGcTimeout(),f(this,Lr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Go,f(this,Go).filter(r=>r!==t)),this.scheduleGc(),f(this,Lr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){f(this,Go).length||(this.state.status==="pending"?this.scheduleGc():f(this,Lr).remove(this));}continue(){return f(this,Ai)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Ue(this,Jo,ei).call(this,{type:"continue"});},o={client:f(this,Oa),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,Ai,Zl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(s,a)=>{Ue(this,Jo,ei).call(this,{type:"failed",failureCount:s,error:a});},onPause:()=>{Ue(this,Jo,ei).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>f(this,Lr).canRun(this)}));let n=this.state.status==="pending",i=!f(this,Ai).canStart();try{if(n)r();else {Ue(this,Jo,ei).call(this,{type:"pending",variables:t,isPaused:i}),f(this,Lr).config.onMutate&&await f(this,Lr).config.onMutate(t,this,o);let a=await this.options.onMutate?.(t,o);a!==this.state.context&&Ue(this,Jo,ei).call(this,{type:"pending",context:a,variables:t,isPaused:i});}let s=await f(this,Ai).start();return await f(this,Lr).config.onSuccess?.(s,t,this.state.context,this,o),await this.options.onSuccess?.(s,t,this.state.context,o),await f(this,Lr).config.onSettled?.(s,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(s,null,t,this.state.context,o),Ue(this,Jo,ei).call(this,{type:"success",data:s}),s}catch(s){try{await f(this,Lr).config.onError?.(s,t,this.state.context,this,o);}catch(a){Promise.reject(a);}try{await this.options.onError?.(s,t,this.state.context,o);}catch(a){Promise.reject(a);}try{await f(this,Lr).config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,o);}catch(a){Promise.reject(a);}try{await this.options.onSettled?.(void 0,s,t,this.state.context,o);}catch(a){Promise.reject(a);}throw Ue(this,Jo,ei).call(this,{type:"error",error:s}),s}finally{f(this,Lr).runNext(this);}}},Oa=new WeakMap,Go=new WeakMap,Lr=new WeakMap,Ai=new WeakMap,Jo=new WeakSet,ei=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),Ht.batch(()=>{f(this,Go).forEach(o=>{o.onMutationUpdate(t);}),f(this,Lr).notify({mutation:this,type:"updated",action:t});});},Mm);function Qy(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var wn,Po,Fa,Um,Hm=(Um=class extends qo{constructor(t={}){super();te(this,wn);te(this,Po);te(this,Fa);this.config=t,A(this,wn,new Set),A(this,Po,new Map),A(this,Fa,0);}build(t,r,o){let n=new zm({client:t,mutationCache:this,mutationId:++Js(this,Fa)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){f(this,wn).add(t);let r=ec(t);if(typeof r=="string"){let o=f(this,Po).get(r);o?o.push(t):f(this,Po).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(f(this,wn).delete(t)){let r=ec(t);if(typeof r=="string"){let o=f(this,Po).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&f(this,Po).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=ec(t);if(typeof r=="string"){let n=f(this,Po).get(r)?.find(i=>i.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=ec(t);return typeof r=="string"?f(this,Po).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ht.batch(()=>{f(this,wn).forEach(t=>{this.notify({type:"removed",mutation:t});}),f(this,wn).clear(),f(this,Po).clear();});}getAll(){return Array.from(f(this,wn))}find(t){let r={exact:true,...t};return this.getAll().find(o=>Kl(r,o))}findAll(t={}){return this.getAll().filter(r=>Kl(t,r))}notify(t){Ht.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return Ht.batch(()=>Promise.all(t.map(r=>r.continue().catch(br))))}},wn=new WeakMap,Po=new WeakMap,Fa=new WeakMap,Um);function ec(e){return e.options.scope?.id}var Zo,Nm,jm=(Nm=class extends qo{constructor(t={}){super();te(this,Zo);this.config=t,A(this,Zo,new Map);}build(t,r,o){let n=r.queryKey,i=r.queryHash??Ta(n,r),s=this.get(i);return s||(s=new Dm({client:t,queryKey:n,queryHash:i,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(s)),s}add(t){f(this,Zo).has(t.queryHash)||(f(this,Zo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=f(this,Zo).get(t.queryHash);r&&(t.destroy(),r===t&&f(this,Zo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){Ht.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return f(this,Zo).get(t)}getAll(){return [...f(this,Zo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>ql(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>ql(t,o)):r}notify(t){Ht.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){Ht.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){Ht.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Zo=new WeakMap,Nm);var ir,ti,ri,Is,Ps,oi,Os,Fs,$m,Xd=($m=class{constructor(e={}){te(this,ir);te(this,ti);te(this,ri);te(this,Is);te(this,Ps);te(this,oi);te(this,Os);te(this,Fs);A(this,ir,e.queryCache||new jm),A(this,ti,e.mutationCache||new Hm),A(this,ri,e.defaultOptions||{}),A(this,Is,new Map),A(this,Ps,new Map),A(this,oi,0);}mount(){Js(this,oi)._++,f(this,oi)===1&&(A(this,Os,Cs.subscribe(async e=>{e&&(await this.resumePausedMutations(),f(this,ir).onFocus());})),A(this,Fs,ks.subscribe(async e=>{e&&(await this.resumePausedMutations(),f(this,ir).onOnline());})));}unmount(){var e,t;Js(this,oi)._--,f(this,oi)===0&&((e=f(this,Os))==null||e.call(this),A(this,Os,void 0),(t=f(this,Fs))==null||t.call(this),A(this,Fs,void 0));}isFetching(e){return f(this,ir).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return f(this,ti).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return f(this,ir).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=f(this,ir).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Io(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return f(this,ir).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),i=f(this,ir).get(o.queryHash)?.state.data,s=Sm(t,i);if(s!==void 0)return f(this,ir).build(this,o).setData(s,{...r,manual:true})}setQueriesData(e,t,r){return Ht.batch(()=>f(this,ir).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return f(this,ir).get(t.queryHash)?.state}removeQueries(e){let t=f(this,ir);Ht.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=f(this,ir);return Ht.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=Ht.batch(()=>f(this,ir).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(br).catch(br)}invalidateQueries(e,t={}){return Ht.batch(()=>(f(this,ir).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=Ht.batch(()=>f(this,ir).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(br)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(o).then(br)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=f(this,ir).build(this,t);return r.isStaleByTime(Io(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(br).catch(br)}fetchInfiniteQuery(e){return e.behavior=Zd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(br).catch(br)}ensureInfiniteQueryData(e){return e.behavior=Zd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ks.isOnline()?f(this,ti).resumePausedMutations():Promise.resolve()}getQueryCache(){return f(this,ir)}getMutationCache(){return f(this,ti)}getDefaultOptions(){return f(this,ri)}setDefaultOptions(e){A(this,ri,e);}setQueryDefaults(e,t){f(this,Is).set(vi(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...f(this,Is).values()],r={};return t.forEach(o=>{Pi(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){f(this,Ps).set(vi(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...f(this,Ps).values()],r={};return t.forEach(o=>{Pi(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...f(this,ri).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Ta(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===Ii&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...f(this,ri).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){f(this,ir).clear(),f(this,ti).clear();}},ir=new WeakMap,ti=new WeakMap,ri=new WeakMap,Is=new WeakMap,Ps=new WeakMap,oi=new WeakMap,Os=new WeakMap,Fs=new WeakMap,$m);var eu=ni.createContext(void 0),tu=e=>{let t=ni.useContext(eu);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ru=({client:e,children:t})=>(ni.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(eu.Provider,{value:e,children:t}));var qm=ni.createContext(false),Km=()=>ni.useContext(qm);qm.Provider;function Gy(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var Jy=ni.createContext(Gy()),Qm=()=>ni.useContext(Jy);var Gm=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?Gl(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Jm=e=>{ni.useEffect(()=>{e.clearReset();},[e]);},Zm=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||Gl(r,[e.error,o]));var Xm=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));}},ef=(e,t)=>e.isLoading&&e.isFetching&&!t,tf=(e,t)=>e?.suspense&&t.isPending,ou=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function rf(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=Km(),n=Qm(),i=tu(),s=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(s);let a=i.getQueryCache().get(s.queryHash);process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.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`)),s._optimisticResults=o?"isRestoring":"optimistic",Xm(s),Gm(s,n,a),Jm(n);let l=!i.getQueryCache().get(s.queryHash),[u]=ni.useState(()=>new t(i,s)),c=u.getOptimisticResult(s),y=!o&&e.subscribed!==false;if(ni.useSyncExternalStore(ni.useCallback(T=>{let w=y?u.subscribe(Ht.batchCalls(T)):br;return u.updateResult(),w},[u,y]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ni.useEffect(()=>{u.setOptions(s);},[s,u]),tf(s,c))throw ou(s,u,n);if(Zm({result:c,errorResetBoundary:n,throwOnError:s.throwOnError,query:a,suspense:s.suspense}))throw c.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(s,c),s.experimental_prefetchInRender&&!Yo.isServer()&&ef(c,o)&&(l?ou(s,u,n):a?.promise)?.catch(br).finally(()=>{u.updateResult();}),s.notifyOnChangeProps?c:u.trackResult(c)}function Sn(e,t){return rf(e,Gd)}var Ls=new Map;function of({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function si({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:i="transparent",backgroundColor:s="transparent",style:a}){let{colors:l}=V(),[u,c]=useState(false),[y,T]=useState(false),[w,m]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let C=Ls.get(e);return C?{uri:e,xml:C}:null}),g=e?.toLowerCase().endsWith(".svg"),h=g&&e&&w?.uri===e?w.xml:null;useEffect(()=>{c(false),T(false);},[e]),useEffect(()=>{if(!g||!e)return;if(Ls.has(e)){m({uri:e,xml:Ls.get(e)});return}let C=false;return fetch(e).then(x=>{if(!x.ok)throw new Error(`HTTP ${x.status}`);return x.text()}).then(x=>{C||(Ls.set(e,x),m({uri:e,xml:x}));}).catch(()=>{C||c(true);}),()=>{C=true;}},[e,g]);let S=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:S},a]});let b={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:i,backgroundColor:s,overflow:"hidden",alignItems:"center",justifyContent:"center",...a},p=t-n*2,d=r-n*2;return u?jsx(View,{style:[b,{backgroundColor:s||S}]}):g?jsxs(View,{style:b,children:[!!!h&&jsx(of,{width:p,height:d,borderRadius:o,color:S}),h?jsx(SvgXml,{xml:h,width:p,height:d,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:p,height:d,onError:()=>c(true)})]}):jsxs(View,{style:b,children:[!y&&jsx(of,{width:p,height:d,borderRadius:o,color:S}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:p,height:d},resizeMode:"contain",onLoad:()=>T(true),onError:()=>c(true)})]})}function su(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(Ls.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{Ls.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Ur({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:i,badge:s,showBalance:a=false,balanceAddress:l,balanceChainType:u,balanceChainId:c,balanceTokenAddress:y,publishableKey:T,projectName:w,leftIcon:m,onLeftAction:g}){let{colors:h,fonts:S,components:b}=V(),[p,d]=useState(null),[C,x]=useState(false),_=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!C)return;let v=Animated.loop(Animated.sequence([Animated.timing(_,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(_,{toValue:0,duration:700,useNativeDriver:true})]));return v.start(),()=>v.stop()},[C,_]),useEffect(()=>{if(!a||!l||!u||!c||!y||!T){d(null),x(false);return}let v=false;return x(true),hl(l,u,c,y,T).then(M=>{if(v)return;let W=M.balance,O=null;W&&(W.amount_usd!=null&&W.amount_usd!==""?O=`$${W.amount_usd}`:O="$0.00"),d(O);}).catch(()=>{v||d(null);}).finally(()=>{v||x(false);}),()=>{v=true;}},[a,l,u,c,y,T]);let k=_.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:Br.header,children:[jsx(View,{style:Br.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[Br.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Xs,{size:20,color:b.header.buttonColor,strokeWidth:2})}):m&&g?jsx(TouchableOpacity,{onPress:g,style:[Br.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:m}):jsx(View,{style:Br.spacer})}),jsxs(View,{style:Br.titleContainer,children:[jsxs(View,{style:Br.titleRow,children:[jsx(Text,{style:[Br.title,{color:b.header.titleColor,fontFamily:S.medium}],children:e}),s&&s.count>0&&jsx(View,{style:[Br.titleBadge,{backgroundColor:h.card}],children:jsx(Text,{style:[Br.titleBadgeText,{color:h.foregroundMuted,fontFamily:S.regular}],children:s.count})})]}),t?jsx(Text,{style:[Br.balanceText,{color:h.foregroundMuted,fontFamily:S.regular}],children:t}):null,a&&(C?jsx(Animated.View,{style:[Br.balanceSkeleton,{backgroundColor:h.cardHover,opacity:k}]}):p!=null?jsxs(Text,{style:[Br.balanceText,{color:h.foregroundMuted,fontFamily:S.regular}],children:[w?`${w} `:"","Balance: ",p]}):null)]}),jsx(View,{style:Br.rightContainer,children:o?jsx(TouchableOpacity,{onPress:i,style:[Br.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:b.header.buttonColor,strokeWidth:2})}):jsx(View,{style:Br.spacer})})]})}var Br=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 Cr({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:i}){let{components:s}=V(),a=i??s.card,l=a.backShadowColor!=="transparent",u={backgroundColor:a.backgroundColor,borderRadius:a.borderRadius,borderWidth:a.borderWidth,borderColor:a.borderColor},c=[lf.wrapper,t,l&&{marginBottom:a.backShadowSpacing}],y=[u,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[lf.backShadow,{top:a.backShadowOffset.top,left:a.backShadowOffset.left,right:a.backShadowOffset.right,bottom:a.backShadowOffset.bottom,backgroundColor:a.backShadowColor,borderRadius:a.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:y,children:e}):jsx(View,{style:y,children:e})]})}var lf=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function Va({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:i}=V(),s=i.depositMenu.card,a=o?[...o].sort((l,u)=>l.position-u.position):[];return jsxs(Cr,{cardTokens:s,onPress:e,style:Xo.wrapper,contentStyle:Xo.container,children:[jsxs(View,{style:Xo.leftContent,children:[jsx(View,{style:[Xo.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:jsx(Yc,{size:20,color:s.iconColor,strokeWidth:2})}),jsxs(View,{style:Xo.textContainer,children:[jsx(Text,{style:[Xo.title,{color:s.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Xo.subtitle,{color:s.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Xo.rightContent,children:jsx(View,{style:Xo.networkIcons,children:a.map((l,u)=>{let c=l.icon_urls.find(y=>y.format==="png")?.url||l.icon_urls.find(y=>y.format==="svg")?.url;return jsx(View,{style:[Xo.networkIconWrapper,{marginLeft:u===0?0:-6,zIndex:a.length-u}],children:jsx(si,{uri:oe(c),width:20,height:20})},l.name)})})})]})}var Xo=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 Ba({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:i}=V(),s=i.depositMenu.card;return jsxs(Cr,{cardTokens:s,onPress:e,style:kn.wrapper,contentStyle:kn.container,children:[jsxs(View,{style:kn.leftContent,children:[jsx(View,{style:[kn.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:jsx(Ji,{size:20,color:s.iconColor,strokeWidth:2})}),jsxs(View,{style:kn.textContainer,children:[jsx(Text,{style:[kn.title,{color:s.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[kn.subtitle,{color:s.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:kn.rightContent,children:jsx(View,{style:kn.paymentIcons,children:o?.map(a=>{let l=a.icon_urls.find(u=>u.format==="png")?.url||a.icon_urls.find(u=>u.format==="svg")?.url;return jsx(si,{uri:oe(l),width:32,height:20,borderRadius:4},a.name)})})})]})}var kn=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 Wa({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:i}=V(),s=i.depositMenu.card;return jsx(Cr,{cardTokens:s,onPress:e,style:Tn.wrapper,contentStyle:Tn.container,children:jsxs(View,{style:Tn.leftContent,children:[jsxs(View,{style:[Tn.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:[jsx(Nr,{size:20,color:s.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[Tn.badge,{backgroundColor:s.iconColor,borderRadius:i.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:s.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Tn.subtitle,{color:s.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 Ea({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=V(),i=n.depositMenu.card;return jsxs(Cr,{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(al,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:en.textContainer,children:[jsx(Text,{style:[en.title,{color:i.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[en.subtitle,{color:i.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:en.rightContent,children:jsx(View,{style:en.badge,children:jsx(Text,{style:[en.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}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},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var pf=1e4,mf=2500,ff=3e3,hf=6e4;function Ma(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:i,modalOpenedAt:s,depositWalletId:a,depositExecutions:l,trackedExecutions:u,setDepositExecutions:c,setTrackedExecutions:y,setLatestExecution:T,setShowStatusSheet:w,onDepositSuccess:m,onExecutionsChange:g,onDepositError:h}=e,[S,b]=useState(false),[p,d]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;b(false),t==="auto_ui"&&d(false);let x=setTimeout(()=>{b(true),t==="auto_ui"&&d(true);},pf);return ()=>clearTimeout(x)},[t,r,o]),useEffect(()=>{if(!n||!s)return;let x=new Date(s.getTime()-hf),_=setInterval(async()=>{try{let M=[...(await pn(n,i)).data??[]].sort((O,F)=>{let U=O.created_at?new Date(O.created_at).getTime():0;return (F.created_at?new Date(F.created_at).getTime():0)-U}),W=null;for(let O of M){let F=O.created_at?new Date(O.created_at):null;if(!F||F<=x)continue;let U=u.get(O.id);if(!U){W=O;break}if(["pending","waiting","delayed"].includes(U)&&O.status==="succeeded"){W=O;break}}if(W){let O=W;c(F=>{let U=F.findIndex(j=>j.id===O.id);if(U>=0){let j=[...F];return j[U]=O,j}return [...F,O]}),y(F=>{let U=new Map(F);return U.set(O.id,O.status),U}),T(O),w(!0),O.status==="succeeded"&&m?.({message:"Deposit completed successfully",executionId:O.id}),g?.([...l,O]);}}catch(k){h?.({message:"Failed to check deposit status",error:k});}},mf);return ()=>clearInterval(_)},[n,i,s,u,l,g,m,h]),useEffect(()=>{if(!S||!a)return;let x=async()=>{try{await ul(a,i);}catch{}};x();let _=setInterval(x,ff);return ()=>clearInterval(_)},[S,a,i]),{pollingEnabled:S,showWaitingUi:p,handleIveDeposited:()=>{b(true),d(true);}}}function Es({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:i,isDark:s}=V(),a=s?"#1a1a1a":"#ffffff",l=s?"#ffffff":"#000000",u=n||a;return jsxs(View,{style:[yf.container,{width:t,height:t}],children:[jsx(db,{value:e||"placeholder",size:t,backgroundColor:a,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[yf.logoContainer,{width:o+12,height:o+12,backgroundColor:u,borderRadius:(o+12)/2}],children:jsx(si,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var yf=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function wf(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function fb(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),i=e.getHours(),s=e.getMinutes(),a=i>=12?"pm":"am";i=i%12,i=i||12;let l=s<10?`0${s}`:s;return `${r} ${o}, ${n} at ${i}:${l}${a}`}function Ms({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:i,amountUsd:s,onClose:a,borderTopLeftRadius:l,borderTopRightRadius:u}){let{colors:c,fonts:y,components:T}=V(),[w,m]=useState(false),g=t==="pending"||t==="waiting"||t==="delayed",h=t==="succeeded",S=()=>{o&&Linking.openURL(o);},b=()=>{n&&Linking.openURL(n);};return jsx(bt,{visible:e,onClose:a,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:u,children:jsxs(View,{style:Zt.container,children:[jsx(TouchableOpacity,{style:Zt.closeButton,onPress:a,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Zt.iconContainer,children:g?jsx(nt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:oe(r)},style:Zt.tokenIconFill}):jsx(View,{style:[Zt.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:oe(r)},style:Zt.tokenIconLarge}):jsx(View,{style:[Zt.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[Zt.statusBadge,{backgroundColor:T.container.iconBackgroundColor}],children:jsx(Le,{size:16,color:T.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Zt.title,{color:T.container.titleColor,fontFamily:y.semibold}],children:g?"Deposit Processing":"Deposit Complete"}),s!==void 0&&jsxs(Text,{style:[Zt.amount,{color:T.container.titleColor,fontFamily:y.bold}],children:["$",s.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),i&&jsx(Text,{style:[Zt.date,{color:T.container.subtitleColor,fontFamily:y.regular}],children:fb(i)}),jsx(Text,{style:[Zt.subtitle,{color:T.container.subtitleColor,fontFamily:y.regular}],children:g?"This usually takes less than a minute.":"Your account has been credited successfully!"}),h&&(o||n)&&jsxs(View,{style:Zt.detailsSection,children:[jsx(View,{style:[Zt.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:Zt.detailsToggle,onPress:()=>m(!w),children:[jsx(Text,{style:[Zt.detailsToggleText,{color:T.container.actionTitle,fontFamily:y.medium}],children:w?"See less":"See more details"}),w?jsx(Vo,{size:18,color:T.container.actionColor,strokeWidth:2}):jsx(Gt,{size:18,color:T.container.actionColor,strokeWidth:2})]}),w&&jsxs(View,{style:Zt.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Zt.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:S,children:[jsx(Text,{style:[Zt.txLabel,{color:T.card.titleColor,fontFamily:y.medium}],children:"Deposit tx"}),jsx(Text,{style:[Zt.txHash,{color:T.card.subtitleColor,fontFamily:y.regular}],children:wf(o)}),jsx(Do,{size:16,color:T.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Zt.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:b,children:[jsx(Text,{style:[Zt.txLabel,{color:T.card.titleColor,fontFamily:y.medium}],children:"Completion tx"}),jsx(Text,{style:[Zt.txHash,{color:T.card.subtitleColor,fontFamily:y.regular}],children:wf(n)}),jsx(Do,{size:16,color:T.card.actionColor,strokeWidth:2})]})]})]})]})})}var Zt=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 ac({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:i,fonts:s,components:a}=V();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[zi.iveDepositedButton,{backgroundColor:i.primary,borderRadius:a.button.borderRadius,borderWidth:a.button.borderWidth,borderColor:a.button.borderColor}],children:jsx(Text,{style:[zi.iveDepositedButtonText,{color:i.primaryForeground??"#FFF",fontFamily:s.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[zi.processingCard,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor,shadowColor:a.card.shadowOpacity>0?a.card.shadowColor:void 0,shadowOffset:a.card.shadowOpacity>0?a.card.shadowOffset:void 0,shadowOpacity:a.card.shadowOpacity,shadowRadius:a.card.shadowRadius,elevation:a.card.elevation}],children:[jsx(View,{style:[zi.detailIcon,{backgroundColor:a.card.iconBackgroundColor,borderRadius:a.card.iconContainerBorderRadius}],children:jsx(Gc,{size:14,color:a.card.iconColor,strokeWidth:2})}),jsxs(View,{style:zi.processingCardText,children:[jsx(Text,{style:[zi.processingCardTitle,{color:a.card.titleColor,fontFamily:s.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[zi.processingCardSubtitle,{color:a.card.subtitleColor,fontFamily:s.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var zi=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 za=(e,t)=>`${t}:${e}`,Tb=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function cc({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:i,destinationTokenSymbol:s,defaultChainType:a,defaultChainId:l,defaultTokenAddress:u,depositConfirmationMode:c="auto_ui",onExecutionsChange:y,onDepositSuccess:T,onDepositError:w,borderTopLeftRadius:m,borderTopRightRadius:g,sheetBorderRadius:h}){let{colors:S,fonts:b,components:p}=V(),d=a&&l?`${a}:${l}`:"solana:mainnet",[C,x]=useState("USDC"),[_,k]=useState(d),[v,M]=useState([]),[W,O]=useState(true),[F,U]=useState([]),[j,le]=useState(true),[Ye,_e]=useState(false),[ne,we]=useState(false),[fe,Pe]=useState(false),[$e,ue]=useState(false),[J,be]=useState([]),[vt,ve]=useState(new Map),[qe]=useState(()=>new Date),[Ne,Ve]=useState(null),[ze,it]=useState(false),[ie,pe]=useState(null),[et,Ae]=useState(false),Ke=new Map;F.forEach(L=>{L.chains.forEach(I=>{let D=`${I.chain_type}:${I.chain_id}`;Ke.has(D)||Ke.set(D,I);});});let $t=Array.from(Ke.values()),Ee=Tb(_),ar=$t.find(L=>L.chain_type===Ee.chainType&&L.chain_id===Ee.chainId)?.chain_type||"ethereum",he=un(v,ar),X=he?.address||"",Ce=useRef(false);useEffect(()=>{async function L(){try{le(!0),Ve(null);let D=await Ci(t,i&&n&&o?{destination_token_address:i,destination_chain_id:n,destination_chain_type:o}:void 0);if(U(D.data),D.data.length>0&&!Ce.current){Ce.current=!0;let q,Fe;if(a&&l)if(u)for(let ke of D.data){let pr=ke.chains.find(ce=>ce.chain_type===a&&ce.chain_id===l&&ce.token_address.toLowerCase()===u.toLowerCase());if(pr){q=ke,Fe=pr;break}}else for(let ke of D.data){let pr=ke.chains.find(ce=>ce.chain_type===a&&ce.chain_id===l);if(pr){q=ke,Fe=pr;break}}if(!q&&i)for(let ke of D.data){let pr=ke.chains.find(ce=>ce.token_address.toLowerCase()===i.toLowerCase());if(pr){q=ke,Fe=pr;break}}q||(q=D.data.find(ke=>ke.symbol==="USDC"),q&&q.chains.length>0&&(Fe=q.chains[0])),q||(q=D.data.find(ke=>ke.symbol==="USDT"),q&&q.chains.length>0&&(Fe=q.chains[0])),q||(q=D.data[0],q.chains.length>0&&(Fe=q.chains[0])),q&&x(q.symbol),Fe&&k(za(Fe.chain_id,Fe.chain_type));}}catch(I){console.error("Error fetching supported tokens:",I),Ve("Failed to load supported tokens"),w?.({message:"Failed to load supported tokens",error:I});}finally{le(false);}}L();},[t,w,a,l,u,i,n,o]),useEffect(()=>{async function L(){try{O(!0),Ve(null);let I=await dn({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:i},t);M(I.data);}catch(I){console.error("Error fetching wallets:",I),Ve("Failed to load wallets"),w?.({message:"Failed to load wallets",error:I});}finally{O(false);}}L();},[e,r,o,n,i,t,w]);let pt=he?.id??"",{showWaitingUi:It,handleIveDeposited:me}=Ma({depositConfirmationMode:c,depositAddress:X,chain:_,externalUserId:e,publishableKey:t,modalOpenedAt:qe,depositWalletId:pt,depositExecutions:J,trackedExecutions:vt,setDepositExecutions:be,setTrackedExecutions:ve,setLatestExecution:pe,setShowStatusSheet:it,onDepositSuccess:T,onExecutionsChange:y,onDepositError:w});useEffect(()=>{if(!F.length)return;let L=F.find(D=>D.symbol===C);if(!L||L.chains.length===0)return;if(!L.chains.some(D=>za(D.chain_id,D.chain_type)===_)){let D=L.chains[0];k(za(D.chain_id,D.chain_type));}},[C,F,_]);let je=F.find(L=>L.symbol===C),Vt=je?.chains||[],ot=Vt.find(L=>za(L.chain_id,L.chain_type)===_),Lt=async()=>{if(X)try{Clipboard.setString(X),_e(!0),setTimeout(()=>_e(!1),2e3);}catch(L){console.error("Failed to copy:",L);}},Bt=ot?.estimated_price_impact_percent??0,yt=ot?.max_slippage_percent??.25,Se=ot?.minimum_deposit_amount_usd??3;if(j)return jsxs(View,{style:B.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:S.primary}),jsx(Text,{style:[B.loadingText,{color:S.foregroundMuted,fontFamily:b.regular}],children:"Loading currencies..."})]});if(Ne&&F.length===0)return jsxs(View,{style:B.errorContainer,children:[jsx(Text,{style:[B.errorText,{color:S.error,fontFamily:b.regular}],children:Ne}),jsx(Text,{style:[B.errorHint,{color:S.foregroundMuted,fontFamily:b.regular}],children:"Please check your network connection and try again."})]});let Z=()=>jsxs(bt,{visible:fe,onClose:()=>Pe(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.tokenSelector?.borderTopLeftRadius??m,borderTopRightRadius:h?.tokenSelector?.borderTopRightRadius??g,children:[jsxs(View,{style:[B.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:B.sheetHeaderSpacer}),jsx(Text,{style:[B.sheetTitle,{color:p.header.titleColor,fontFamily:b.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Pe(false),style:B.sheetCloseButton,children:jsx(st,{size:20,color:p.header.buttonColor,strokeWidth:2})})]}),jsx(at,{style:B.sheetList,contentContainerStyle:B.sheetListContent,showsVerticalScrollIndicator:false,children:F.map(L=>jsxs(TouchableOpacity$1,{onPress:()=>{x(L.symbol),Pe(false);},activeOpacity:.7,style:[B.sheetItem,{backgroundColor:C===L.symbol?p.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:oe(Te(L,"png"))},style:B.sheetItemIcon}),jsxs(View,{style:B.sheetItemText,children:[jsx(Text,{style:[B.sheetItemTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:L.symbol}),jsxs(Text,{style:[B.sheetItemSubtitle,{color:p.card.subtitleColor,fontFamily:b.regular}],children:[L.chains.length," network",L.chains.length!==1?"s":""," available"]})]}),C===L.symbol&&jsx(Le,{size:20,color:S.primary,strokeWidth:2})]},L.symbol))})]}),Q=()=>jsxs(bt,{visible:$e,onClose:()=>ue(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.chainSelector?.borderTopLeftRadius??m,borderTopRightRadius:h?.chainSelector?.borderTopRightRadius??g,children:[jsxs(View,{style:[B.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:B.sheetHeaderSpacer}),jsx(Text,{style:[B.sheetTitle,{color:p.header.titleColor,fontFamily:b.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>ue(false),style:B.sheetCloseButton,children:jsx(st,{size:20,color:p.header.buttonColor,strokeWidth:2})})]}),jsx(at,{style:B.sheetList,contentContainerStyle:B.sheetListContent,showsVerticalScrollIndicator:false,children:Vt.map(L=>{let I=za(L.chain_id,L.chain_type),D=_===I;return jsxs(TouchableOpacity$1,{onPress:()=>{k(I),ue(false);},activeOpacity:.7,style:[B.sheetItem,{backgroundColor:D?p.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:oe(Te(L,"png"))},style:B.sheetItemIcon}),jsxs(View,{style:B.sheetItemText,children:[jsx(Text,{style:[B.sheetItemTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:L.chain_name}),jsxs(Text,{style:[B.sheetItemSubtitle,{color:p.card.subtitleColor,fontFamily:b.regular}],children:["Min deposit: $",L.minimum_deposit_amount_usd]})]}),D&&jsx(Le,{size:20,color:S.primary,strokeWidth:2})]},I)})})]});return jsxs(View,{style:B.container,children:[jsxs(View,{style:B.selectorSection,children:[jsx(Text,{style:[B.selectorLabel,{color:p.card.labelColor,fontFamily:b.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Pe(true),style:[B.selector,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[je&&jsx(Image,{source:{uri:oe(Te(je,"png"))},style:B.selectorIcon}),jsx(Text,{style:[B.selectorText,{color:p.card.titleColor,fontFamily:b.medium}],children:C}),jsx(Gt,{size:16,color:p.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:B.selectorSection,children:[jsxs(Text,{style:[B.selectorLabel,{color:p.card.labelColor,fontFamily:b.regular}],children:["Network"," ",jsxs(Text,{style:[B.minDeposit,{fontFamily:b.regular}],children:["($",Se," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>ue(true),style:[B.selector,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[ot&&jsx(Image,{source:{uri:oe(Te(ot,"png"))},style:B.selectorIcon}),jsx(Text,{style:[B.selectorText,{color:p.card.titleColor,fontFamily:b.medium}],numberOfLines:1,children:ot?.chain_name||"Select network"}),jsx(Gt,{size:16,color:p.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:B.qrContainer,children:jsx(View,{style:[B.qrWrapper,{backgroundColor:S.background,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth>0?p.card.borderWidth:1,borderColor:p.card.borderColor}],children:W?jsxs(View,{style:B.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:S.primary}),jsx(Text,{style:[B.loadingText,{color:S.foregroundMuted,fontFamily:b.regular}],children:"Loading..."})]}):X?jsx(Es,{value:X,size:160,logoUri:oe(Te(ot,"png")||cr("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:B.qrLoading,children:jsx(Text,{style:[B.errorText,{color:S.error,fontFamily:b.regular}],children:"No address available"})})})}),jsxs(View,{style:B.addressSection,children:[jsxs(View,{style:B.addressHeader,children:[jsx(Text,{style:[B.addressLabel,{color:p.card.labelColor,fontFamily:b.medium}],children:"Deposit Address"}),Ye&&jsxs(View,{style:B.copiedIndicator,children:[jsx(Le,{size:14,color:S.success,strokeWidth:2}),jsx(Text,{style:[B.copiedText,{color:S.success,fontFamily:b.regular}],children:"Copied"})]})]}),jsxs(Cr,{cardTokens:p.transferCrypto.depositAddress.card,onPress:!W&&X?Lt:void 0,contentStyle:B.addressBox,children:[jsx(Text,{style:[B.addressText,{color:p.card.titleColor,fontFamily:b.regular}],numberOfLines:2,children:W?"Loading...":X||"No address available"}),jsx(View,{style:B.addressCopyIcon,children:jsx(ln,{size:16,color:p.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[B.detailsCard,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>we(!ne),style:B.detailsHeader,children:[jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(Nr,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:B.chevronContainer,children:ne?jsx(Vo,{size:16,color:p.card.actionColor,strokeWidth:2}):jsx(Gt,{size:16,color:p.card.actionColor,strokeWidth:2})})]}),ne&&jsxs(View,{style:B.detailsContent,children:[jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(An,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:["Price impact: ",Bt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:p.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(jr,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:["Slippage: Auto \u2022 ",yt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:p.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(il,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ac,{depositConfirmationMode:c,depositAddress:X,showWaitingUi:It,latestExecution:ie,onIveDeposited:me}),jsx(TouchableOpacity$1,{style:B.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[B.termsText,{color:S.primary,fontFamily:b.regular}],children:"Terms apply"})}),Z(),Q(),jsxs(bt,{visible:et,onClose:()=>Ae(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:h?.infoSheet?.borderTopLeftRadius??m,borderTopRightRadius:h?.infoSheet?.borderTopRightRadius??g,children:[jsxs(View,{style:[B.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:B.sheetHeaderSpacer}),jsx(Text,{style:[B.sheetTitle,{color:p.header.titleColor,fontFamily:b.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Ae(false),style:B.sheetCloseButton,children:jsx(st,{size:20,color:p.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:B.infoSheetContent,children:[jsxs(View,{style:[B.infoCard,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[jsxs(View,{style:B.infoCardHeader,children:[jsx(View,{style:[B.infoCardIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(An,{size:16,color:p.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[B.infoCardTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:"Price Impact"}),jsxs(Text,{style:[B.infoCardValue,{color:p.card.titleColor,fontFamily:b.medium}],children:[Bt.toFixed(2),"%"]})]}),jsx(Text,{style:[B.infoCardDescription,{color:p.card.descriptionColor,fontFamily:b.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[B.infoCard,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[jsxs(View,{style:B.infoCardHeader,children:[jsx(View,{style:[B.infoCardIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(jr,{size:16,color:p.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[B.infoCardTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:"Max Slippage"}),jsxs(Text,{style:[B.infoCardValue,{color:p.card.titleColor,fontFamily:b.medium}],children:[yt.toFixed(2),"%"]})]}),jsx(Text,{style:[B.infoCardDescription,{color:p.card.descriptionColor,fontFamily:b.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),ie&&jsx(Ms,{visible:ze,status:ie.status,tokenIconUrl:ie.destination_token_metadata?.icon_urls?.find(L=>L.format==="png")?.url||ie.destination_token_metadata?.icon_url||Te(je,"png"),explorerUrl:ie.explorer_url,completionExplorerUrl:ie.destination_explorer_url,date:ie.created_at?new Date(ie.created_at):void 0,amountUsd:ie.source_amount_usd?parseFloat(ie.source_amount_usd):void 0,onClose:()=>it(false),borderTopLeftRadius:h?.depositStatus?.borderTopLeftRadius??m,borderTopRightRadius:h?.depositStatus?.borderTopRightRadius??g})]})}var B=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 dc({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:i}=V();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ui.container,{backgroundColor:i.card.backgroundColor,borderRadius:i.list.rowBorderRadius,borderWidth:i.card.borderWidth,borderColor:i.card.borderColor}],children:[jsxs(View,{style:Ui.leftContent,children:[jsx(View,{style:[Ui.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:oe(Te(e,"png"))},style:Ui.icon})}),jsxs(View,{style:Ui.textContainer,children:[jsx(Text,{style:[Ui.name,{color:i.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ui.code,{color:i.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(Le,{size:16,color:o.primary,strokeWidth:2})]})}var Ui=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 Ha({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:i}=V();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:xf.headerContainer,children:jsx(Text,{style:[xf.title,{color:i.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(s=>jsx(dc,{currency:s,isSelected:r.toLowerCase()===s.currency_code.toLowerCase(),onSelect:o},s.currency_code))]})}var xf=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function pc({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:i,borderTopLeftRadius:s,borderTopRightRadius:a}){let{colors:l,fonts:u,components:c}=V(),[y,T]=useState(""),w=o.map(d=>r.find(C=>C.currency_code.toLowerCase()===d.toLowerCase())).filter(d=>d!==void 0),m=r.filter(d=>!o.includes(d.currency_code.toLowerCase())),g=d=>{if(!y)return d;let C=y.toLowerCase();return d.filter(x=>x.name.toLowerCase().includes(C)||x.currency_code.toLowerCase().includes(C))},h=g(w),S=g(m),b=d=>{i(d),t(false),T("");},p=()=>{t(false),T("");};return jsxs(bt,{visible:e,onClose:p,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:s,borderTopRightRadius:a,children:[jsx(Ur,{title:"Currency",showBack:false,onClose:p}),jsx(View,{style:Hi.searchContainer,children:jsx(TextInput,{style:[Hi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:u.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:y,onChangeText:T,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(at,{style:Hi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:Hi.listContent,children:[jsx(Ha,{title:"Popular currencies",currencies:h,selectedCurrency:n,onSelect:b}),h.length>0&&S.length>0&&jsx(View,{style:Hi.sectionSpacer}),jsx(Ha,{title:"All currencies",currencies:S,selectedCurrency:n,onSelect:b}),h.length===0&&S.length===0&&jsx(View,{style:Hi.noResultsContainer,children:jsx(Text,{style:[Hi.noResultsText,{color:c.container.subtitleColor,fontFamily:u.regular}],children:"No currencies found"})})]})})]})}var Hi=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 vu(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 hc({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:i,destinationChainType:s,destinationChainId:a,destinationTokenAddress:l,onDepositSuccess:u,onDepositError:c,borderTopLeftRadius:y,borderTopRightRadius:T,sheetBorderRadius:w}){let{colors:m,fonts:g,components:h}=V(),[S,b]=useState(""),[p,d]=useState("usd"),[C,x]=useState(false),[_,k]=useState(false),[v,M]=useState([]),[W,O]=useState(false),[F,U]=useState(null),[j,le]=useState(null),[Ye,_e]=useState("amount"),[ne,we]=useState(null),[fe,Pe]=useState(true),[$e,ue]=useState(null),[J,be]=useState(false),vt=useRef(null),ve=useRef(false);useEffect(()=>{vt.current=ne;},[ne]),useEffect(()=>{ve.current=J;},[J]);let[qe,Ne]=useState([]),[Ve,ze]=useState(true),[it,ie]=useState(60),[pe,et]=useState([]),[Ae,Ke]=useState([]),[$t,Ee]=useState(null),[Oe,ar]=useState(null),[he,X]=useState(true),[Ce,pt]=useState(null),[It,me]=useState(false),[je,Vt]=useState(null),[ot,Lt]=useState(false),[Bt,yt]=useState(false),[Se,Z]=useState(false),[Q,L]=useState(null),I=r??Ye,D=useRef(null),q=pe.find(Y=>Y.currency_code.toLowerCase()===p.toLowerCase()),Fe=useCallback(Y=>{_e(Y),Y==="quotes"?o?.(Y,v.length):o?.(Y);},[v.length,o]);useEffect(()=>{async function Y(){try{let ae=await ca();ar(ae);}catch(ae){console.error("Error fetching user IP:",ae);}finally{X(false);}}Y();},[]),useEffect(()=>{async function Y(){try{let ae=await dn({external_user_id:e,recipient_address:i,destination_chain_type:s,destination_chain_id:a,destination_token_address:l},t);Ne(ae.data);}catch(ae){console.error("Error fetching wallets:",ae),U("Failed to load wallet addresses");}finally{ze(false);}}Y();},[e,i,s,a,l,t]);let ke=n||$t?.symbol.toUpperCase()||"USDC",pr=os($t?.icon_urls,"png")||$t?.icon_url,ce=os($t?.chain_icon_urls,"png")||$t?.chain_icon_url;useEffect(()=>{async function Y(){try{let ae=await aa(t);et(ae.data),Ke(ae.preferred||[]);}catch(ae){console.error("Error fetching fiat currencies:",ae);}}Y();},[t]),useEffect(()=>{if(C||pe.length===0||!Oe?.alpha2)return;let Y=Oe.alpha2.toUpperCase(),ae=pe.find(qt=>qt.country_codes.includes(Y));if(ae)d(ae.currency_code.toLowerCase()),!S&&!_&&b(String(ae.default_amount??100));else if(!S&&!_){let qt=pe.find(Tr=>Tr.currency_code.toLowerCase()==="usd");qt&&b(String(qt.default_amount??100));}},[pe,Oe,C,S,_]),useEffect(()=>{if(pe.length!==0){if(D.current!==null&&D.current!==p){let Y=pe.find(ae=>ae.currency_code.toLowerCase()===p.toLowerCase());Y&&b(String(Y.default_amount??100));}D.current=p;}},[p,pe]),useEffect(()=>{async function Y(){try{let ae=await rd({chain_type:s||"",chain_id:a||"",token_address:l||""},t);Ee(ae);}catch(ae){console.error("Error fetching supported tokens:",ae);}}Y();},[s,a,l,t]),useEffect(()=>{async function Y(){if(!(!l||!a||!s)&&!he){me(true);try{let ae=await id({country_code:Oe?.alpha2?.toUpperCase()||"US",subdivision_code:Oe?.state||void 0,token_address:l,chain_id:a,chain_type:s},t);pt(ae);}catch(ae){console.error("Error fetching default onramp token:",ae);}finally{me(false);}}}Y();},[l,a,s,Oe,he,t]),useEffect(()=>{let Y=parseFloat(S);if(isNaN(Y)||Y<=0){M([]),le(null);return}if(!Ce||It){M([]),we(null);return}let ae=pe.find(Tr=>Tr.currency_code.toLowerCase()===p.toLowerCase());if(ae){if(Y<ae.minimum_amount){M([]),we(null),le(`Minimum amount is ${vu(p)}${ae.minimum_amount.toLocaleString()}`);return}if(Y>ae.maximum_amount){M([]),we(null),le(`Maximum amount is ${vu(p)}${ae.maximum_amount.toLocaleString()}`);return}}le(null);let qt=setTimeout(()=>{xt(Y);},500);return ()=>clearTimeout(qt)},[S,p,t,Ce,It,pe]);let xt=async Y=>{if(!Ce){U("Loading token information...");return}O(true),U(null);try{let ae={country_code:Oe?.alpha2?.toUpperCase()||"US",source_amount:Y.toString(),source_currency:p.toLowerCase(),destination_currency:Ce.destination_currency,destination_network:Ce.destination_network,subdivision_code:Oe?.state||void 0},qt=await od(ae,t);M(qt.data);let Tr=ve.current,an=vt.current;if(Tr&&an){let Bn=qt.data.find(Wn=>Wn.service_provider===an.service_provider);if(Bn){if(we(Bn),qt.data.length>0){let Wn=qt.data[0];$e||ue(Wn.service_provider),Pe(Bn.service_provider===$e);}}else if(qt.data.length>0){let Wn=qt.data[0];we(Wn),ue(Wn.service_provider),Pe(!0),be(!1);}}else if(qt.data.length>0){let Bn=qt.data[0];we(Bn),ue(Bn.service_provider),Pe(!0);}ie(60);}catch(ae){console.error("Failed to fetch quotes:",ae),U("Failed to fetch quotes. Please try again."),M([]);}finally{O(false);}};useEffect(()=>{if(v.length===0)return;let Y=setInterval(()=>{ie(ae=>{if(ae<=1){let qt=parseFloat(S);return !isNaN(qt)&&qt>0&&xt(qt),60}return ae-1});},1e3);return ()=>clearInterval(Y)},[v.length,S]);let Ct=Y=>{(/^\d*\.?\d{0,2}$/.test(Y)||Y==="")&&(b(Y),k(true));},z=Y=>{b(Y.toString()),k(true);},Xr=async()=>{if(ne&&Ce)try{let Y=Ce.destination_token_metadata.chain_type,ae=un(qe,Y);if(!ae?.address){U("Wallet address not available");return}let qt={service_provider:ne.service_provider,country_code:ne.country_code?.toUpperCase()||Oe?.alpha2?.toUpperCase()||"US",source_currency:ne.source_currency,source_amount:S,destination_currency:ne.destination_currency,destination_network:ne.destination_network,wallet_address:ae.address,subdivision_code:Oe?.state||void 0},Tr=await nd(qt,t);Vt({provider:ne,sourceCurrency:p,sourceAmount:S,sessionUrl:Tr.url}),L(Tr.url),Z(!0);}catch(Y){console.error("Failed to create session:",Y),U("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:Y});}},dt=vu(p),Ga=()=>{Z(false),Fe("onramp"),u?.({message:"Payment flow completed"});},Yi=()=>jsx(Ab,{visible:Se,onClose:Ga,url:Q,providerName:ne?.service_provider_display_name||"Complete Payment",colors:m,fonts:g,borderTopLeftRadius:w?.webView?.borderTopLeftRadius??y,borderTopRightRadius:w?.webView?.borderTopRightRadius??T});return I==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:K.amountViewContainer,children:[jsxs(at,{style:K.scrollContainer,contentContainerStyle:K.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:K.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Lt(true),style:[K.currencyButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.input.borderRadius,borderWidth:h.input.borderWidth,borderColor:h.input.borderColor}],children:[q&&jsx(Image,{source:{uri:oe(Te(q,"png"))},style:K.currencyIcon}),jsx(Text,{style:[K.currencyText,{color:h.card.titleColor,fontFamily:g.medium}],children:p.toUpperCase()}),jsx(Gt,{size:16,color:h.card.actionColor,strokeWidth:2})]})}),jsx(pc,{open:ot,onOpenChange:Lt,currencies:pe,preferredCurrencyCodes:Ae,selectedCurrency:p,onSelectCurrency:Y=>{d(Y.toLowerCase()),x(true);},borderTopLeftRadius:w?.currencyModal?.borderTopLeftRadius??y,borderTopRightRadius:w?.currencyModal?.borderTopRightRadius??T}),jsx(View,{style:K.amountContainer,children:jsxs(View,{style:K.amountInputRow,children:[jsx(Text,{style:[K.currencySymbol,{color:h.container.titleColor,fontFamily:g.medium}],children:dt}),jsx(TextInput,{style:[K.amountInput,{color:h.container.titleColor,fontFamily:g.medium}],value:S,onChangeText:Ct,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:m.foregroundMuted})]})}),q?.suggested_amounts&&q.suggested_amounts.length>0&&jsx(View,{style:K.quickAmounts,children:q.suggested_amounts.map(Y=>jsx(TouchableOpacity$1,{onPress:()=>z(Y),style:[K.quickAmountButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.button.borderRadius,borderWidth:parseFloat(S)===Y?2:h.button.borderWidth,borderColor:parseFloat(S)===Y?m.primary:h.button.borderColor}],children:jsxs(Text,{style:[K.quickAmountText,{color:h.card.titleColor,fontFamily:g.medium}],children:[dt,Y.toLocaleString()]})},Y))}),j&&jsx(Text,{style:[K.validationError,{color:m.error,fontFamily:g.regular}],children:j}),jsxs(View,{style:K.providerSection,children:[jsxs(View,{style:K.providerHeader,children:[jsx(Text,{style:[K.providerLabel,{color:h.card.labelColor,fontFamily:g.medium}],children:"Provider"}),v.length>0&&!W&&jsxs(Text,{style:[K.refreshText,{color:h.card.labelRightColor,fontFamily:g.regular}],children:["Refreshing in ",it,"s"]})]}),jsx(Cr,{cardTokens:h.depositCard.quoteProvider.card,onPress:W||v.length===0?void 0:()=>yt(true),contentStyle:StyleSheet.flatten([K.providerButton,(W||v.length===0)&&K.disabled]),children:W?jsxs(View,{style:K.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:m.primary}),jsx(Text,{style:[K.loadingText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:"Finding best rates..."})]}):ne?jsxs(View,{style:K.providerContent,children:[jsxs(View,{style:K.providerInfo,children:[fe&&jsx(Text,{style:[K.autoPickedText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:"Auto-picked for you"}),jsxs(View,{style:K.providerRow,children:[jsx(Image,{source:{uri:oe(pl(ne.icon_urls,"png",ne.icon_url))},style:K.providerIconImage},`provider-${ne.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[K.providerName,{color:h.card.titleColor,fontFamily:g.medium}],children:ne.service_provider_display_name}),jsxs(Text,{style:[K.bestPriceText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:[ne.destination_amount.toFixed(2)," ",ke]})]})]})]}),jsx(_r,{size:20,color:h.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[K.noProviderText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),F&&jsx(Text,{style:[K.errorText,{color:m.error,fontFamily:g.regular}],children:F})]}),jsxs(bt,{visible:Bt,onClose:()=>yt(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:w?.providerModal?.borderTopLeftRadius??y,borderTopRightRadius:w?.providerModal?.borderTopRightRadius??T,children:[jsx(Ur,{title:"Select Provider",showBack:false,onClose:()=>yt(false)}),jsx(at,{style:K.providerModalList,contentContainerStyle:K.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:K.quotesList,children:v.map(Y=>{let ae=ne?.service_provider===Y.service_provider;return jsxs(Cr,{cardTokens:h.depositCard.quoteProvider.card,onPress:()=>{we(Y),be(true),Pe(Y.service_provider===$e),yt(false);},contentStyle:StyleSheet.flatten([K.quoteItem,ae&&{borderWidth:2,borderColor:m.primary}]),children:[jsxs(View,{style:K.quoteLeft,children:[jsx(Image,{source:{uri:oe(pl(Y.icon_urls,"png",Y.icon_url))},style:K.providerIconImage}),jsx(View,{children:jsx(Text,{style:[K.quoteName,{color:h.card.titleColor,fontFamily:g.medium}],children:Y.service_provider_display_name})})]}),jsxs(View,{style:K.quoteRight,children:[jsxs(Text,{style:[K.quoteAmount,{color:h.card.textRightColor,fontFamily:g.medium}],children:[Y.destination_amount.toFixed(2)," ",ke]}),jsxs(Text,{style:[K.quoteSource,{color:h.card.subtextRightColor,fontFamily:g.regular}],children:["Fee: ",dt,Y.total_fee.toFixed(2)]})]})]},Y.service_provider)})})})]})]}),jsx(View,{style:[K.continueButtonContainer,{backgroundColor:m.background}],children:jsx(View,{style:{opacity:W||Ve||!ne||parseFloat(S)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:Xr,disabled:W||Ve||!ne||parseFloat(S)<=0,style:[K.continueButton,{backgroundColor:h.container.buttonColor,borderRadius:h.button.borderRadius,borderWidth:h.button.borderWidth,borderColor:h.button.borderColor}],children:jsx(Text,{style:[K.continueButtonText,{color:h.container.buttonTitleColor,fontFamily:g.medium}],children:Ve?"Loading...":"Continue"})})})})]}),Yi()]}):I==="onramp"&&je?jsxs(View,{style:K.onrampContainer,children:[jsx(Image,{source:{uri:oe(pl(je.provider.icon_urls,"png",je.provider.icon_url))},style:K.onrampProviderIcon}),jsxs(Text,{style:[K.onrampTitle,{color:h.container.titleColor,fontFamily:g.medium}],children:["Complete transaction with ",je.provider.service_provider_display_name]}),jsx(Text,{style:[K.onrampSubtitle,{color:h.container.subtitleColor,fontFamily:g.regular}],children:"You can close this modal."}),jsxs(View,{style:[K.flowDiagram,{backgroundColor:h.card.backgroundColor}],children:[jsxs(View,{style:K.flowStep,children:[jsx(Image,{source:{uri:cr(`/icons/currencies/png/${je.sourceCurrency.toLowerCase()}.png`)},style:K.flowIconImage}),jsx(Text,{style:[K.flowLabel,{color:h.card.subtitleColor,fontFamily:g.regular}],children:"You use"}),jsx(Text,{style:[K.flowValue,{color:h.card.titleColor,fontFamily:g.medium}],children:je.sourceCurrency.toUpperCase()})]}),jsx(_r,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:K.flowStep,children:[jsxs(View,{style:K.flowIconWithBadge,children:[jsx(Image,{source:{uri:os(Ce?.destination_token_metadata?.icon_urls,"png")||Ce?.destination_token_metadata?.icon_url||cr("/icons/tokens/png/usdc.png")},style:K.flowIconImageNoBadge}),jsx(Image,{source:{uri:os(Ce?.destination_token_metadata?.chain?.icon_urls,"png")||Ce?.destination_token_metadata?.chain?.icon_url||cr("/icons/networks/png/polygon.png")},style:[K.flowNetworkBadge,{borderColor:m.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[K.flowLabel,{color:h.card.subtitleColor,fontFamily:g.regular}],children:"You buy"}),jsx(Text,{style:[K.flowValue,{color:h.card.titleColor,fontFamily:g.medium}],children:"USDC"})]}),jsx(_r,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:K.flowStep,children:[jsxs(View,{style:K.flowIconWithBadge,children:[jsx(Image,{source:{uri:pr||cr("/icons/tokens/png/usdc.png")},style:K.flowIconImageNoBadge}),jsx(Image,{source:{uri:ce||cr("/icons/networks/png/polygon.png")},style:[K.flowNetworkBadge,{borderColor:m.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[K.flowLabel,{color:h.card.subtitleColor,fontFamily:g.regular}],children:"You receive"}),jsx(Text,{style:[K.flowValue,{color:h.card.titleColor,fontFamily:g.medium}],children:ke})]})]}),jsx(View,{style:[K.onrampInfoBox,{backgroundColor:h.card.backgroundColor,borderRadius:h.card.borderRadius,borderWidth:h.card.borderWidth,borderColor:h.card.borderColor}],children:jsx(Text,{style:[K.onrampInfoText,{color:h.card.descriptionColor,fontFamily:g.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 Ab({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:i,borderTopLeftRadius:s,borderTopRightRadius:a}){return jsxs(bt,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:s,borderTopRightRadius:a,children:[jsxs(View,{style:Ni.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:Ni.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Le,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Ni.headerTitle,{color:n.foreground,fontFamily:i.medium}],children:o}),jsx(View,{style:Ni.headerSpacer})]}),r&&jsx(View,{style:Ni.container,children:jsx(WebView,{source:{uri:r},style:Ni.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Ni.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var Ni=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"}}),K=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 Ub(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 Hb(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function bc({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=V(),i=n.depositTracker.executionRow.card,s=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=oe(Te(e.destination_token_metadata,"png")||cr("/icons/tokens/png/usdc.png")),u=s?"Deposit Processing":"Deposit Completed",c=Ub(e.created_at||new Date().toISOString()),y=Hb(e.source_amount_usd);return jsxs(Cr,{cardTokens:i,onPress:t,contentStyle:vn.container,children:[jsxs(View,{style:vn.iconContainer,children:[jsx(Image,{source:{uri:l},style:vn.tokenIcon}),jsx(View,{style:[vn.statusBadge,{backgroundColor:s?r.warning:r.success,borderColor:i.backgroundColor}],children:s?jsx(Xi,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Le,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:vn.textContainer,children:[jsx(Text,{style:[vn.title,{color:i.titleColor,fontFamily:o.medium}],children:u}),jsx(Text,{style:[vn.dateTime,{color:i.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:vn.rightContainer,children:[jsx(Text,{style:[vn.amount,{color:i.textRightColor,fontFamily:o.medium}],children:y}),jsx(_r,{size:20,color:i.actionColor,strokeWidth:2})]})]})}var vn=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 If(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 Pf(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 jb(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var Of=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Ff(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function $b(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 qb({count:e=4}){let{colors:t,components:r}=V(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,i=t.cardHover;return useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[o]),jsx(View,{style:ji.list,children:Array.from({length:e}).map((s,a)=>jsxs(View,{style:[ji.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[ji.icon,{backgroundColor:i,opacity:o}]}),jsxs(View,{style:ji.textBlock,children:[jsx(Animated.View,{style:[ji.titleBar,{backgroundColor:i,opacity:o}]}),jsx(Animated.View,{style:[ji.subtitleBar,{backgroundColor:i,opacity:o}]})]}),jsx(Animated.View,{style:[ji.amountBar,{backgroundColor:i,opacity:o}]})]},a))})}var ji=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 Ou({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:i,fonts:s,components:a}=V(),[l,u]=useState(r),[c,y]=useState(false),[T,w]=useState(null),[m,g]=useState(false),h=useRef(null);useEffect(()=>{if(!e||!o)return;let _=async()=>{y(true);try{let M=[...(await pn(o,n)).data].sort((W,O)=>{let F=W.created_at?new Date(W.created_at).getTime():0;return (O.created_at?new Date(O.created_at).getTime():0)-F});u(M);}catch(v){console.error("Failed to fetch executions:",v),u(r);}finally{y(false);}};_();let k=setInterval(_,1e4);return ()=>clearInterval(k)},[e,o,n,r]),useEffect(()=>{r.length>0&&u(_=>{let k=new Set(_.map(M=>M.id)),v=r.filter(M=>!k.has(M.id));return v.length>0?[...v,..._]:_});},[r]),useEffect(()=>{e||w(null);},[e]);let S=_=>{w(_);},b=()=>{w(null),g(false);},p=()=>{w(null),t();},d=()=>{if(!T)return null;let _=T,k=_.status==="pending"||_.status==="waiting"||_.status==="delayed",v=_.status==="succeeded",M=oe(Te(_.destination_token_metadata,"png")||cr("/icons/tokens/png/usdc.png")),W=_.provider_metadata?.details,O=W?.currencyIn,F=W?.currencyOut;O?.currency?.symbol||"USDC";F?.currency?.symbol||"USDC";let le=Pf(_.source_amount_base_unit,_.source_token_metadata?.decimals),Ye=Pf(_.destination_amount_base_unit,_.destination_token_metadata?.decimals),_e=jb(_.source_amount_usd),ne=If(_.source_chain_type,_.source_chain_id),we=If(_.destination_chain_type,_.destination_chain_id),fe=()=>{_.explorer_url&&Linking.openURL(_.explorer_url);},Pe=()=>{_.destination_explorer_url&&Linking.openURL(_.destination_explorer_url);};return jsxs(at,{ref:h,style:ge.scrollContainer,contentContainerStyle:ge.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:ge.iconSection,children:[jsxs(View,{style:ge.iconWrapper,children:[jsx(Image,{source:{uri:M},style:ge.tokenIcon}),jsx(View,{style:[ge.statusBadge,{backgroundColor:k?i.warning:i.success,borderColor:i.background}],children:k?jsx(Gt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(Le,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:ge.statusRow,children:[jsx(View,{style:[ge.statusDot,{backgroundColor:k?i.warning:i.success}]}),jsx(Text,{style:[ge.statusText,{color:a.container.titleColor,fontFamily:s.semibold}],children:k?"Processing":"Completed"})]}),jsx(Text,{style:[ge.dateText,{color:a.container.subtitleColor,fontFamily:s.regular}],children:$b(_.created_at||new Date().toISOString())})]}),jsxs(View,{style:[ge.card,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Amount Sent"}),jsxs(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:[le," ",Ff(_.source_currency)]})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Amount Received"}),jsxs(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:[Ye," ",Ff(_.destination_currency)]})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"USD Value"}),jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:_e})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Source Network"}),jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:ne})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Destination Network"}),jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:we})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let $e=!m;g($e),$e?setTimeout(()=>{h.current?.scrollToEnd({animated:true});},100):h.current?.scrollTo({y:0,animated:true});},style:ge.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[ge.toggleText,{color:a.container.actionTitle,fontFamily:s.regular}],children:m?"See less":"See more details"}),m?jsx(Vo,{size:14,color:a.container.actionColor,strokeWidth:2}):jsx(Gt,{size:14,color:a.container.actionColor,strokeWidth:2})]}),m&&jsxs(View,{style:[ge.card,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[_.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:fe,style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Deposit Tx"}),jsxs(View,{style:ge.cardRowRight,children:[jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:Of(_.transaction_hash)}),jsx(Do,{size:14,color:a.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]})]}),_.destination_explorer_url&&v&&jsxs(TouchableOpacity,{onPress:Pe,style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Completion Tx"}),jsxs(View,{style:ge.cardRowRight,children:[jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:Of(_.destination_transaction_hashes[0])}),jsx(Do,{size:14,color:a.card.actionIcon,strokeWidth:2})]})]})]})]})},C=c&&l.length===0;return jsxs(Fragment,{children:[jsx(Ur,{title:T?"Deposit Details":"Deposit Tracker",onClose:p,showClose:!T,showBack:!!T,onBack:b}),T?d():C?jsx(qb,{}):jsx(at,{style:ge.scrollContainer,contentContainerStyle:ge.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:ge.emptyContainer,children:[jsx(Text,{style:[ge.emptyText,{color:a.container.titleColor,fontFamily:s.medium}],children:"No deposits yet"}),jsx(Text,{style:[ge.emptySubtext,{color:a.container.subtitleColor,fontFamily:s.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:ge.executionsList,children:l.map(_=>jsx(bc,{execution:_,onPress:()=>S(_)},_.id))})})]})}var ge=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 Na(e,t=true){let[r,o]=useState(null),[n,i]=useState(null),[s,a]=useState(false),[l,u]=useState(false),[c,y]=useState(null),[T,w]=useState(null);useEffect(()=>{!t||r||(a(true),ca().then(S=>{o(S),y(null);}).catch(S=>{y(S instanceof Error?S:new Error(String(S)));}).finally(()=>{a(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(u(true),la(e).then(S=>{i(S),w(null);}).catch(S=>{w(S instanceof Error?S:new Error(String(S)));}).finally(()=>{u(false);}));},[t,e,n]);let m=s||l,g=c||T||null,h=null;if(r&&n){let S=n.blocked_country_codes||[],b=r.alpha2.toUpperCase();h=!S.some(p=>p.toUpperCase()===b);}return {isAllowed:h,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:m,error:g}}var Vu="unifold_recent_tokens",Jb=5,Af=[{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 Tc(){try{let e=await Fd.getItem(Vu);return e?JSON.parse(e):[]}catch{return []}}async function Zb(e){try{let r=(await Tc()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,Jb);await Fd.setItem(Vu,JSON.stringify(o));}catch{}}async function Xb(e){try{let r=(await Tc()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Fd.setItem(Vu,JSON.stringify(r)),r}catch{return []}}function Lu({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:i,borderTopLeftRadius:s,borderTopRightRadius:a}){let{colors:l,fonts:u,components:c}=V(),[y,T]=useState(""),[w,m]=useState([]);useEffect(()=>{e&&Tc().then(m);},[e]),useEffect(()=>{e||T("");},[e]);let g=useMemo(()=>{let C=[];return r.forEach(x=>{x.chains.forEach(_=>{C.push({token:x,chain:_});});}),C},[r]),h=useMemo(()=>{let C=[],x=new Set,_=(k,v,M,W)=>{let O=`${k}-${v}:${M}`;if(x.has(O))return;let F=r.find(j=>j.symbol===k);if(!F)return;let U=F.chains.find(j=>j.chain_type===v&&j.chain_id===M);U&&(x.add(O),C.push({token:F,chain:U,isRecent:W}));};return w.forEach(k=>{_(k.symbol,k.chainType,k.chainId,true);}),Af.forEach(k=>{_(k.symbol,k.chainType,k.chainId,false);}),C},[r,w]),S=useMemo(()=>{if(!y.trim())return g;let C=y.toLowerCase();return g.filter(({token:x,chain:_})=>x.symbol.toLowerCase().includes(C)||x.name.toLowerCase().includes(C)||_.chain_name.toLowerCase().includes(C))},[g,y]),b=(C,x,_)=>Af.some(k=>k.symbol===C&&k.chainType===x&&k.chainId===_),p=async(C,x)=>{let _=`${x.chain_type}:${x.chain_id}`;if(!b(C.symbol,x.chain_type,x.chain_id)){await Zb({symbol:C.symbol,chainType:x.chain_type,chainId:x.chain_id});let k=await Tc();m(k);}T(""),i(C.symbol,_),t();},d=async(C,x)=>{let _=await Xb({symbol:C.symbol,chainType:x.chain_type,chainId:x.chain_id});m(_);};return jsxs(bt,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:s,borderTopRightRadius:a,children:[jsxs(View,{style:gt.header,children:[jsx(View,{style:gt.headerSpacer}),jsx(Text,{style:[gt.headerTitle,{color:c.header.titleColor,fontFamily:u.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:gt.closeButton,children:jsx(st,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:gt.searchContainer,children:jsx(TextInput,{style:[gt.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:u.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:y,onChangeText:T,autoCapitalize:"none",autoCorrect:false})}),h.length>0&&!y&&jsxs(View,{style:gt.quickSelectSection,children:[jsx(Text,{style:[gt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:u.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:gt.quickSelectScroll,children:h.map(({token:C,chain:x,isRecent:_})=>{let k=`${x.chain_type}:${x.chain_id}`;C.symbol===o&&k===n;return jsxs(View,{children:[_&&jsx(TouchableOpacity$1,{onPress:()=>d(C,x),style:gt.removeButton,children:jsx(st,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>p(C,x),activeOpacity:.7,style:[gt.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:gt.tokenIconContainer,children:[jsx(Image,{source:{uri:oe(Te(C,"png"))},style:gt.quickSelectIcon}),jsx(Image,{source:{uri:oe(Te(x,"png"))},style:[gt.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:gt.quickSelectText,children:[jsx(Text,{style:[gt.quickSelectSymbol,{color:c.card.titleColor,fontFamily:u.medium}],children:C.symbol}),jsx(Text,{style:[gt.quickSelectChain,{color:c.card.subtitleColor,fontFamily:u.regular}],children:x.chain_name})]})]})]},`quick-${C.symbol}-${k}`)})})]}),jsx(Text,{style:[gt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:u.regular}],children:"All supported tokens"}),jsx(at,{style:gt.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:gt.tokenListContent,children:S.length===0?jsx(View,{style:gt.emptyState,children:jsx(Text,{style:[gt.emptyText,{color:l.foregroundMuted,fontFamily:u.regular}],children:"No tokens found"})}):S.map(({token:C,chain:x})=>{let _=`${x.chain_type}:${x.chain_id}`,k=C.symbol===o&&_===n;return jsxs(TouchableOpacity$1,{onPress:()=>p(C,x),activeOpacity:.7,style:[gt.tokenItem,{backgroundColor:k?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:gt.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:oe(Te(C,"png"))},style:gt.tokenIcon}),jsx(Image,{source:{uri:oe(Te(x,"png"))},style:[gt.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:gt.tokenInfo,children:[jsx(Text,{style:[gt.tokenSymbol,{color:c.card.titleColor,fontFamily:u.medium}],children:C.symbol}),jsx(Text,{style:[gt.tokenChainName,{color:c.card.subtitleColor,fontFamily:u.regular}],children:x.chain_name})]}),jsxs(Text,{style:[gt.minDeposit,{color:c.card.labelColor,fontFamily:u.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:u.regular},children:["$",x.minimum_deposit_amount_usd]})]})]},`${C.symbol}-${_}`)})})]})}var gt=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 _c=(e,t)=>`${t}:${e}`,nC=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Bu({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:i,destinationTokenSymbol:s,defaultChainType:a,defaultChainId:l,defaultTokenAddress:u,depositConfirmationMode:c="auto_ui",onExecutionsChange:y,onDepositSuccess:T,onDepositError:w,wallets:m,borderTopLeftRadius:g,borderTopRightRadius:h,sheetBorderRadius:S}){let{colors:b,fonts:p,components:d}=V(),C=a&&l?`${a}:${l}`:"solana:mainnet",[x,_]=useState("USDC"),[k,v]=useState(C),[M,W]=useState([]),[O,F]=useState(!m?.length),U=m?.length?m:M,[j,le]=useState([]),[Ye,_e]=useState(true),[ne,we]=useState(false),[fe,Pe]=useState(false),[$e,ue]=useState(false),[J,be]=useState([]),[vt,ve]=useState(new Map),[qe]=useState(()=>new Date),[Ne,Ve]=useState(null),[ze,it]=useState(false),[ie,pe]=useState(null),[et,Ae]=useState(false),Ke=new Map;j.forEach(Z=>{Z.chains.forEach(Q=>{let L=`${Q.chain_type}:${Q.chain_id}`;Ke.has(L)||Ke.set(L,Q);});});let $t=Array.from(Ke.values()),Ee=nC(k),Oe=$t.find(Z=>Z.chain_type===Ee.chainType&&Z.chain_id===Ee.chainId),ar=Oe?.chain_type||"ethereum",he=un(U,ar),X=he?.address||"",Ce=useRef(false);useEffect(()=>{async function Z(){try{_e(!0),Ve(null);let L=await Ci(t,i&&n&&o?{destination_token_address:i,destination_chain_id:n,destination_chain_type:o}:void 0);if(le(L.data),L.data.length>0&&!Ce.current){Ce.current=!0;let I,D;if(a&&l)if(u)for(let q of L.data){let Fe=q.chains.find(ke=>ke.chain_type===a&&ke.chain_id===l&&ke.token_address.toLowerCase()===u.toLowerCase());if(Fe){I=q,D=Fe;break}}else for(let q of L.data){let Fe=q.chains.find(ke=>ke.chain_type===a&&ke.chain_id===l);if(Fe){I=q,D=Fe;break}}if(!I&&i)for(let q of L.data){let Fe=q.chains.find(ke=>ke.token_address.toLowerCase()===i.toLowerCase());if(Fe){I=q,D=Fe;break}}I||(I=L.data.find(q=>q.symbol==="USDC"),I&&I.chains.length>0&&(D=I.chains[0])),I||(I=L.data.find(q=>q.symbol==="USDT"),I&&I.chains.length>0&&(D=I.chains[0])),I||(I=L.data[0],I.chains.length>0&&(D=I.chains[0])),I&&_(I.symbol),D&&v(_c(D.chain_id,D.chain_type));}}catch(Q){console.error("Error fetching supported tokens:",Q),Ve("Failed to load supported tokens"),w?.({message:"Failed to load supported tokens",error:Q});}finally{_e(false);}}Z();},[t,i,n,o,a,l,u,w]),useEffect(()=>{y&&y(J);},[J,y]),useEffect(()=>{if(m?.length){F(false);return}if(M.length>0){F(false);return}let Z=null,Q=false,L=async()=>{if(!Q){F(true);try{let I=await dn({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:i},t);Q||(W(I.data),Ve(null),F(!1));}catch(I){console.error("Error fetching wallets, retrying in 5s:",I),Q||(Ve(I instanceof Error?I.message:"Failed to load wallets"),F(false),Z=setTimeout(L,5e3));}}};return L(),()=>{Q=true,Z&&clearTimeout(Z);}},[e,r,o,n,i,t,m,M.length]);let pt=he?.id??"",{showWaitingUi:It,handleIveDeposited:me}=Ma({depositConfirmationMode:c,depositAddress:X,chain:k,externalUserId:e,publishableKey:t,modalOpenedAt:qe,depositWalletId:pt,depositExecutions:J,trackedExecutions:vt,setDepositExecutions:be,setTrackedExecutions:ve,setLatestExecution:pe,setShowStatusSheet:it,onDepositSuccess:T,onExecutionsChange:y,onDepositError:w});useEffect(()=>{if(!j.length)return;let Z=j.find(L=>L.symbol===x);if(!Z||Z.chains.length===0)return;if(!Z.chains.some(L=>_c(L.chain_id,L.chain_type)===k)){let L=Z.chains[0];v(_c(L.chain_id,L.chain_type));}},[x,j,k]);let je=j.find(Z=>Z.symbol===x),ot=(je?.chains||[]).find(Z=>_c(Z.chain_id,Z.chain_type)===k),Lt=async()=>{if(X)try{Clipboard.setString(X),we(!0),setTimeout(()=>we(!1),2e3);}catch(Z){console.error("Failed to copy:",Z);}},Bt=ot?.estimated_price_impact_percent??0,yt=ot?.max_slippage_percent??.25,Se=ot?.minimum_deposit_amount_usd??3;return Ye?jsxs(View,{style:N.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:b.primary}),jsx(Text,{style:[N.loadingText,{color:b.foregroundMuted,fontFamily:p.regular}],children:"Loading currencies..."})]}):Ne&&j.length===0?jsxs(View,{style:N.errorContainer,children:[jsx(Text,{style:[N.errorText,{color:b.error,fontFamily:p.regular}],children:Ne}),jsx(Text,{style:[N.errorHint,{color:b.foregroundMuted,fontFamily:p.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:N.container,children:[jsxs(View,{style:N.selectorSection,children:[jsx(Text,{style:[N.selectorLabel,{color:d.card.labelColor,fontFamily:p.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>ue(true),disabled:Ye||j.length===0,style:[N.tokenSelectorButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],activeOpacity:.7,children:Ye?jsxs(View,{style:N.tokenSelectorLoading,children:[jsx(View,{style:[N.loadingIcon,{backgroundColor:b.cardHover}]}),jsxs(View,{style:N.loadingTextContainer,children:[jsx(View,{style:[N.loadingLine,{backgroundColor:b.cardHover,width:60}]}),jsx(View,{style:[N.loadingLine,{backgroundColor:b.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:N.tokenIconWrapper,children:[je&&jsx(Image,{source:{uri:oe(Te(je,"png"))},style:N.tokenMainIcon}),(ot||Oe)&&jsx(Image,{source:{uri:oe(Te(ot||Oe,"png"))},style:[N.tokenChainBadge,{borderColor:d.card.backgroundColor,borderRadius:d.badge.borderRadius}]})]}),jsxs(View,{style:N.tokenSelectorInfo,children:[jsx(Text,{style:[N.tokenSelectorSymbol,{color:d.card.titleColor,fontFamily:p.semibold}],children:je?.symbol||x}),jsx(Text,{style:[N.tokenSelectorNetwork,{color:d.card.subtitleColor,fontFamily:p.regular}],numberOfLines:1,children:ot?.chain_name||Oe?.chain_name||"Select network"})]}),jsxs(View,{style:N.tokenSelectorRight,children:[jsxs(Text,{style:[N.minDepositText,{color:d.card.labelHighlightRightColor,fontFamily:p.medium}],children:["$",Se," min"]}),jsx(_r,{size:16,color:d.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Lu,{visible:$e,onClose:()=>ue(false),tokens:j,selectedToken:x,selectedChainKey:k,onSelect:(Z,Q)=>{_(Z),v(Q);},borderTopLeftRadius:S?.tokenSelector?.borderTopLeftRadius??g,borderTopRightRadius:S?.tokenSelector?.borderTopRightRadius??h}),jsx(View,{style:N.qrContainer,children:jsx(View,{style:[N.qrWrapper,{backgroundColor:b.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:O?jsxs(View,{style:N.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[N.loadingText,{color:b.foregroundMuted,fontFamily:p.regular}],children:"Loading..."})]}):X?jsx(Es,{value:X,size:180,logoUri:oe(Te(ot,"png")||cr("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:N.qrLoading,children:jsx(Text,{style:[N.errorText,{color:b.error,fontFamily:p.regular}],children:"No address available"})})})}),jsxs(View,{style:N.addressSection,children:[jsxs(View,{style:N.addressHeader,children:[jsx(Text,{style:[N.addressLabel,{color:d.card.labelColor,fontFamily:p.medium}],children:"Deposit Address"}),ne&&jsxs(View,{style:N.copiedIndicator,children:[jsx(Le,{size:14,color:b.success,strokeWidth:2}),jsx(Text,{style:[N.copiedText,{color:b.success,fontFamily:p.regular}],children:"Copied"})]})]}),jsxs(Cr,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!O&&X?Lt:void 0,contentStyle:N.addressBox,children:[jsx(Text,{style:[N.addressText,{color:d.card.titleColor,fontFamily:p.regular}],numberOfLines:2,children:O?"Loading...":X||"No address available"}),jsx(View,{style:N.addressCopyIcon,children:jsx(ln,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[N.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Pe(!fe),style:N.detailsHeader,children:[jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(Nr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:N.chevronContainer,children:fe?jsx(Vo,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(Gt,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),fe&&jsxs(View,{style:N.detailsContent,children:[jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(An,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:["Price impact: ",Bt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(jr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:["Slippage: Auto \u2022 ",yt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(il,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ac,{depositConfirmationMode:c,depositAddress:X,showWaitingUi:It,latestExecution:ie,onIveDeposited:me}),jsx(TouchableOpacity$1,{style:N.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[N.termsText,{color:b.primary,fontFamily:p.regular}],children:"Terms apply"})}),jsxs(bt,{visible:et,onClose:()=>Ae(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:S?.infoSheet?.borderTopLeftRadius??g,borderTopRightRadius:S?.infoSheet?.borderTopRightRadius??h,children:[jsxs(View,{style:[N.sheetHeader,{borderBottomColor:b.border}],children:[jsx(View,{style:N.sheetHeaderSpacer}),jsx(Text,{style:[N.sheetTitle,{color:d.header.titleColor,fontFamily:p.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Ae(false),style:N.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:N.infoSheetContent,children:[jsxs(View,{style:[N.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:N.infoCardHeader,children:[jsx(View,{style:[N.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(An,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[N.infoCardTitle,{color:d.card.titleColor,fontFamily:p.medium}],children:"Price Impact"}),jsxs(Text,{style:[N.infoCardValue,{color:d.card.titleColor,fontFamily:p.medium}],children:[Bt.toFixed(2),"%"]})]}),jsx(Text,{style:[N.infoCardDescription,{color:d.card.descriptionColor,fontFamily:p.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:[N.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:N.infoCardHeader,children:[jsx(View,{style:[N.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(jr,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[N.infoCardTitle,{color:d.card.titleColor,fontFamily:p.medium}],children:"Max Slippage"}),jsxs(Text,{style:[N.infoCardValue,{color:d.card.titleColor,fontFamily:p.medium}],children:[yt.toFixed(2),"%"]})]}),jsx(Text,{style:[N.infoCardDescription,{color:d.card.descriptionColor,fontFamily:p.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."})]})]})]}),ie&&jsx(Ms,{visible:ze,status:ie.status,tokenIconUrl:ie.destination_token_metadata?.icon_urls?.find(Z=>Z.format==="png")?.url||ie.destination_token_metadata?.icon_url||Te(je,"png"),explorerUrl:ie.explorer_url,completionExplorerUrl:ie.destination_explorer_url,date:ie.created_at?new Date(ie.created_at):void 0,amountUsd:ie.source_amount_usd?parseFloat(ie.source_amount_usd):void 0,onClose:()=>it(false),borderTopLeftRadius:S?.depositStatus?.borderTopLeftRadius??g,borderTopRightRadius:S?.depositStatus?.borderTopRightRadius??h})]})}var N=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 On={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 cC(){let{colors:e,components:t}=V(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[r]);let i=({rightIcons:s=2})=>jsxs(View,{style:[mi.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[mi.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:mi.textBlock,children:[jsx(Animated.View,{style:[mi.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[mi.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:mi.rightIcons,children:Array.from({length:s}).map((a,l)=>jsx(Animated.View,{style:[mi.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:mi.container,children:[jsx(i,{rightIcons:3}),jsx(i,{rightIcons:2}),jsx(i,{rightIcons:0})]})}var mi=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 dC({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:i,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,defaultChainType:c,defaultChainId:y,defaultTokenAddress:T,showBalance:w=false,hideDepositTracker:m=false,enableStripeLinkPay:g=false,StripeOnrampComponent:h,stripeOnrampEmail:S,stripeOnrampPhone:b,stripeMerchantIdentifier:p,stripePaymentSelectorPosition:d,stripeSkipSuccessConfirmation:C,stripeTheme:x,depositConfirmationMode:_="auto_ui",transferInputVariant:k="double_input",initialScreen:v="main",onDepositSuccess:M,onDepositError:W,sheetBorderRadius:O}){let F=O?.globalBorderTopLeftRadius,U=O?.globalBorderTopRightRadius,{colors:j,fonts:le}=V(),[Ye,_e]=useState([]),[ne,we]=useState(null),[fe,Pe]=useState("amount"),$e=v==="tracker"&&!m?"tracker":v==="transfer"?"transfer":v==="card"?"card":"main",ue=$e==="main",[J,be]=useState($e),{isAllowed:vt,isLoading:ve}=Na(o,e);useEffect(()=>{if(!e||ne)return;let he=false;return la(o).then(async X=>{if(he)return;let Ce=[];for(let pt of X?.transfer_crypto?.networks??[]){let It=pt.icon_urls.find(me=>me.format==="png")?.url||pt.icon_urls.find(me=>me.format==="svg")?.url;It&&Ce.push(oe(It));}for(let pt of X?.payment_networks?.networks??[]){let It=pt.icon_urls.find(me=>me.format==="png")?.url||pt.icon_urls.find(me=>me.format==="svg")?.url;It&&Ce.push(oe(It));}Ce.length>0&&await su(Ce),he||we(X);}).catch(console.error),()=>{he=true;}},[e,ne,o]);let qe=()=>{t();};useEffect(()=>{e&&(be($e),Pe("amount"));},[e,$e]);let Ne=useCallback(()=>{ue?(be("main"),Pe("amount")):qe();},[ue,qe]),Ve=Ye.filter(he=>he.status==="pending"||he.status==="waiting").length,it=!!(s&&a&&l&&u&&o)&&w!==false&&!!ne,ie=ve||e&&!ne,pe=vt===false,et=null;if(J==="stripe"&&h){let he=jsx(h,{publishableKey:o,email:S,phone:b,externalUserId:r,recipientAddress:s??"",destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,merchantIdentifier:p,paymentSelectorPosition:d,skipSuccessConfirmation:C,appName:ne?.project_name??"",onClose:Ne});et=x?jsx(ts,{...x,children:he}):he;}let Ae=J==="stripe"?.9:J==="transfer"||J==="card"?.94:J==="tracker"?.6:J==="main"?.5:void 0,Ke=J==="tracker"||J==="main"?.9:void 0,Ee={main:O?.main,transfer:O?.transferCrypto,card:O?.buyWithCard,stripe:O?.stripeLinkPay,tracker:O?.depositsTracker}[J],Oe=Ee?.borderTopLeftRadius??F,ar=Ee?.borderTopRightRadius??U;return jsxs(bt,{visible:e,onClose:J==="main"?qe:Ne,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:Ae,maxHeightPercent:Ke,borderTopLeftRadius:Oe,borderTopRightRadius:ar,children:[J==="main"&&jsxs(Fragment,{children:[jsx(Ur,{title:n,showBack:false,onClose:qe,showBalance:it,balanceAddress:s,balanceChainType:a,balanceChainId:l,balanceTokenAddress:u,publishableKey:o,projectName:ne?.project_name}),ie&&jsx(cC,{}),!ie&&pe&&jsxs(View,{style:Ar.centeredContainer,children:[jsx(View,{style:[Ar.iconContainer,{backgroundColor:j.cardHover}],children:jsx(ta,{size:32,color:j.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Ar.blockedTitle,{color:j.foreground,fontFamily:le.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Ar.blockedDescription,{color:j.foreground,opacity:.7,fontFamily:le.regular}],children:"There are no supported tokens available from your current location."})]}),!ie&&!pe&&jsxs(View,{style:Ar.optionsContainer,children:[jsx(Va,{onPress:()=>be("transfer"),title:On.transferCrypto.title,subtitle:On.transferCrypto.subtitle,featuredTokens:ne?.transfer_crypto?.networks}),jsx(Ba,{onPress:()=>be("card"),title:On.depositWithCard.title,subtitle:On.depositWithCard.subtitle,paymentNetworks:ne?.payment_networks?.networks}),g&&h&&jsx(Ea,{onPress:()=>be("stripe"),title:On.stripeLinkPay.title,subtitle:On.stripeLinkPay.subtitle}),!m&&jsx(Wa,{onPress:()=>be("tracker"),title:On.depositTracker.title,subtitle:On.depositTracker.subtitle,badge:Ve>0?Ve:void 0})]})]}),J==="transfer"&&jsxs(Fragment,{children:[jsx(Ur,{title:On.transferCrypto.title,showBack:false,onClose:Ne,showBalance:it,balanceAddress:s,balanceChainType:a,balanceChainId:l,balanceTokenAddress:u,publishableKey:o,projectName:ne?.project_name}),ve&&jsx(View,{style:[Ar.centeredContainer,Ar.centeredFlex],children:jsx(ActivityIndicator,{color:j.primary})}),!ve&&pe&&jsxs(View,{style:[Ar.centeredContainer,Ar.centeredFlex],children:[jsx(View,{style:[Ar.iconContainer,{backgroundColor:j.cardHover}],children:jsx(ta,{size:32,color:j.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Ar.blockedTitle,{color:j.foreground,fontFamily:le.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Ar.blockedDescription,{color:j.foreground,opacity:.7,fontFamily:le.regular}],children:"There are no supported tokens available from your current location."})]}),!ve&&!pe&&jsx(at,{style:Ar.transferScrollContainer,contentContainerStyle:Ar.scrollContent,showsVerticalScrollIndicator:false,children:k==="single_input"?jsx(Bu,{externalUserId:r,publishableKey:o,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,destinationTokenSymbol:i,defaultChainType:c,defaultChainId:y,defaultTokenAddress:T,depositConfirmationMode:_,onExecutionsChange:_e,onDepositSuccess:M,onDepositError:W,borderTopLeftRadius:F,borderTopRightRadius:U,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(cc,{externalUserId:r,publishableKey:o,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,destinationTokenSymbol:i,defaultChainType:c,defaultChainId:y,defaultTokenAddress:T,depositConfirmationMode:_,onExecutionsChange:_e,onDepositSuccess:M,onDepositError:W,borderTopLeftRadius:F,borderTopRightRadius:U,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),J==="card"&&jsxs(Fragment,{children:[jsx(Ur,{title:`Deposit ${i||"USDC"}`,showBack:fe==="onramp",onBack:()=>Pe("amount"),onClose:Ne,showBalance:it,balanceAddress:s,balanceChainType:a,balanceChainId:l,balanceTokenAddress:u,publishableKey:o,projectName:ne?.project_name}),jsx(View,{style:Ar.buyWithCardContainer,children:jsx(hc,{externalUserId:r,publishableKey:o,destinationTokenSymbol:i,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,onDepositSuccess:M,onDepositError:W,view:fe,onViewChange:he=>Pe(he),borderTopLeftRadius:F,borderTopRightRadius:U,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),J==="stripe"&&et&&jsx(View,{style:Ar.stripeLinkPayContainer,children:et}),J==="tracker"&&jsx(Ou,{active:J==="tracker",onClose:Ne,executions:Ye,externalUserId:r,publishableKey:o})]})}function Ic({theme:e="auto",...t}){return jsx(dC,{...t})}var Ar=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 Pc(e,t=true){return Sn({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>fl(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Eu(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:i,enabled:s=true}=e;return Sn({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,i],queryFn:async()=>{let l=await Ci(i),u=null,c=null,y=null,T=null,w,m,g,h=l.data.some(S=>S.chains.some(b=>{let p=b.chain_type===t&&b.chain_id===r&&b.token_address.toLowerCase()===o.toLowerCase();return p&&(u=b.minimum_deposit_amount_usd,c=b.estimated_processing_time,y=b.max_slippage_percent,T=b.estimated_price_impact_percent,g=b.chain_name,m=S),p}));if(m){let S=Te(m,"png");S&&(w=oe(S));}return {isSupported:h,minimumAmountUsd:u,estimatedProcessingTime:c,maxSlippagePercent:y,priceImpactPercent:T,errorMessage:h?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:w,chainName:g}},enabled:s&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Mu(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:i,enabled:s=true}=e;return Sn({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,i],queryFn:async()=>{let l=await hl(t,r,o,n,i);if(l.balance){let u=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",y=l.balance.amount,T=BigInt(y),w=BigInt(10**u),m=T/w,h=(T%w).toString().padStart(u,"0").replace(/0+$/,""),S=h?`${m}.${h}`:m.toString();return {balanceBaseUnit:y,balanceHuman:S,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:u,symbol:c}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:s&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var pC=2500,mC=3e3,fC=6e4;function zu({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:i}){let[s,a]=useState([]),[l,u]=useState(false),c=useRef(new Date),y=useRef(new Map),T=useRef(false),w=useRef(n),m=useRef(i);return useEffect(()=>{w.current=n;},[n]),useEffect(()=>{m.current=i;},[i]),useEffect(()=>{o&&!T.current&&(c.current=new Date,y.current.clear()),o||y.current.clear(),T.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let g=c.current,h=async()=>{try{let b=await pn(e,t,"withdraw"),p=new Date(g.getTime()-fC),d=[...b.data].sort((k,v)=>{let M=k.created_at?new Date(k.created_at).getTime():0;return (v.created_at?new Date(v.created_at).getTime():0)-M}),C=["pending","waiting","delayed"],x=["succeeded","failed"],_=null;for(let k of d){let v=k.created_at?new Date(k.created_at):null;if(!v||v<p)continue;let M=y.current.get(k.id);if(!M){_=k;break}if(C.includes(M)&&x.includes(k.status)){_=k;break}}if(_){let k=_,v=k.created_at?new Date(k.created_at):null;if(!v||v<c.current)return;let M=y.current.get(k.id);y.current.set(k.id,k.status),a(W=>{let O=W.findIndex(F=>F.id===k.id);if(O>=0){let F=[...W];return F[O]=k,F}return [...W,k]}),k.status==="succeeded"&&(!M||C.includes(M))?w.current?.({message:"Withdrawal completed successfully",transaction:k}):k.status==="failed"&&M!=="failed"&&m.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:k});}}catch(b){console.error("Failed to fetch withdraw executions:",b),m.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:b});}};h();let S=setInterval(h,pC);return u(true),()=>{clearInterval(S),u(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let g=async()=>{try{await ld({deposit_wallet_id:r},t);}catch{}};g();let h=setInterval(g,mC);return ()=>clearInterval(h)},[o,r,t]),{executions:s,isPolling:l}}var Uu=(e,t)=>`${t}:${e}`;function qa({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:i=false,tokenLabel:s="Receive token",chainLabel:a="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:u,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:y}){let{colors:T,fonts:w,components:m}=V(),[g,h]=useState(false),[S,b]=useState(false),p=m.card,d=t?e.find(k=>k.symbol===t):void 0,C=d?.chains||[],x=r?C.find(k=>Uu(k.chain_id,k.chain_type)===r):void 0,_={backgroundColor:p.backgroundColor,borderRadius:p.borderRadius,borderWidth:p.borderWidth||1,borderColor:p.borderColor};return jsxs(View,{style:rt.row,children:[jsxs(View,{style:rt.col,children:[jsx(Text,{style:[rt.label,{color:p.labelColor,fontFamily:w.medium}],children:s}),jsxs(TouchableOpacity,{style:[rt.selectButton,_],onPress:()=>!i&&e.length>0&&h(true),activeOpacity:.7,disabled:i||e.length===0,children:[i?jsx(Text,{style:[rt.placeholder,{color:p.subtitleColor,fontFamily:w.regular}],children:"Loading..."}):d?jsxs(View,{style:rt.selectedItem,children:[jsx(Image,{source:{uri:oe(Te(d,"png"))},style:rt.icon}),jsx(Text,{style:[rt.selectedText,{color:p.titleColor,fontFamily:w.medium}],numberOfLines:1,children:d.symbol})]}):jsx(Text,{style:[rt.placeholder,{color:p.subtitleColor,fontFamily:w.regular}],children:"Select receive token"}),jsx(Gt,{size:16,color:p.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:rt.col,children:[jsx(Text,{style:[rt.label,{color:p.labelColor,fontFamily:w.medium}],children:a}),jsxs(TouchableOpacity,{style:[rt.selectButton,_,(!d||C.length===0)&&rt.disabled],onPress:()=>!i&&d&&C.length>0&&b(true),activeOpacity:.7,disabled:i||!d||C.length===0,children:[x?jsxs(View,{style:rt.selectedItem,children:[jsx(Image,{source:{uri:oe(Te(x,"png"))},style:rt.icon}),jsx(Text,{style:[rt.selectedText,{color:p.titleColor,fontFamily:w.medium}],numberOfLines:1,children:x.chain_name})]}):jsx(Text,{style:[rt.placeholder,{color:p.subtitleColor,fontFamily:w.regular}],children:"Chain"}),jsx(Gt,{size:16,color:p.actionColor,strokeWidth:2})]})]}),jsxs(bt,{visible:g,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:u,children:[jsxs(View,{style:rt.pickerHeader,children:[jsx(View,{style:rt.pickerHeaderSpacer}),jsx(Text,{style:[rt.pickerTitle,{color:T.foreground,fontFamily:w.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:rt.pickerHeaderClose,onPress:()=>h(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(rs,{data:e,keyExtractor:k=>k.symbol,contentContainerStyle:rt.listContent,showsVerticalScrollIndicator:false,renderItem:({item:k})=>jsxs(TouchableOpacity,{style:[rt.pickerItem,{backgroundColor:k.symbol===t?T.cardHover:"transparent"}],onPress:()=>{o(k.symbol),h(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:oe(Te(k,"png"))},style:rt.pickerIcon}),jsx(Text,{style:[rt.pickerItemText,{color:T.foreground,fontFamily:w.medium}],children:k.symbol}),jsx(Text,{style:[rt.pickerItemSub,{color:T.foregroundMuted,fontFamily:w.regular}],children:k.name}),k.symbol===t&&jsx(Le,{size:18,color:T.primary,strokeWidth:2.5})]})})]}),jsxs(bt,{visible:S,onClose:()=>b(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c,borderTopRightRadius:y,children:[jsxs(View,{style:rt.pickerHeader,children:[jsx(View,{style:rt.pickerHeaderSpacer}),jsx(Text,{style:[rt.pickerTitle,{color:T.foreground,fontFamily:w.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:rt.pickerHeaderClose,onPress:()=>b(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(rs,{data:C,keyExtractor:k=>Uu(k.chain_id,k.chain_type),contentContainerStyle:rt.listContent,showsVerticalScrollIndicator:false,renderItem:({item:k})=>{let v=Uu(k.chain_id,k.chain_type);return jsxs(TouchableOpacity,{style:[rt.pickerItem,{backgroundColor:v===r?T.cardHover:"transparent"}],onPress:()=>{n(v),b(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:oe(Te(k,"png"))},style:rt.pickerIcon}),jsx(Text,{style:[rt.pickerItemText,{color:T.foreground,fontFamily:w.medium}],children:k.chain_name}),v===r&&jsx(Le,{size:18,color:T.primary,strokeWidth:2.5})]})}})]})]})}var rt=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 Hu(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:i,enabled:s=true}=e,a=n?.trim()||"",l=!!t&&!!r&&!!o&&a.length>0;return Sn({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,a,i],queryFn:()=>ad({chain_type:t,chain_id:r,token_address:o,recipient_address:a},i),enabled:s&&l,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function bC(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function CC(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("."),i=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(i)).toString()}function wC(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Fc({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:i,sourceTokenIconUrl:s,recipientAddressProp:a,selectedToken:l,selectedChain:u,balanceData:c,isLoadingBalance:y,minimumWithdrawAmountUsd:T,estimatedProcessingTime:w,maxSlippagePercent:m,priceImpactPercent:g,canWithdraw:h,onDepositWalletCreation:S,onWithdraw:b,onWithdrawError:p,onWithdrawSubmitted:d,onViewTracker:C}){let x="https://unifold.io/terms",_="https://unifold.io/support",{colors:k,fonts:v,components:M}=V(),[W,O]=useState(a||""),[F,U]=useState(""),[j,le]=useState(false),[Ye,_e]=useState(null),[ne,we]=useState(false),[fe,Pe]=useState(""),$e=useRef(null);useEffect(()=>{O(a||""),U(""),_e(null);},[a]);let ue=W.trim();useEffect(()=>{let me=setTimeout(()=>Pe(ue),500);return ()=>clearTimeout(me)},[ue]);let{data:J,isLoading:be,error:vt}=Hu({chainType:u?.chain_type,chainId:u?.chain_id,tokenAddress:u?.token_address,recipientAddress:fe,publishableKey:e,enabled:fe.length>5&&!!u}),ve=ue!==fe,qe=useMemo(()=>!ue||ue.length<=5||ve||be?null:vt?"Invalid address":J&&!J.valid?J.failure_code==="account_not_found"?`Account not found on ${u?.chain_name}`:J.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${u?.chain_name}`:"Invalid address":null,[ue,ve,be,vt,J,u,l]),Ne=!ve&&!!J?.valid&&!qe,Ve=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),ze=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),it=n||c?.symbol||"TOKEN",ie=c?.decimals??6,pe=useMemo(()=>{let me=parseFloat(F);return !me||me<=0?0:me},[F]),et=useMemo(()=>{let me=parseFloat(F);return !me||me<=0?0:me*Ve},[F,Ve]),Ae=useCallback(async()=>{try{let je=await hh("expo-clipboard").getStringAsync();je&&(O(je.trim()),_e(null));}catch{}},[]),Ke=useCallback(()=>{ze<=0||U(c?.balanceHuman??"0");},[ze,c]),$t=T!==null&&et>0&&et<T,Ee=pe>0&&ze>0&&pe>ze,Oe=ue.length>0&&F.trim().length>0&&pe>0&&Ne&&!$t&&!Ee&&!!c,ar=useCallback(async()=>{if(!(!l||!u||!Oe||!h)){le(true),_e(null);try{let me=await S({destinationChainType:u.chain_type,destinationChainId:u.chain_id,destinationTokenAddress:u.token_address,recipientAddress:ue}),je=CC(pe,ie),Vt=wC(pe,ie),ot={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:it,sourceTokenIconUrl:s,destinationChainType:u.chain_type,destinationChainId:u.chain_id,destinationTokenAddress:u.token_address,destinationTokenSymbol:l.symbol,destinationChainName:u.chain_name,destinationTokenIconUrl:l?oe(Te(l,"png")):void 0,amount:Vt,amountBaseUnit:je,submittedAt:new Date,withdrawIntentAddress:me.address,recipientAddress:ue};await b(ot),d(ot);}catch(me){let je=me instanceof Error?me.message:"Withdrawal failed. Please try again.",Vt=je.length>120?"Withdrawal failed. Please try again.":je;_e(Vt),p?.({message:je,error:me,code:"WITHDRAW_FAILED"});}finally{le(false);}}},[l,u,Oe,h,ue,t,r,o,it,s,F,ze,c,pe,ie,et,S,b,p,d]),he=M.input,X=M.card,Ce=M.button,pt=qe?k.error:he.borderColor,It=useMemo(()=>j?"Processing...":Ee?"Insufficient balance":$t?`Minimum $${T?.toFixed(2)}`:Ye?"Withdrawal failed \u2014 try again":"Withdraw",[j,Ee,$t,T,Ye]);return jsxs(View,{style:Xe.container,children:[jsxs(View,{children:[jsxs(View,{style:Xe.labelRow,children:[jsx(Text,{style:[Xe.label,{color:X.labelColor,fontFamily:v.medium}],children:"Recipient address"}),(ve||be)&&ue.length>5?jsx(ActivityIndicator,{size:"small",color:k.primary}):jsx(TouchableOpacity,{onPress:Ae,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(rp,{size:16,color:k.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Xe.inputRow,{backgroundColor:he.backgroundColor,borderRadius:he.borderRadius,borderWidth:he.borderWidth,borderColor:pt}],children:jsx(TextInput,{style:[Xe.textInput,{color:he.textColor,fontFamily:v.regular}],placeholder:"Enter wallet address",placeholderTextColor:he.placeholderColor,value:W,onChangeText:me=>{O(me),_e(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>$e.current?.focus()})}),qe?jsx(Text,{style:[Xe.errorText,{color:k.error,fontFamily:v.regular}],children:qe}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Xe.label,{color:X.labelColor,fontFamily:v.medium,paddingBottom:8}],children:["Amount",T!=null&&T>0&&jsx(Text,{style:{color:k.warning,fontFamily:v.regular},children:` ($${T.toFixed(2)} min)`})]}),jsxs(View,{style:[Xe.amountRow,{backgroundColor:he.backgroundColor,borderRadius:he.borderRadius,borderWidth:he.borderWidth,borderColor:he.borderColor}],children:[jsx(TextInput,{ref:$e,style:[Xe.amountInput,{color:he.textColor,fontFamily:v.regular}],placeholder:"0.00",placeholderTextColor:he.placeholderColor,value:F,onChangeText:me=>{(me===""||/^\d*\.?\d*$/.test(me))&&(U(me),_e(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[Xe.unitLabel,{color:k.foregroundMuted,fontFamily:v.medium}],children:it}),jsx(TouchableOpacity,{style:[Xe.maxButton,{backgroundColor:`${k.primary}20`}],onPress:Ke,activeOpacity:.7,children:jsx(Text,{style:[Xe.maxText,{color:k.primary,fontFamily:v.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Xe.detailsCard,{marginTop:24,backgroundColor:X.backgroundColor,borderRadius:X.borderRadius,borderWidth:X.borderWidth||1,borderColor:X.borderColor}],children:[jsx(TouchableOpacity,{style:Xe.detailsToggle,onPress:()=>we(!ne),activeOpacity:.7,children:jsxs(View,{style:Xe.detailsRow,children:[jsx(View,{style:[Xe.detailIcon,{backgroundColor:X.iconBackgroundColor,borderRadius:X.iconContainerBorderRadius}],children:jsx(Nr,{size:12,color:X.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Xe.detailsLabel,{color:X.titleColor,fontFamily:v.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:v.medium},children:bC(w)})]}),jsx(View,{style:{transform:[{rotate:ne?"180deg":"0deg"}]},children:jsx(Gt,{size:16,color:X.actionColor,strokeWidth:2})})]})}),ne&&jsxs(View,{style:Xe.detailsExpanded,children:[jsxs(View,{style:Xe.detailsRow,children:[jsx(View,{style:[Xe.detailIcon,{backgroundColor:X.iconBackgroundColor,borderRadius:X.iconContainerBorderRadius}],children:jsx(jr,{size:12,color:X.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Xe.detailsLabel,{color:X.titleColor,fontFamily:v.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:v.medium},children:["Auto \u2022 ",(m??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Xe.detailsRow,children:[jsx(View,{style:[Xe.detailIcon,{backgroundColor:X.iconBackgroundColor,borderRadius:X.iconContainerBorderRadius}],children:jsx(An,{size:12,color:X.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Xe.detailsLabel,{color:X.titleColor,fontFamily:v.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:v.medium},children:[(g??0).toFixed(2),"%"]})]})]})]})]}),Ye&&jsx(Text,{style:[Xe.errorText,{color:k.error,fontFamily:v.regular,textAlign:"center"}],children:Ye}),jsxs(View,{style:Xe.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Xe.withdrawButton,{backgroundColor:Ce.primaryBackground,borderRadius:Ce.borderRadius,borderWidth:Ce.borderWidth,borderColor:Ce.borderColor,opacity:!Oe||!h||j?.5:1}],onPress:ar,disabled:!Oe||!h||j,activeOpacity:.8,children:[j&&jsx(ActivityIndicator,{size:"small",color:Ce.primaryText}),jsx(Text,{style:[Xe.withdrawButtonText,{color:Ce.primaryText,fontFamily:v.medium}],children:It})]}),jsxs(View,{style:Xe.footerRow,children:[jsxs(TouchableOpacity,{style:Xe.historyLink,onPress:C,activeOpacity:.7,children:[jsx(Nr,{size:14,color:k.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Xe.historyText,{color:k.foregroundMuted,fontFamily:v.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Xe.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(x),activeOpacity:.7,children:jsx(Text,{style:[Xe.legalText,{color:k.foregroundMuted,fontFamily:v.regular}],children:"Terms"})}),jsx(Text,{style:[Xe.legalSeparator,{color:k.foregroundMuted,fontFamily:v.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[Xe.legalText,{color:k.foregroundMuted,fontFamily:v.regular}],children:"Help"})})]})]})]})]})}var Xe=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 TC(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 xC(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Lc({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=V(),i=n.depositTracker.executionRow.card,s=e.status==="pending"||e.status==="waiting"||e.status==="delayed",a=e.status==="failed"||e.status==="refunded",l=a?r.error:s?r.warning:r.success,u=oe(Te(e.destination_token_metadata,"png")||cr("/icons/tokens/png/usdc.png")),c=a?"Withdrawal Failed":s?"Withdrawal Processing":"Withdrawal Completed",y=TC(e.created_at||new Date().toISOString()),T=xC(e.source_amount_usd);return jsxs(Cr,{cardTokens:i,onPress:t,contentStyle:Dn.container,children:[jsxs(View,{style:Dn.iconContainer,children:[jsx(Image,{source:{uri:u},style:Dn.tokenIcon}),jsx(View,{style:[Dn.statusBadge,{backgroundColor:l,borderColor:i.backgroundColor}],children:a?jsx(ea,{size:12,color:"#FFFFFF",strokeWidth:2.5}):s?jsx(Xi,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Le,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Dn.textContainer,children:[jsx(Text,{style:[Dn.title,{color:i.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[Dn.dateTime,{color:i.subtitleColor,fontFamily:o.regular}],children:y})]}),jsxs(View,{style:Dn.rightContainer,children:[jsx(Text,{style:[Dn.amount,{color:i.textRightColor,fontFamily:o.medium}],children:T}),jsx(_r,{size:20,color:i.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},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function $u(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(),i=t.getFullYear(),s=t.getHours(),a=t.getMinutes(),l=s>=12?"PM":"AM";s=s%12||12;let u=a<10?`0${a}`:`${a}`;return `${o} ${n}, ${i} at ${s}:${u} ${l}`}catch{return e}}function Zf(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 RC(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 Xf(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function eh(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}=V(),i=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:He.detailRow,children:[jsx(Text,{style:[He.detailLabel,{color:i.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[He.detailValue,{color:i.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[He.divider,{backgroundColor:i.borderColor}]})]})}function Ku({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:i}){let{colors:s,fonts:a,components:l}=V(),[u,c]=useState([]),[y,T]=useState(!!n),w=l.card,m=l.button,g=l.header,h=l.container;useEffect(()=>{sd().then(le=>c(le.data)).catch(()=>{});},[]),useEffect(()=>{T(!!n);},[e?.id]);let S=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,b=e?e.status==="failed"||e.status==="refunded":false,p=b?s.error:S?s.warning:s.success,d=b?"Failed":S?"Processing":"Completed",C=e?.destination_token_metadata?oe(Te(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?oe(t.destinationTokenIconUrl):oe(cr("/icons/tokens/png/usdc.png")),x=e?.created_at?$u(e.created_at):t.submittedAt?$u(t.submittedAt.toISOString()):$u(new Date().toISOString()),_=e?`${Zf(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Xf(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,k=e?`${Zf(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Xf(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,v=e?RC(e.source_amount_usd,e.source_amount_base_unit):"$0.00",M=e?ml(u,e.source_chain_type,e.source_chain_id):t.sourceChainId,W=e?ml(u,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,F=e?.explorer_url,U=e?.destination_transaction_hashes?.[0],j=e?.destination_explorer_url;return jsxs(at,{style:He.scroll,contentContainerStyle:He.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:He.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Zi,{size:22,color:g.buttonColor,strokeWidth:2})}):jsx(View,{style:He.headerSpacer}),jsx(Text,{style:[He.headerTitle,{color:g.titleColor,fontFamily:a.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:He.headerSpacer}):jsx(TouchableOpacity,{onPress:i??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:g.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:He.iconContainer,children:[jsx(Image,{source:{uri:C},style:He.tokenIcon}),jsx(View,{style:[He.statusBadge,{backgroundColor:p}],children:b?jsx(ea,{size:10,color:"#FFFFFF",strokeWidth:3}):S?jsx(View,{style:He.spinnerDot}):jsx(Le,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:He.statusRow,children:[jsx(View,{style:[He.statusDot,{backgroundColor:p}]}),jsx(Text,{style:[He.statusText,{color:p,fontFamily:a.medium}],children:d})]}),jsx(Text,{style:[He.dateText,{color:h.subtitleColor,fontFamily:a.regular}],children:x}),jsxs(View,{style:[He.detailsCard,{backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,borderWidth:w.borderWidth??1,borderColor:w.borderColor}],children:[jsx(Ka,{label:"Amount Sent",value:_}),jsx(Ka,{label:"Amount Received",value:k}),jsx(Ka,{label:"USD Value",value:v}),jsx(Ka,{label:"Source Network",value:M}),jsx(Ka,{label:"Destination Network",value:W,isLast:true})]}),jsxs(TouchableOpacity,{style:He.moreDetailsRow,onPress:()=>T(le=>!le),activeOpacity:.7,children:[jsx(Text,{style:[He.moreDetailsText,{color:h.actionTitle,fontFamily:a.regular}],children:y?"See less":n?"See more":"See more details"}),y?jsx(Vo,{size:16,color:h.actionColor,strokeWidth:2}):jsx(Gt,{size:16,color:h.actionColor,strokeWidth:2})]}),y&&jsx(View,{style:[He.detailsCard,{backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,borderWidth:w.borderWidth??1,borderColor:w.borderColor}],children:O&&F?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:He.txRow,onPress:()=>Linking.openURL(F),activeOpacity:.7,children:[jsx(Text,{style:[He.txLabel,{color:w.subtitleColor,fontFamily:a.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[He.txHash,{color:w.titleColor,fontFamily:a.regular}],children:eh(O)}),jsx(Do,{size:14,color:w.actionColor,strokeWidth:2})]}),!S&&U&&j&&jsxs(Fragment,{children:[jsx(View,{style:[He.divider,{backgroundColor:w.borderColor}]}),jsxs(TouchableOpacity,{style:He.txRow,onPress:()=>Linking.openURL(j),activeOpacity:.7,children:[jsx(Text,{style:[He.txLabel,{color:w.subtitleColor,fontFamily:a.regular}],children:"Completion Tx"}),jsx(Text,{style:[He.txHash,{color:w.titleColor,fontFamily:a.regular}],children:eh(U)}),jsx(Do,{size:14,color:w.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:He.detailRow,children:jsx(Text,{style:[He.detailLabel,{color:w.subtitleColor,fontFamily:a.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:He.buttonRow,children:[jsx(TouchableOpacity,{style:[He.button,He.halfButton,{backgroundColor:m.secondaryBackground,borderRadius:m.borderRadius,borderWidth:m.borderWidth,borderColor:m.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[He.buttonText,{color:m.secondaryText,fontFamily:a.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[He.button,He.halfButton,{backgroundColor:m.primaryBackground,borderRadius:m.borderRadius,borderWidth:m.borderWidth,borderColor:m.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[He.buttonText,{color:m.primaryText,fontFamily:a.medium}],children:"Close"})})]})]})}var He=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 th(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Bc({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:i,components:s}=V(),a=t.length>0?t[t.length-1]:null,l=a?.status==="succeeded",u=a?.status==="failed",c={borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor};return l?jsxs(View,{style:Dt.container,children:[jsx(TouchableOpacity,{style:Dt.closeButton,onPress:r,children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Dt.iconRing,{backgroundColor:n.successBackground}],children:jsx(Le,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[Dt.title,{color:n.foreground,fontFamily:i.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[Dt.subtitle,{color:n.foregroundMuted,fontFamily:i.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",th(e.recipientAddress)]}),jsxs(View,{style:Dt.buttonRow,children:[jsx(TouchableOpacity,{style:[Dt.button,Dt.halfButton,c,{backgroundColor:s.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Dt.buttonText,{color:s.button.secondaryText,fontFamily:i.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[Dt.button,Dt.halfButton,c,{backgroundColor:s.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Dt.buttonText,{color:s.button.primaryText,fontFamily:i.medium}],children:"Close"})})]})]}):u?jsxs(View,{style:Dt.container,children:[jsx(TouchableOpacity,{style:Dt.closeButton,onPress:r,children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Dt.iconRing,{backgroundColor:n.errorBackground}],children:jsx(st,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[Dt.title,{color:n.foreground,fontFamily:i.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[Dt.subtitle,{color:n.foregroundMuted,fontFamily:i.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[Dt.button,Dt.fullButton,c,{backgroundColor:s.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Dt.buttonText,{color:s.button.primaryText,fontFamily:i.medium}],children:"Close"})})]}):jsxs(View,{style:Dt.container,children:[jsx(TouchableOpacity,{style:Dt.closeButton,onPress:r,children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})}),jsx(nt,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:oe(e.sourceTokenIconUrl)},style:Dt.tokenIconFill}):jsx(View,{style:[Dt.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[Dt.title,{color:n.foreground,fontFamily:i.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[Dt.subtitle,{color:n.foregroundMuted,fontFamily:i.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",th(e.recipientAddress)]})]})}var Dt=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 DC(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:oe(Te(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:oe(Te(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 rh=(e,t)=>`${t}:${e}`;function VC(){let{colors:e}=V(),t=useRef(new Animated.Value(.5)).current,r=e.cardHover;return useEffect(()=>{let o=Animated.loop(Animated.sequence([Animated.timing(t,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(t,{toValue:.5,duration:800,useNativeDriver:true})]));return o.start(),()=>o.stop()},[t]),jsx(View,{style:{gap:12,paddingHorizontal:16},children:[1,2,3].map(o=>jsx(Animated.View,{style:{height:48,borderRadius:12,backgroundColor:r,opacity:t}},o))})}function Ec({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:i,defaultDestinationChainType:s,defaultDestinationChainId:a,defaultDestinationTokenAddress:l,modalTitle:u="Withdraw Crypto",onWithdraw:c,onWithdrawSuccess:y,onWithdrawError:T,heightPercent:w=.94,sheetBorderRadius:m,sourceChainType:g,sourceChainId:h,sourceTokenAddress:S,sourceTokenSymbol:b,sourceChainName:p,sourceTokenIconUrl:d}){let{colors:C,fonts:x}=V(),[_,k]=useState("form"),[v,M]=useState(g),[W,O]=useState(h),[F,U]=useState(S),[j,le]=useState(b),[Ye,_e]=useState(p),[ne,we]=useState(d),[fe,Pe]=useState(null),[$e,ue]=useState(null),[J,be]=useState(null),[vt,ve]=useState(),[qe,Ne]=useState([]),[Ve,ze]=useState(null),[it,ie]=useState("form"),pe=useRef(new Animated.Value(Dimensions.get("window").width)).current,et=useRef(null),Ae=!!v&&!!W&&!!F,{data:Ke,isLoading:$t}=Pc(r,e&&_==="form"),Ee=Ke?.data??[],{data:Oe,isLoading:ar}=Eu({sourceChainType:v,sourceChainId:W,sourceTokenAddress:F,sourceTokenSymbol:j,publishableKey:r,enabled:e&&Ae&&_==="form"}),{data:he,isLoading:X}=Mu({address:n,chainType:v,chainId:W,tokenAddress:F,publishableKey:r,enabled:e&&Ae}),{executions:Ce}=zu({userId:o,publishableKey:r,depositWalletId:vt,enabled:!!vt&&e,onWithdrawSuccess:y,onWithdrawError:T});useEffect(()=>{if(!e||_!=="tracker")return;let ce=false;return pn(o,r,"withdraw").then(xt=>{ce||Ne(xt.data);}).catch(console.error),()=>{ce=true;}},[e,_,o,r]),useEffect(()=>{e&&(et.current&&(clearTimeout(et.current),et.current=null),k("form"),M(g),O(h),U(S),le(b),_e(p),we(d),Pe(null),ue(null),be(null),ve(void 0),Ne([]),ze(null),ie("form"),pe.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{et.current&&clearTimeout(et.current);},[]),useEffect(()=>{ne||Oe?.iconUrl&&we(Oe.iconUrl);},[Oe?.iconUrl,ne]),useEffect(()=>{Ye||Oe?.chainName&&_e(Oe.chainName);},[Oe?.chainName,Ye]),useEffect(()=>{if(!Ee.length||fe)return;let ce,xt;if(s&&a)if(l)for(let Ct of Ee){let z=Ct.chains.find(Xr=>Xr.chain_type===s&&Xr.chain_id===a&&Xr.token_address.toLowerCase()===l.toLowerCase());if(z){ce=Ct,xt=z;break}}else for(let Ct of Ee){let z=Ct.chains.find(Xr=>Xr.chain_type===s&&Xr.chain_id===a);if(z){ce=Ct,xt=z;break}}ce||(ce=Ee[0]),ce&&(Pe(ce),ue(xt??ce.chains[0]??null));},[Ee,fe,s,a,l]),useEffect(()=>{_==="confirming"&&Ce.length>0&&k("details");},[_,Ce]);let pt=useCallback(()=>{t(),et.current=setTimeout(()=>{k("form"),M(g),O(h),U(S),le(b),_e(p),we(d),Pe(null),ue(null),be(null),ve(void 0),Ne([]),ze(null),ie("form"),et.current=null;},300);},[t,g,h,S,b,p,d]),It=useCallback(ce=>{let xt=Ee.find(Ct=>Ct.symbol===ce);xt&&(Pe(xt),xt.chains.length>0&&ue(xt.chains[0]));},[Ee]),me=useCallback(ce=>{if(!fe)return;let xt=fe.chains.find(Ct=>rh(Ct.chain_id,Ct.chain_type)===ce);xt&&ue(xt);},[fe]),je=useCallback(async ce=>{let xt=await dn({external_user_id:o,destination_chain_type:ce.destinationChainType,destination_chain_id:ce.destinationChainId,destination_token_address:ce.destinationTokenAddress,recipient_address:ce.recipientAddress,action_type:"withdraw"},r),Ct=un(xt.data,v??"");if(!Ct)throw new Error(`No deposit wallet found for chain type: ${v}`);return ve(Ct.id),{id:Ct.id,address:Ct.address}},[o,r,v]),Vt=useCallback(ce=>{be(ce),k("confirming");},[]),ot=useCallback(ce=>{ze(ce),pe.setValue(Dimensions.get("window").width),Animated.timing(pe,{toValue:0,duration:280,useNativeDriver:true}).start();},[pe]),Lt=useCallback(()=>{Animated.timing(pe,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>ze(null));},[pe]),Bt=$t||ar,yt=Oe?.isSupported??null,Se=_==="confirming"?"Withdrawal Status":u,Z=m?.globalBorderTopLeftRadius,Q=m?.globalBorderTopRightRadius,L=m?.main?.borderTopLeftRadius??Z,I=m?.main?.borderTopRightRadius??Q,D=m?.tokenSelector?.borderTopLeftRadius??Z,q=m?.tokenSelector?.borderTopRightRadius??Q,Fe=m?.chainSelector?.borderTopLeftRadius??Z,ke=m?.chainSelector?.borderTopRightRadius??Q,pr=(()=>{if(_!=="form"||!Ae||X||!he)return;let ce=j||he.symbol,xt=he.balanceUsd;if(xt!=null){let Xr=`$${parseFloat(xt).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return ce?`Balance: ${Xr} ${ce}`:`Balance: ${Xr}`}let Ct=he.balanceHuman;if(!(!Ct||Ct==="0"))return ce?`Balance: ${Ct} ${ce}`:`Balance: ${Ct}`})();return jsx(bt,{visible:e,onClose:pt,closeOnBackdropPress:false,enablePanDownToClose:_==="tracker"||_==="form",showHandle:_==="tracker"||_==="form",heightPercent:_==="confirming"?.3:_==="details"?.7:_==="tracker"?.6:w,maxHeightPercent:_==="tracker"?.9:void 0,borderTopLeftRadius:L,borderTopRightRadius:I,children:_==="confirming"&&J?jsx(Bc,{txInfo:J,executions:Ce,onClose:pt,onViewTracker:()=>{ie("confirming"),k("tracker");}}):_==="details"&&J?jsx(Ku,{execution:Ce.length>0?Ce[Ce.length-1]:null,txInfo:J,onClose:pt,onViewHistory:()=>{ie("details"),k("tracker");},onHeaderClose:()=>k("form")}):_==="tracker"?jsxs(View,{style:nn.trackerContainer,children:[jsx(Ur,{title:"Withdrawal History",onClose:()=>k(it)}),qe.length===0?jsx(View,{style:nn.emptyState,children:jsx(Text,{style:[nn.emptyText,{color:C.foregroundMuted,fontFamily:x.regular}],children:"No withdrawals to track yet"})}):jsx(rs,{data:qe,keyExtractor:ce=>ce.id,contentContainerStyle:nn.listContent,showsVerticalScrollIndicator:false,renderItem:({item:ce})=>jsx(Lc,{execution:ce,onPress:()=>ot(ce)})}),Ve&&jsx(Animated.View,{style:[nn.historyDetailOverlay,{backgroundColor:C.background,transform:[{translateX:pe}]}],children:jsx(Ku,{execution:Ve,txInfo:DC(Ve),onClose:pt,onBack:Lt,onViewHistory:Lt})})]}):jsxs(Fragment,{children:[jsx(Ur,{title:Se,subtitle:pr,onClose:pt}),Bt?jsx(VC,{}):yt===false?jsxs(View,{style:nn.unsupportedContainer,children:[jsx(Text,{style:[nn.unsupportedTitle,{color:C.foreground,fontFamily:x.medium}],children:"Unsupported Token"}),jsx(Text,{style:[nn.unsupportedMessage,{color:C.foregroundMuted,fontFamily:x.regular}],children:Oe?.errorMessage})]}):jsx(LC,{publishableKey:r,sourceChainType:v??"",sourceChainId:W??"",sourceTokenAddress:F??"",sourceTokenSymbol:j,sourceChainName:Ye,sourceTokenIconUrl:ne,recipientAddressProp:i,destinationTokens:Ee,selectedToken:fe,selectedChain:$e,selectedChainKey:$e?rh($e.chain_id,$e.chain_type):null,onTokenChange:It,onChainChange:me,tokensLoading:$t,balanceData:he??null,isLoadingBalance:X,sourceValidation:Oe??null,onDepositWalletCreation:je,onWithdraw:c,onWithdrawError:T,onWithdrawSubmitted:Vt,onViewTracker:()=>{ie("form"),k("tracker");},tokenSelectorLeft:D,tokenSelectorRight:q,chainSelectorLeft:Fe,chainSelectorRight:ke})]})})}function LC({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:i,sourceTokenIconUrl:s,recipientAddressProp:a,destinationTokens:l,selectedToken:u,selectedChain:c,selectedChainKey:y,onTokenChange:T,onChainChange:w,tokensLoading:m,balanceData:g,isLoadingBalance:h,sourceValidation:S,onDepositWalletCreation:b,onWithdraw:p,onWithdrawError:d,onWithdrawSubmitted:C,onViewTracker:x,tokenSelectorLeft:_,tokenSelectorRight:k,chainSelectorLeft:v,chainSelectorRight:M}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(at,{style:{flex:1,paddingTop:16},contentContainerStyle:nn.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:nn.doubleInputWrapper,children:jsx(qa,{tokens:l,selectedTokenSymbol:u?.symbol??null,selectedChainKey:y,onTokenChange:T,onChainChange:w,isLoading:m,tokenPickerBorderTopLeftRadius:_,tokenPickerBorderTopRightRadius:k,chainPickerBorderTopLeftRadius:v,chainPickerBorderTopRightRadius:M})}),jsx(Fc,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:i,sourceTokenIconUrl:s,recipientAddressProp:a,selectedToken:u,selectedChain:c,balanceData:g,isLoadingBalance:h,minimumWithdrawAmountUsd:S?.minimumAmountUsd??null,estimatedProcessingTime:S?.estimatedProcessingTime??null,maxSlippagePercent:S?.maxSlippagePercent??null,priceImpactPercent:S?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:b,onWithdraw:p,onWithdrawError:d,onWithdrawSubmitted:C,onViewTracker:x})]})})}var nn=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 ih=createContext(null);function jC({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new Xd({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,i]=useState(false),[s,a]=useState(null),[l,u]=useState(false),[c,y]=useState(null),T=useColorScheme(),w=useRef(false);w.current||(cl({publishableKey:t}),w.current=true);let m=useMemo(()=>{let F=r?.appearance||"dark";return F==="auto"?T==="dark"?"dark":"light":F},[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.'),cl({publishableKey:t});},[t]),useEffect(()=>()=>{h.current&&clearTimeout(h.current),x.current&&clearTimeout(x.current);},[]);let g=useRef(null),h=useRef(null),S=useCallback(F=>{h.current&&(clearTimeout(h.current),h.current=null),g.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),g.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),g.current=null);let U=new Promise((j,le)=>{g.current={resolve:j,reject:le};});return a(F),i(true),U},[]),b=useCallback(()=>{g.current&&(g.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),g.current=null),i(false),h.current=setTimeout(()=>{a(null),h.current=null;},200);},[]),p=useCallback(F=>{s?.onSuccess&&s.onSuccess(F),g.current&&(g.current.resolve(F),g.current=null);},[s]),d=useCallback(F=>{console.error("[UnifoldProvider] Deposit error:",F),s?.onError&&s.onError(F),g.current&&(g.current.reject(F),g.current=null);},[s]),C=useRef(null),x=useRef(null),_=useRef(void 0),k=useCallback(F=>{x.current&&(clearTimeout(x.current),x.current=null),C.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),C.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),C.current=null);let U=new Promise((j,le)=>{C.current={resolve:j,reject:le};});return _.current=F.onClose,y(F),u(true),U},[]),v=useCallback(()=>{C.current&&(C.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),C.current=null),_.current?.(),_.current=void 0,u(false),x.current=setTimeout(()=>{y(null),x.current=null;},200);},[]),M=useCallback(F=>{c?.onSuccess&&c.onSuccess(F),C.current&&(C.current.resolve(F),C.current=null);},[c]),W=useCallback(F=>{console.error("[UnifoldProvider] Withdraw error:",F),c?.onError&&c.onError(F),C.current&&(C.current.reject(F),C.current=null);},[c]),O=useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:b,beginWithdraw:k,closeWithdraw:v}),[t,S,b,k,v]);return jsx(ru,{client:o,children:jsx(ih.Provider,{value:O,children:jsxs(ts,{mode:m,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,s&&jsx(Ic,{visible:n,onClose:b,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:s.externalUserId,destinationChainType:s.destinationChainType,destinationChainId:s.destinationChainId,destinationTokenSymbol:s.destinationTokenSymbol,recipientAddress:s.recipientAddress,destinationTokenAddress:s.destinationTokenAddress,defaultChainType:s.defaultChainType,defaultChainId:s.defaultChainId,defaultTokenAddress:s.defaultTokenAddress,showBalance:s.showBalance,stripeOnrampEmail:s.stripeOnrampEmail,stripeOnrampPhone:s.stripeOnrampPhone,stripeTheme:{mode:m,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:s.depositConfirmationMode??"auto_ui",initialScreen:s.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?hm():void 0,onDepositSuccess:p,onDepositError:d,theme:m,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Ec,{visible:l,onClose:v,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:M,onWithdrawError:W,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function $C(){let e=useContext(ih);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
+ export{Pl as AmountScreen,bt as BottomSheet,Ol as KYCWizardScreen,Ul as OnrampScreen,Hl as StripeOnramp,mm as StripeOnrampPreconfigure,jC as UnifoldProvider,Te as getPreferredIcon,xl as getStripePublishableKey,fl as getSupportedDestinationTokens,oe as normalizeIconUrl,Nl as registerStripeOnramp,cp as setDevApiUrl,Tl as setStripeOnrampApiUrl,kl as setStripeOnrampPublishableKey,Na as useAllowedCountry,Fl as useStripeOnramp,V as useTheme,$C as useUnifold};