@unifold/connect-react-native 0.1.41-beta-001 → 0.1.41-beta-002

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import*as An from'react';import An__default,{createContext,useContext,useState,useRef,useCallback,useEffect,useMemo,useId,Fragment as Fragment$1}from'react';import {StyleSheet,ScrollView,useWindowDimensions,Platform,PanResponder,Modal,View,Pressable,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Image,Easing,Dimensions,Clipboard,Linking,FlatList}from'react-native';import Nt,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Polyline,Line,SvgXml,SvgUri}from'react-native-svg';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import au,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Wc from'@react-native-async-storage/async-storage';import Gh from'expo-constants';import Fg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var tu=e=>{throw TypeError(e)};var tf=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Xl=(e,t,r)=>t.has(e)||tu("Cannot "+r);var u=(e,t,r)=>(Xl(e,t,"read from private field"),r?r.call(e):t.get(e)),Z=(e,t,r)=>t.has(e)?tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(Xl(e,t,"write to private field"),t.set(e,r),r),Ae=(e,t,r)=>(Xl(e,t,"access private method"),r);var xs=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return u(e,t,o)}});var ec={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)"}},tc=ec;function ka(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function _s(e,t,r){let o=r?t?.[r]:void 0,n=(c,h,k)=>{let g=o?.[c]?.[h];if(g!==void 0)return g;let C=t?.[c]?.[h];return C!==void 0?C:k},a={backgroundColor:n("card","backgroundColor",e.card),titleColor:n("card","titleColor",e.foreground),subtitleColor:n("card","subtitleColor",e.foregroundMuted),labelColor:n("card","labelColor",e.foregroundMuted),headerColor:n("card","headerColor",e.foregroundMuted),labelRightColor:n("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:n("card","labelHighlightRightColor",e.warning),textRightColor:n("card","textRightColor",e.foreground),subtextRightColor:n("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:n("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:n("card","rowRightLabel",e.foreground),iconColor:n("card","iconColor",e.primary),iconBackgroundColor:n("card","iconBackgroundColor",e.primary+"26"),actionColor:n("card","actionColor",e.foregroundMuted),actionIcon:n("card","actionIcon",e.foregroundMuted),descriptionColor:n("card","descriptionColor",e.foregroundMuted),borderRadius:n("card","borderRadius",12),borderWidth:n("card","borderWidth",0),borderColor:n("card","borderColor",e.border),shadowColor:n("card","shadowColor","#000"),shadowOffset:n("card","shadowOffset",{width:0,height:-4}),shadowOpacity:n("card","shadowOpacity",0),shadowRadius:n("card","shadowRadius",12),elevation:n("card","elevation",0),iconContainerBorderRadius:n("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},i=(o?.depositMenu??t?.depositMenu)?.card,s=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,l=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,p=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:a,input:{backgroundColor:n("input","backgroundColor",n("search","backgroundColor",e.card)),textColor:n("input","textColor",n("search","inputColor",e.foreground)),placeholderColor:n("input","placeholderColor",n("search","placeholderColor",e.foregroundMuted)),borderColor:n("input","borderColor",e.border),borderRadius:n("input","borderRadius",n("search","borderRadius",8)),borderWidth:n("input","borderWidth",1)},button:{primaryBackground:n("button","primaryBackground",e.primary),primaryText:n("button","primaryText",e.primaryForeground),secondaryBackground:n("button","secondaryBackground",e.card),secondaryText:n("button","secondaryText",e.foreground),borderRadius:n("button","borderRadius",12),borderWidth:n("button","borderWidth",0),borderColor:n("button","borderColor",e.border)},container:{titleColor:n("container","titleColor",e.foreground),subtitleColor:n("container","subtitleColor",e.foregroundMuted),actionColor:n("container","actionColor",e.foregroundMuted),actionTitle:n("container","actionTitle",e.foregroundMuted),buttonColor:n("container","buttonColor",e.primary),buttonTitleColor:n("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:n("container","iconBackgroundColor",e.success),iconColor:n("container","iconColor",e.foreground)},search:{backgroundColor:n("search","backgroundColor",e.card),inputColor:n("search","inputColor",e.foreground),placeholderColor:n("search","placeholderColor",e.foregroundMuted),borderRadius:n("search","borderRadius",8)},list:{titleSectionColor:n("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:n("list","rowBorderRadius",12)},badge:{borderRadius:n("badge","borderRadius",8)},sheet:{shadowColor:n("sheet","shadowColor","#000"),shadowOffset:n("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:n("sheet","shadowOpacity",.1),shadowRadius:n("sheet","shadowRadius",12),elevation:n("sheet","elevation",16)},depositMenu:{card:ka(a,i)},transferCrypto:{depositAddress:{card:ka(a,s)}},depositCard:{quoteProvider:{card:ka(a,l)}},depositTracker:{executionRow:{card:ka(a,p)}}}}function rc(e,t,r){let n={...ec[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var oc=createContext(null);function O(){let e=useContext(oc);if(!e){let t=tc.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:_s(t,void 0,"dark"),isDark:true}}return e}function kt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=O(),l=a??s.warning,p=i??"#FBBF24",c=useRef(new Animated.Value(0)).current,h=useId(),k=useMemo(()=>`circularProgressGrad_${h.replace(/[^a-zA-Z0-9_-]/g,"")}`,[h]),g=(e-t)/2,C=2*Math.PI*g,S=e/2,y=o??Math.max(0,Math.round(e-t*2-8)),m=(e-y)/2;useEffect(()=>{let d=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return d.start(),()=>d.stop()},[c]);let 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(Nt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:k,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:p})]})}),jsx(Circle,{cx:S,cy:S,r:g,stroke:`url(#${k})`,strokeWidth:t,fill:"none",strokeDasharray:`${C*.75} ${C*.25}`,strokeLinecap:"round",rotation:-90,origin:`${S}, ${S}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:m+1.5,left:m,width:y,height:y},children:r}):null]})}function sc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Pi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function zr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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 Rs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function at({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Fi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{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 At({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function No({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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 Ue({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{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 Is({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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 ac({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"2",x2:"12",y2:"6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"18",x2:"12",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"12",x2:"6",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"18",y1:"12",x2:"22",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ko({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function gn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function xa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function To({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function _a({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function yn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ra({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function iu({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M11 14h10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 10l4 4-4 4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Di({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:a,components:i}){let s=useColorScheme(),l=useMemo(()=>t==="auto"?s==="dark"?"dark":"light":t,[t,s]),p=useMemo(()=>{let g=o?.[l];return rc(l,g,r)},[l,o,r]),c=useMemo(()=>_s(p,i,l),[p,i,l]),h=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]),k=useMemo(()=>({mode:l,colors:p,fonts:h,components:c,isDark:l==="dark"}),[l,p,h,c]);return jsx(oc.Provider,{value:k,children:e})}var Ds={damping:28,stiffness:300,mass:.8},Df=80,Vf=500;function ut({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:a=true,heightPercent:i,maxHeightPercent:s,startExpanded:l=false,noPadding:p=false,borderTopLeftRadius:c=24,borderTopRightRadius:h=24}){let{colors:k}=O(),{height:g}=useWindowDimensions(),[C,S]=useState(false),y=useRef(e);y.current=e;let m=useRef(0),b=i!=null&&i>=1,d=b||p?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:_,w=useSharedValue(g),x=useRef(null),W=useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),y.current||S(false);},[]);useEffect(()=>{e?(x.current&&(clearTimeout(x.current),x.current=null),S(true),w.value=withSpring(T,Ds)):C&&(w.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(()=>{C&&e&&(w.value=withSpring(T,Ds));},[T]);let D=useCallback(()=>{o&&t();},[o,t]),F=useMemo(()=>{if(!(!n&&!f))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{m.current=w.value;},onPanResponderMove:(N,ae)=>{if(Math.abs(ae.dy)<4)return;let ze=m.current+ae.dy;w.value=Math.max(0,ze);},onPanResponderRelease:(N,ae)=>{if(!(Math.abs(ae.dy)<4)){if(n&&(ae.dy>Df||ae.vy>Vf)){t();return}if(f){let ze=_/2,ve=w.value<ze?0:_;w.value=withSpring(ve,Ds);}else w.value=withSpring(T,Ds);}},onPanResponderTerminate:()=>{w.value=withSpring(T,Ds);}}).panHandlers},[n,f,_,T,w,t]),v=useAnimatedStyle(()=>({transform:[{translateY:w.value}]})),q=useAnimatedStyle(()=>({opacity:interpolate(w.value,[0,g*.5,g],[.5,.25,0],Extrapolation.CLAMP)}));return C?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:Kn.root,pointerEvents:e?"auto":"none",children:[jsx(au.View,{style:[Kn.backdrop,q],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:D})}),jsxs(au.View,{style:[Kn.sheet,v,{height:R,backgroundColor:k.background,borderTopLeftRadius:b?0:c,borderTopRightRadius:b?0:h}],children:[jsxs(GestureHandlerRootView,{style:Kn.gestureRoot,children:[a&&jsx(View,{style:Kn.handleContainer,pointerEvents:"none",children:jsx(View,{style:[Kn.handle,{backgroundColor:k.foreground+"33"}]})}),r,d>0&&jsx(View,{style:{height:d}})]}),F&&jsx(View,{...F,style:Kn.dragOverlay})]})]})}):null}var Kn=StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject,backgroundColor:"#000"},sheet:{overflow:"hidden"},gestureRoot:{flex:1},handleContainer:{alignItems:"center",paddingTop:10,paddingBottom:4,zIndex:1},dragOverlay:{position:"absolute",top:0,left:0,right:0,height:40,zIndex:2},handle:{width:36,height:5,borderRadius:2.5}}),gt=An__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));gt.displayName="BottomSheetScrollView";function Vi(e){return jsx(FlatList,{...e})}var Lf="https://api.unifold.io",pc="__UnifoldDevApiBaseUrl__",Rr="pk_test_123",Ia={};function Bf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[pc];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function tr(){return Bf()??Lf}function va(e){if(e.publishableKey!==void 0){if(!e.publishableKey||e.publishableKey.trim()==="")throw new Error("Unifold SDK: publishableKey cannot be empty. Please provide a valid publishable key.");!e.publishableKey.startsWith("pk_test_")&&!e.publishableKey.startsWith("pk_live_")&&console.warn('Unifold SDK: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),Rr=e.publishableKey;}e.defaultConfig&&(Ia=e.defaultConfig);}function cu(e){if(typeof __DEV__>"u"||!__DEV__){console.warn("[Unifold] setDevApiUrl() is only available in development mode");return}if(typeof globalThis>"u")return;let t=e.trim();t.length>0?globalThis[pc]=t:delete globalThis[pc];}function Vs(){return tr()}function Pa(){return Rr}function Ur(e){if(!e||e.trim()==="")throw new Error("Unifold SDK: No publishable key configured. Please provide a valid publishable key via setApiConfig() or pass it directly to the API function.");e==="pk_test_123"&&console.warn('Unifold SDK: Using default test key "pk_test_123". This should only be used for local development. Please use a real publishable key in production.');}function Yt(e){let t=e.startsWith("/")?e:`/${e}`;return `${tr()}/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+)?/,tr()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${tr()}${e}`:`${tr()}/api/public${e}`:""}async function $o(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||Ia.recipientAddress;if(!r)throw new Error("[Unifold] recipient_address is required for createDepositAddress. Pass recipientAddress in your beginDeposit() config.");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Ia.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Ia.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||Rr;Ur(n);let a=await fetch(`${tr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create deposit address: ${a.statusText}`);return await a.json()}function qo(e,t){return e.find(r=>r.chain_type===t)}async function Qo(e,t,r){let o=t||Rr;Ur(o);let n=await fetch(`${tr()}/v1/public/direct_executions/query`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify({external_user_id:e,...r&&{action_type:r}})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}async function Fa(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/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 Ce(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let r=e.icon_urls.find(o=>o.format===t);return r?r.url:e.icon_url}async function Gn(e,t){let r=e||Rr;Ur(r);let o=`${tr()}/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 mc(e,t){let r=t||Rr;Ur(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${tr()}/v1/public/tokens/token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch token metadata: ${n.statusText}`);return n.json()}function Oa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function fc(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/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 hc(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/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 gc(e,t){let r=t||Rr;Ur(r);let o=new URLSearchParams;e.country_code&&o.append("country_code",e.country_code),e.subdivision_code&&o.append("subdivision_code",e.subdivision_code),o.append("token_address",e.token_address),o.append("chain_id",e.chain_id),o.append("chain_type",e.chain_type);let n=await fetch(`${tr()}/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 yc(e){let t=e||Rr;Ur(t);let r=await fetch(`${tr()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch fiat currencies: ${r.statusText}`);return r.json()}function Li(e,t="png"){if(!e||e.length===0)return;let r=e.find(o=>o.format===t);return r?r.url:e[0]?.url}async function Ls(e){let t=e||Rr;Ur(t);let r=await fetch(`${tr()}/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 bc(){let e=await fetch(`${tr()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function Da(e,t,r){let o=e.find(a=>a.chain_id===r);if(o)return o.chain_name;let n=e.find(a=>a.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function Bs(){let e=await fetch(`${tr()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}async function Va(e){let t=e||Rr;Ur(t);let r=await fetch(`${tr()}/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 Cc(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/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 wc(e,t){return Fa(e.deposit_wallet_id,t)}async function La(e,t,r,o,n){let a=n||Rr;Ur(a);let i=await fetch(`${tr()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":a},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!i.ok)throw new Error(`Failed to fetch address balance: ${i.statusText}`);return i.json()}function uu({size:e=28}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxs(G,{fillRule:"evenodd",children:[jsx(Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsx(Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function mu({size:e=28}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#eth_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsx(Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsx(Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsx(Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsx(Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsx(Defs,{children:jsx(ClipPath,{id:"eth_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function gu({size:e=28}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#btc_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsx(Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsx(Defs,{children:jsx(ClipPath,{id:"btc_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function yu({size:e=28}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxs(Defs,{children:[jsxs(LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsx(Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxs(G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsx(Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsx(Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsx(Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function bu({size:e=28}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxs(G,{children:[jsx(Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsx(Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var Ba=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:uu},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:mu},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:gu},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:yu},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:bu}];function Aa(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Wa(e,t){let r=parseFloat(e);if(isNaN(r))return e;let o=t.toLowerCase(),n=["eth","btc"].includes(o)?4:2;return r.toFixed(n)}function Wi(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=Ba.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=Ba.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Jt({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:a}=O(),i=r==="back",s=i?jsx(Fi,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(at,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:bn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:i?"Back":"Close",children:s});return t?jsxs(View,{style:bn.headerWithTitle,children:[i?l:o??jsx(View,{style:bn.headerSide}),jsx(Text,{style:[bn.headerTitleText,{color:n.header.titleColor},...a.bold?[{fontFamily:a.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),i?jsx(View,{style:bn.headerSide}):l]}):jsxs(View,{style:i?bn.headerWithTitle:bn.header,children:[i?l:jsx(View,{style:bn.headerSpacer}),!i&&l]})}var Ea={paddingTop:8,paddingBottom:8},bn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ea},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ea},headerSpacer:{flex:1},headerSide:{width:28},headerTitleText:{flex:1,textAlign:"center",fontSize:17},closeBtn:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"}});function Ir({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=O();return e?jsx(Text,{style:[Cu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[Cu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var Cu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function fo({quote:e,label:t,value:r,last:o,hideDivider:n}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsx(Text,{style:[e.rowValue],children:r})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}function Rc({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=O(),p=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},c=Aa(r);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:c}),jsx(TouchableOpacity,{onPress:p,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx(Ue,{size:14,color:s.success,strokeWidth:2.5}):jsx(No,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Ma={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function Ms({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=O(),a=e.toLowerCase(),i=Ma[a]??n.primary,s=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:i,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:s,height:s,borderRadius:s/2,borderWidth:2,borderColor:n.background}}):null]})}function za({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=O(),p=Yt(`/icons/currencies/png/${e.toLowerCase()}.png`),c=Wi(r);return jsxs(View,{style:[eo.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:eo.step,children:[jsx(Image,{source:{uri:p},style:eo.iconImage}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(_r,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:eo.step,children:[jsxs(View,{style:eo.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:eo.tokenIcon}):jsx(View,{style:[eo.tokenIcon,{backgroundColor:Ma[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[eo.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var eo=StyleSheet.create({diagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",paddingVertical:20,paddingHorizontal:24,width:"100%"},step:{alignItems:"center"},iconImage:{width:24,height:24,borderRadius:12,marginBottom:4},iconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},tokenIcon:{width:24,height:24,borderRadius:12},networkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},label:{fontSize:10},value:{fontSize:14,fontWeight:"500",paddingTop:4}});function Ei(){let{colors:e,fonts:t,components:r}=O(),o=r.input,n=r.button,a=r.container,i=r.card,s=r.header;return useMemo(()=>{let l=i.borderRadius,p={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},content:{flex:1,paddingTop:16},title:{fontSize:28,color:s.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:e.foregroundSubtle,marginBottom:8,textTransform:"uppercase",letterSpacing:.5,...t.semibold?{fontFamily:t.semibold}:{}},input:{backgroundColor:o.backgroundColor,borderRadius:o.borderRadius,padding:16,fontSize:17,color:o.textColor,borderWidth:o.borderWidth,borderColor:o.borderColor,...t.regular?{fontFamily:t.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...t.regular?{fontFamily:t.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(l,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:a.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:a.buttonTitleColor,fontSize:17,...t.bold?{fontFamily:t.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...t.medium?{fontFamily:t.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},c={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...t.medium?{fontFamily:t.medium}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor},quickPillText:{fontSize:14,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},numpad:{gap:4,marginBottom:12},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:56,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...t.regular?{fontFamily:t.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...t.regular?{fontFamily:t.regular}:{}},paymentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,borderRadius:999,backgroundColor:"transparent",alignSelf:"flex-start",marginBottom:12},paymentRowHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:16,borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor,alignSelf:"center"},paymentLeft:{flexDirection:"row",alignItems:"center",gap:6},applePayIcon:{fontSize:20,color:e.foreground},paymentLabel:{fontSize:15,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},paymentHint:{fontSize:13,color:e.foregroundMuted,marginLeft:12,...t.regular?{fontFamily:t.regular}:{}},inlineError:{fontSize:13,color:e.error,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},inlineStatus:{fontSize:13,color:e.foregroundMuted,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},sheetContent:{flex:1,paddingHorizontal:24,paddingTop:8,paddingBottom:32,gap:12},sheetHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:4},sheetBackBtn:{width:32,height:32,borderRadius:16,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},sheetCloseBtn:{width:28,height:28,borderRadius:14,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitle:{fontSize:18,color:e.foreground,...t.bold?{fontFamily:t.bold}:{}},sheetOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border},sheetOptionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:12},sheetOptionIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},sheetOptionLabel:{fontSize:16,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},sheetOptionHint:{fontSize:13,color:e.foregroundMuted,marginTop:2,...t.regular?{fontFamily:t.regular}:{}},sheetLoading:{alignItems:"center",paddingVertical:32,gap:12},sheetStatusText:{fontSize:15,color:e.foregroundMuted,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},sheetError:{flex:1,justifyContent:"center",paddingVertical:20},sheetErrorText:{fontSize:14,color:e.error,textAlign:"center",lineHeight:20,...t.regular?{fontFamily:t.regular}:{}},addPaymentBtn:{marginTop:12,paddingVertical:14,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},h={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}:{}}},k=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:k,borderTopRightRadius:k,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:k,borderBottomRightRadius:k,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}:{}}},C={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"}},S={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:e.successBackground,borderWidth:2,borderColor:e.success,alignItems:"center",justifyContent:"center",marginBottom:28},heading:{fontSize:28,color:s.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:p,quote:h,pm:g,wallet:C,flow:S,amount:c}},[e,t,o,n,a,i,s])}var ku="",Tu;function Ua(e){ku=e;}function Ha(e){Tu=e;}function Dr(){let e=ku||Pa();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Vr(){return Tu??Vs()}async function Na(){let e=`${Vr()}/v1/public/onramps/headless/stripe/config`,t=Dr(),r=await fetch(e,{method:"GET",headers:{"x-publishable-key":t,"Content-Type":"application/json"}});if(!r.ok)throw new Error(`Failed to load Stripe config: ${r.status}`);let o=await r.json();if(!o?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return o.publishable_key}async function Ic(e){let t=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw new Error(`Failed to create auth intent: ${t.status}`);let r=await t.json();return r.auth_intent_id??r.id}async function xu(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e,...t&&{crypto_customer_id:t}})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function vc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e,...t&&{crypto_customer_id:t}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.message??`Failed to refresh OAuth token: ${r.status}`);return o}async function _u(e,t){let r={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},o=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await o.text();if(!o.ok)throw new Error(`Failed to create onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Ru(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}}),o=await r.text();if(!r.ok)throw new Error(`Failed to confirm onramp session: ${r.status} ${o}`);return JSON.parse(o)}async function ja(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp customer: ${o.status} ${n}`);return JSON.parse(n)}async function Iu(e){let t=`${Vr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e}}),o=await r.text();if(!r.ok)throw new Error(`Failed to list onramp sessions: ${r.status} ${o}`);return JSON.parse(o)}async function vu(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Pc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}});if(!r.ok){let o=await r.text();throw new Error(`Failed to refresh quote: ${r.status} ${o}`)}return r.json()}async function Pu(e){let t=new URLSearchParams({destinationNetwork:e.destinationNetwork,walletAddress:e.walletAddress});e.destinationTag&&t.set("destinationTag",e.destinationTag),e.cryptoCustomerId&&t.set("crypto_customer_id",e.cryptoCustomerId);let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e.accessToken}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch transaction limits: ${r.status} ${o}`)}return r.json()}async function Fc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch payment tokens: ${r.status} ${o}`)}return r.json()}async function Fu(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let t={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},r=await fetch(`${Vr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.status}`);return r.json()}function Cn(e,t){if(e?.length){let r=e.find(n=>n.format==="png");if(r)return r.url;let o=e.find(n=>n.format==="svg");if(o)return o.url}return t}async function Ou(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Dr()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function lh({size:e=24}){let t=e,r=e*(471/750);return jsxs(Nt,{width:t,height:r,viewBox:"0 0 750 471",children:[jsx(Rect,{width:"750",height:"471",rx:"40",fill:"#1A1F71"}),jsx(Path,{fill:"#FFFFFF",d:"M278.198,334.228l33.36-195.763h53.358l-33.384,195.763H278.198z"}),jsx(Path,{fill:"#FFFFFF",d:"M524.307,142.687c-10.57-3.966-27.135-8.222-47.822-8.222c-52.725,0-89.863,26.551-90.18,64.604c-0.297,28.129,26.514,43.821,46.754,53.185c20.77,9.597,27.752,15.716,27.652,24.283c-0.133,13.123-16.586,19.116-31.924,19.116c-21.355,0-32.701-2.967-50.225-10.274l-6.877-3.112l-7.488,43.823c12.463,5.466,35.508,10.199,59.438,10.445c56.09,0,92.502-26.248,92.916-66.884c0.199-22.27-14.016-39.216-44.801-53.188c-18.65-9.056-30.072-15.099-29.951-24.269c0-8.137,9.668-16.838,30.559-16.838c17.447-0.271,30.088,3.534,39.936,7.5l4.781,2.259L524.307,142.687"}),jsx(Path,{fill:"#FFFFFF",d:"M661.615,138.464h-41.23c-12.773,0-22.332,3.486-27.941,16.234l-79.244,179.402h56.031c0,0,9.16-24.121,11.232-29.418c6.123,0,60.555,0.084,68.336,0.084c1.596,6.854,6.492,29.334,6.492,29.334h49.512L661.615,138.464z M596.198,264.872c4.414-11.279,21.26-54.724,21.26-54.724c-0.314,0.521,4.381-11.334,7.074-18.684l3.607,16.878c0,0,10.217,46.729,12.352,56.527h-44.293V264.872z"}),jsx(Path,{fill:"#FFFFFF",d:"M45.879,138.465l-0.682,4.073c21.093,5.106,39.932,12.496,56.426,21.689l47.346,169.688h56.455l83.004-195.45h-56.526l-52.238,133.496l-5.564-27.131c-0.261-0.838-0.544-1.678-0.834-2.52L156.106,154.992c-3.229-12.396-12.597-16.095-24.186-16.528H45.879z"})]})}function ch({size:e=24}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",children:jsxs(G,{fill:"none",fillRule:"evenodd",children:[jsx(Circle,{cx:"7",cy:"12",r:"7",fill:"#EA001B"}),jsx(Circle,{cx:"17",cy:"12",r:"7",fill:"#FFA200",fillOpacity:.8})]})})}function dh({size:e=24}){return jsx(Nt,{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 Dc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(lh,{size:t}):o.includes("mastercard")?jsx(ch,{size:t}):o.includes("amex")||o.includes("american express")?jsx(dh,{size:t}):jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75})}var mh=[50,100,500],fh=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Bu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hh(e){return e.card?`${Bu(e.card.brand)} ${Bu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Wu(e){if(!e)return "";let t=new Date(e*1e3);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true})}var Eu={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function Mu(e,t){switch(e){case "fulfillment_complete":return "#22C55E";case "fulfillment_processing":case "requires_payment":return "#f59e0b";case "rejected":return "#ef4444";default:return t.foregroundMuted}}function gh({status:e,colors:t}){let r=Mu(e,t);return jsx(View,{style:{paddingHorizontal:8,paddingVertical:2,borderRadius:6,backgroundColor:r+"20"},children:jsx(Text,{style:{fontSize:11,color:r},children:Eu[e]??e})})}function yh({session:e,visible:t,onClose:r,borderTopLeftRadius:o,borderTopRightRadius:n}){let{colors:a,components:i,fonts:s}=O(),[l,p]=useState(false),c=useRef(null);e&&(c.current=e);let h=e??c.current;if(!h)return null;let k=()=>{Clipboard.setString(h.id),p(true),setTimeout(()=>p(false),2e3);},g=h.transaction_details,C=h.status!=="fulfillment_complete"&&h.status!=="rejected",S=Mu(h.status,a),y=g?.source_amount?`$${parseFloat(g.source_amount).toFixed(2)}`:"\u2014",m=g?.destination_amount?parseFloat(g.destination_amount).toFixed(2):"\u2014",b=(g?.destination_currency??"").toUpperCase(),d=h.destination_token_metadata,f=Cn(d?.icon_urls,d?.icon_url),R=Cn(d?.chain?.icon_urls,d?.chain?.icon_url),_=Wi(g?.destination_network??""),T=g?.wallet_address?Aa(g.wallet_address):null,w=g?.fees?.network_fee_amount?`$${parseFloat(g.fees.network_fee_amount).toFixed(2)}`:null,x=g?.fees?.transaction_fee_amount?`$${parseFloat(g.fees.transaction_fee_amount).toFixed(2)}`:null,W=h.payment_method?h.payment_method.replace(/_/g," ").replace(/\b\w/g,F=>F.toUpperCase()):null,D=[{label:"Amount",value:y},{label:"Received",value:`${m} ${b}`},...W?[{label:"Payment",value:W}]:[],{label:"Network",value:_},...T?[{label:"Wallet",value:T}]:[],...w?[{label:"Network Fee",value:w}]:[],...x?[{label:"Transaction Fee",value:x}]:[]];return jsxs(ut,{visible:t,onClose:r,closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:o,borderTopRightRadius:n,children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(Jt,{onPress:r,title:"Purchase Details",variant:"back"})}),jsxs(gt,{style:rr.scroll,contentContainerStyle:rr.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:rr.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(Ms,{currency:b||"USD",tokenIconUrl:f,networkIconUrl:R,size:64}),jsx(View,{style:[rr.statusBadge,{backgroundColor:S,borderColor:i.card.backgroundColor??a.background}],children:C?jsx(zr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):h.status==="rejected"?jsx(at,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx(Ue,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:rr.statusRow,children:[jsx(View,{style:[rr.statusDot,{backgroundColor:S}]}),jsx(Text,{style:[rr.statusText,{color:i.container.titleColor,fontFamily:s.semibold}],children:Eu[h.status]??h.status})]}),h.created?jsx(Text,{style:[rr.dateText,{color:i.container.subtitleColor,fontFamily:s.regular}],children:Wu(h.created)}):null]}),jsxs(View,{style:[rr.card,{backgroundColor:i.card.backgroundColor,borderRadius:i.card.borderRadius,borderWidth:i.card.borderWidth,borderColor:i.card.borderColor}],children:[jsxs(View,{style:rr.cardRow,children:[jsx(Text,{style:[rr.cardLabel,{color:i.card.rowLeftLabel,fontFamily:s.regular}],children:"ID"}),jsxs(TouchableOpacity$1,{onPress:k,activeOpacity:.7,style:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},children:[jsx(Text,{style:[rr.cardValue,{color:i.card.rowRightLabel,fontFamily:s.medium,fontSize:12}],numberOfLines:1,children:h.id.length>12?h.id.slice(0,12)+"\u2026":h.id}),l?jsx(Ue,{size:14,color:a.primary,strokeWidth:2}):jsx(No,{size:14,color:a.foregroundMuted,strokeWidth:2})]})]}),D.map((F,v)=>jsxs(An__default.Fragment,{children:[jsx(View,{style:[rr.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:rr.cardRow,children:[jsx(Text,{style:[rr.cardLabel,{color:i.card.rowLeftLabel,fontFamily:s.regular}],children:F.label}),jsx(Text,{style:[rr.cardValue,{color:i.card.rowRightLabel,fontFamily:s.medium}],selectable:true,children:F.value})]})]},F.label))]}),g?.last_error?jsx(View,{style:[rr.card,{backgroundColor:"#ef444415",borderRadius:i.card.borderRadius}],children:jsxs(View,{style:rr.cardRow,children:[jsx(Text,{style:[rr.cardLabel,{color:"#ef4444",fontFamily:s.regular}],children:"Error"}),jsx(Text,{style:[rr.cardValue,{color:"#ef4444",fontFamily:s.medium,flex:1,textAlign:"right"}],selectable:true,children:g.last_error})]})}):null]})]})}var rr=StyleSheet.create({scroll:{flex:1,paddingTop:8},scrollContent:{paddingHorizontal:24,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},statusBadge:{position:"absolute",bottom:-4,right:-4,width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center",borderWidth:2},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14,marginBottom:2},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"}});function bh({count:e=4}){let{colors:t,components:r}=O(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,a=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:Mi.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[Mi.row,{backgroundColor:t.card,borderRadius:a,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:Mi.left,children:[jsx(Animated.View,{style:[Mi.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[Mi.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[Mi.badgeBar,{backgroundColor:n,opacity:o}]})]},s))})}var Mi=StyleSheet.create({list:{gap:8},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16},left:{flex:1,gap:6},amountBar:{height:16,width:"40%",borderRadius:8},subtitleBar:{height:12,width:"55%",borderRadius:6},badgeBar:{height:20,width:80,borderRadius:6,marginLeft:12}});function qa({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:a="inline",onCollectPayment:i,paymentLoading:s=false,paymentStatus:l,paymentError:p,paymentTokens:c=[],onAddPaymentMethod:h,onConfirm:k,onCancel:g,sheetBorderTopLeftRadius:C,sheetBorderTopRightRadius:S,accessToken:y}){let m=Ei(),{colors:b,components:d}=O(),f=C??d.card.borderRadius,R=S??d.card.borderRadius,[_,T]=useState(e),[w,x]=useState(r?"apple_pay":c.length>0?c[0].id:null),W=useRef(false),D=$=>{W.current=true,x($);};useEffect(()=>{W.current||r||c.length>0&&x(c[0].id);},[c,r]);let[F,v]=useState(false),[q,N]=useState("select"),[ae,ze]=useState(null),ve=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&N("card");},[s,l]);let J=w==="apple_pay",Ve=1e3,me=J?Ve:n,_e=me!=null&&me>0,Ne=useMemo(()=>{if(o)return [];let $=mh.map(re=>({label:`$${re}`,amount:String(re),disabled:false}));return J?$.push({label:`$${Ve}`,amount:String(Ve),disabled:false}):$.push({label:"MAX",amount:_e?String(me):"0",disabled:!_e}),$},[o,_e,me,J]),Se=$=>{if($==="\u232B"){T(re=>re.slice(0,-1));return}if($==="."){if(_.includes("."))return;T(re=>re===""?"0.":re+".");return}T(re=>{let et=re.indexOf(".");return et!==-1&&re.length-et>2?re:re==="0"&&$!=="."?$:re+$});},oe=_===""?"0":_,Pe=parseFloat(_),rt=_!==""&&!isNaN(Pe)&&Pe>0,je=r||c.length>0,ot=a==="header",$e=useMemo(()=>{let $=[];r&&$.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let re of c)$.push({id:re.id,label:hh(re),hint:re.card?`Expires ${re.card.exp_month}/${re.card.exp_year}`:re.type,brand:re.card?.brand,isApplePay:false});return $},[r,c]),Fe=$e.find($=>$.id===w),Re=w!=null&&w!=="apple_pay",X=Fe?Fe.label:Re&&ae?ae:Re?"Card":"Pay With",ce=Fe?!Fe.isApplePay:Re,st=Fe?.brand??ae??void 0,[Je,Le]=useState(false),[be,ie]=useState([]),[de,zt]=useState(false),[ue,se]=useState(null),[ye,wt]=useState(null),dt=useRef(null);dt.current=ye;let le=useRef(false);le.current=Je;let qe=useCallback(async($=false)=>{if(y){$||(zt(true),se(null));try{let re=await Iu(y);if(!le.current)return;let et=Array.isArray(re.data)?re.data:Array.isArray(re)?re:[];ie(et),$||se(null);let pe=dt.current?.id;if(pe){let Me=et.find(M=>M.id===pe);Me&&wt(Me);}}catch(re){if(!le.current)return;$||se(re?.message??"Failed to load history");}finally{!$&&le.current&&zt(false);}}},[y]),yr=useCallback(()=>{Le(true),qe();},[qe]);useEffect(()=>{if(!Je||!y)return;let $=setInterval(()=>qe(true),15e3);return ()=>clearInterval($)},[Je,y,qe]);let xt=y?jsx(TouchableOpacity,{style:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},onPress:yr,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"History",children:jsx(zr,{size:20,color:b.foreground,strokeWidth:2})}):void 0,xr=je?jsx(TouchableOpacity,{style:[ot?m.amount.paymentRowHeader:m.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(N("select"),v(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:m.amount.paymentLeft,children:[Fe?.isApplePay?jsx(Text,{style:m.amount.applePayIcon,children:"\uF8FF"}):ce?jsx(Dc,{sublabel:st,size:20}):null,jsx(Text,{style:m.amount.paymentLabel,children:X}),jsx(At,{size:12,color:m.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:m.form.screen,children:[jsx(Jt,{onPress:g,title:"Enter amount",leftAction:xt}),ot&&xr,jsxs(View,{style:m.form.content,children:[jsxs(View,{style:m.amount.amountContainer,children:[jsxs(Text,{style:[m.amount.amountText,oe==="0"&&m.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",oe]}),jsx(Text,{style:m.amount.currencyLabel,children:t.toUpperCase()})]}),!ot&&xr,Ne.length>0&&jsx(View,{style:m.amount.quickRow,children:Ne.map($=>{let re=!$.disabled&&_===$.amount&&_!=="";return jsx(TouchableOpacity,{style:[m.amount.quickPill,re&&{backgroundColor:b.primary},$.disabled&&{opacity:.4}],activeOpacity:.7,disabled:$.disabled||s,onPress:()=>T($.amount),children:jsx(Text,{style:[m.amount.quickPillText,re&&{color:b.primaryForeground}],children:$.label})},$.label)})}),jsx(View,{style:m.amount.numpad,children:fh.map(($,re)=>jsx(View,{style:m.amount.numpadRow,children:$.map(et=>jsx(TouchableOpacity,{style:[m.amount.numpadKey,s&&{opacity:.3}],onPress:()=>Se(et),activeOpacity:.6,disabled:s,children:jsx(Text,{style:et==="\u232B"?m.amount.backspaceText:m.amount.numpadKeyText,children:et})},et))},re))}),jsx(TouchableOpacity,{style:[m.form.continueBtn,(!rt||s)&&m.form.continueBtnDisabled],onPress:()=>rt&&!s&&k(_,w),disabled:!rt||s,children:s?jsx(ActivityIndicator,{size:"small",color:b.primaryForeground}):jsx(Text,{style:[m.form.continueBtnText,!rt&&m.form.continueBtnTextDisabled],children:"Continue"})}),!F&&p?jsx(Text,{style:m.amount.inlineError,children:p}):!F&&s&&l&&__DEV__?jsx(Text,{style:m.amount.inlineStatus,children:l}):null]}),jsx(ut,{visible:F,onClose:()=>{s||(v(false),N("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:!s,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:f,borderTopRightRadius:R,children:jsx(View,{style:m.amount.sheetContent,children:q==="select"?jsxs(Fragment,{children:[jsxs(View,{style:m.amount.sheetTitleRow,children:[jsx(Text,{style:m.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>v(false),activeOpacity:.7,style:m.amount.sheetCloseBtn,children:jsx(at,{size:16,color:b.foregroundMuted,strokeWidth:2.5})})]}),jsxs(gt,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[$e.map($=>{let re=w===$.id;return jsxs(TouchableOpacity$1,{style:[m.amount.sheetOption,re&&{borderColor:b.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{D($.id),ze($.isApplePay?null:$.label),v(false);},children:[jsxs(View,{style:m.amount.sheetOptionLeft,children:[jsx(View,{style:m.amount.sheetOptionIcon,children:$.isApplePay?jsx(Text,{style:m.amount.applePayIcon,children:"\uF8FF"}):jsx(Dc,{sublabel:$.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:m.amount.sheetOptionLabel,children:$.label}),jsx(Text,{style:m.amount.sheetOptionHint,children:$.hint})]})]}),re&&jsx(Ue,{size:18,color:b.primary,strokeWidth:2.5})]},$.id)}),jsx(TouchableOpacity$1,{style:m.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!ve.current){ve.current=true;try{let $=await h?.();$&&(D($.token),ze($.sublabel),v(!1));}finally{ve.current=false;}}},children:jsx(Text,{style:m.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:m.amount.sheetHeader,children:[jsx(TouchableOpacity$1,{onPress:()=>{s||N("select");},activeOpacity:.7,style:m.amount.sheetBackBtn,children:jsx(Fi,{size:20,color:b.foreground,strokeWidth:2})}),jsx(Text,{style:m.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:m.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),__DEV__?jsx(Text,{style:m.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):p?jsxs(Fragment,{children:[jsx(View,{style:m.amount.sheetError,children:jsx(Text,{style:m.amount.sheetErrorText,children:p})}),jsx(TouchableOpacity$1,{style:m.form.continueBtn,onPress:()=>{i&&rt&&i(false,_);},children:jsx(Text,{style:m.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:m.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),__DEV__?jsx(Text,{style:m.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(ut,{visible:Je,onClose:()=>Le(false),closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:f,borderTopRightRadius:R,children:jsxs(View,{style:m.amount.sheetContent,children:[jsx(Jt,{onPress:()=>Le(false),title:"Purchase History"}),de?jsx(bh,{}):ue?jsx(View,{style:m.amount.sheetError,children:jsx(Text,{style:m.amount.sheetErrorText,children:ue})}):be.length===0?jsx(View,{style:m.amount.sheetLoading,children:jsx(Text,{style:[m.amount.sheetStatusText,{color:b.foregroundMuted}],children:"No purchases yet"})}):jsx(gt,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:be.map($=>{let re=$.transaction_details,et=re?.source_amount?`$${parseFloat(re.source_amount).toFixed(2)}`:"\u2014",pe=(re?.destination_currency??"").toUpperCase(),Me=re?.destination_amount?`${parseFloat(re.destination_amount).toFixed(2)} ${pe}`:"",M=Wu($.created),ee=$.destination_token_metadata,ke=Cn(ee?.icon_urls,ee?.icon_url),fe=Cn(ee?.chain?.icon_urls,ee?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:m.amount.sheetOption,activeOpacity:.7,onPress:()=>wt($),children:[jsx(Ms,{currency:pe||"USD",tokenIconUrl:ke,networkIconUrl:fe,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:m.amount.sheetOptionLabel,children:et}),Me?jsx(Text,{style:m.amount.sheetOptionHint,children:Me}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx(gh,{status:$.status,colors:b}),M?jsx(Text,{style:{fontSize:11,color:b.foregroundMuted},children:M}):null]}),jsx(_r,{size:14,color:b.foregroundMuted,strokeWidth:2})]})]},$.id)})})]})}),jsx(yh,{session:ye,visible:!!ye,onClose:()=>wt(null),borderTopLeftRadius:f,borderTopRightRadius:R})]})}var Us=4;function Qa({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Ei(),{colors:a,fonts:i,components:s}=O(),l=s.input.placeholderColor,[p,c]=useState(1),[h,k]=useState(e.firstName??""),[g,C]=useState(e.lastName??""),[S,y]=useState(e.dobMonth??""),[m,b]=useState(e.dobDay??""),[d,f]=useState(e.dobYear??""),[R,_]=useState(e.addressLine1??""),[T,w]=useState(e.addressLine2??""),[x,W]=useState(e.city??""),[D,F]=useState(e.state??""),[v,q]=useState(e.postalCode??""),[N,ae]=useState(e.country??"US"),[ze,ve]=useState(e.idNumber??""),J=useRef(null),Ve=useRef(null),me=useRef(null),_e=useRef(null),Ne=useRef(null),Se=useRef(null),oe=useRef(null),Pe=useRef(null),rt=()=>{switch(p){case 1:return h.trim().length>0&&g.trim().length>0;case 2:return S.length===2&&m.length===2&&d.length===4;case 3:return R.trim().length>0&&x.trim().length>0&&D.trim().length>0&&v.trim().length>0;case 4:return ze.trim().length>0;default:return false}},je=()=>{rt()&&(p<Us?c(Re=>Re+1):r({firstName:h,lastName:g,idNumber:ze,dobMonth:S,dobDay:m,dobYear:d,addressLine1:R,addressLine2:T,city:x,state:D,postalCode:v,country:N}));},ot=()=>{p>1?c(Re=>Re-1):o();},$e=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Fe=["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."],ct=[jt.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:jt.header,children:[jsx(View,{style:jt.headerSide,children:jsx(TouchableOpacity,{style:jt.iconButton,onPress:ot,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:p>1?"Back":"Cancel",children:jsx(Rs,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:jt.headerCenter,children:jsxs(Text,{style:ct,children:[p," of ",Us]})}),jsx(View,{style:jt.headerSide,children:jsx(TouchableOpacity,{style:jt.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(at,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:jt.progressTrack,children:Array.from({length:Us}).map((Re,X)=>jsx(View,{style:[jt.progressSegment,{backgroundColor:X<p||X+1===p?a.primary:a.border}]},X))}),jsxs(gt,{style:n.form.flex,contentContainerStyle:jt.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:$e[p-1]}),jsx(Text,{style:n.form.subtitle,children:Fe[p-1]}),p===1&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:h,onChangeText:k,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>J.current?.focus()})}),jsx(Ko,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:J,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:g,onChangeText:C,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:je})})]}),p===2&&jsxs(View,{style:jt.dobRow,children:[jsxs(View,{style:jt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,jt.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,jt.dobInput],placeholder:"MM",placeholderTextColor:l,value:S,onChangeText:Re=>{let X=Re.replace(/\D/g,"").slice(0,2);y(X),X.length===2&&Ve.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:jt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,jt.dobLabel],children:"Day"}),jsx(TextInput,{ref:Ve,style:[n.form.input,jt.dobInput],placeholder:"DD",placeholderTextColor:l,value:m,onChangeText:Re=>{let X=Re.replace(/\D/g,"").slice(0,2);b(X),X.length===2&&me.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:jt.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,jt.dobLabel],children:"Year"}),jsx(TextInput,{ref:me,style:[n.form.input,jt.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:d,onChangeText:Re=>{let X=Re.replace(/\D/g,"").slice(0,4);f(X);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:je})]})]}),p===3&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:R,onChangeText:_,returnKeyType:"next",onSubmitEditing:()=>_e.current?.focus()})}),jsx(Ko,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:_e,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:T,onChangeText:w,returnKeyType:"next",onSubmitEditing:()=>Ne.current?.focus()})}),jsx(Ko,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ne,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:x,onChangeText:W,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Se.current?.focus()})}),jsxs(View,{style:jt.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx(Ko,{form:n.form,label:"State",children:jsx(TextInput,{ref:Se,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:D,onChangeText:Re=>F(Re.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>oe.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx(Ko,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:oe,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:v,onChangeText:q,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Pe.current?.focus()})})})]}),jsx(Ko,{form:n.form,label:"Country",children:jsx(TextInput,{ref:Pe,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:N,onChangeText:Re=>ae(Re.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:je})})]}),p===4&&jsxs(Ko,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:ze,onChangeText:ve,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:je}),jsx(Text,{style:[n.form.hint,jt.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&p===Us?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!rt()&&n.form.continueBtnDisabled],onPress:je,disabled:!rt(),children:jsx(Text,{style:[n.form.continueBtnText,!rt()&&n.form.continueBtnTextDisabled],children:p===Us?"Submit":"Continue"})})})]})})}function Ko({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var jt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:16},headerSide:{width:40,alignItems:"center"},headerCenter:{flex:1,alignItems:"center",justifyContent:"center"},iconButton:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"},stepCounter:{fontSize:15},progressTrack:{flexDirection:"row",gap:4,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{marginTop:10,lineHeight:18}});var Ec="@unifold/stripe_oauth";async function Uu(){try{let e=await Wc.getItem(Ec);return e?JSON.parse(e):null}catch{return null}}async function Mc(e){try{await Wc.setItem(Ec,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function Tn(){try{await Wc.removeItem(Ec);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Rh=5,_n=null,Hu={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Ka(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:a,authorize:i,attachKycInfo:s,presentKycInfoVerification:l,verifyIdentity:p,registerWalletAddress:c,collectPaymentMethod:h,createCryptoPaymentToken:k}=useOnramp(),[g,C]=useState(r),[S,y]=useState(!!e?.externalUserId),[m,b]=useState(false),[d,f]=useState(""),[R,_]=useState(null),[T,w]=useState(e?.email??""),[x,W]=useState(e?.phone??""),[D,F]=useState(""),[v,q]=useState("US"),[N,ae]=useState(""),[ze,ve]=useState(""),J=useRef(""),Ve=useRef(""),me=useRef(""),[_e,Ne]=useState(false),[Se,oe]=useState(false),Pe=useRef(0),rt=useRef(false),je=useRef(false),ot=useRef(false),$e=useRef(""),Fe=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),ct=useRef(null),[Re,X]=useState(Hu),[ce,st]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[Je,Le]=useState(""),[be,ie]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[de,zt]=useState(e?.defaultSourceAmount??"100"),[ue,se]=useState(e?.defaultSourceCurrency??"usd"),[ye,wt]=useState(e?.defaultDestinationCurrency??"usdc"),[dt,le]=useState(null),[qe,yr]=useState(),[xt,xr]=useState(),[$,re]=useState(false),et=useRef(null),pe=useRef(false),Me=useRef(0),M=useRef(e?.onComplete),ee=useRef(e?.onError),ke=useRef(e?.onStepChange),fe=useRef(r);useEffect(()=>{M.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{ee.current=e?.onError;},[e?.onError]),useEffect(()=>{ke.current=e?.onStepChange;},[e?.onStepChange]);let _t=useRef(r);useEffect(()=>{g!==_t.current&&(ke.current?.(g,_t.current),_t.current=g),fe.current=g;},[g]),useEffect(()=>{S&&g!==r&&y(false);},[S,g,r]);let V=useCallback((I,P,H)=>{let K={code:I,message:P,step:fe.current,stripeErrorCode:H};_(K),f(""),ee.current?.(K);},[]),Or=useCallback(I=>{let P={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?.(P),P},[]),z=useCallback(()=>_(null),[]),Ot=I=>I.refresh_token??I.refresh?.refresh_token??"",St=useCallback((I,P,H,K,xe)=>{Ve.current=P,J.current=H,e?.externalUserId&&Mc({accessToken:P,refreshToken:H,customerId:I,externalUserId:e.externalUserId,email:xe||T,expiresAt:Date.now()+K*1e3});},[e?.externalUserId,T]),Mr=useCallback(async()=>{let I=J.current;if(!I)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let P=await vc(I,me.current??void 0),H=P.access_token,K=Ot(P)||I;return ve(H),St(me.current,H,K,P.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),H}catch(P){return console.error("[tryRefreshAccessToken] refresh failed:",P?.message),await Tn(),_n=null,Ve.current="",J.current="",me.current="",ve(""),ae(""),null}},[St]),er=useCallback(async I=>{try{return await I(Ve.current)}catch(P){let H=P?.message??"";if(H.includes("stripe_onramp_forbidden")||H.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let K=await Mr();if(!K)throw V("authorization_error","Session expired. Please sign in again."),C("email"),P;return await I(K)}throw P}},[Mr,V]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){re(false);return}let P=false;return isPlatformPaySupported().then(H=>{P||re(H);}),()=>{P=true;}},[e?.merchantIdentifier]),useEffect(()=>(pe.current=false,()=>{pe.current=true,et.current&&clearTimeout(et.current);}),[]);let Ii=useRef(false);useEffect(()=>{if(Ii.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),Tn(),_n=null,y(false);return}let I=false;return (async()=>{try{let P=await Uu();if(I||!P){I||y(!1);return}if(P.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",P.externalUserId,"current:",e.externalUserId),await Tn(),_n=null,I||y(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",P.customerId);let H=Date.now()>=P.expiresAt,K=P.accessToken,xe=P.refreshToken;if(H){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Qe=await vc(P.refreshToken,P.customerId);if(I)return;K=Qe.access_token,xe=Qe.refresh_token??Qe.refresh?.refresh_token??P.refreshToken,await Mc({accessToken:K,refreshToken:xe,customerId:P.customerId,externalUserId:e.externalUserId,email:P.email,expiresAt:Date.now()+(Qe.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Qe){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Qe?.message),await Tn(),_n=null,I||y(!1);return}}if(I)return;if(Ii.current=!0,ae(P.customerId),me.current=P.customerId,ve(K),Ve.current=K,J.current=xe,P.email&&w(P.email),_n===P.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",P.customerId,"\u2014 skipping configure()"),ct.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",P.customerId);let Qe=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});Qe.error?console.error("[useStripeOnramp] restore configureSDK error:",Qe.error.message):_n=P.customerId,ct.current=Promise.resolve(Qe);}if(I)return;let yt=()=>new Promise(Qe=>{let br=()=>{ot.current&&$e.current?Qe():setTimeout(br,200);};br();});try{if(await Promise.race([yt(),new Promise((br,Ut)=>setTimeout(()=>Ut(new Error("timeout")),1e4))]),I)return;let Qe=$e.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Qe,"network:",Fe.current),await c(Qe,Fe.current);}catch(Qe){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Qe?.message);}if(I)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),C("session_params");}finally{I||y(false);}})(),()=>{I=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||_e||Se)return;let I=false;oe(true);async function P(){try{let[H,K]=await Promise.all([Fu({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?Ou({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Ht=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Ht?.message),null)):Promise.resolve(null)]);if(I)return;let xe=e?.destinationChainType??"ethereum",yt=H.data.find(Ht=>Ht.chain_type===xe);if(yt?.address){let Ht=yt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Ht,"recipient:",yt.recipient_address),st(Ht),$e.current=Ht,yt.recipient_address&&Le(yt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",xe,"in",H.data?.length,"wallets");let Qe={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"},Ut=K?.destination_network,pr="none";if(Ut&&Qe[Ut])ie(Qe[Ut]),Fe.current=Qe[Ut],pr=Ut+" (from default_token API)";else if(e?.destinationChainId&&br[e.destinationChainId]){let Ht=br[e.destinationChainId];Qe[Ht]&&(ie(Qe[Ht]),Fe.current=Qe[Ht]),pr=Ht+" (from chain_id "+e.destinationChainId+")";}else Qe[xe]&&(ie(Qe[xe]),Fe.current=Qe[xe],pr=xe+" (from chain_type fallback)");K?.destination_currency&&wt(K.destination_currency.toLowerCase());let ar=K?.destination_token_metadata,Jr=Cn(ar?.icon_urls,ar?.icon_url),Zr=Cn(ar?.chain?.icon_urls,ar?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",Jr,"network:",Zr),Jr&&yr(Jr),Zr&&xr(Zr),Ne(!0),ot.current=!0;}catch(H){console.error("[useStripeOnramp] Failed to resolve wallet:",H?.message),Ne(true),ot.current=true;}finally{I||oe(false);}}return P(),()=>{I=true;}},[e?.publishableKey,e?.externalUserId]);let uo=useCallback(async()=>{if(ct.current)return ct.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(P=>(P.error&&(console.error("[useStripeOnramp] configureSDK error:",P.error.message,P.error.code),ct.current=null),P)).catch(P=>{throw console.error("[useStripeOnramp] configureSDK threw:",P?.message??P),ct.current=null,P});return ct.current=I,I},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||uo();},[]);let Ho=useCallback(async I=>{if(!rt.current){rt.current=true,b(true),z(),f("Creating auth intent...");try{let P=await Ic(I);f("Waiting for authorization...");let H=await i(P);if(H?.error){console.log("[proceedToAuthorize] authorize error:",H.error.message),V("authorization_error","Something went wrong during authorization. Please try again."),C("email");return}if(H?.status==="Denied"){V("authorization_error","Authorization denied by user."),C("email");return}if(H?.status!=="Consented"||!H.customerId){V("authorization_error","Authorization was canceled."),C("email");return}f("Exchanging tokens...");let K=H.customerId,xe=await xu(P,K),yt=xe.access_token,Qe=Ot(xe);console.log("[useStripeOnramp] customerId:",K),console.log("[useStripeOnramp] accessToken acquired, length:",yt.length),ae(K),me.current=K,_n=K,ve(yt),St(K,yt,Qe,xe.expires_in??3600),f("Checking verification status...");try{let br=await ja(K,yt),Ut=br.verifications.find(hn=>hn.name==="kyc_verified"),pr=br.verifications.find(hn=>hn.name==="id_document_verified"),ar=Ut?.status==="verified",Jr=Ut?.status==="rejected",Zr=pr?.status==="verified",Ht=br.provided_fields.includes("first_name");if(f(""),Jr&&!Ht)V("kyc_error","KYC was previously rejected. Please submit with correct info."),C("kyc");else if(Jr&&Ht)C(Zr?"wallet":"identity");else if(!ar&&!Ht)C("kyc");else if(!Zr)C("identity");else if(ot.current&&$e.current)try{let hn=$e.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",hn,"network:",be);let Sa=await c(hn,be);Sa?.error?(console.warn("[proceedToAuthorize] wallet registration error:",Sa.error.message),V("wallet_error",Sa.error.message,Sa.error.code),C("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),C("session_params"));}catch(hn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",hn?.message),C("wallet");}else C("wallet");}catch(br){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",br?.message),f(""),C("kyc");}}catch(P){V("authorization_error",P?.message??String(P)),C("email");}finally{rt.current=false,b(false);}}},[i,z,V,St,c,be]),Q=useCallback(async()=>{if(Keyboard.dismiss(),!T){V("validation_error","Please enter an email address.");return}b(true),z(),f("");try{f("Configuring...");let I=await uo();if(I.error){V("configuration_error",I.error.message,I.error.code);return}f("Checking Link account...");let P=await n(T);if(P.error){V("authorization_error",P.error.message,P.error.code);return}P.hasLinkAccount?await Ho(T):(f(""),C("register"));}catch(I){V("unknown_error",I?.message??String(I));}finally{b(false);}},[z,uo,T,V,n,Ho]),ge=useCallback(async()=>{if(!x){V("validation_error","Please enter your phone number.");return}b(true),z(),f("");try{f("Creating Link account...");let I=await a({email:T,phone:x,fullName:D||T,country:v||"US"});if(I.error){V("registration_error",I.error.message,I.error.code);return}await Ho(T);}catch(I){V("registration_error",I?.message??String(I));}finally{b(false);}},[z,v,T,V,D,x,a,Ho]);useEffect(()=>{if(g!=="email"||!e?.email||S)return;let I=++Pe.current,P=false,H=()=>P||Pe.current!==I;return e?.phone?(async()=>{b(true),z();try{f("Configuring...");let K=await uo();if(H())return;if(K.error){V("configuration_error",K.error.message,K.error.code);return}f("Checking Link account...");let xe=await n(e.email);if(H())return;if(xe.error){V("authorization_error",xe.error.message,xe.error.code);return}if(xe.hasLinkAccount){if(H())return;await Ho(e.email);}else {f("Creating Link account...");let yt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(H())return;if(yt.error){V("registration_error",yt.error.message,yt.error.code);return}if(H())return;await Ho(e.email);}}catch(K){H()||V("unknown_error",K?.message??String(K));}finally{b(false);}})():(async()=>{b(true),z();try{f("Configuring...");let K=await uo();if(H())return;if(K.error){V("configuration_error",K.error.message,K.error.code);return}f("Checking Link account...");let xe=await n(e.email);if(H())return;if(xe.error){V("authorization_error",xe.error.message,xe.error.code);return}if(xe.hasLinkAccount){if(H())return;await Ho(e.email);}else {if(H())return;f(""),C("register");}}catch(K){H()||V("unknown_error",K?.message??String(K));}finally{b(false);}})(),()=>{P=true;}},[g,e?.email,e?.phone,S]);let Bt=useCallback(async I=>{b(true),z(),f(""),X(I);try{let P={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}},H=await s(P);if(H?.error){if(H.error.stripeErrorCode==="consumer_person_already_verified"){f(""),C("identity");return}V("kyc_error",H.error.message,H.error.stripeErrorCode??H.error.code),C("kyc");return}f("Please review your KYC information...");let K=await l(null);if(K?.error){V("kyc_error",K.error.message,K.error.stripeErrorCode??K.error.code),C("kyc");return}if(K?.status==="UpdateAddress"){V("kyc_error","Please update your address and resubmit."),C("kyc");return}f(""),C("identity");}catch(P){V("kyc_error",P?.message??String(P)),C("kyc");}finally{b(false);}},[s,z,V,l]),po=useCallback(async()=>{if(!je.current){je.current=true,b(true),z(),f("Launching identity verification...");try{let I=await p();if(I?.error){V("identity_error",I.error.message,I.error.code);return}f(""),C("wallet");}catch(I){V("identity_error",I?.message??String(I));}finally{je.current=false,b(false);}}},[z,V,p]);useEffect(()=>{g==="identity"&&!m&&po();},[g]);let Ts=useCallback(async()=>{if(!ce){V("validation_error","Please enter a wallet address.");return}b(true),z(),f("");try{let I=ce.toLowerCase();console.log("[registerWallet] registering wallet:",I,"network:",be);let P=await c(I,be);if(P?.error){console.warn("[registerWallet] error:",P.error.message),V("wallet_error",P.error.message,P.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),C("session_params");}catch(I){V("wallet_error",I?.message??String(I));}finally{b(false);}},[z,V,ce,be,c]);useEffect(()=>{g==="wallet"&&_e&&ce&&Ts();},[g,_e,ce]);let mo=useCallback(I=>{pe.current=false,Me.current=0;let P=0,H=async()=>{P+=1;let K=Ve.current;try{let xe=await vu(I,K);if(console.log(`[pollSessionStatus] poll #${P} session=${I} status="${xe.status}"`),pe.current)return;Me.current=0,xe.status==="fulfillment_complete"?(le(xe),C("success")):et.current=setTimeout(H,3e3);}catch(xe){if(pe.current)return;let yt=xe?.message??"";if((yt.includes("stripe_onramp_forbidden")||yt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Mr()&&!pe.current)){et.current=setTimeout(H,1e3);return}if(Me.current+=1,console.error(`[pollSessionStatus] poll #${P} error:`,yt),Me.current>=Rh){V("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}et.current=setTimeout(H,5e3);}};et.current=setTimeout(H,3e3);},[V,Mr]),fn=useCallback(()=>{if(fe.current==="processing"&&dt?.id){if(!Ve.current){V("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}z(),Me.current=0,et.current&&(clearTimeout(et.current),et.current=null),mo(dt.id);}},[z,V,mo,dt?.id]),wa=useCallback(async I=>{b(true),z(),f("");try{f("Confirming purchase...");let P=await er(H=>Ru(I,H));console.log("[finalizeOnrampSession] confirmed session:",P.id,"status:",P.status),le(P),C("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",P.id),mo(P.id);}finally{b(false);}},[z,mo,er]),Zl=useRef(false),Ym=useCallback(async()=>{if(!(!dt||Zl.current)){Zl.current=true;try{b(!0),z(),f("Refreshing quote...");let I=await er(P=>Pc(dt.id,P));le(I),await wa(I.id);}catch(I){console.log("[confirmCheckout] error:",I?.message),V("session_error","Something went wrong. Please try again."),C("quote");}finally{b(false),Zl.current=false;}}},[z,V,wa,dt,er]),eu=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 P=await Ic(I),H=await i(P);return H?.status==="Consented"&&H.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",H.customerId),me.current=H.customerId,ae(H.customerId),_n=H.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",H?.status),!1)}catch(P){return console.warn("[reauthorizeLink] failed:",P?.message),false}},[i,T]),Jm=useCallback(async(I=false,P,H)=>{let K=P??de;if(console.log("[collectPaymentMethod] called:",{useApplePay:I,amt:K,amountOverride:P,sourceAmount:de,hasSavedToken:!!H}),!K||isNaN(Number(K))||Number(K)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),V("validation_error","Please enter a valid amount.");return}P&&zt(P),b(true),z(),f("");try{let xe=await uo();if(xe.error){V("configuration_error",xe.error.message,xe.error.code);return}let yt;if(H)console.log("[collectPaymentMethod] using saved payment token"),yt=H;else if(I){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),V("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),C("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Ut={applePay:{merchantCountryCode:"US",currencyCode:ue.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${ye.toUpperCase()} purchase + fees`,amount:K}]}},pr=await h("PlatformPay",Ut);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!pr?.error),pr?.error){let Jr=pr.error.message??"",Zr=pr.error.code??"",Ht=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",pr.error,"isCancellation:",Ht),Ht||(V("payment_error",Jr,Zr),C("session_params"));return}if(!pr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let ar=await k();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),C("session_params");return}yt=ar.cryptoPaymentToken;}else {f("Select a payment method...");let Ut=await h("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Ut?.error),Ut?.error){let Jr=Ut.error.message??"",Zr=Ut.error.code??"",Ht=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",Ut.error,"isCancellation:",Ht),Ht||(V("payment_error",Jr,Zr),C("session_params"));return}if(!Ut?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let pr=Ut.displayData;console.log("[collectPaymentMethod] displayData:",{type:pr.type,label:pr.label,sublabel:pr.sublabel,hasIcon:!!pr.icon}),f("Creating payment token...");let ar=await k();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),C("session_params");return}yt=ar.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",ce,"walletAddressRef:",$e.current);let Qe=$e.current||ce.toLowerCase(),br=await er(Ut=>_u({cryptoCustomerId:me.current,paymentToken:yt,sourceAmount:Number(K),sourceCurrency:ue,destinationCurrency:ye,walletAddress:Qe,destinationNetwork:be},Ut));console.log("[collectPaymentMethod] session created:",br?.id,"useApplePay:",I),le(br),f(""),I?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await wa(br.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):C("quote");}catch(xe){console.log("[collectPaymentMethod] error caught:",xe?.message),V("session_error","Something went wrong. Please try again."),C("session_params");}finally{b(false),f("");}},[z,uo,h,k,ye,V,wa,zt,de,ue,ce,be,er,e?.merchantIdentifier]),Zm=useCallback(async()=>{b(true),z(),f("Select a payment method...");try{let I=await uo();if(I.error)return V("configuration_error",I.error.message,I.error.code),null;let P=await h("Card");if(console.log("[addPaymentMethod] Card result ok:",!P?.error),P?.error?.message&&/no active link consumer/i.test(P.error.message)){if(console.log("[addPaymentMethod] no active Link consumer \u2014 attempting re-authorization"),!await eu())return V("authorization_error","Please verify your identity to add a payment method."),null;P=await h("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!P?.error);}if(P?.error){let xe=P.error.message??"",yt=P.error.code??"",Qe=/cancel/i.test(xe)||/cancel/i.test(yt);return console.log("[addPaymentMethod] pmResult error:",P.error,"isCancellation:",Qe),Qe||V("payment_error",xe,yt),null}if(!P?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let H=P.displayData;console.log("[addPaymentMethod] displayData:",{type:H.type,label:H.label,sublabel:H.sublabel,hasIcon:!!H.icon}),f("Saving payment method...");let K=await k();return console.log("[addPaymentMethod] tokenResult ok:",!K?.error),K?.error?(V("payment_error",K.error.message,K.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:K.cryptoPaymentToken,sublabel:H.sublabel??""})}catch(I){return console.log("[addPaymentMethod] error:",I?.message),V("session_error",I?.message??String(I)),null}finally{b(false),f("");}},[z,uo,h,k,V,eu]),Xm=useCallback(async()=>{if(dt){b(true),z(),f("");try{let I=await er(P=>Pc(dt.id,P));le(I);}catch(I){console.log("[refreshQuote] error:",I?.message),V("session_error","Something went wrong. Please try again.");}finally{b(false);}}},[z,V,dt,er]),ef=useCallback(()=>{pe.current=true,Me.current=0,et.current&&(clearTimeout(et.current),et.current=null),C(r),b(false),f(""),_(null),w(e?.email??""),W(e?.phone??""),F(""),q("US"),ae(""),me.current="",ve(""),Ve.current="",J.current="",Ne(false),oe(false),X(Hu),st(e?.recipientAddress??""),$e.current="",ot.current=false,ie(Onramp.CryptoNetwork.ethereum),zt(e?.defaultSourceAmount??"100"),se(e?.defaultSourceCurrency??"usd"),wt(e?.defaultDestinationCurrency??"usdc"),Le(""),yr(void 0),xr(void 0),le(null),Pe.current+=1,rt.current=false,je.current=false;},[e,r]);return {step:g,restoring:S,loading:m,status:d,error:R,email:T,phone:x,fullName:D,country:v,customerId:N,accessToken:ze,session:dt,kycData:Re,walletAddress:ce,resolvedRecipientAddress:Je,walletNetwork:be,sourceAmount:de,sourceCurrency:ue,destinationCurrency:ye,tokenIconUrl:qe,networkIconUrl:xt,applePaySupported:$,walletReady:_e,walletLoading:Se,setStep:C,setStatus:f,setEmail:w,setPhone:W,setFullName:F,setCountry:q,setWalletAddress:st,setWalletNetwork:ie,setSourceAmount:zt,setSourceCurrency:se,setDestinationCurrency:wt,checkEmail:Q,register:ge,attachKyc:Bt,verifyIdentity:po,registerWallet:Ts,collectPaymentMethod:Jm,addPaymentMethod:Zm,refreshQuote:Xm,confirmCheckout:Ym,reset:ef,clearError:z,emitComplete:Or,resumeFulfillmentPolling:fn,amountFirst:t}}function Nu({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:a,email:i,setEmail:s,checkEmail:l,onClose:p}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(Ir,{error:n,progress:a,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your email"}),jsx(Text,{style:e.form.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Email address"}),jsx(TextInput,{style:e.form.input,placeholder:"jane@example.com",placeholderTextColor:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:s,autoFocus:true,returnKeyType:"done",onSubmitEditing:l})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Ir,{error:n,progress:a,loading:o})]})]})})}function $u({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(kt,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:r||"Preparing identity verification..."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Text,{style:e.flow.idIcon,children:"\u{1FAAA}"})}),jsx(Text,{style:e.flow.heading,children:"Identity verification"}),jsx(Text,{style:e.flow.sub,children:r||"Tap below to continue verification."})]}),jsx(Ir,{error:o,progress:r,loading:false})]}),!t&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:n,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function Qu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:p,onRetryStatusCheck:c}){let{colors:h}=O(),k=!!t;return jsxs(View,{style:e.form.screen,children:[k?jsx(Jt,{onPress:p}):jsx(View,{style:Ea}),jsx(View,{style:e.flow.centered,children:t?jsxs(Fragment,{children:[jsx(Text,{style:e.flow.heading,children:"Could not confirm status"}),jsx(Text,{style:e.flow.sub,children:"Your payment may still be completing. Try checking again, or close this screen and verify your wallet balance."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(kt,{size:48,strokeWidth:3,gradientFrom:h.primary,gradientTo:h.primary})}),jsx(Text,{style:e.flow.heading,children:"Processing your purchase"}),jsxs(Text,{style:e.flow.sub,children:["Your payment has been confirmed.",`
2
- `,"We're sending your crypto \u2014 this usually takes less than a minute."]}),n&&a&&i&&jsx(za,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(Ir,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:c,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Ku({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:p}){let{colors:c}=O(),h=t.transaction_details,k=Wa(h.destination_amount,h.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p??l,title:"Review your purchase",variant:p?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(Ms,{currency:h.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(fo,{quote:e.quote,label:"You pay",value:`${h.source_amount} ${h.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You receive",value:`${k} ${h.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network fee",value:`$${h.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction fee",value:`$${h.fees.transaction_fee_amount}`,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(Ir,{error:o,progress:n,loading:r})]})]})}function Gu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:p}){let c=O();return t?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(Ir,{error:o,progress:n,loading:r})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:p}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your phone"}),jsx(Text,{style:e.form.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Phone number"}),jsx(TextInput,{style:e.form.input,placeholder:"+12125551234",placeholderTextColor:c.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:h=>s(h.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:l}),jsx(Text,{style:e.form.hint,children:"Include country code, e.g. +12125551234"})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:a})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Ir,{error:o,progress:n,loading:r})]})]})})}function Hh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=O(),n=e.toLowerCase(),a=Ma[n]??o.primary,i=Math.round(r*.36);return jsxs(View,{style:{width:r,height:r,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:r,height:r,borderRadius:r/2}}):jsx(View,{style:[Io.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[Io.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[Io.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(Ue,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Yu({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:p}=O(),c=t.transaction_details,h=Wa(c.destination_amount,c.destination_currency),k=r||o||"";Wi(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(gt,{style:e.form.flex,contentContainerStyle:Io.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Io.iconSection,children:[jsx(Hh,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:Io.statusRow,children:[jsx(View,{style:[Io.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[Io.statusText,{color:s.foreground,fontFamily:p.semibold}],children:"Completed"})]}),jsx(Text,{style:[Io.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(za,{sourceCurrency:c.source_currency,destinationCurrency:c.destination_currency,destinationNetwork:c.destination_network,tokenIconUrl:n,networkIconUrl:a,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor},Io.detailCard],children:[jsx(fo,{quote:e.quote,label:"You Paid",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You Received",value:`${h} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(Rc,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),k?jsx(Rc,{quote:e.quote,label:"Recipient Address",address:k,last:true}):jsx(fo,{quote:e.quote,label:"Session",value:t.id.slice(0,8)+"..."+t.id.slice(-6),last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var Io=StyleSheet.create({scrollContent:{paddingBottom:24,alignItems:"center"},iconSection:{alignItems:"center",marginTop:24,marginBottom:24},tokenCircle:{alignItems:"center",justifyContent:"center"},tokenLetter:{color:"#FFFFFF",fontWeight:"700",letterSpacing:.5},checkBadge:{position:"absolute",bottom:0,right:0,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",marginTop:16,gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16},subtitle:{fontSize:14,marginTop:4},detailCard:{width:"100%"}});function Ju({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:p,registerWallet:c,onClose:h}){let{components:k}=O();if(t){let g=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:h}),jsxs(View,{style:e.flow.centered,children:[!g&&jsx(kt,{size:56,strokeWidth:3}),jsx(Ir,{error:o,progress:n,loading:r})]}),g&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:c,children:jsx(Text,{style:e.form.continueBtnText,children:"Retry"})})})]})}return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:h}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Your crypto wallet"}),jsx(Text,{style:e.form.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[e.form.input,e.wallet.input],placeholder:"0x...",placeholderTextColor:k.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:a,onChangeText:s})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:Ba.map(g=>{let C=i===g.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,C&&e.wallet.rowSelected],onPress:()=>{l(g.value),p(g.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(g.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,C&&e.wallet.rowTextSelected],children:g.label}),C&&jsx(View,{style:e.wallet.checkCircle,children:jsx(Ue,{size:14,color:k.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(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:c,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Ir,{error:o,progress:n,loading:r})]})]})})}function Xa({config:e,onClose:t}){let r=O(),o=Ei(),{step:n,restoring:a,loading:i,status:s,error:l,email:p,phone:c,session:h,kycData:k,walletAddress:g,resolvedRecipientAddress:C,walletNetwork:S,sourceAmount:y,sourceCurrency:m,destinationCurrency:b,tokenIconUrl:d,networkIconUrl:f,applePaySupported:R,setStep:_,setEmail:T,setPhone:w,setWalletAddress:x,setWalletNetwork:W,setSourceAmount:D,setDestinationCurrency:F,checkEmail:v,register:q,attachKyc:N,verifyIdentity:ae,registerWallet:ze,collectPaymentMethod:ve,addPaymentMethod:J,confirmCheckout:Ve,reset:me,emitComplete:_e,resumeFulfillmentPolling:Ne,amountFirst:Se,customerId:oe,accessToken:Pe}=Ka(e),rt=!!e?.email,je=!!e?.phone,ot=!!e?.publishableKey&&!!e?.externalUserId,[$e,Fe]=useState(void 0),[ct,Re]=useState([]);useEffect(()=>{if(a||n!=="session_params"||!oe||!Pe)return;console.log("[OnrampScreen] customerId:",oe);let Le=ie=>{let de=ie?.message??"";return de.includes("stripe_onramp_forbidden")||de.includes("403")},be=ie=>{Le(ie)&&(Tn(),me());};ja(oe,Pe).then(ie=>{console.log("[OnrampScreen] customer fetched, id:",ie?.id);}).catch(ie=>{console.warn("[OnrampScreen] customer fetch error:",ie?.message),be(ie);}),Fc(oe,Pe).then(ie=>{console.log("[OnrampScreen] payment_tokens fetched, count:",ie.data?.length??0),Re(ie.data??[]);}).catch(ie=>{console.warn("[OnrampScreen] payment_tokens error:",ie?.message),be(ie);}),console.log("[OnrampScreen] walletAddress:",g,"walletNetwork:",S),g&&(console.log("[OnrampScreen] calling getTransactionLimits..."),Pu({destinationNetwork:S||"ethereum",walletAddress:g,accessToken:Pe,cryptoCustomerId:oe}).then(ie=>{console.log("[OnrampScreen] transaction_limits fetched");let de=ie.limits?.usd;if(de?.card?.length){let zt=Math.max(...de.card.map(ue=>ue.limit));Fe(zt),console.log("[OnrampScreen] card max amount:",zt);}}).catch(ie=>{console.warn("[OnrampScreen] transaction_limits error:",ie?.message),be(ie);}));},[a,n,oe,Pe,g,S,me]);let X=async()=>{if(!(!oe||!Pe))try{let Le=await Fc(oe,Pe);console.log("[OnrampScreen] payment_tokens refreshed, count:",Le.data?.length??0),Re(Le.data??[]);}catch(Le){console.warn("[OnrampScreen] payment_tokens refresh error:",Le?.message);let be=Le?.message??"";(be.includes("stripe_onramp_forbidden")||be.includes("403"))&&(Tn(),me());}},ce=async()=>{let Le=await J();return Le&&await X(),Le},st=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&st&&h&&(_e(h),me(),t?.());},[n,st,h,_e,me,t]);let Je=()=>{me(),t?.();};return a?jsx(View,{style:[Kh.container,{backgroundColor:r.colors.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})}):n==="email"?jsx(Nu,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:rt,loading:i,error:l,status:s,email:p,setEmail:T,checkEmail:v,onClose:Je}):n==="register"?jsx(Gu,{styles:o,hasPrefilledPhone:je,loading:i,error:l,status:s,email:p,phone:c,setPhone:w,register:q,onClose:Je}):n==="kyc"?jsx(Qa,{initialData:k,loading:i,onComplete:N,onCancel:()=>_("email")}):n==="identity"?jsx($u,{styles:o,loading:i,status:s,error:l,verifyIdentity:ae,onClose:Je}):n==="wallet"?jsx(Ju,{styles:o,hasAutoWallet:ot,loading:i,error:l,status:s,walletAddress:g,walletNetwork:S,setWalletAddress:x,setWalletNetwork:W,setDestinationCurrency:F,registerWallet:ze,onClose:Je}):n==="session_params"?jsx(qa,{initialAmount:y,currency:m,applePaySupported:R,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:$e,paymentTokens:ct,onAddPaymentMethod:ce,onCollectPayment:(Le,be)=>{ve(Le,be);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(Le,be)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:Le,selectedMethod:be,amountFirst:Se}),Se&&!oe)D(Le),_("email");else {let ie=be==="apple_pay",de=!ie&&be?be:void 0;console.log("[OnrampScreen] isApplePay:",ie,"hasSavedToken:",!!de),ve(ie,Le,de);}},onCancel:Je,accessToken:Pe}):n==="quote"&&h?jsx(Ku,{styles:o,session:h,loading:i,error:l,status:s,confirmCheckout:Ve,tokenIconUrl:d,networkIconUrl:f,onClose:Je,onBack:()=>_("session_params")}):n==="processing"?jsx(Qu,{styles:o,error:l,status:s,loading:i,sourceCurrency:h?.transaction_details.source_currency,destinationCurrency:h?.transaction_details.destination_currency??b,destinationNetwork:h?.transaction_details.destination_network??"base",tokenIconUrl:d,networkIconUrl:f,onClose:Je,onRetryStatusCheck:Ne}):n==="success"&&h&&!st?jsx(Yu,{styles:o,session:h,resolvedRecipientAddress:C,recipientFromConfig:e?.recipientAddress,tokenIconUrl:d,networkIconUrl:f,onDone:()=>{_e(h),me(),t?.();}}):null}var Kh=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function ep(){try{let e=Gh.expoConfig?.plugins;if(!Array.isArray(e))return;for(let t of e){if(!Array.isArray(t))continue;let[r,o]=t;if(r!=="@stripe/stripe-react-native"||!o||typeof o!="object")continue;let n=o.merchantIdentifier;if(typeof n=="string"){let a=n.trim();if(a.length>0)return a}}}catch{}}function el({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:p,onError:c,onStepChange:h,onClose:k,merchantIdentifier:g="",urlScheme:C="unifoldOnramp",paymentSelectorPosition:S,skipSuccessConfirmation:y=false}){let{colors:m,fonts:b,components:d}=O(),f=e||Pa(),R=useMemo(()=>{let D=g.trim();return D.length>0?D:ep()??""},[g]),[_,T]=useState("loading"),[w,x]=useState(null);useEffect(()=>{let D=false;async function F(){try{f&&(Ua(f),Ha(Vs()));let v=await Na();if(D)return;let q=R.trim();if(await initStripe({publishableKey:v,urlScheme:C,...q?{merchantIdentifier:q}:{}}),D)return;T("ready");}catch(v){if(D)return;console.error("[StripeOnramp] Init failed:",v),x(v?.message??"Failed to load Stripe configuration"),T("error");}}return F(),()=>{D=true;}},[f,R,C]);let W=useMemo(()=>{let D={publishableKey:f,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:p,onError:c,onStepChange:h};return s&&(D.destinationTokenAddress=s),l&&(D.recipientAddress=l),t&&(D.email=t),r&&(D.phone=r),n&&(D.flowOrder=n),S&&(D.paymentSelectorPosition=S),D.skipSuccessConfirmation=y,D.merchantIdentifier=R,D},[f,o,a,i,s,l,t,r,n,S,y,R,p,c,h]);return _==="error"?jsxs(View,{style:[$i.centered,{backgroundColor:m.background}],children:[jsx(Text,{style:[$i.errorText,{color:m.error,fontFamily:b.medium}],children:"Unable to initialize"}),jsx(Text,{style:[$i.errorDetail,{color:m.foregroundMuted,fontFamily:b.regular}],children:w}),k&&jsx(TouchableOpacity,{style:[$i.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:k,children:jsx(Text,{style:[$i.retryBtnText,{color:d.button.primaryText,fontFamily:b.medium}],children:"Go Back"})})]}):_==="loading"?jsx(View,{style:[$i.centered,{backgroundColor:m.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:m.primary,gradientTo:m.primary})}):jsx(Xa,{config:W,onClose:k})}var $i=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",paddingHorizontal:24},errorText:{fontSize:18,marginBottom:8},errorDetail:{fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{paddingVertical:14,paddingHorizontal:32},retryBtnText:{fontSize:16}});function np(){let{configure:e}=useOnramp(),t=useRef(false);return useEffect(()=>{t.current||(t.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(r=>{r.error&&console.error("[StripeOnrampPreconfigure] error:",r.error.message);}).catch(r=>{console.error("[StripeOnrampPreconfigure] threw:",r?.message);}));},[e]),null}var ip="__unifold_stripe_onramp__";function tl(e){globalThis[ip]=e;}function sp(){return globalThis[ip]}tl(el);var vo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this);}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe();}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var oi,vn,qi,ap,ng=(ap=class extends vo{constructor(){super();Z(this,oi);Z(this,vn);Z(this,qi);A(this,qi,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){u(this,vn)||this.setEventListener(u(this,qi));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,vn))==null||t.call(this),A(this,vn,void 0));}setEventListener(t){var r;A(this,qi,t),(r=u(this,vn))==null||r.call(this),A(this,vn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){u(this,oi)!==t&&(A(this,oi,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof u(this,oi)=="boolean"?u(this,oi):globalThis.document?.visibilityState!=="hidden"}},oi=new WeakMap,vn=new WeakMap,qi=new WeakMap,ap),Qi=new ng;var ig={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Po,ni,lp,sg=(lp=class{constructor(){Z(this,Po,ig);Z(this,ni,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&u(this,ni)&&e!==u(this,Po)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:u(this,Po),provider:e}),A(this,Po,e),process.env.NODE_ENV!=="production"&&A(this,ni,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setTimeout(e,t)}clearTimeout(e){u(this,Po).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setInterval(e,t)}clearInterval(e){u(this,Po).clearInterval(e);}},Po=new WeakMap,ni=new WeakMap,lp),Fo=new sg;function cp(e){setTimeout(e,0);}var Nc=typeof window>"u"||"Deno"in globalThis;function nr(){}function pp(e,t){return typeof e=="function"?e(t):e}function qs(e){return typeof e=="number"&&e>=0&&e!==1/0}function ol(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bo(e,t){return typeof e=="function"?e(t):e}function Br(e,t){return typeof e=="function"?e(t):e}function nl(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Qs(i,t.options))return false}else if(!ai(t.queryKey,i))return false}if(r!=="all"){let l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return false}return !(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||a&&!a(t))}function il(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(ii(t.options.mutationKey)!==ii(a))return false}else if(!ai(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Qs(e,t){return (t?.queryKeyHashFn||ii)(e)}function ii(e){return JSON.stringify(e,(t,r)=>Hc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ai(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ai(e[r],t[r])):false}var ag=Object.prototype.hasOwnProperty;function rl(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=dp(e)&&dp(t);if(!o&&!(Hc(e)&&Hc(t)))return t;let a=(o?e:Object.keys(e)).length,i=o?t:Object.keys(t),s=i.length,l=o?new Array(s):{},p=0;for(let c=0;c<s;c++){let h=o?c:i[c],k=e[h],g=t[h];if(k===g){l[h]=k,(o?c<a:ag.call(e,h))&&p++;continue}if(k===null||g===null||typeof k!="object"||typeof g!="object"){l[h]=g;continue}let C=rl(k,g,r+1);l[h]=C,C===k&&p++;}return a===s&&p===a?e:l}function sl(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return false;for(let r in e)if(e[r]!==t[r])return false;return true}function dp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Hc(e){if(!up(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!up(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function up(e){return Object.prototype.toString.call(e)==="[object Object]"}function mp(e){return new Promise(t=>{Fo.setTimeout(t,e);})}function Ks(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==false){if(process.env.NODE_ENV!=="production")try{return rl(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 rl(e,t)}return t}function fp(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function hp(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var si=Symbol();function al(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===si&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ll(e,t){return typeof e=="function"?e(...t):!!e}function gp(e,t,r){let o=false,n;return Object.defineProperty(e,"signal",{enumerable:true,get:()=>(n??(n=t()),o||(o=true,n.aborted?r():n.addEventListener("abort",r,{once:true})),n)}),e}var Oo=(()=>{let e=()=>Nc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function Gs(){let e,t,r=new Promise((n,a)=>{e=n,t=a;});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject;}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n);},r.reject=n=>{o({status:"rejected",reason:n}),t(n);},r}var yp=cp;function lg(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=yp,a=s=>{t?e.push(s):n(()=>{r(s);});},i=()=>{let s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(l);});});});};return {batch:s=>{let l;t++;try{l=s();}finally{t--,t||i();}return l},batchCalls:s=>(...l)=>{a(()=>{s(...l);});},schedule:a,setNotifyFunction:s=>{r=s;},setBatchNotifyFunction:s=>{o=s;},setScheduler:s=>{n=s;}}}var vt=lg();var Ki,Pn,Gi,bp,cg=(bp=class extends vo{constructor(){super();Z(this,Ki,true);Z(this,Pn);Z(this,Gi);A(this,Gi,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t(true),o=()=>t(false);return window.addEventListener("online",r,false),window.addEventListener("offline",o,false),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o);}}});}onSubscribe(){u(this,Pn)||this.setEventListener(u(this,Gi));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,Pn))==null||t.call(this),A(this,Pn,void 0));}setEventListener(t){var r;A(this,Gi,t),(r=u(this,Pn))==null||r.call(this),A(this,Pn,t(this.setOnline.bind(this)));}setOnline(t){u(this,Ki)!==t&&(A(this,Ki,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return u(this,Ki)}},Ki=new WeakMap,Pn=new WeakMap,Gi=new WeakMap,bp),Yi=new cg;function dg(e){return Math.min(1e3*2**e,3e4)}function jc(e){return (e??"online")==="online"?Yi.isOnline():true}var cl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function dl(e){let t=false,r=0,o,n=Gs(),a=()=>n.status!=="pending",i=S=>{if(!a()){let y=new cl(S);k(y),e.onCancel?.(y);}},s=()=>{t=true;},l=()=>{t=false;},p=()=>Qi.isFocused()&&(e.networkMode==="always"||Yi.isOnline())&&e.canRun(),c=()=>jc(e.networkMode)&&e.canRun(),h=S=>{a()||(o?.(),n.resolve(S));},k=S=>{a()||(o?.(),n.reject(S));},g=()=>new Promise(S=>{o=y=>{(a()||p())&&S(y);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),C=()=>{if(a())return;let S,y=r===0?e.initialPromise:void 0;try{S=y??e.fn();}catch(m){S=Promise.reject(m);}Promise.resolve(S).then(h).catch(m=>{if(a())return;let b=e.retry??(Oo.isServer()?0:3),d=e.retryDelay??dg,f=typeof d=="function"?d(r,m):d,R=b===true||typeof b=="number"&&r<b||typeof b=="function"&&b(r,m);if(t||!R){k(m);return}r++,e.onFail?.(r,m),mp(f).then(()=>p()?void 0:g()).then(()=>{t?k(m):C();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?C():g().then(C),n)}}var li,Cp,ul=(Cp=class{constructor(){Z(this,li);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),qs(this.gcTime)&&A(this,li,Fo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Oo.isServer()?1/0:300*1e3));}clearGcTimeout(){u(this,li)!==void 0&&(Fo.clearTimeout(u(this,li)),A(this,li,void 0));}},li=new WeakMap,Cp);var ci,Ji,so,di,cr,Ys,ui,Qr,xp,Yo,kp,Tp=(kp=class extends ul{constructor(t){super();Z(this,Qr);Z(this,ci);Z(this,Ji);Z(this,so);Z(this,di);Z(this,cr);Z(this,Ys);Z(this,ui);A(this,ui,false),A(this,Ys,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,di,t.client),A(this,so,u(this,di).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,ci,Sp(this.options)),this.state=t.state??u(this,ci),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return u(this,cr)?.promise}setOptions(t){if(this.options={...u(this,Ys),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Sp(this.options);r.data!==void 0&&(this.setState(wp(r.data,r.dataUpdatedAt)),A(this,ci,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&u(this,so).remove(this);}setData(t,r){let o=Ks(this.state.data,t,this.options);return Ae(this,Qr,Yo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Ae(this,Qr,Yo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=u(this,cr)?.promise;return u(this,cr)?.cancel(t),r?r.then(nr).catch(nr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return u(this,ci)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Br(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===si||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bo(t.options.staleTime,this)==="static"):false}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?true:t==="static"?false:this.state.isInvalidated?true:!ol(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),u(this,so).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(u(this,cr)&&(u(this,ui)||Ae(this,Qr,xp).call(this)?u(this,cr).cancel({revert:true}):u(this,cr).cancelRetry()),this.scheduleGc()),u(this,so).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Qr,Yo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&u(this,cr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(u(this,cr))return u(this,cr).continueRetry(),u(this,cr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(p=>p.options.queryFn);l&&this.setOptions(l.options);}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));let o=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:true,get:()=>(A(this,ui,true),o.signal)});},a=()=>{let l=al(this.options,r),c=(()=>{let h={client:u(this,di),queryKey:this.queryKey,meta:this.meta};return n(h),h})();return A(this,ui,false),this.options.persister?this.options.persister(l,c,this):l(c)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:u(this,di),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),A(this,Ji,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Ae(this,Qr,Yo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),A(this,cr,dl({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof cl&&l.revert&&this.setState({...u(this,Ji),fetchStatus:"idle"}),o.abort();},onFail:(l,p)=>{Ae(this,Qr,Yo).call(this,{type:"failed",failureCount:l,error:p});},onPause:()=>{Ae(this,Qr,Yo).call(this,{type:"pause"});},onContinue:()=>{Ae(this,Qr,Yo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await u(this,cr).start();if(l===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(l),u(this,so).config.onSuccess?.(l,this),u(this,so).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof cl){if(l.silent)return u(this,cr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Ae(this,Qr,Yo).call(this,{type:"error",error:l}),u(this,so).config.onError?.(l,this),u(this,so).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ci=new WeakMap,Ji=new WeakMap,so=new WeakMap,di=new WeakMap,cr=new WeakMap,Ys=new WeakMap,ui=new WeakMap,Qr=new WeakSet,xp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Yo=function(t){let r=o=>{switch(t.type){case "failed":return {...o,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case "pause":return {...o,fetchStatus:"paused"};case "continue":return {...o,fetchStatus:"fetching"};case "fetch":return {...o,...$c(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...wp(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,Ji,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),vt.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),u(this,so).notify({query:this,type:"updated",action:t});});},kp);function $c(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function wp(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Sp(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return {data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:false,status:r?"success":"pending",fetchStatus:"idle"}}var Ar,Ke,Zs,vr,pi,Zi,Jo,Fn,Xs,Xi,es,mi,fi,On,ts,mt,Js,qc,Qc,Kc,Gc,Yc,Jc,Zc,vp,Ip,ed=(Ip=class extends vo{constructor(t,r){super();Z(this,mt);Z(this,Ar);Z(this,Ke);Z(this,Zs);Z(this,vr);Z(this,pi);Z(this,Zi);Z(this,Jo);Z(this,Fn);Z(this,Xs);Z(this,Xi);Z(this,es);Z(this,mi);Z(this,fi);Z(this,On);Z(this,ts,new Set);this.options=r,A(this,Ar,t),A(this,Fn,null),A(this,Jo,Gs()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(u(this,Ke).addObserver(this),_p(u(this,Ke),this.options)?Ae(this,mt,Js).call(this):this.updateResult(),Ae(this,mt,Gc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Xc(u(this,Ke),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xc(u(this,Ke),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,mt,Yc).call(this),Ae(this,mt,Jc).call(this),u(this,Ke).removeObserver(this);}setOptions(t){let r=this.options,o=u(this,Ke);if(this.options=u(this,Ar).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Br(this.options.enabled,u(this,Ke))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,mt,Zc).call(this),u(this,Ke).setOptions(this.options),r._defaulted&&!sl(this.options,r)&&u(this,Ar).getQueryCache().notify({type:"observerOptionsUpdated",query:u(this,Ke),observer:this});let n=this.hasListeners();n&&Rp(u(this,Ke),o,this.options,r)&&Ae(this,mt,Js).call(this),this.updateResult(),n&&(u(this,Ke)!==o||Br(this.options.enabled,u(this,Ke))!==Br(r.enabled,u(this,Ke))||bo(this.options.staleTime,u(this,Ke))!==bo(r.staleTime,u(this,Ke)))&&Ae(this,mt,qc).call(this);let a=Ae(this,mt,Qc).call(this);n&&(u(this,Ke)!==o||Br(this.options.enabled,u(this,Ke))!==Br(r.enabled,u(this,Ke))||a!==u(this,On))&&Ae(this,mt,Kc).call(this,a);}getOptimisticResult(t){let r=u(this,Ar).getQueryCache().build(u(this,Ar),t),o=this.createResult(r,t);return pg(this,o)&&(A(this,vr,o),A(this,Zi,this.options),A(this,pi,u(this,Ke).state)),o}getCurrentResult(){return u(this,vr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&u(this,Jo).status==="pending"&&u(this,Jo).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){u(this,ts).add(t);}getCurrentQuery(){return u(this,Ke)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=u(this,Ar).defaultQueryOptions(t),o=u(this,Ar).getQueryCache().build(u(this,Ar),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Ae(this,mt,Js).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),u(this,vr)))}createResult(t,r){let o=u(this,Ke),n=this.options,a=u(this,vr),i=u(this,pi),s=u(this,Zi),p=t!==o?t.state:u(this,Zs),{state:c}=t,h={...c},k=false,g;if(r._optimisticResults){let x=this.hasListeners(),W=!x&&_p(t,r),D=x&&Rp(t,o,r,n);(W||D)&&(h={...h,...$c(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle");}let{error:C,errorUpdatedAt:S,status:y}=h;g=h.data;let m=false;if(r.placeholderData!==void 0&&g===void 0&&y==="pending"){let x;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(x=a.data,m=true):x=typeof r.placeholderData=="function"?r.placeholderData(u(this,es)?.state.data,u(this,es)):r.placeholderData,x!==void 0&&(y="success",g=Ks(a?.data,x,r),k=true);}if(r.select&&g!==void 0&&!m)if(a&&g===i?.data&&r.select===u(this,Xs))g=u(this,Xi);else try{A(this,Xs,r.select),g=r.select(g),g=Ks(a?.data,g,r),A(this,Xi,g),A(this,Fn,null);}catch(x){A(this,Fn,x);}u(this,Fn)&&(C=u(this,Fn),g=u(this,Xi),S=Date.now(),y="error");let b=h.fetchStatus==="fetching",d=y==="pending",f=y==="error",R=d&&b,_=g!==void 0,w={status:y,fetchStatus:h.fetchStatus,isPending:d,isSuccess:y==="success",isError:f,isInitialLoading:R,isLoading:R,data:g,dataUpdatedAt:h.dataUpdatedAt,error:C,errorUpdatedAt:S,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>p.dataUpdateCount||h.errorUpdateCount>p.errorUpdateCount,isFetching:b,isRefetching:b&&!d,isLoadingError:f&&!_,isPaused:h.fetchStatus==="paused",isPlaceholderData:k,isRefetchError:f&&_,isStale:td(t,r),refetch:this.refetch,promise:u(this,Jo),isEnabled:Br(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let x=w.data!==void 0,W=w.status==="error"&&!x,D=q=>{W?q.reject(w.error):x&&q.resolve(w.data);},F=()=>{let q=A(this,Jo,w.promise=Gs());D(q);},v=u(this,Jo);switch(v.status){case "pending":t.queryHash===o.queryHash&&D(v);break;case "fulfilled":(W||w.data!==v.value)&&F();break;case "rejected":(!W||w.error!==v.reason)&&F();break}}return w}updateResult(){let t=u(this,vr),r=this.createResult(u(this,Ke),this.options);if(A(this,pi,u(this,Ke).state),A(this,Zi,this.options),u(this,pi).data!==void 0&&A(this,es,u(this,Ke)),sl(r,t))return;A(this,vr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!u(this,ts).size)return true;let i=new Set(a??u(this,ts));return this.options.throwOnError&&i.add("error"),Object.keys(u(this,vr)).some(s=>{let l=s;return u(this,vr)[l]!==t[l]&&i.has(l)})};Ae(this,mt,vp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,mt,Gc).call(this);}},Ar=new WeakMap,Ke=new WeakMap,Zs=new WeakMap,vr=new WeakMap,pi=new WeakMap,Zi=new WeakMap,Jo=new WeakMap,Fn=new WeakMap,Xs=new WeakMap,Xi=new WeakMap,es=new WeakMap,mi=new WeakMap,fi=new WeakMap,On=new WeakMap,ts=new WeakMap,mt=new WeakSet,Js=function(t){Ae(this,mt,Zc).call(this);let r=u(this,Ke).fetch(this.options,t);return t?.throwOnError||(r=r.catch(nr)),r},qc=function(){Ae(this,mt,Yc).call(this);let t=bo(this.options.staleTime,u(this,Ke));if(Oo.isServer()||u(this,vr).isStale||!qs(t))return;let o=ol(u(this,vr).dataUpdatedAt,t)+1;A(this,mi,Fo.setTimeout(()=>{u(this,vr).isStale||this.updateResult();},o));},Qc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(u(this,Ke)):this.options.refetchInterval)??false},Kc=function(t){Ae(this,mt,Jc).call(this),A(this,On,t),!(Oo.isServer()||Br(this.options.enabled,u(this,Ke))===false||!qs(u(this,On))||u(this,On)===0)&&A(this,fi,Fo.setInterval(()=>{(this.options.refetchIntervalInBackground||Qi.isFocused())&&Ae(this,mt,Js).call(this);},u(this,On)));},Gc=function(){Ae(this,mt,qc).call(this),Ae(this,mt,Kc).call(this,Ae(this,mt,Qc).call(this));},Yc=function(){u(this,mi)!==void 0&&(Fo.clearTimeout(u(this,mi)),A(this,mi,void 0));},Jc=function(){u(this,fi)!==void 0&&(Fo.clearInterval(u(this,fi)),A(this,fi,void 0));},Zc=function(){let t=u(this,Ar).getQueryCache().build(u(this,Ar),this.options);if(t===u(this,Ke))return;let r=u(this,Ke);A(this,Ke,t),A(this,Zs,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},vp=function(t){vt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(u(this,vr));}),u(this,Ar).getQueryCache().notify({query:u(this,Ke),type:"observerResultsUpdated"});});},Ip);function ug(e,t){return Br(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function _p(e,t){return ug(e,t)||e.state.data!==void 0&&Xc(e,t,t.refetchOnMount)}function Xc(e,t,r){if(Br(t.enabled,e)!==false&&bo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&td(e,t)}return false}function Rp(e,t,r,o){return (e!==t||Br(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&td(e,r)}function td(e,t){return Br(t.enabled,e)!==false&&e.isStaleByTime(bo(t.staleTime,e))}function pg(e,t){return !sl(e.getCurrentResult(),t)}function rd(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],i=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},l=0,p=async()=>{let c=false,h=C=>{gp(C,()=>t.signal,()=>c=true);},k=al(t.options,t.fetchOptions),g=async(C,S,y)=>{if(c)return Promise.reject();if(S==null&&C.pages.length)return Promise.resolve(C);let b=(()=>{let _={client:t.client,queryKey:t.queryKey,pageParam:S,direction:y?"backward":"forward",meta:t.options.meta};return h(_),_})(),d=await k(b),{maxPages:f}=t.options,R=y?hp:fp;return {pages:R(C.pages,d,f),pageParams:R(C.pageParams,S,f)}};if(n&&a.length){let C=n==="backward",S=C?mg:Pp,y={pages:a,pageParams:i},m=S(o,y);s=await g(y,m,C);}else {let C=e??a.length;do{let S=l===0?i[0]??o.initialPageParam:Pp(o,s);if(l>0&&S==null)break;s=await g(s,S),l++;}while(l<C)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=p;}}}function Pp(e,{pages:t,pageParams:r}){let o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function mg(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ea,Do,wr,hi,Vo,Dn,Fp,Op=(Fp=class extends ul{constructor(t){super();Z(this,Vo);Z(this,ea);Z(this,Do);Z(this,wr);Z(this,hi);A(this,ea,t.client),this.mutationId=t.mutationId,A(this,wr,t.mutationCache),A(this,Do,[]),this.state=t.state||fg(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){u(this,Do).includes(t)||(u(this,Do).push(t),this.clearGcTimeout(),u(this,wr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Do,u(this,Do).filter(r=>r!==t)),this.scheduleGc(),u(this,wr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){u(this,Do).length||(this.state.status==="pending"?this.scheduleGc():u(this,wr).remove(this));}continue(){return u(this,hi)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Ae(this,Vo,Dn).call(this,{type:"continue"});},o={client:u(this,ea),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,hi,dl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Ae(this,Vo,Dn).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Ae(this,Vo,Dn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>u(this,wr).canRun(this)}));let n=this.state.status==="pending",a=!u(this,hi).canStart();try{if(n)r();else {Ae(this,Vo,Dn).call(this,{type:"pending",variables:t,isPaused:a}),u(this,wr).config.onMutate&&await u(this,wr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Ae(this,Vo,Dn).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await u(this,hi).start();return await u(this,wr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await u(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),Ae(this,Vo,Dn).call(this,{type:"success",data:i}),i}catch(i){try{await u(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 u(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 Ae(this,Vo,Dn).call(this,{type:"error",error:i}),i}finally{u(this,wr).runNext(this);}}},ea=new WeakMap,Do=new WeakMap,wr=new WeakMap,hi=new WeakMap,Vo=new WeakSet,Dn=function(t){let r=o=>{switch(t.type){case "failed":return {...o,failureCount:t.failureCount,failureReason:t.error};case "pause":return {...o,isPaused:true};case "continue":return {...o,isPaused:false};case "pending":return {...o,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case "success":return {...o,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:false};case "error":return {...o,data:void 0,error:t.error,failureCount:o.failureCount+1,failureReason:t.error,isPaused:false,status:"error"}}};this.state=r(this.state),vt.batch(()=>{u(this,Do).forEach(o=>{o.onMutationUpdate(t);}),u(this,wr).notify({mutation:this,type:"updated",action:t});});},Fp);function fg(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Zo,Co,ta,Dp,Vp=(Dp=class extends vo{constructor(t={}){super();Z(this,Zo);Z(this,Co);Z(this,ta);this.config=t,A(this,Zo,new Set),A(this,Co,new Map),A(this,ta,0);}build(t,r,o){let n=new Op({client:t,mutationCache:this,mutationId:++xs(this,ta)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){u(this,Zo).add(t);let r=pl(t);if(typeof r=="string"){let o=u(this,Co).get(r);o?o.push(t):u(this,Co).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(u(this,Zo).delete(t)){let r=pl(t);if(typeof r=="string"){let o=u(this,Co).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&u(this,Co).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=pl(t);if(typeof r=="string"){let n=u(this,Co).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=pl(t);return typeof r=="string"?u(this,Co).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){vt.batch(()=>{u(this,Zo).forEach(t=>{this.notify({type:"removed",mutation:t});}),u(this,Zo).clear(),u(this,Co).clear();});}getAll(){return Array.from(u(this,Zo))}find(t){let r={exact:true,...t};return this.getAll().find(o=>il(r,o))}findAll(t={}){return this.getAll().filter(r=>il(t,r))}notify(t){vt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return vt.batch(()=>Promise.all(t.map(r=>r.continue().catch(nr))))}},Zo=new WeakMap,Co=new WeakMap,ta=new WeakMap,Dp);function pl(e){return e.options.scope?.id}var Lo,Lp,Bp=(Lp=class extends vo{constructor(t={}){super();Z(this,Lo);this.config=t,A(this,Lo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Qs(n,r),i=this.get(a);return i||(i=new Tp({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){u(this,Lo).has(t.queryHash)||(u(this,Lo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=u(this,Lo).get(t.queryHash);r&&(t.destroy(),r===t&&u(this,Lo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){vt.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return u(this,Lo).get(t)}getAll(){return [...u(this,Lo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>nl(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>nl(t,o)):r}notify(t){vt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){vt.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){vt.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Lo=new WeakMap,Lp);var Qt,Vn,Ln,rs,os,Bn,ns,is,Ap,od=(Ap=class{constructor(e={}){Z(this,Qt);Z(this,Vn);Z(this,Ln);Z(this,rs);Z(this,os);Z(this,Bn);Z(this,ns);Z(this,is);A(this,Qt,e.queryCache||new Bp),A(this,Vn,e.mutationCache||new Vp),A(this,Ln,e.defaultOptions||{}),A(this,rs,new Map),A(this,os,new Map),A(this,Bn,0);}mount(){xs(this,Bn)._++,u(this,Bn)===1&&(A(this,ns,Qi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,Qt).onFocus());})),A(this,is,Yi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,Qt).onOnline());})));}unmount(){var e,t;xs(this,Bn)._--,u(this,Bn)===0&&((e=u(this,ns))==null||e.call(this),A(this,ns,void 0),(t=u(this,is))==null||t.call(this),A(this,is,void 0));}isFetching(e){return u(this,Qt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return u(this,Vn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,Qt).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=u(this,Qt).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(bo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return u(this,Qt).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),a=u(this,Qt).get(o.queryHash)?.state.data,i=pp(t,a);if(i!==void 0)return u(this,Qt).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return vt.batch(()=>u(this,Qt).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,Qt).get(t.queryHash)?.state}removeQueries(e){let t=u(this,Qt);vt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=u(this,Qt);return vt.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=vt.batch(()=>u(this,Qt).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(nr).catch(nr)}invalidateQueries(e,t={}){return vt.batch(()=>(u(this,Qt).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=vt.batch(()=>u(this,Qt).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(nr)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(nr)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=u(this,Qt).build(this,t);return r.isStaleByTime(bo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(nr).catch(nr)}fetchInfiniteQuery(e){return e.behavior=rd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(nr).catch(nr)}ensureInfiniteQueryData(e){return e.behavior=rd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Yi.isOnline()?u(this,Vn).resumePausedMutations():Promise.resolve()}getQueryCache(){return u(this,Qt)}getMutationCache(){return u(this,Vn)}getDefaultOptions(){return u(this,Ln)}setDefaultOptions(e){A(this,Ln,e);}setQueryDefaults(e,t){u(this,rs).set(ii(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...u(this,rs).values()],r={};return t.forEach(o=>{ai(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){u(this,os).set(ii(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...u(this,os).values()],r={};return t.forEach(o=>{ai(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...u(this,Ln).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Qs(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===si&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...u(this,Ln).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){u(this,Qt).clear(),u(this,Vn).clear();}},Qt=new WeakMap,Vn=new WeakMap,Ln=new WeakMap,rs=new WeakMap,os=new WeakMap,Bn=new WeakMap,ns=new WeakMap,is=new WeakMap,Ap);var nd=An.createContext(void 0),id=e=>{let t=An.useContext(nd);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},sd=({client:e,children:t})=>(An.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(nd.Provider,{value:e,children:t}));var Wp=An.createContext(false),Ep=()=>An.useContext(Wp);Wp.Provider;function gg(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var yg=An.createContext(gg()),Mp=()=>An.useContext(yg);var Up=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?ll(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Hp=e=>{An.useEffect(()=>{e.clearReset();},[e]);},Np=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||ll(r,[e.error,o]));var jp=e=>{if(e.suspense){let r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3));}},$p=(e,t)=>e.isLoading&&e.isFetching&&!t,qp=(e,t)=>e?.suspense&&t.isPending,ad=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Qp(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let o=Ep(),n=Mp(),a=id(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);let s=a.getQueryCache().get(i.queryHash);process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=o?"isRestoring":"optimistic",jp(i),Up(i,n,s),Hp(n);let l=!a.getQueryCache().get(i.queryHash),[p]=An.useState(()=>new t(a,i)),c=p.getOptimisticResult(i),h=!o&&e.subscribed!==false;if(An.useSyncExternalStore(An.useCallback(k=>{let g=h?p.subscribe(vt.batchCalls(k)):nr;return p.updateResult(),g},[p,h]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),An.useEffect(()=>{p.setOptions(i);},[i,p]),qp(i,c))throw ad(i,p,n);if(Np({result:c,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,c),i.experimental_prefetchInRender&&!Oo.isServer()&&$p(c,o)&&(l?ad(i,p,n):s?.promise)?.catch(nr).finally(()=>{p.updateResult();}),i.notifyOnChangeProps?c:p.trackResult(c)}function Xo(e,t){return Qp(e,ed)}var ls=new Map;function Kp({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let a=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return a.start(),()=>a.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function En({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=O(),[p,c]=useState(false),[h,k]=useState(false),[g,C]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let R=ls.get(e);return R?{uri:e,xml:R}:null}),S=e?.toLowerCase().endsWith(".svg"),y=S&&e&&g?.uri===e?g.xml:null;useEffect(()=>{c(false),k(false);},[e]),useEffect(()=>{if(!S||!e)return;if(ls.has(e)){C({uri:e,xml:ls.get(e)});return}let R=false;return fetch(e).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.text()}).then(_=>{R||(ls.set(e,_),C({uri:e,xml:_}));}).catch(()=>{R||c(true);}),()=>{R=true;}},[e,S]);let m=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:m},s]});let b={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 p?jsx(View,{style:[b,{backgroundColor:i||m}]}):S?jsxs(View,{style:b,children:[!!!y&&jsx(Kp,{width:d,height:f,borderRadius:o,color:m}),y?jsx(SvgXml,{xml:y,width:d,height:f,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:d,height:f,onError:()=>c(true)})]}):jsxs(View,{style:b,children:[!h&&jsx(Kp,{width:d,height:f,borderRadius:o,color:m}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:d,height:f},resizeMode:"contain",onLoad:()=>k(true),onError:()=>c(true)})]})}function dd(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 Pr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:p,balanceChainId:c,balanceTokenAddress:h,publishableKey:k,projectName:g,leftIcon:C,onLeftAction:S}){let{colors:y,fonts:m,components:b}=O(),[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||!p||!c||!h||!k){f(null),_(false);return}let x=false;return _(true),La(l,p,c,h,k).then(W=>{if(x)return;let D=W.balance,F=null;D&&(D.amount_usd!=null&&D.amount_usd!==""?F=`$${D.amount_usd}`:F="$0.00"),f(F);}).catch(()=>{x||f(null);}).finally(()=>{x||_(false);}),()=>{x=true;}},[s,l,p,c,h,k]);let w=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(Rs,{size:20,color:b.header.buttonColor,strokeWidth:2})}):C&&S?jsx(TouchableOpacity,{onPress:S,style:[Sr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:C}):jsx(View,{style:Sr.spacer})}),jsxs(View,{style:Sr.titleContainer,children:[jsxs(View,{style:Sr.titleRow,children:[jsx(Text,{style:[Sr.title,{color:b.header.titleColor,fontFamily:m.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[Sr.titleBadge,{backgroundColor:y.card}],children:jsx(Text,{style:[Sr.titleBadgeText,{color:y.foregroundMuted,fontFamily:m.regular}],children:i.count})})]}),t?jsx(Text,{style:[Sr.balanceText,{color:y.foregroundMuted,fontFamily:m.regular}],children:t}):null,s&&(R?jsx(Animated.View,{style:[Sr.balanceSkeleton,{backgroundColor:y.cardHover,opacity:w}]}):d!=null?jsxs(Text,{style:[Sr.balanceText,{color:y.foregroundMuted,fontFamily:m.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(at,{size:20,color:b.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 ir({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=O(),s=a??i.card,l=s.backShadowColor!=="transparent",p={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},c=[Zp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],h=[p,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[Zp.backShadow,{top:s.backShadowOffset.top,left:s.backShadowOffset.left,right:s.backShadowOffset.right,bottom:s.backShadowOffset.bottom,backgroundColor:s.backShadowColor,borderRadius:s.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:h,children:e}):jsx(View,{style:h,children:e})]})}var Zp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function oa({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=O(),i=a.depositMenu.card,s=o?[...o].sort((l,p)=>l.position-p.position):[];return jsxs(ir,{cardTokens:i,onPress:e,style:Bo.wrapper,contentStyle:Bo.container,children:[jsxs(View,{style:Bo.leftContent,children:[jsx(View,{style:[Bo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(sc,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Bo.textContainer,children:[jsx(Text,{style:[Bo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Bo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Bo.rightContent,children:jsx(View,{style:Bo.networkIcons,children:s.map((l,p)=>{let c=l.icon_urls.find(h=>h.format==="png")?.url||l.icon_urls.find(h=>h.format==="svg")?.url;return jsx(View,{style:[Bo.networkIconWrapper,{marginLeft:p===0?0:-6,zIndex:s.length-p}],children:jsx(En,{uri:te(c),width:20,height:20})},l.name)})})})]})}var Bo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},networkIcons:{flexDirection:"row",alignItems:"center"},networkIconWrapper:{}});function ia({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=O(),i=a.depositMenu.card;return jsxs(ir,{cardTokens:i,onPress:e,style:en.wrapper,contentStyle:en.container,children:[jsxs(View,{style:en.leftContent,children:[jsx(View,{style:[en.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Pi,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:en.textContainer,children:[jsx(Text,{style:[en.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[en.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:en.rightContent,children:jsx(View,{style:en.paymentIcons,children:o?.map(s=>{let l=s.icon_urls.find(p=>p.format==="png")?.url||s.icon_urls.find(p=>p.format==="svg")?.url;return jsx(En,{uri:te(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var en=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},paymentIcons:{flexDirection:"row",alignItems:"center",gap:6}});function sa({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=O(),i=a.depositMenu.card;return jsx(ir,{cardTokens:i,onPress:e,style:tn.wrapper,contentStyle:tn.container,children:jsxs(View,{style:tn.leftContent,children:[jsxs(View,{style:[tn.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(zr,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[tn.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[tn.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:tn.textContainer,children:[jsx(Text,{style:[tn.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[tn.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var tn=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,alignItems:"center",justifyContent:"center",paddingHorizontal:4},badgeText:{color:"#FFFFFF",fontSize:10,fontWeight:"600"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"}});function la({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=O(),a=n.depositMenu.card;return jsxs(ir,{cardTokens:a,onPress:e,style:Ao.wrapper,contentStyle:Ao.container,children:[jsxs(View,{style:Ao.leftContent,children:[jsx(View,{style:[Ao.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(Ra,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Ao.textContainer,children:[jsx(Text,{style:[Ao.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Ao.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Ao.rightContent,children:jsx(View,{style:Ao.badge,children:jsx(Text,{style:[Ao.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Ao=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var rm=1e4,om=2500,nm=3e3,im=6e4;function ca(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:p,setDepositExecutions:c,setTrackedExecutions:h,setLatestExecution:k,setShowStatusSheet:g,onDepositSuccess:C,onExecutionsChange:S,onDepositError:y}=e,[m,b]=useState(false),[d,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;b(false),t==="auto_ui"&&f(false);let _=setTimeout(()=>{b(true),t==="auto_ui"&&f(true);},rm);return ()=>clearTimeout(_)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let _=new Date(i.getTime()-im),T=setInterval(async()=>{try{let W=[...(await Qo(n,a)).data??[]].sort((F,v)=>{let q=F.created_at?new Date(F.created_at).getTime():0;return (v.created_at?new Date(v.created_at).getTime():0)-q}),D=null;for(let F of W){let v=F.created_at?new Date(F.created_at):null;if(!v||v<=_)continue;let q=p.get(F.id);if(!q){D=F;break}if(["pending","waiting","delayed"].includes(q)&&F.status==="succeeded"){D=F;break}}if(D){let F=D;c(v=>{let q=v.findIndex(N=>N.id===F.id);if(q>=0){let N=[...v];return N[q]=F,N}return [...v,F]}),h(v=>{let q=new Map(v);return q.set(F.id,F.status),q}),k(F),g(!0),F.status==="succeeded"&&C?.({message:"Deposit completed successfully",executionId:F.id}),S?.([...l,F]);}}catch(w){y?.({message:"Failed to check deposit status",error:w});}},om);return ()=>clearInterval(T)},[n,a,i,p,l,S,C,y]),useEffect(()=>{if(!m||!s)return;let _=async()=>{try{await Fa(s,a);}catch{}};_();let T=setInterval(_,nm);return ()=>clearInterval(T)},[m,s,a]),{pollingEnabled:m,showWaitingUi:d,handleIveDeposited:()=>{b(true),f(true);}}}function ps({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=O(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",p=n||s;return jsxs(View,{style:[am.container,{width:t,height:t}],children:[jsx(Fg,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[am.logoContainer,{width:o+12,height:o+12,backgroundColor:p,borderRadius:(o+12)/2}],children:jsx(En,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var am=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function dm(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function Lg(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),a=e.getHours(),i=e.getMinutes(),s=a>=12?"pm":"am";a=a%12,a=a||12;let l=i<10?`0${i}`:i;return `${r} ${o}, ${n} at ${a}:${l}${s}`}function ms({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:p}){let{colors:c,fonts:h,components:k}=O(),[g,C]=useState(false),S=t==="pending"||t==="waiting"||t==="delayed",y=t==="succeeded",m=()=>{o&&Linking.openURL(o);},b=()=>{n&&Linking.openURL(n);};return jsx(ut,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:p,children:jsxs(View,{style:Wt.container,children:[jsx(TouchableOpacity,{style:Wt.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:k.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Wt.iconContainer,children:S?jsx(kt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:te(r)},style:Wt.tokenIconFill}):jsx(View,{style:[Wt.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:te(r)},style:Wt.tokenIconLarge}):jsx(View,{style:[Wt.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[Wt.statusBadge,{backgroundColor:k.container.iconBackgroundColor}],children:jsx(Ue,{size:16,color:k.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Wt.title,{color:k.container.titleColor,fontFamily:h.semibold}],children:S?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Wt.amount,{color:k.container.titleColor,fontFamily:h.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[Wt.date,{color:k.container.subtitleColor,fontFamily:h.regular}],children:Lg(a)}),jsx(Text,{style:[Wt.subtitle,{color:k.container.subtitleColor,fontFamily:h.regular}],children:S?"This usually takes less than a minute.":"Your account has been credited successfully!"}),y&&(o||n)&&jsxs(View,{style:Wt.detailsSection,children:[jsx(View,{style:[Wt.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:Wt.detailsToggle,onPress:()=>C(!g),children:[jsx(Text,{style:[Wt.detailsToggleText,{color:k.container.actionTitle,fontFamily:h.medium}],children:g?"See less":"See more details"}),g?jsx(To,{size:18,color:k.container.actionColor,strokeWidth:2}):jsx(At,{size:18,color:k.container.actionColor,strokeWidth:2})]}),g&&jsxs(View,{style:Wt.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Wt.txButton,{backgroundColor:k.card.backgroundColor,borderColor:c.border}],onPress:m,children:[jsx(Text,{style:[Wt.txLabel,{color:k.card.titleColor,fontFamily:h.medium}],children:"Deposit tx"}),jsx(Text,{style:[Wt.txHash,{color:k.card.subtitleColor,fontFamily:h.regular}],children:dm(o)}),jsx(ko,{size:16,color:k.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Wt.txButton,{backgroundColor:k.card.backgroundColor,borderColor:c.border}],onPress:b,children:[jsx(Text,{style:[Wt.txLabel,{color:k.card.titleColor,fontFamily:h.medium}],children:"Completion tx"}),jsx(Text,{style:[Wt.txHash,{color:k.card.subtitleColor,fontFamily:h.regular}],children:dm(n)}),jsx(ko,{size:16,color:k.card.actionColor,strokeWidth:2})]})]})]})]})})}var Wt=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 Cl({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=O();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[bi.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[bi.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[bi.processingCard,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor,shadowColor:s.card.shadowOpacity>0?s.card.shadowColor:void 0,shadowOffset:s.card.shadowOpacity>0?s.card.shadowOffset:void 0,shadowOpacity:s.card.shadowOpacity,shadowRadius:s.card.shadowRadius,elevation:s.card.elevation}],children:[jsx(View,{style:[bi.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(ac,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:bi.processingCardText,children:[jsx(Text,{style:[bi.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[bi.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var bi=StyleSheet.create({iveDepositedButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginBottom:12},iveDepositedButtonText:{fontSize:16},processingCard:{flexDirection:"row",alignItems:"center",padding:12,marginBottom:12,gap:12},processingCardText:{flex:1,gap:4},processingCardTitle:{fontSize:14},processingCardSubtitle:{fontSize:12,lineHeight:18},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"}});var da=(e,t)=>`${t}:${e}`,Ng=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Sl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:p,depositConfirmationMode:c="auto_ui",onExecutionsChange:h,onDepositSuccess:k,onDepositError:g,borderTopLeftRadius:C,borderTopRightRadius:S,sheetBorderRadius:y}){let{colors:m,fonts:b,components:d}=O(),f=s&&l?`${s}:${l}`:"solana:mainnet",[R,_]=useState("USDC"),[T,w]=useState(f),[x,W]=useState([]),[D,F]=useState(true),[v,q]=useState([]),[N,ae]=useState(true),[ze,ve]=useState(false),[J,Ve]=useState(false),[me,_e]=useState(false),[Ne,Se]=useState(false),[oe,Pe]=useState([]),[rt,je]=useState(new Map),[ot]=useState(()=>new Date),[$e,Fe]=useState(null),[ct,Re]=useState(false),[X,ce]=useState(null),[st,Je]=useState(false),Le=new Map;v.forEach(M=>{M.chains.forEach(ee=>{let ke=`${ee.chain_type}:${ee.chain_id}`;Le.has(ke)||Le.set(ke,ee);});});let be=Array.from(Le.values()),ie=Ng(T),zt=be.find(M=>M.chain_type===ie.chainType&&M.chain_id===ie.chainId)?.chain_type||"ethereum",ue=qo(x,zt),se=ue?.address||"",ye=useRef(false);useEffect(()=>{async function M(){try{ae(!0),Fe(null);let ke=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(q(ke.data),ke.data.length>0&&!ye.current){ye.current=!0;let fe,_t;if(s&&l)if(p)for(let V of ke.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l&&z.token_address.toLowerCase()===p.toLowerCase());if(Or){fe=V,_t=Or;break}}else for(let V of ke.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l);if(Or){fe=V,_t=Or;break}}if(!fe&&a)for(let V of ke.data){let Or=V.chains.find(z=>z.token_address.toLowerCase()===a.toLowerCase());if(Or){fe=V,_t=Or;break}}fe||(fe=ke.data.find(V=>V.symbol==="USDC"),fe&&fe.chains.length>0&&(_t=fe.chains[0])),fe||(fe=ke.data.find(V=>V.symbol==="USDT"),fe&&fe.chains.length>0&&(_t=fe.chains[0])),fe||(fe=ke.data[0],fe.chains.length>0&&(_t=fe.chains[0])),fe&&_(fe.symbol),_t&&w(da(_t.chain_id,_t.chain_type));}}catch(ee){console.error("Error fetching supported tokens:",ee),Fe("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:ee});}finally{ae(false);}}M();},[t,g,s,l,p,a,n,o]),useEffect(()=>{async function M(){try{F(!0),Fe(null);let ee=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);W(ee.data);}catch(ee){console.error("Error fetching wallets:",ee),Fe("Failed to load wallets"),g?.({message:"Failed to load wallets",error:ee});}finally{F(false);}}M();},[e,r,o,n,a,t,g]);let wt=ue?.id??"",{showWaitingUi:dt,handleIveDeposited:le}=ca({depositConfirmationMode:c,depositAddress:se,chain:T,externalUserId:e,publishableKey:t,modalOpenedAt:ot,depositWalletId:wt,depositExecutions:oe,trackedExecutions:rt,setDepositExecutions:Pe,setTrackedExecutions:je,setLatestExecution:ce,setShowStatusSheet:Re,onDepositSuccess:k,onExecutionsChange:h,onDepositError:g});useEffect(()=>{if(!v.length)return;let M=v.find(ke=>ke.symbol===R);if(!M||M.chains.length===0)return;if(!M.chains.some(ke=>da(ke.chain_id,ke.chain_type)===T)){let ke=M.chains[0];w(da(ke.chain_id,ke.chain_type));}},[R,v,T]);let qe=v.find(M=>M.symbol===R),yr=qe?.chains||[],xt=yr.find(M=>da(M.chain_id,M.chain_type)===T),xr=async()=>{if(se)try{Clipboard.setString(se),ve(!0),setTimeout(()=>ve(!1),2e3);}catch(M){console.error("Failed to copy:",M);}},$=xt?.estimated_price_impact_percent??0,re=xt?.max_slippage_percent??.25,et=xt?.minimum_deposit_amount_usd??3;if(N)return jsxs(View,{style:L.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:m.primary}),jsx(Text,{style:[L.loadingText,{color:m.foregroundMuted,fontFamily:b.regular}],children:"Loading currencies..."})]});if($e&&v.length===0)return jsxs(View,{style:L.errorContainer,children:[jsx(Text,{style:[L.errorText,{color:m.error,fontFamily:b.regular}],children:$e}),jsx(Text,{style:[L.errorHint,{color:m.foregroundMuted,fontFamily:b.regular}],children:"Please check your network connection and try again."})]});let pe=()=>jsxs(ut,{visible:me,onClose:()=>_e(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:y?.tokenSelector?.borderTopLeftRadius??C,borderTopRightRadius:y?.tokenSelector?.borderTopRightRadius??S,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:m.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:b.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>_e(false),style:L.sheetCloseButton,children:jsx(at,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(gt,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:v.map(M=>jsxs(TouchableOpacity$1,{onPress:()=>{_(M.symbol),_e(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:R===M.symbol?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:te(Ce(M,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:b.medium}],children:M.symbol}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:b.regular}],children:[M.chains.length," network",M.chains.length!==1?"s":""," available"]})]}),R===M.symbol&&jsx(Ue,{size:20,color:m.primary,strokeWidth:2})]},M.symbol))})]}),Me=()=>jsxs(ut,{visible:Ne,onClose:()=>Se(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:y?.chainSelector?.borderTopLeftRadius??C,borderTopRightRadius:y?.chainSelector?.borderTopRightRadius??S,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:m.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:b.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>Se(false),style:L.sheetCloseButton,children:jsx(at,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(gt,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:yr.map(M=>{let ee=da(M.chain_id,M.chain_type),ke=T===ee;return jsxs(TouchableOpacity$1,{onPress:()=>{w(ee),Se(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:ke?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:te(Ce(M,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:b.medium}],children:M.chain_name}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:b.regular}],children:["Min deposit: $",M.minimum_deposit_amount_usd]})]}),ke&&jsx(Ue,{size:20,color:m.primary,strokeWidth:2})]},ee)})})]});return jsxs(View,{style:L.container,children:[jsxs(View,{style:L.selectorSection,children:[jsx(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:b.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>_e(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[qe&&jsx(Image,{source:{uri:te(Ce(qe,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:b.medium}],children:R}),jsx(At,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:L.selectorSection,children:[jsxs(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:b.regular}],children:["Network"," ",jsxs(Text,{style:[L.minDeposit,{fontFamily:b.regular}],children:["($",et," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>Se(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[xt&&jsx(Image,{source:{uri:te(Ce(xt,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:b.medium}],numberOfLines:1,children:xt?.chain_name||"Select network"}),jsx(At,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:L.qrContainer,children:jsx(View,{style:[L.qrWrapper,{backgroundColor:m.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:D?jsxs(View,{style:L.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:m.primary}),jsx(Text,{style:[L.loadingText,{color:m.foregroundMuted,fontFamily:b.regular}],children:"Loading..."})]}):se?jsx(ps,{value:se,size:160,logoUri:te(Ce(xt,"png")||Yt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:L.qrLoading,children:jsx(Text,{style:[L.errorText,{color:m.error,fontFamily:b.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:b.medium}],children:"Deposit Address"}),ze&&jsxs(View,{style:L.copiedIndicator,children:[jsx(Ue,{size:14,color:m.success,strokeWidth:2}),jsx(Text,{style:[L.copiedText,{color:m.success,fontFamily:b.regular}],children:"Copied"})]})]}),jsxs(ir,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!D&&se?xr:void 0,contentStyle:L.addressBox,children:[jsx(Text,{style:[L.addressText,{color:d.card.titleColor,fontFamily:b.regular}],numberOfLines:2,children:D?"Loading...":se||"No address available"}),jsx(View,{style:L.addressCopyIcon,children:jsx(No,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[L.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Ve(!J),style:L.detailsHeader,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:b.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:L.chevronContainer,children:J?jsx(To,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(At,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),J&&jsxs(View,{style:L.detailsContent,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:b.regular}],children:["Price impact: ",$.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:b.regular}],children:["Slippage: Auto \u2022 ",re.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:b.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(Cl,{depositConfirmationMode:c,depositAddress:se,showWaitingUi:dt,latestExecution:X,onIveDeposited:le}),jsx(TouchableOpacity$1,{style:L.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[L.termsText,{color:m.primary,fontFamily:b.regular}],children:"Terms apply"})}),pe(),Me(),jsxs(ut,{visible:st,onClose:()=>Je(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:y?.infoSheet?.borderTopLeftRadius??C,borderTopRightRadius:y?.infoSheet?.borderTopRightRadius??S,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:m.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:b.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Je(false),style:L.sheetCloseButton,children:jsx(at,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:L.infoSheetContent,children:[jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:b.medium}],children:"Price Impact"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:b.medium}],children:[$.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.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:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:b.medium}],children:"Max Slippage"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:b.medium}],children:[re.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.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."})]})]})]}),X&&jsx(ms,{visible:ct,status:X.status,tokenIconUrl:X.destination_token_metadata?.icon_urls?.find(M=>M.format==="png")?.url||X.destination_token_metadata?.icon_url||Ce(qe,"png"),explorerUrl:X.explorer_url,completionExplorerUrl:X.destination_explorer_url,date:X.created_at?new Date(X.created_at):void 0,amountUsd:X.source_amount_usd?parseFloat(X.source_amount_usd):void 0,onClose:()=>Re(false),borderTopLeftRadius:y?.depositStatus?.borderTopLeftRadius??C,borderTopRightRadius:y?.depositStatus?.borderTopRightRadius??S})]})}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 kl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=O();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ci.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:Ci.leftContent,children:[jsx(View,{style:[Ci.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:te(Ce(e,"png"))},style:Ci.icon})}),jsxs(View,{style:Ci.textContainer,children:[jsx(Text,{style:[Ci.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ci.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(Ue,{size:16,color:o.primary,strokeWidth:2})]})}var Ci=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,marginHorizontal:8,marginVertical:4},leftContent:{flexDirection:"row",alignItems:"center",gap:12},iconContainer:{width:40,height:40,borderRadius:20,overflow:"hidden",alignItems:"center",justifyContent:"center"},icon:{width:40,height:40,borderRadius:20},textContainer:{gap:2},name:{fontSize:14,fontWeight:"400"},code:{fontSize:12,fontWeight:"300"}});function pa({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=O();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:fm.headerContainer,children:jsx(Text,{style:[fm.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(kl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var fm=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function xl({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:p,components:c}=O(),[h,k]=useState(""),g=o.map(f=>r.find(R=>R.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),C=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),S=f=>{if(!h)return f;let R=h.toLowerCase();return f.filter(_=>_.name.toLowerCase().includes(R)||_.currency_code.toLowerCase().includes(R))},y=S(g),m=S(C),b=f=>{a(f),t(false),k("");},d=()=>{t(false),k("");};return jsxs(ut,{visible:e,onClose:d,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(Pr,{title:"Currency",showBack:false,onClose:d}),jsx(View,{style:wi.searchContainer,children:jsx(TextInput,{style:[wi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:p.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:h,onChangeText:k,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(gt,{style:wi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:wi.listContent,children:[jsx(pa,{title:"Popular currencies",currencies:y,selectedCurrency:n,onSelect:b}),y.length>0&&m.length>0&&jsx(View,{style:wi.sectionSpacer}),jsx(pa,{title:"All currencies",currencies:m,selectedCurrency:n,onSelect:b}),y.length===0&&m.length===0&&jsx(View,{style:wi.noResultsContainer,children:jsx(Text,{style:[wi.noResultsText,{color:c.container.subtitleColor,fontFamily:p.regular}],children:"No currencies found"})})]})})]})}var wi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:72},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function Od(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e.toUpperCase(),minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/\d/g,"").trim()}catch{return e.toUpperCase()}}function Il({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:p,onDepositError:c,borderTopLeftRadius:h,borderTopRightRadius:k,sheetBorderRadius:g}){let{colors:C,fonts:S,components:y}=O(),[m,b]=useState(""),[d,f]=useState("usd"),[R,_]=useState(false),[T,w]=useState(false),[x,W]=useState([]),[D,F]=useState(false),[v,q]=useState(null),[N,ae]=useState(null),[ze,ve]=useState("amount"),[J,Ve]=useState(null),[me,_e]=useState(true),[Ne,Se]=useState(null),[oe,Pe]=useState(false),rt=useRef(null),je=useRef(false);useEffect(()=>{rt.current=J;},[J]),useEffect(()=>{je.current=oe;},[oe]);let[ot,$e]=useState([]),[Fe,ct]=useState(true),[Re,X]=useState(60),[ce,st]=useState([]),[Je,Le]=useState([]),[be,ie]=useState(null),[de,zt]=useState(null),[ue,se]=useState(true),[ye,wt]=useState(null),[dt,le]=useState(false),[qe,yr]=useState(null),[xt,xr]=useState(false),[$,re]=useState(false),[et,pe]=useState(false),[Me,M]=useState(null),ee=r??ze,ke=useRef(null),fe=ce.find(Q=>Q.currency_code.toLowerCase()===d.toLowerCase()),_t=useCallback(Q=>{ve(Q),Q==="quotes"?o?.(Q,x.length):o?.(Q);},[x.length,o]);useEffect(()=>{async function Q(){try{let ge=await Bs();zt(ge);}catch(ge){console.error("Error fetching user IP:",ge);}finally{se(false);}}Q();},[]),useEffect(()=>{async function Q(){try{let ge=await $o({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);$e(ge.data);}catch(ge){console.error("Error fetching wallets:",ge),q("Failed to load wallet addresses");}finally{ct(false);}}Q();},[e,a,i,s,l,t]);let V=n||be?.symbol.toUpperCase()||"USDC",Or=Li(be?.icon_urls,"png")||be?.icon_url,z=Li(be?.chain_icon_urls,"png")||be?.chain_icon_url;useEffect(()=>{async function Q(){try{let ge=await yc(t);st(ge.data),Le(ge.preferred||[]);}catch(ge){console.error("Error fetching fiat currencies:",ge);}}Q();},[t]),useEffect(()=>{if(R||ce.length===0||!de?.alpha2)return;let Q=de.alpha2.toUpperCase(),ge=ce.find(Bt=>Bt.country_codes.includes(Q));if(ge)f(ge.currency_code.toLowerCase()),!m&&!T&&b(String(ge.default_amount??100));else if(!m&&!T){let Bt=ce.find(po=>po.currency_code.toLowerCase()==="usd");Bt&&b(String(Bt.default_amount??100));}},[ce,de,R,m,T]),useEffect(()=>{if(ce.length!==0){if(ke.current!==null&&ke.current!==d){let Q=ce.find(ge=>ge.currency_code.toLowerCase()===d.toLowerCase());Q&&b(String(Q.default_amount??100));}ke.current=d;}},[d,ce]),useEffect(()=>{async function Q(){try{let ge=await mc({chain_type:i||"",chain_id:s||"",token_address:l||""},t);ie(ge);}catch(ge){console.error("Error fetching supported tokens:",ge);}}Q();},[i,s,l,t]),useEffect(()=>{async function Q(){if(!(!l||!s||!i)&&!ue){le(true);try{let ge=await gc({country_code:de?.alpha2?.toUpperCase()||"US",subdivision_code:de?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);wt(ge);}catch(ge){console.error("Error fetching default onramp token:",ge);}finally{le(false);}}}Q();},[l,s,i,de,ue,t]),useEffect(()=>{let Q=parseFloat(m);if(isNaN(Q)||Q<=0){W([]),ae(null);return}if(!ye||dt){W([]),Ve(null);return}let ge=ce.find(po=>po.currency_code.toLowerCase()===d.toLowerCase());if(ge){if(Q<ge.minimum_amount){W([]),Ve(null),ae(`Minimum amount is ${Od(d)}${ge.minimum_amount.toLocaleString()}`);return}if(Q>ge.maximum_amount){W([]),Ve(null),ae(`Maximum amount is ${Od(d)}${ge.maximum_amount.toLocaleString()}`);return}}ae(null);let Bt=setTimeout(()=>{Ot(Q);},500);return ()=>clearTimeout(Bt)},[m,d,t,ye,dt,ce]);let Ot=async Q=>{if(!ye){q("Loading token information...");return}F(true),q(null);try{let ge={country_code:de?.alpha2?.toUpperCase()||"US",source_amount:Q.toString(),source_currency:d.toLowerCase(),destination_currency:ye.destination_currency,destination_network:ye.destination_network,subdivision_code:de?.state||void 0},Bt=await fc(ge,t);W(Bt.data);let po=je.current,Ts=rt.current;if(po&&Ts){let mo=Bt.data.find(fn=>fn.service_provider===Ts.service_provider);if(mo){if(Ve(mo),Bt.data.length>0){let fn=Bt.data[0];Ne||Se(fn.service_provider),_e(mo.service_provider===Ne);}}else if(Bt.data.length>0){let fn=Bt.data[0];Ve(fn),Se(fn.service_provider),_e(!0),Pe(!1);}}else if(Bt.data.length>0){let mo=Bt.data[0];Ve(mo),Se(mo.service_provider),_e(!0);}X(60);}catch(ge){console.error("Failed to fetch quotes:",ge),q("Failed to fetch quotes. Please try again."),W([]);}finally{F(false);}};useEffect(()=>{if(x.length===0)return;let Q=setInterval(()=>{X(ge=>{if(ge<=1){let Bt=parseFloat(m);return !isNaN(Bt)&&Bt>0&&Ot(Bt),60}return ge-1});},1e3);return ()=>clearInterval(Q)},[x.length,m]);let St=Q=>{(/^\d*\.?\d{0,2}$/.test(Q)||Q==="")&&(b(Q),w(true));},Mr=Q=>{b(Q.toString()),w(true);},er=async()=>{if(J&&ye)try{let Q=ye.destination_token_metadata.chain_type,ge=qo(ot,Q);if(!ge?.address){q("Wallet address not available");return}let Bt={service_provider:J.service_provider,country_code:J.country_code?.toUpperCase()||de?.alpha2?.toUpperCase()||"US",source_currency:J.source_currency,source_amount:m,destination_currency:J.destination_currency,destination_network:J.destination_network,wallet_address:ge.address,subdivision_code:de?.state||void 0},po=await hc(Bt,t);yr({provider:J,sourceCurrency:d,sourceAmount:m,sessionUrl:po.url}),M(po.url),pe(!0);}catch(Q){console.error("Failed to create session:",Q),q("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:Q});}},Ii=Od(d),uo=()=>{pe(false),_t("onramp"),p?.({message:"Payment flow completed"});},Ho=()=>jsx(oy,{visible:et,onClose:uo,url:Me,providerName:J?.service_provider_display_name||"Complete Payment",colors:C,fonts:S,borderTopLeftRadius:g?.webView?.borderTopLeftRadius??h,borderTopRightRadius:g?.webView?.borderTopRightRadius??k});return ee==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:j.amountViewContainer,children:[jsxs(gt,{style:j.scrollContainer,contentContainerStyle:j.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:j.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>xr(true),style:[j.currencyButton,{backgroundColor:y.card.backgroundColor,borderRadius:y.input.borderRadius,borderWidth:y.input.borderWidth,borderColor:y.input.borderColor}],children:[fe&&jsx(Image,{source:{uri:te(Ce(fe,"png"))},style:j.currencyIcon}),jsx(Text,{style:[j.currencyText,{color:y.card.titleColor,fontFamily:S.medium}],children:d.toUpperCase()}),jsx(At,{size:16,color:y.card.actionColor,strokeWidth:2})]})}),jsx(xl,{open:xt,onOpenChange:xr,currencies:ce,preferredCurrencyCodes:Je,selectedCurrency:d,onSelectCurrency:Q=>{f(Q.toLowerCase()),_(true);},borderTopLeftRadius:g?.currencyModal?.borderTopLeftRadius??h,borderTopRightRadius:g?.currencyModal?.borderTopRightRadius??k}),jsx(View,{style:j.amountContainer,children:jsxs(View,{style:j.amountInputRow,children:[jsx(Text,{style:[j.currencySymbol,{color:y.container.titleColor,fontFamily:S.medium}],children:Ii}),jsx(TextInput,{style:[j.amountInput,{color:y.container.titleColor,fontFamily:S.medium}],value:m,onChangeText:St,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:C.foregroundMuted})]})}),fe?.suggested_amounts&&fe.suggested_amounts.length>0&&jsx(View,{style:j.quickAmounts,children:fe.suggested_amounts.map(Q=>jsx(TouchableOpacity$1,{onPress:()=>Mr(Q),style:[j.quickAmountButton,{backgroundColor:y.card.backgroundColor,borderRadius:y.button.borderRadius,borderWidth:parseFloat(m)===Q?2:y.button.borderWidth,borderColor:parseFloat(m)===Q?C.primary:y.button.borderColor}],children:jsxs(Text,{style:[j.quickAmountText,{color:y.card.titleColor,fontFamily:S.medium}],children:[Ii,Q.toLocaleString()]})},Q))}),N&&jsx(Text,{style:[j.validationError,{color:C.error,fontFamily:S.regular}],children:N}),jsxs(View,{style:j.providerSection,children:[jsxs(View,{style:j.providerHeader,children:[jsx(Text,{style:[j.providerLabel,{color:y.card.labelColor,fontFamily:S.medium}],children:"Provider"}),x.length>0&&!D&&jsxs(Text,{style:[j.refreshText,{color:y.card.labelRightColor,fontFamily:S.regular}],children:["Refreshing in ",Re,"s"]})]}),jsx(ir,{cardTokens:y.depositCard.quoteProvider.card,onPress:D||x.length===0?void 0:()=>re(true),contentStyle:StyleSheet.flatten([j.providerButton,(D||x.length===0)&&j.disabled]),children:D?jsxs(View,{style:j.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:C.primary}),jsx(Text,{style:[j.loadingText,{color:y.container.subtitleColor,fontFamily:S.regular}],children:"Finding best rates..."})]}):J?jsxs(View,{style:j.providerContent,children:[jsxs(View,{style:j.providerInfo,children:[me&&jsx(Text,{style:[j.autoPickedText,{color:y.container.subtitleColor,fontFamily:S.regular}],children:"Auto-picked for you"}),jsxs(View,{style:j.providerRow,children:[jsx(Image,{source:{uri:te(Oa(J.icon_urls,"png",J.icon_url))},style:j.providerIconImage},`provider-${J.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[j.providerName,{color:y.card.titleColor,fontFamily:S.medium}],children:J.service_provider_display_name}),jsxs(Text,{style:[j.bestPriceText,{color:y.container.subtitleColor,fontFamily:S.regular}],children:[J.destination_amount.toFixed(2)," ",V]})]})]})]}),jsx(_r,{size:20,color:y.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[j.noProviderText,{color:y.container.subtitleColor,fontFamily:S.regular}],children:parseFloat(m)>0?"No providers available":"Enter an amount to see providers"})}),v&&jsx(Text,{style:[j.errorText,{color:C.error,fontFamily:S.regular}],children:v})]}),jsxs(ut,{visible:$,onClose:()=>re(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:g?.providerModal?.borderTopLeftRadius??h,borderTopRightRadius:g?.providerModal?.borderTopRightRadius??k,children:[jsx(Pr,{title:"Select Provider",showBack:false,onClose:()=>re(false)}),jsx(gt,{style:j.providerModalList,contentContainerStyle:j.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:j.quotesList,children:x.map(Q=>{let ge=J?.service_provider===Q.service_provider;return jsxs(ir,{cardTokens:y.depositCard.quoteProvider.card,onPress:()=>{Ve(Q),Pe(true),_e(Q.service_provider===Ne),re(false);},contentStyle:StyleSheet.flatten([j.quoteItem,ge&&{borderWidth:2,borderColor:C.primary}]),children:[jsxs(View,{style:j.quoteLeft,children:[jsx(Image,{source:{uri:te(Oa(Q.icon_urls,"png",Q.icon_url))},style:j.providerIconImage}),jsx(View,{children:jsx(Text,{style:[j.quoteName,{color:y.card.titleColor,fontFamily:S.medium}],children:Q.service_provider_display_name})})]}),jsxs(View,{style:j.quoteRight,children:[jsxs(Text,{style:[j.quoteAmount,{color:y.card.textRightColor,fontFamily:S.medium}],children:[Q.destination_amount.toFixed(2)," ",V]}),jsxs(Text,{style:[j.quoteSource,{color:y.card.subtextRightColor,fontFamily:S.regular}],children:["Fee: ",Ii,Q.total_fee.toFixed(2)]})]})]},Q.service_provider)})})})]})]}),jsx(View,{style:[j.continueButtonContainer,{backgroundColor:C.background}],children:jsx(View,{style:{opacity:D||Fe||!J||parseFloat(m)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:er,disabled:D||Fe||!J||parseFloat(m)<=0,style:[j.continueButton,{backgroundColor:y.container.buttonColor,borderRadius:y.button.borderRadius,borderWidth:y.button.borderWidth,borderColor:y.button.borderColor}],children:jsx(Text,{style:[j.continueButtonText,{color:y.container.buttonTitleColor,fontFamily:S.medium}],children:Fe?"Loading...":"Continue"})})})})]}),Ho()]}):ee==="onramp"&&qe?jsxs(View,{style:j.onrampContainer,children:[jsx(Image,{source:{uri:te(Oa(qe.provider.icon_urls,"png",qe.provider.icon_url))},style:j.onrampProviderIcon}),jsxs(Text,{style:[j.onrampTitle,{color:y.container.titleColor,fontFamily:S.medium}],children:["Complete transaction with ",qe.provider.service_provider_display_name]}),jsx(Text,{style:[j.onrampSubtitle,{color:y.container.subtitleColor,fontFamily:S.regular}],children:"You can close this modal."}),jsxs(View,{style:[j.flowDiagram,{backgroundColor:y.card.backgroundColor}],children:[jsxs(View,{style:j.flowStep,children:[jsx(Image,{source:{uri:Yt(`/icons/currencies/png/${qe.sourceCurrency.toLowerCase()}.png`)},style:j.flowIconImage}),jsx(Text,{style:[j.flowLabel,{color:y.card.subtitleColor,fontFamily:S.regular}],children:"You use"}),jsx(Text,{style:[j.flowValue,{color:y.card.titleColor,fontFamily:S.medium}],children:qe.sourceCurrency.toUpperCase()})]}),jsx(_r,{size:16,color:y.card.actionColor,strokeWidth:2}),jsxs(View,{style:j.flowStep,children:[jsxs(View,{style:j.flowIconWithBadge,children:[jsx(Image,{source:{uri:Li(ye?.destination_token_metadata?.icon_urls,"png")||ye?.destination_token_metadata?.icon_url||Yt("/icons/tokens/png/usdc.png")},style:j.flowIconImageNoBadge}),jsx(Image,{source:{uri:Li(ye?.destination_token_metadata?.chain?.icon_urls,"png")||ye?.destination_token_metadata?.chain?.icon_url||Yt("/icons/networks/png/polygon.png")},style:[j.flowNetworkBadge,{borderColor:C.background,borderRadius:y.badge.borderRadius}]})]}),jsx(Text,{style:[j.flowLabel,{color:y.card.subtitleColor,fontFamily:S.regular}],children:"You buy"}),jsx(Text,{style:[j.flowValue,{color:y.card.titleColor,fontFamily:S.medium}],children:"USDC"})]}),jsx(_r,{size:16,color:y.card.actionColor,strokeWidth:2}),jsxs(View,{style:j.flowStep,children:[jsxs(View,{style:j.flowIconWithBadge,children:[jsx(Image,{source:{uri:Or||Yt("/icons/tokens/png/usdc.png")},style:j.flowIconImageNoBadge}),jsx(Image,{source:{uri:z||Yt("/icons/networks/png/polygon.png")},style:[j.flowNetworkBadge,{borderColor:C.background,borderRadius:y.badge.borderRadius}]})]}),jsx(Text,{style:[j.flowLabel,{color:y.card.subtitleColor,fontFamily:S.regular}],children:"You receive"}),jsx(Text,{style:[j.flowValue,{color:y.card.titleColor,fontFamily:S.medium}],children:V})]})]}),jsx(View,{style:[j.onrampInfoBox,{backgroundColor:y.card.backgroundColor,borderRadius:y.card.borderRadius,borderWidth:y.card.borderWidth,borderColor:y.card.borderColor}],children:jsx(Text,{style:[j.onrampInfoText,{color:y.card.descriptionColor,fontFamily:S.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function oy({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(ut,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:Si.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:Si.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ue,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Si.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:Si.headerSpacer})]}),r&&jsx(View,{style:Si.container,children:jsx(WebView,{source:{uri:r},style:Si.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Si.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var Si=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),j=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8},currencyText:{fontSize:14,fontWeight:"500"},currencyIcon:{width:24,height:24,borderRadius:12},amountContainer:{alignItems:"center",marginBottom:24},amountInputRow:{flexDirection:"row",alignItems:"center",marginBottom:8},currencySymbol:{fontSize:48,fontWeight:"300"},amountInput:{fontSize:48,fontWeight:"300",minWidth:50},usdcPreview:{fontSize:14},quickAmounts:{flexDirection:"row",justifyContent:"center",gap:12,marginBottom:24},quickAmountButton:{paddingHorizontal:20,paddingVertical:10},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:48},continueButton:{paddingVertical:16,alignItems:"center"},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{flex:1,paddingHorizontal:12,marginTop:8},providerModalListContent:{paddingBottom:72},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function ay(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function ly(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Fl({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=O(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=te(Ce(e.destination_token_metadata,"png")||Yt("/icons/tokens/png/usdc.png")),p=i?"Deposit Processing":"Deposit Completed",c=ay(e.created_at||new Date().toISOString()),h=ly(e.source_amount_usd);return jsxs(ir,{cardTokens:a,onPress:t,contentStyle:sn.container,children:[jsxs(View,{style:sn.iconContainer,children:[jsx(Image,{source:{uri:l},style:sn.tokenIcon}),jsx(View,{style:[sn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Ue,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:sn.textContainer,children:[jsx(Text,{style:[sn.title,{color:a.titleColor,fontFamily:o.medium}],children:p}),jsx(Text,{style:[sn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:sn.rightContainer,children:[jsx(Text,{style:[sn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:h}),jsx(_r,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var sn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});function bm(e,t){let r={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||r[e]||e:r[e]||e}function Cm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function dy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var wm=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Sm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function uy(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function py({count:e=4}){let{colors:t,components:r}=O(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,a=t.cardHover;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:ki.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[ki.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[ki.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:ki.textBlock,children:[jsx(Animated.View,{style:[ki.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[ki.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[ki.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var ki=StyleSheet.create({list:{paddingTop:16,paddingHorizontal:16,gap:12},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},icon:{width:40,height:40,borderRadius:20,marginRight:12},textBlock:{flex:1,gap:6},titleBar:{height:14,width:"65%",borderRadius:7},subtitleBar:{height:11,width:"45%",borderRadius:5.5},amountBar:{height:14,width:50,borderRadius:7,marginLeft:12}});function Ld({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=O(),[l,p]=useState(r),[c,h]=useState(false),[k,g]=useState(null),[C,S]=useState(false),y=useRef(null);useEffect(()=>{if(!e||!o)return;let T=async()=>{h(true);try{let W=[...(await Qo(o,n)).data].sort((D,F)=>{let v=D.created_at?new Date(D.created_at).getTime():0;return (F.created_at?new Date(F.created_at).getTime():0)-v});p(W);}catch(x){console.error("Failed to fetch executions:",x),p(r);}finally{h(false);}};T();let w=setInterval(T,1e4);return ()=>clearInterval(w)},[e,o,n,r]),useEffect(()=>{r.length>0&&p(T=>{let w=new Set(T.map(W=>W.id)),x=r.filter(W=>!w.has(W.id));return x.length>0?[...x,...T]:T});},[r]),useEffect(()=>{e||g(null);},[e]);let m=T=>{g(T);},b=()=>{g(null),S(false);},d=()=>{g(null),t();},f=()=>{if(!k)return null;let T=k,w=T.status==="pending"||T.status==="waiting"||T.status==="delayed",x=T.status==="succeeded",W=te(Ce(T.destination_token_metadata,"png")||Yt("/icons/tokens/png/usdc.png")),D=T.provider_metadata?.details,F=D?.currencyIn,v=D?.currencyOut;F?.currency?.symbol||"USDC";v?.currency?.symbol||"USDC";let ae=Cm(T.source_amount_base_unit,T.source_token_metadata?.decimals),ze=Cm(T.destination_amount_base_unit,T.destination_token_metadata?.decimals),ve=dy(T.source_amount_usd),J=bm(T.source_chain_type,T.source_chain_id),Ve=bm(T.destination_chain_type,T.destination_chain_id),me=()=>{T.explorer_url&&Linking.openURL(T.explorer_url);},_e=()=>{T.destination_explorer_url&&Linking.openURL(T.destination_explorer_url);};return jsxs(gt,{ref:y,style:he.scrollContainer,contentContainerStyle:he.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:he.iconSection,children:[jsxs(View,{style:he.iconWrapper,children:[jsx(Image,{source:{uri:W},style:he.tokenIcon}),jsx(View,{style:[he.statusBadge,{backgroundColor:w?a.warning:a.success,borderColor:a.background}],children:w?jsx(At,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(Ue,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:he.statusRow,children:[jsx(View,{style:[he.statusDot,{backgroundColor:w?a.warning:a.success}]}),jsx(Text,{style:[he.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:w?"Processing":"Completed"})]}),jsx(Text,{style:[he.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:uy(T.created_at||new Date().toISOString())})]}),jsxs(View,{style:[he.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ae," ",Sm(T.source_currency)]})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ze," ",Sm(T.destination_currency)]})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:ve})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:J})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Ve})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ne=!C;S(Ne),Ne?setTimeout(()=>{y.current?.scrollToEnd({animated:true});},100):y.current?.scrollTo({y:0,animated:true});},style:he.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[he.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:C?"See less":"See more details"}),C?jsx(To,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(At,{size:14,color:s.container.actionColor,strokeWidth:2})]}),C&&jsxs(View,{style:[he.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:me,style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:he.cardRowRight,children:[jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(T.transaction_hash)}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]})]}),T.destination_explorer_url&&x&&jsxs(TouchableOpacity,{onPress:_e,style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:he.cardRowRight,children:[jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(T.destination_transaction_hashes[0])}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},R=c&&l.length===0;return jsxs(Fragment,{children:[jsx(Pr,{title:k?"Deposit Details":"Deposit Tracker",onClose:d,showClose:!k,showBack:!!k,onBack:b}),k?f():R?jsx(py,{}):jsx(gt,{style:he.scrollContainer,contentContainerStyle:he.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:he.emptyContainer,children:[jsx(Text,{style:[he.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[he.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:he.executionsList,children:l.map(T=>jsx(Fl,{execution:T,onPress:()=>m(T)},T.id))})})]})}var he=StyleSheet.create({scrollContainer:{flex:1,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:40},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function ma(e,t=true){let[r,o]=useState(null),[n,a]=useState(null),[i,s]=useState(false),[l,p]=useState(false),[c,h]=useState(null),[k,g]=useState(null);useEffect(()=>{!t||r||(s(true),Bs().then(m=>{o(m),h(null);}).catch(m=>{h(m instanceof Error?m:new Error(String(m)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(p(true),Ls(e).then(m=>{a(m),g(null);}).catch(m=>{g(m instanceof Error?m:new Error(String(m)));}).finally(()=>{p(false);}));},[t,e,n]);let C=i||l,S=c||k||null,y=null;if(r&&n){let m=n.blocked_country_codes||[],b=r.alpha2.toUpperCase();y=!m.some(d=>d.toUpperCase()===b);}return {isAllowed:y,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:C,error:S}}var Wd="unifold_recent_tokens",yy=5,Im=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function Bl(){try{let e=await Wc.getItem(Wd);return e?JSON.parse(e):[]}catch{return []}}async function by(e){try{let r=(await Bl()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,yy);await Wc.setItem(Wd,JSON.stringify(o));}catch{}}async function Cy(e){try{let r=(await Bl()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Wc.setItem(Wd,JSON.stringify(r)),r}catch{return []}}function Ed({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:p,components:c}=O(),[h,k]=useState(""),[g,C]=useState([]);useEffect(()=>{e&&Bl().then(C);},[e]),useEffect(()=>{e||k("");},[e]);let S=useMemo(()=>{let R=[];return r.forEach(_=>{_.chains.forEach(T=>{R.push({token:_,chain:T});});}),R},[r]),y=useMemo(()=>{let R=[],_=new Set,T=(w,x,W,D)=>{let F=`${w}-${x}:${W}`;if(_.has(F))return;let v=r.find(N=>N.symbol===w);if(!v)return;let q=v.chains.find(N=>N.chain_type===x&&N.chain_id===W);q&&(_.add(F),R.push({token:v,chain:q,isRecent:D}));};return g.forEach(w=>{T(w.symbol,w.chainType,w.chainId,true);}),Im.forEach(w=>{T(w.symbol,w.chainType,w.chainId,false);}),R},[r,g]),m=useMemo(()=>{if(!h.trim())return S;let R=h.toLowerCase();return S.filter(({token:_,chain:T})=>_.symbol.toLowerCase().includes(R)||_.name.toLowerCase().includes(R)||T.chain_name.toLowerCase().includes(R))},[S,h]),b=(R,_,T)=>Im.some(w=>w.symbol===R&&w.chainType===_&&w.chainId===T),d=async(R,_)=>{let T=`${_.chain_type}:${_.chain_id}`;if(!b(R.symbol,_.chain_type,_.chain_id)){await by({symbol:R.symbol,chainType:_.chain_type,chainId:_.chain_id});let w=await Bl();C(w);}k(""),a(R.symbol,T),t();},f=async(R,_)=>{let T=await Cy({symbol:R.symbol,chainType:_.chain_type,chainId:_.chain_id});C(T);};return jsxs(ut,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:ht.header,children:[jsx(View,{style:ht.headerSpacer}),jsx(Text,{style:[ht.headerTitle,{color:c.header.titleColor,fontFamily:p.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:ht.closeButton,children:jsx(at,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:ht.searchContainer,children:jsx(TextInput,{style:[ht.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:p.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:h,onChangeText:k,autoCapitalize:"none",autoCorrect:false})}),y.length>0&&!h&&jsxs(View,{style:ht.quickSelectSection,children:[jsx(Text,{style:[ht.sectionLabel,{color:c.list.titleSectionColor,fontFamily:p.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:ht.quickSelectScroll,children:y.map(({token:R,chain:_,isRecent:T})=>{let w=`${_.chain_type}:${_.chain_id}`;R.symbol===o&&w===n;return jsxs(View,{children:[T&&jsx(TouchableOpacity$1,{onPress:()=>f(R,_),style:ht.removeButton,children:jsx(at,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>d(R,_),activeOpacity:.7,style:[ht.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:ht.tokenIconContainer,children:[jsx(Image,{source:{uri:te(Ce(R,"png"))},style:ht.quickSelectIcon}),jsx(Image,{source:{uri:te(Ce(_,"png"))},style:[ht.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:ht.quickSelectText,children:[jsx(Text,{style:[ht.quickSelectSymbol,{color:c.card.titleColor,fontFamily:p.medium}],children:R.symbol}),jsx(Text,{style:[ht.quickSelectChain,{color:c.card.subtitleColor,fontFamily:p.regular}],children:_.chain_name})]})]})]},`quick-${R.symbol}-${w}`)})})]}),jsx(Text,{style:[ht.sectionLabel,{color:c.list.titleSectionColor,fontFamily:p.regular}],children:"All supported tokens"}),jsx(gt,{style:ht.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:ht.tokenListContent,children:m.length===0?jsx(View,{style:ht.emptyState,children:jsx(Text,{style:[ht.emptyText,{color:l.foregroundMuted,fontFamily:p.regular}],children:"No tokens found"})}):m.map(({token:R,chain:_})=>{let T=`${_.chain_type}:${_.chain_id}`,w=R.symbol===o&&T===n;return jsxs(TouchableOpacity$1,{onPress:()=>d(R,_),activeOpacity:.7,style:[ht.tokenItem,{backgroundColor:w?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:ht.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:te(Ce(R,"png"))},style:ht.tokenIcon}),jsx(Image,{source:{uri:te(Ce(_,"png"))},style:[ht.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:ht.tokenInfo,children:[jsx(Text,{style:[ht.tokenSymbol,{color:c.card.titleColor,fontFamily:p.medium}],children:R.symbol}),jsx(Text,{style:[ht.tokenChainName,{color:c.card.subtitleColor,fontFamily:p.regular}],children:_.chain_name})]}),jsxs(Text,{style:[ht.minDeposit,{color:c.card.labelColor,fontFamily:p.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:p.regular},children:["$",_.minimum_deposit_amount_usd]})]})]},`${R.symbol}-${T}`)})})]})}var ht=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 Wl=(e,t)=>`${t}:${e}`,xy=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Md({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:p,depositConfirmationMode:c="auto_ui",onExecutionsChange:h,onDepositSuccess:k,onDepositError:g,wallets:C,borderTopLeftRadius:S,borderTopRightRadius:y,sheetBorderRadius:m}){let{colors:b,fonts:d,components:f}=O(),R=s&&l?`${s}:${l}`:"solana:mainnet",[_,T]=useState("USDC"),[w,x]=useState(R),[W,D]=useState([]),[F,v]=useState(!C?.length),q=C?.length?C:W,[N,ae]=useState([]),[ze,ve]=useState(true),[J,Ve]=useState(false),[me,_e]=useState(false),[Ne,Se]=useState(false),[oe,Pe]=useState([]),[rt,je]=useState(new Map),[ot]=useState(()=>new Date),[$e,Fe]=useState(null),[ct,Re]=useState(false),[X,ce]=useState(null),[st,Je]=useState(false),Le=new Map;N.forEach(pe=>{pe.chains.forEach(Me=>{let M=`${Me.chain_type}:${Me.chain_id}`;Le.has(M)||Le.set(M,Me);});});let be=Array.from(Le.values()),ie=xy(w),de=be.find(pe=>pe.chain_type===ie.chainType&&pe.chain_id===ie.chainId),zt=de?.chain_type||"ethereum",ue=qo(q,zt),se=ue?.address||"",ye=useRef(false);useEffect(()=>{async function pe(){try{ve(!0),Fe(null);let M=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(ae(M.data),M.data.length>0&&!ye.current){ye.current=!0;let ee,ke;if(s&&l)if(p)for(let fe of M.data){let _t=fe.chains.find(V=>V.chain_type===s&&V.chain_id===l&&V.token_address.toLowerCase()===p.toLowerCase());if(_t){ee=fe,ke=_t;break}}else for(let fe of M.data){let _t=fe.chains.find(V=>V.chain_type===s&&V.chain_id===l);if(_t){ee=fe,ke=_t;break}}if(!ee&&a)for(let fe of M.data){let _t=fe.chains.find(V=>V.token_address.toLowerCase()===a.toLowerCase());if(_t){ee=fe,ke=_t;break}}ee||(ee=M.data.find(fe=>fe.symbol==="USDC"),ee&&ee.chains.length>0&&(ke=ee.chains[0])),ee||(ee=M.data.find(fe=>fe.symbol==="USDT"),ee&&ee.chains.length>0&&(ke=ee.chains[0])),ee||(ee=M.data[0],ee.chains.length>0&&(ke=ee.chains[0])),ee&&T(ee.symbol),ke&&x(Wl(ke.chain_id,ke.chain_type));}}catch(Me){console.error("Error fetching supported tokens:",Me),Fe("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:Me});}finally{ve(false);}}pe();},[t,a,n,o,s,l,p,g]),useEffect(()=>{h&&h(oe);},[oe,h]),useEffect(()=>{if(C?.length){v(false);return}if(W.length>0){v(false);return}let pe=null,Me=false,M=async()=>{if(!Me){v(true);try{let ee=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);Me||(D(ee.data),Fe(null),v(!1));}catch(ee){console.error("Error fetching wallets, retrying in 5s:",ee),Me||(Fe(ee instanceof Error?ee.message:"Failed to load wallets"),v(false),pe=setTimeout(M,5e3));}}};return M(),()=>{Me=true,pe&&clearTimeout(pe);}},[e,r,o,n,a,t,C,W.length]);let wt=ue?.id??"",{showWaitingUi:dt,handleIveDeposited:le}=ca({depositConfirmationMode:c,depositAddress:se,chain:w,externalUserId:e,publishableKey:t,modalOpenedAt:ot,depositWalletId:wt,depositExecutions:oe,trackedExecutions:rt,setDepositExecutions:Pe,setTrackedExecutions:je,setLatestExecution:ce,setShowStatusSheet:Re,onDepositSuccess:k,onExecutionsChange:h,onDepositError:g});useEffect(()=>{if(!N.length)return;let pe=N.find(M=>M.symbol===_);if(!pe||pe.chains.length===0)return;if(!pe.chains.some(M=>Wl(M.chain_id,M.chain_type)===w)){let M=pe.chains[0];x(Wl(M.chain_id,M.chain_type));}},[_,N,w]);let qe=N.find(pe=>pe.symbol===_),xt=(qe?.chains||[]).find(pe=>Wl(pe.chain_id,pe.chain_type)===w),xr=async()=>{if(se)try{Clipboard.setString(se),Ve(!0),setTimeout(()=>Ve(!1),2e3);}catch(pe){console.error("Failed to copy:",pe);}},$=xt?.estimated_price_impact_percent??0,re=xt?.max_slippage_percent??.25,et=xt?.minimum_deposit_amount_usd??3;return ze?jsxs(View,{style:U.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:b.primary}),jsx(Text,{style:[U.loadingText,{color:b.foregroundMuted,fontFamily:d.regular}],children:"Loading currencies..."})]}):$e&&N.length===0?jsxs(View,{style:U.errorContainer,children:[jsx(Text,{style:[U.errorText,{color:b.error,fontFamily:d.regular}],children:$e}),jsx(Text,{style:[U.errorHint,{color:b.foregroundMuted,fontFamily:d.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:U.container,children:[jsxs(View,{style:U.selectorSection,children:[jsx(Text,{style:[U.selectorLabel,{color:f.card.labelColor,fontFamily:d.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>Se(true),disabled:ze||N.length===0,style:[U.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:ze?jsxs(View,{style:U.tokenSelectorLoading,children:[jsx(View,{style:[U.loadingIcon,{backgroundColor:b.cardHover}]}),jsxs(View,{style:U.loadingTextContainer,children:[jsx(View,{style:[U.loadingLine,{backgroundColor:b.cardHover,width:60}]}),jsx(View,{style:[U.loadingLine,{backgroundColor:b.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:U.tokenIconWrapper,children:[qe&&jsx(Image,{source:{uri:te(Ce(qe,"png"))},style:U.tokenMainIcon}),(xt||de)&&jsx(Image,{source:{uri:te(Ce(xt||de,"png"))},style:[U.tokenChainBadge,{borderColor:f.card.backgroundColor,borderRadius:f.badge.borderRadius}]})]}),jsxs(View,{style:U.tokenSelectorInfo,children:[jsx(Text,{style:[U.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:d.semibold}],children:qe?.symbol||_}),jsx(Text,{style:[U.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:d.regular}],numberOfLines:1,children:xt?.chain_name||de?.chain_name||"Select network"})]}),jsxs(View,{style:U.tokenSelectorRight,children:[jsxs(Text,{style:[U.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:d.medium}],children:["$",et," min"]}),jsx(_r,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Ed,{visible:Ne,onClose:()=>Se(false),tokens:N,selectedToken:_,selectedChainKey:w,onSelect:(pe,Me)=>{T(pe),x(Me);},borderTopLeftRadius:m?.tokenSelector?.borderTopLeftRadius??S,borderTopRightRadius:m?.tokenSelector?.borderTopRightRadius??y}),jsx(View,{style:U.qrContainer,children:jsx(View,{style:[U.qrWrapper,{backgroundColor:b.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:F?jsxs(View,{style:U.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[U.loadingText,{color:b.foregroundMuted,fontFamily:d.regular}],children:"Loading..."})]}):se?jsx(ps,{value:se,size:180,logoUri:te(Ce(xt,"png")||Yt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:U.qrLoading,children:jsx(Text,{style:[U.errorText,{color:b.error,fontFamily:d.regular}],children:"No address available"})})})}),jsxs(View,{style:U.addressSection,children:[jsxs(View,{style:U.addressHeader,children:[jsx(Text,{style:[U.addressLabel,{color:f.card.labelColor,fontFamily:d.medium}],children:"Deposit Address"}),J&&jsxs(View,{style:U.copiedIndicator,children:[jsx(Ue,{size:14,color:b.success,strokeWidth:2}),jsx(Text,{style:[U.copiedText,{color:b.success,fontFamily:d.regular}],children:"Copied"})]})]}),jsxs(ir,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!F&&se?xr:void 0,contentStyle:U.addressBox,children:[jsx(Text,{style:[U.addressText,{color:f.card.titleColor,fontFamily:d.regular}],numberOfLines:2,children:F?"Loading...":se||"No address available"}),jsx(View,{style:U.addressCopyIcon,children:jsx(No,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[U.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>_e(!me),style:U.detailsHeader,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:U.chevronContainer,children:me?jsx(To,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(At,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),me&&jsxs(View,{style:U.detailsContent,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Price impact: ",$.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Slippage: Auto \u2022 ",re.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(Cl,{depositConfirmationMode:c,depositAddress:se,showWaitingUi:dt,latestExecution:X,onIveDeposited:le}),jsx(TouchableOpacity$1,{style:U.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[U.termsText,{color:b.primary,fontFamily:d.regular}],children:"Terms apply"})}),jsxs(ut,{visible:st,onClose:()=>Je(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:m?.infoSheet?.borderTopLeftRadius??S,borderTopRightRadius:m?.infoSheet?.borderTopRightRadius??y,children:[jsxs(View,{style:[U.sheetHeader,{borderBottomColor:b.border}],children:[jsx(View,{style:U.sheetHeaderSpacer}),jsx(Text,{style:[U.sheetTitle,{color:f.header.titleColor,fontFamily:d.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Je(false),style:U.sheetCloseButton,children:jsx(at,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:U.infoSheetContent,children:[jsxs(View,{style:[U.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Price Impact"}),jsxs(Text,{style:[U.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[$.toFixed(2),"%"]})]}),jsx(Text,{style:[U.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:[U.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Max Slippage"}),jsxs(Text,{style:[U.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[re.toFixed(2),"%"]})]}),jsx(Text,{style:[U.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."})]})]})]}),X&&jsx(ms,{visible:ct,status:X.status,tokenIconUrl:X.destination_token_metadata?.icon_urls?.find(pe=>pe.format==="png")?.url||X.destination_token_metadata?.icon_url||Ce(qe,"png"),explorerUrl:X.explorer_url,completionExplorerUrl:X.destination_explorer_url,date:X.created_at?new Date(X.created_at):void 0,amountUsd:X.source_amount_usd?parseFloat(X.source_amount_usd):void 0,onClose:()=>Re(false),borderTopLeftRadius:m?.depositStatus?.borderTopLeftRadius??S,borderTopRightRadius:m?.depositStatus?.borderTopRightRadius??y})]})}var U=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var cn={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},stripeLinkPay:{title:"Pay with Stripe Link",subtitle:"Apple Pay or Card"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Py(){let{colors:e,components:t}=O(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[r]);let a=({rightIcons:i=2})=>jsxs(View,{style:[$n.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[$n.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:$n.textBlock,children:[jsx(Animated.View,{style:[$n.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[$n.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:$n.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[$n.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:$n.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var $n=StyleSheet.create({container:{paddingTop:8,paddingBottom:24,gap:8},card:{marginHorizontal:16,flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:12,gap:12},leftIcon:{width:36,height:36},textBlock:{flex:1,gap:6},titleBar:{height:12,width:"70%",borderRadius:6},subtitleBar:{height:10,width:"50%",borderRadius:5},rightIcons:{flexDirection:"row",alignItems:"center",gap:4},rightIcon:{width:20,height:20,borderRadius:10}});function Fy({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,defaultChainType:c,defaultChainId:h,defaultTokenAddress:k,showBalance:g=false,hideDepositTracker:C=false,enableStripeLinkPay:S=false,StripeOnrampComponent:y,stripeOnrampEmail:m,stripeOnrampPhone:b,stripeMerchantIdentifier:d,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:R,stripeTheme:_,depositConfirmationMode:T="auto_ui",transferInputVariant:w="double_input",initialScreen:x="main",onDepositSuccess:W,onDepositError:D,sheetBorderRadius:F}){let v=F?.globalBorderTopLeftRadius,q=F?.globalBorderTopRightRadius,{colors:N,fonts:ae}=O(),[ze,ve]=useState([]),[J,Ve]=useState(null),[me,_e]=useState("amount"),Ne=x==="tracker"&&!C?"tracker":x==="transfer"?"transfer":x==="card"?"card":"main",Se=Ne==="main",[oe,Pe]=useState(Ne),{isAllowed:rt,isLoading:je}=ma(o,e);useEffect(()=>{if(!e||J)return;let ue=false;return Ls(o).then(async se=>{if(ue)return;let ye=[];for(let wt of se?.transfer_crypto?.networks??[]){let dt=wt.icon_urls.find(le=>le.format==="png")?.url||wt.icon_urls.find(le=>le.format==="svg")?.url;dt&&ye.push(te(dt));}for(let wt of se?.payment_networks?.networks??[]){let dt=wt.icon_urls.find(le=>le.format==="png")?.url||wt.icon_urls.find(le=>le.format==="svg")?.url;dt&&ye.push(te(dt));}ye.length>0&&await dd(ye),ue||Ve(se);}).catch(console.error),()=>{ue=true;}},[e,J,o]);let ot=()=>{t();};useEffect(()=>{e&&(Pe(Ne),_e("amount"));},[e,Ne]);let $e=useCallback(()=>{Se?(Pe("main"),_e("amount")):ot();},[Se,ot]),Fe=ze.filter(ue=>ue.status==="pending"||ue.status==="waiting").length,Re=!!(i&&s&&l&&p&&o)&&g!==false&&!!J,X=je||e&&!J,ce=rt===false,st=null;if(oe==="stripe"&&y){let ue=jsx(y,{publishableKey:o,email:m,phone:b,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,merchantIdentifier:d,paymentSelectorPosition:f,skipSuccessConfirmation:R,onClose:$e});st=_?jsx(Di,{..._,children:ue}):ue;}let Je=oe==="stripe"?.9:oe==="transfer"||oe==="card"?.94:oe==="tracker"?.6:oe==="main"?.5:void 0,Le=oe==="tracker"||oe==="main"?.9:void 0,ie={main:F?.main,transfer:F?.transferCrypto,card:F?.buyWithCard,stripe:F?.stripeLinkPay,tracker:F?.depositsTracker}[oe],de=ie?.borderTopLeftRadius??v,zt=ie?.borderTopRightRadius??q;return jsxs(ut,{visible:e,onClose:oe==="main"?ot:$e,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:Je,maxHeightPercent:Le,borderTopLeftRadius:de,borderTopRightRadius:zt,children:[oe==="main"&&jsxs(Fragment,{children:[jsx(Pr,{title:n,showBack:false,onClose:ot,showBalance:Re,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:p,publishableKey:o,projectName:J?.project_name}),X&&jsx(Py,{}),!X&&ce&&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:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tr.blockedDescription,{color:N.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!X&&!ce&&jsxs(View,{style:Tr.optionsContainer,children:[jsx(oa,{onPress:()=>Pe("transfer"),title:cn.transferCrypto.title,subtitle:cn.transferCrypto.subtitle,featuredTokens:J?.transfer_crypto?.networks}),jsx(ia,{onPress:()=>Pe("card"),title:cn.depositWithCard.title,subtitle:cn.depositWithCard.subtitle,paymentNetworks:J?.payment_networks?.networks}),S&&y&&jsx(la,{onPress:()=>Pe("stripe"),title:cn.stripeLinkPay.title,subtitle:cn.stripeLinkPay.subtitle}),!C&&jsx(sa,{onPress:()=>Pe("tracker"),title:cn.depositTracker.title,subtitle:cn.depositTracker.subtitle,badge:Fe>0?Fe:void 0})]})]}),oe==="transfer"&&jsxs(Fragment,{children:[jsx(Pr,{title:cn.transferCrypto.title,showBack:false,onClose:$e,showBalance:Re,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:p,publishableKey:o,projectName:J?.project_name}),je&&jsx(View,{style:[Tr.centeredContainer,Tr.centeredFlex],children:jsx(ActivityIndicator,{color:N.primary})}),!je&&ce&&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:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tr.blockedDescription,{color:N.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!je&&!ce&&jsx(gt,{style:Tr.transferScrollContainer,contentContainerStyle:Tr.scrollContent,showsVerticalScrollIndicator:false,children:w==="single_input"?jsx(Md,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:h,defaultTokenAddress:k,depositConfirmationMode:T,onExecutionsChange:ve,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:v,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:F?.tokenSelector,infoSheet:F?.infoSheet,depositStatus:F?.depositStatus}}):jsx(Sl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:h,defaultTokenAddress:k,depositConfirmationMode:T,onExecutionsChange:ve,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:v,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:F?.tokenSelector,chainSelector:F?.chainSelector,infoSheet:F?.infoSheet,depositStatus:F?.depositStatus}})})]}),oe==="card"&&jsxs(Fragment,{children:[jsx(Pr,{title:`Deposit ${a||"USDC"}`,showBack:me==="onramp",onBack:()=>_e("amount"),onClose:$e,showBalance:Re,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:p,publishableKey:o,projectName:J?.project_name}),jsx(View,{style:Tr.buyWithCardContainer,children:jsx(Il,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:p,onDepositSuccess:W,onDepositError:D,view:me,onViewChange:ue=>_e(ue),borderTopLeftRadius:v,borderTopRightRadius:q,sheetBorderRadius:{providerModal:F?.providerModal,webView:F?.webView,currencyModal:F?.currencyModal}})})]}),oe==="stripe"&&st&&jsx(View,{style:Tr.stripeLinkPayContainer,children:st}),oe==="tracker"&&jsx(Ld,{active:oe==="tracker",onClose:$e,executions:ze,externalUserId:r,publishableKey:o})]})}function zl({theme:e="auto",...t}){return jsx(Fy,{...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 Ul(e,t=true){return Xo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Va(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Hd(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await Gn(a),p=null,c=null,h=null,k=null,g,C,S,y=l.data.some(m=>m.chains.some(b=>{let d=b.chain_type===t&&b.chain_id===r&&b.token_address.toLowerCase()===o.toLowerCase();return d&&(p=b.minimum_deposit_amount_usd,c=b.estimated_processing_time,h=b.max_slippage_percent,k=b.estimated_price_impact_percent,S=b.chain_name,C=m),d}));if(C){let m=Ce(C,"png");m&&(g=te(m));}return {isSupported:y,minimumAmountUsd:p,estimatedProcessingTime:c,maxSlippagePercent:h,priceImpactPercent:k,errorMessage:y?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:g,chainName:S}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Nd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await La(t,r,o,n,a);if(l.balance){let p=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",h=l.balance.amount,k=BigInt(h),g=BigInt(10**p),C=k/g,y=(k%g).toString().padStart(p,"0").replace(/0+$/,""),m=y?`${C}.${y}`:C.toString();return {balanceBaseUnit:h,balanceHuman:m,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:p,symbol:c}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:i&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var Dy=2500,Vy=3e3,Ly=6e4;function jd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,p]=useState(false),c=useRef(new Date),h=useRef(new Map),k=useRef(false),g=useRef(n),C=useRef(a);return useEffect(()=>{g.current=n;},[n]),useEffect(()=>{C.current=a;},[a]),useEffect(()=>{o&&!k.current&&(c.current=new Date,h.current.clear()),o||h.current.clear(),k.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let S=c.current,y=async()=>{try{let b=await Qo(e,t,"withdraw"),d=new Date(S.getTime()-Ly),f=[...b.data].sort((w,x)=>{let W=w.created_at?new Date(w.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 w of f){let x=w.created_at?new Date(w.created_at):null;if(!x||x<d)continue;let W=h.current.get(w.id);if(!W){T=w;break}if(R.includes(W)&&_.includes(w.status)){T=w;break}}if(T){let w=T,x=w.created_at?new Date(w.created_at):null;if(!x||x<c.current)return;let W=h.current.get(w.id);h.current.set(w.id,w.status),s(D=>{let F=D.findIndex(v=>v.id===w.id);if(F>=0){let v=[...D];return v[F]=w,v}return [...D,w]}),w.status==="succeeded"&&(!W||R.includes(W))?g.current?.({message:"Withdrawal completed successfully",transaction:w}):w.status==="failed"&&W!=="failed"&&C.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:w});}}catch(b){console.error("Failed to fetch withdraw executions:",b),C.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:b});}};y();let m=setInterval(y,Dy);return p(true),()=>{clearInterval(m),p(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let S=async()=>{try{await wc({deposit_wallet_id:r},t);}catch{}};S();let y=setInterval(S,Vy);return ()=>clearInterval(y)},[o,r,t]),{executions:i,isPolling:l}}var $d=(e,t)=>`${t}:${e}`;function ga({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:a=false,tokenLabel:i="Receive token",chainLabel:s="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:p,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:h}){let{colors:k,fonts:g,components:C}=O(),[S,y]=useState(false),[m,b]=useState(false),d=C.card,f=t?e.find(w=>w.symbol===t):void 0,R=f?.chains||[],_=r?R.find(w=>$d(w.chain_id,w.chain_type)===r):void 0,T={backgroundColor:d.backgroundColor,borderRadius:d.borderRadius,borderWidth:d.borderWidth||1,borderColor:d.borderColor};return jsxs(View,{style:Xe.row,children:[jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:g.medium}],children:i}),jsxs(TouchableOpacity,{style:[Xe.selectButton,T],onPress:()=>!a&&e.length>0&&y(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:g.regular}],children:"Loading..."}):f?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:te(Ce(f,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:g.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:g.regular}],children:"Select receive token"}),jsx(At,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:g.medium}],children:s}),jsxs(TouchableOpacity,{style:[Xe.selectButton,T,(!f||R.length===0)&&Xe.disabled],onPress:()=>!a&&f&&R.length>0&&b(true),activeOpacity:.7,disabled:a||!f||R.length===0,children:[_?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:te(Ce(_,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:g.medium}],numberOfLines:1,children:_.chain_name})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:g.regular}],children:"Chain"}),jsx(At,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(ut,{visible:S,onClose:()=>y(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:p,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:k.foreground,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>y(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:k.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:e,keyExtractor:w=>w.symbol,contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:w})=>jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:w.symbol===t?k.cardHover:"transparent"}],onPress:()=>{o(w.symbol),y(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:te(Ce(w,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:k.foreground,fontFamily:g.medium}],children:w.symbol}),jsx(Text,{style:[Xe.pickerItemSub,{color:k.foregroundMuted,fontFamily:g.regular}],children:w.name}),w.symbol===t&&jsx(Ue,{size:18,color:k.primary,strokeWidth:2.5})]})})]}),jsxs(ut,{visible:m,onClose:()=>b(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c,borderTopRightRadius:h,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:k.foreground,fontFamily:g.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>b(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:k.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:R,keyExtractor:w=>$d(w.chain_id,w.chain_type),contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:w})=>{let x=$d(w.chain_id,w.chain_type);return jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:x===r?k.cardHover:"transparent"}],onPress:()=>{n(x),b(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:te(Ce(w,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:k.foreground,fontFamily:g.medium}],children:w.chain_name}),x===r&&jsx(Ue,{size:18,color:k.primary,strokeWidth:2.5})]})}})]})]})}var Xe=StyleSheet.create({row:{flexDirection:"column",gap:10},col:{},label:{fontSize:12,marginBottom:6},selectButton:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:12,gap:6,minHeight:48},selectedItem:{flex:1,flexDirection:"row",alignItems:"center",gap:6},icon:{width:20,height:20,borderRadius:10},selectedText:{fontSize:13,flexShrink:1},placeholder:{flex:1,fontSize:13},disabled:{opacity:.4},pickerHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:16,paddingBottom:12},pickerHeaderSpacer:{width:28},pickerHeaderClose:{width:28,alignItems:"flex-end"},pickerTitle:{flex:1,fontSize:16,textAlign:"center"},listContent:{paddingHorizontal:16,paddingVertical:8},pickerItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:12,borderRadius:10,gap:10},pickerIcon:{width:32,height:32,borderRadius:16},pickerItemText:{fontSize:15,flex:1},pickerItemSub:{fontSize:13}});function qd(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:a,enabled:i=true}=e,s=n?.trim()||"",l=!!t&&!!r&&!!o&&s.length>0;return Xo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>Cc({chain_type:t,chain_id:r,token_address:o,recipient_address:s},a),enabled:i&&l,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function Ey(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function My(e,t){if(e<=0)return "0";if(t===0)return BigInt(Math.round(e)).toString();let r=e.toFixed(t),[o,n=""]=r.split("."),a=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(a)).toString()}function zy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Nl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:p,balanceData:c,isLoadingBalance:h,minimumWithdrawAmountUsd:k,estimatedProcessingTime:g,maxSlippagePercent:C,priceImpactPercent:S,canWithdraw:y,onDepositWalletCreation:m,onWithdraw:b,onWithdrawError:d,onWithdrawSubmitted:f,onViewTracker:R}){let _="https://unifold.io/terms",T="https://unifold.io/support",{colors:w,fonts:x,components:W}=O(),[D,F]=useState(s||""),[v,q]=useState(""),[N,ae]=useState(false),[ze,ve]=useState(null),[J,Ve]=useState(false),[me,_e]=useState(""),Ne=useRef(null);useEffect(()=>{F(s||""),q(""),ve(null);},[s]);let Se=D.trim();useEffect(()=>{let le=setTimeout(()=>_e(Se),500);return ()=>clearTimeout(le)},[Se]);let{data:oe,isLoading:Pe,error:rt}=qd({chainType:p?.chain_type,chainId:p?.chain_id,tokenAddress:p?.token_address,recipientAddress:me,publishableKey:e,enabled:me.length>5&&!!p}),je=Se!==me,ot=useMemo(()=>!Se||Se.length<=5||je||Pe?null:rt?"Invalid address":oe&&!oe.valid?oe.failure_code==="account_not_found"?`Account not found on ${p?.chain_name}`:oe.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${p?.chain_name}`:"Invalid address":null,[Se,je,Pe,rt,oe,p,l]),$e=!je&&!!oe?.valid&&!ot,Fe=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),ct=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),Re=n||c?.symbol||"TOKEN",X=c?.decimals??6,ce=useMemo(()=>{let le=parseFloat(v);return !le||le<=0?0:le},[v]),st=useMemo(()=>{let le=parseFloat(v);return !le||le<=0?0:le*Fe},[v,Fe]),Je=useCallback(async()=>{try{let qe=await tf("expo-clipboard").getStringAsync();qe&&(F(qe.trim()),ve(null));}catch{}},[]),Le=useCallback(()=>{ct<=0||q(c?.balanceHuman??"0");},[ct,c]),be=k!==null&&st>0&&st<k,ie=ce>0&&ct>0&&ce>ct,de=Se.length>0&&v.trim().length>0&&ce>0&&$e&&!be&&!ie&&!!c,zt=useCallback(async()=>{if(!(!l||!p||!de||!y)){ae(true),ve(null);try{let le=await m({destinationChainType:p.chain_type,destinationChainId:p.chain_id,destinationTokenAddress:p.token_address,recipientAddress:Se}),qe=My(ce,X),yr=zy(ce,X),xt={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:Re,sourceTokenIconUrl:i,destinationChainType:p.chain_type,destinationChainId:p.chain_id,destinationTokenAddress:p.token_address,destinationTokenSymbol:l.symbol,destinationChainName:p.chain_name,destinationTokenIconUrl:l?te(Ce(l,"png")):void 0,amount:yr,amountBaseUnit:qe,submittedAt:new Date,withdrawIntentAddress:le.address,recipientAddress:Se};await b(xt),f(xt);}catch(le){let qe=le instanceof Error?le.message:"Withdrawal failed. Please try again.",yr=qe.length>120?"Withdrawal failed. Please try again.":qe;ve(yr),d?.({message:qe,error:le,code:"WITHDRAW_FAILED"});}finally{ae(false);}}},[l,p,de,y,Se,t,r,o,Re,i,v,ct,c,ce,X,st,m,b,d,f]),ue=W.input,se=W.card,ye=W.button,wt=ot?w.error:ue.borderColor,dt=useMemo(()=>N?"Processing...":ie?"Insufficient balance":be?`Minimum $${k?.toFixed(2)}`:ze?"Withdrawal failed \u2014 try again":"Withdraw",[N,ie,be,k,ze]);return jsxs(View,{style:Ye.container,children:[jsxs(View,{children:[jsxs(View,{style:Ye.labelRow,children:[jsx(Text,{style:[Ye.label,{color:se.labelColor,fontFamily:x.medium}],children:"Recipient address"}),(je||Pe)&&Se.length>5?jsx(ActivityIndicator,{size:"small",color:w.primary}):jsx(TouchableOpacity,{onPress:Je,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(iu,{size:16,color:w.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Ye.inputRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:wt}],children:jsx(TextInput,{style:[Ye.textInput,{color:ue.textColor,fontFamily:x.regular}],placeholder:"Enter wallet address",placeholderTextColor:ue.placeholderColor,value:D,onChangeText:le=>{F(le),ve(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Ne.current?.focus()})}),ot?jsx(Text,{style:[Ye.errorText,{color:w.error,fontFamily:x.regular}],children:ot}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Ye.label,{color:se.labelColor,fontFamily:x.medium,paddingBottom:8}],children:["Amount",k!=null&&k>0&&jsx(Text,{style:{color:w.warning,fontFamily:x.regular},children:` ($${k.toFixed(2)} min)`})]}),jsxs(View,{style:[Ye.amountRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:ue.borderColor}],children:[jsx(TextInput,{ref:Ne,style:[Ye.amountInput,{color:ue.textColor,fontFamily:x.regular}],placeholder:"0.00",placeholderTextColor:ue.placeholderColor,value:v,onChangeText:le=>{(le===""||/^\d*\.?\d*$/.test(le))&&(q(le),ve(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[Ye.unitLabel,{color:w.foregroundMuted,fontFamily:x.medium}],children:Re}),jsx(TouchableOpacity,{style:[Ye.maxButton,{backgroundColor:`${w.primary}20`}],onPress:Le,activeOpacity:.7,children:jsx(Text,{style:[Ye.maxText,{color:w.primary,fontFamily:x.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Ye.detailsCard,{marginTop:24,backgroundColor:se.backgroundColor,borderRadius:se.borderRadius,borderWidth:se.borderWidth||1,borderColor:se.borderColor}],children:[jsx(TouchableOpacity,{style:Ye.detailsToggle,onPress:()=>Ve(!J),activeOpacity:.7,children:jsxs(View,{style:Ye.detailsRow,children:[jsx(View,{style:[Ye.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ye.detailsLabel,{color:se.titleColor,fontFamily:x.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:x.medium},children:Ey(g)})]}),jsx(View,{style:{transform:[{rotate:J?"180deg":"0deg"}]},children:jsx(At,{size:16,color:se.actionColor,strokeWidth:2})})]})}),J&&jsxs(View,{style:Ye.detailsExpanded,children:[jsxs(View,{style:Ye.detailsRow,children:[jsx(View,{style:[Ye.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ye.detailsLabel,{color:se.titleColor,fontFamily:x.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:["Auto \u2022 ",(C??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Ye.detailsRow,children:[jsx(View,{style:[Ye.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ye.detailsLabel,{color:se.titleColor,fontFamily:x.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:[(S??0).toFixed(2),"%"]})]})]})]})]}),ze&&jsx(Text,{style:[Ye.errorText,{color:w.error,fontFamily:x.regular,textAlign:"center"}],children:ze}),jsxs(View,{style:Ye.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Ye.withdrawButton,{backgroundColor:ye.primaryBackground,borderRadius:ye.borderRadius,borderWidth:ye.borderWidth,borderColor:ye.borderColor,opacity:!de||!y||N?.5:1}],onPress:zt,disabled:!de||!y||N,activeOpacity:.8,children:[N&&jsx(ActivityIndicator,{size:"small",color:ye.primaryText}),jsx(Text,{style:[Ye.withdrawButtonText,{color:ye.primaryText,fontFamily:x.medium}],children:dt})]}),jsxs(View,{style:Ye.footerRow,children:[jsxs(TouchableOpacity,{style:Ye.historyLink,onPress:R,activeOpacity:.7,children:[jsx(zr,{size:14,color:w.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Ye.historyText,{color:w.foregroundMuted,fontFamily:x.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Ye.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[Ye.legalText,{color:w.foregroundMuted,fontFamily:x.regular}],children:"Terms"})}),jsx(Text,{style:[Ye.legalSeparator,{color:w.foregroundMuted,fontFamily:x.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(T),activeOpacity:.7,children:jsx(Text,{style:[Ye.legalText,{color:w.foregroundMuted,fontFamily:x.regular}],children:"Help"})})]})]})]})]})}var Ye=StyleSheet.create({container:{gap:12,paddingHorizontal:16,paddingBottom:16},label:{fontSize:12},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:6},inputRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48,gap:8},amountInput:{flex:1,fontSize:14,paddingVertical:8},unitLabel:{fontSize:14,flexShrink:0},maxButton:{paddingHorizontal:8,paddingVertical:4,borderRadius:6},maxText:{fontSize:12,fontWeight:"600"},withdrawRow:{gap:12},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},historyLink:{flexDirection:"row",alignItems:"center",gap:6},historyText:{fontSize:13},legalLinks:{flexDirection:"row",alignItems:"center",gap:6},legalText:{fontSize:13},legalSeparator:{fontSize:13},detailsCard:{paddingHorizontal:12,overflow:"hidden"},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13,flex:1},detailsExpanded:{gap:10,paddingBottom:12},withdrawButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:15,gap:8},withdrawButtonText:{fontSize:16,fontWeight:"600"}});function Ny(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function jy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function ql({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=O(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed",s=e.status==="failed"||e.status==="refunded",l=s?r.error:i?r.warning:r.success,p=te(Ce(e.destination_token_metadata,"png")||Yt("/icons/tokens/png/usdc.png")),c=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",h=Ny(e.created_at||new Date().toISOString()),k=jy(e.source_amount_usd);return jsxs(ir,{cardTokens:a,onPress:t,contentStyle:un.container,children:[jsxs(View,{style:un.iconContainer,children:[jsx(Image,{source:{uri:p},style:un.tokenIcon}),jsx(View,{style:[un.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Is,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Ue,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:un.textContainer,children:[jsx(Text,{style:[un.title,{color:a.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[un.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:h})]}),jsxs(View,{style:un.rightContainer,children:[jsx(Text,{style:[un.amount,{color:a.textRightColor,fontFamily:o.medium}],children:k}),jsx(_r,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var un=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function Gd(e){try{let t=new Date(e),o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=t.getDate(),a=t.getFullYear(),i=t.getHours(),s=t.getMinutes(),l=i>=12?"PM":"AM";i=i%12||12;let p=s<10?`0${s}`:`${s}`;return `${o} ${n}, ${a} at ${i}:${p} ${l}`}catch{return e}}function Hm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function qy(e,t){if(e)try{return `$${Number(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}if(t)try{return `$${(Number(t)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}return "$0.00"}function Nm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function jm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function ya({label:e,value:t,isLast:r}){let{fonts:o,components:n}=O(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Ee.detailRow,children:[jsx(Text,{style:[Ee.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Ee.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Ee.divider,{backgroundColor:a.borderColor}]})]})}function Jd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=O(),[p,c]=useState([]),[h,k]=useState(!!n),g=l.card,C=l.button,S=l.header,y=l.container;useEffect(()=>{bc().then(ae=>c(ae.data)).catch(()=>{});},[]),useEffect(()=>{k(!!n);},[e?.id]);let m=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,b=e?e.status==="failed"||e.status==="refunded":false,d=b?i.error:m?i.warning:i.success,f=b?"Failed":m?"Processing":"Completed",R=e?.destination_token_metadata?te(Ce(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?te(t.destinationTokenIconUrl):te(Yt("/icons/tokens/png/usdc.png")),_=e?.created_at?Gd(e.created_at):t.submittedAt?Gd(t.submittedAt.toISOString()):Gd(new Date().toISOString()),T=e?`${Hm(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Nm(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,w=e?`${Hm(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Nm(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,x=e?qy(e.source_amount_usd,e.source_amount_base_unit):"$0.00",W=e?Da(p,e.source_chain_type,e.source_chain_id):t.sourceChainId,D=e?Da(p,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,F=e?.transaction_hash,v=e?.explorer_url,q=e?.destination_transaction_hashes?.[0],N=e?.destination_explorer_url;return jsxs(gt,{style:Ee.scroll,contentContainerStyle:Ee.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Ee.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Fi,{size:22,color:S.buttonColor,strokeWidth:2})}):jsx(View,{style:Ee.headerSpacer}),jsx(Text,{style:[Ee.headerTitle,{color:S.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Ee.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:S.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Ee.iconContainer,children:[jsx(Image,{source:{uri:R},style:Ee.tokenIcon}),jsx(View,{style:[Ee.statusBadge,{backgroundColor:d}],children:b?jsx(Is,{size:10,color:"#FFFFFF",strokeWidth:3}):m?jsx(View,{style:Ee.spinnerDot}):jsx(Ue,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Ee.statusRow,children:[jsx(View,{style:[Ee.statusDot,{backgroundColor:d}]}),jsx(Text,{style:[Ee.statusText,{color:d,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Ee.dateText,{color:y.subtitleColor,fontFamily:s.regular}],children:_}),jsxs(View,{style:[Ee.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:[jsx(ya,{label:"Amount Sent",value:T}),jsx(ya,{label:"Amount Received",value:w}),jsx(ya,{label:"USD Value",value:x}),jsx(ya,{label:"Source Network",value:W}),jsx(ya,{label:"Destination Network",value:D,isLast:true})]}),jsxs(TouchableOpacity,{style:Ee.moreDetailsRow,onPress:()=>k(ae=>!ae),activeOpacity:.7,children:[jsx(Text,{style:[Ee.moreDetailsText,{color:y.actionTitle,fontFamily:s.regular}],children:h?"See less":n?"See more":"See more details"}),h?jsx(To,{size:16,color:y.actionColor,strokeWidth:2}):jsx(At,{size:16,color:y.actionColor,strokeWidth:2})]}),h&&jsx(View,{style:[Ee.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:F&&v?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(v),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Ee.txHash,{color:g.titleColor,fontFamily:s.regular}],children:jm(F)}),jsx(ko,{size:14,color:g.actionColor,strokeWidth:2})]}),!m&&q&&N&&jsxs(Fragment,{children:[jsx(View,{style:[Ee.divider,{backgroundColor:g.borderColor}]}),jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(N),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Ee.txHash,{color:g.titleColor,fontFamily:s.regular}],children:jm(q)}),jsx(ko,{size:14,color:g.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Ee.detailRow,children:jsx(Text,{style:[Ee.detailLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Ee.buttonRow,children:[jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:C.secondaryBackground,borderRadius:C.borderRadius,borderWidth:C.borderWidth,borderColor:C.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:C.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:C.primaryBackground,borderRadius:C.borderRadius,borderWidth:C.borderWidth,borderColor:C.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:C.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Ee=StyleSheet.create({scroll:{flex:1},container:{alignItems:"center",paddingHorizontal:20,paddingTop:8,paddingBottom:32,gap:12},headerRow:{flexDirection:"row",alignItems:"center",width:"100%",paddingTop:16,marginBottom:4},headerSpacer:{width:28},headerTitle:{flex:1,fontSize:16,textAlign:"center"},iconContainer:{position:"relative",marginTop:8},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center"},spinnerDot:{width:10,height:10,borderRadius:5,borderWidth:2,borderColor:"#FFFFFF",borderTopColor:"transparent"},statusRow:{flexDirection:"row",alignItems:"center",gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:15},dateText:{fontSize:13,marginTop:-4},detailsCard:{width:"100%",paddingHorizontal:16,overflow:"hidden"},detailRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailLabel:{fontSize:13,flex:1},detailValue:{fontSize:13,flexShrink:0,maxWidth:"55%",textAlign:"right"},divider:{height:StyleSheet.hairlineWidth,opacity:.5},moreDetailsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingHorizontal:4},moreDetailsText:{fontSize:14},txRow:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:12},txLabel:{fontSize:13},txHash:{fontSize:13,flex:1,textAlign:"right"},buttonRow:{flexDirection:"row",gap:10,width:"100%",marginTop:4},button:{paddingVertical:14,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:14}});function $m(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Ql({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=O(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",p=s?.status==="failed",c={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:It.container,children:[jsx(TouchableOpacity,{style:It.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[It.iconRing,{backgroundColor:n.successBackground}],children:jsx(Ue,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[It.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[It.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]}),jsxs(View,{style:It.buttonRow,children:[jsx(TouchableOpacity,{style:[It.button,It.halfButton,c,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[It.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[It.button,It.halfButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[It.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):p?jsxs(View,{style:It.container,children:[jsx(TouchableOpacity,{style:It.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[It.iconRing,{backgroundColor:n.errorBackground}],children:jsx(at,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[It.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[It.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[It.button,It.fullButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[It.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:It.container,children:[jsx(TouchableOpacity,{style:It.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(kt,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:te(e.sourceTokenIconUrl)},style:It.tokenIconFill}):jsx(View,{style:[It.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[It.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[It.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]})]})}var It=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:48,paddingBottom:24},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconRing:{width:80,height:80,borderRadius:40,alignItems:"center",justifyContent:"center",marginBottom:20},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},title:{fontSize:20,marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,marginBottom:24},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,alignItems:"center",justifyContent:"center",borderRadius:12},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:15}});function Zy(e){let t=e.source_token_metadata?.decimals??6,r=e.source_amount_base_unit??"0",o=Number(r)/Math.pow(10,t),n=o>=1?o.toFixed(2):o.toPrecision(4).replace(/\.?0+$/,"");return {sourceChainType:e.source_chain_type,sourceChainId:e.source_chain_id,sourceTokenAddress:e.source_token_address,sourceTokenSymbol:e.source_currency?.toUpperCase()??"",sourceTokenIconUrl:te(Ce(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(Ce(e.destination_token_metadata,"png")),amount:n,amountBaseUnit:r,submittedAt:e.created_at?new Date(e.created_at):void 0,withdrawIntentAddress:e.deposit_wallet?.address??"",recipientAddress:e.recipient_address??""}}var qm=(e,t)=>`${t}:${e}`;function Xy(){let{colors:e}=O(),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 Yl({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,defaultDestinationChainType:i,defaultDestinationChainId:s,defaultDestinationTokenAddress:l,modalTitle:p="Withdraw Crypto",onWithdraw:c,onWithdrawSuccess:h,onWithdrawError:k,heightPercent:g=.94,sheetBorderRadius:C,sourceChainType:S,sourceChainId:y,sourceTokenAddress:m,sourceTokenSymbol:b,sourceChainName:d,sourceTokenIconUrl:f}){let{colors:R,fonts:_}=O(),[T,w]=useState("form"),[x,W]=useState(S),[D,F]=useState(y),[v,q]=useState(m),[N,ae]=useState(b),[ze,ve]=useState(d),[J,Ve]=useState(f),[me,_e]=useState(null),[Ne,Se]=useState(null),[oe,Pe]=useState(null),[rt,je]=useState(),[ot,$e]=useState([]),[Fe,ct]=useState(null),[Re,X]=useState("form"),ce=useRef(new Animated.Value(Dimensions.get("window").width)).current,st=useRef(null),Je=!!x&&!!D&&!!v,{data:Le,isLoading:be}=Ul(r,e&&T==="form"),ie=Le?.data??[],{data:de,isLoading:zt}=Hd({sourceChainType:x,sourceChainId:D,sourceTokenAddress:v,sourceTokenSymbol:N,publishableKey:r,enabled:e&&Je&&T==="form"}),{data:ue,isLoading:se}=Nd({address:n,chainType:x,chainId:D,tokenAddress:v,publishableKey:r,enabled:e&&Je}),{executions:ye}=jd({userId:o,publishableKey:r,depositWalletId:rt,enabled:!!rt&&e,onWithdrawSuccess:h,onWithdrawError:k});useEffect(()=>{if(!e||T!=="tracker")return;let z=false;return Qo(o,r,"withdraw").then(Ot=>{z||$e(Ot.data);}).catch(console.error),()=>{z=true;}},[e,T,o,r]),useEffect(()=>{e&&(st.current&&(clearTimeout(st.current),st.current=null),w("form"),W(S),F(y),q(m),ae(b),ve(d),Ve(f),_e(null),Se(null),Pe(null),je(void 0),$e([]),ct(null),X("form"),ce.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{st.current&&clearTimeout(st.current);},[]),useEffect(()=>{J||de?.iconUrl&&Ve(de.iconUrl);},[de?.iconUrl,J]),useEffect(()=>{ze||de?.chainName&&ve(de.chainName);},[de?.chainName,ze]),useEffect(()=>{if(!ie.length||me)return;let z,Ot;if(i&&s)if(l)for(let St of ie){let Mr=St.chains.find(er=>er.chain_type===i&&er.chain_id===s&&er.token_address.toLowerCase()===l.toLowerCase());if(Mr){z=St,Ot=Mr;break}}else for(let St of ie){let Mr=St.chains.find(er=>er.chain_type===i&&er.chain_id===s);if(Mr){z=St,Ot=Mr;break}}z||(z=ie[0]),z&&(_e(z),Se(Ot??z.chains[0]??null));},[ie,me,i,s,l]),useEffect(()=>{T==="confirming"&&ye.length>0&&w("details");},[T,ye]);let wt=useCallback(()=>{t(),st.current=setTimeout(()=>{w("form"),W(S),F(y),q(m),ae(b),ve(d),Ve(f),_e(null),Se(null),Pe(null),je(void 0),$e([]),ct(null),X("form"),st.current=null;},300);},[t,S,y,m,b,d,f]),dt=useCallback(z=>{let Ot=ie.find(St=>St.symbol===z);Ot&&(_e(Ot),Ot.chains.length>0&&Se(Ot.chains[0]));},[ie]),le=useCallback(z=>{if(!me)return;let Ot=me.chains.find(St=>qm(St.chain_id,St.chain_type)===z);Ot&&Se(Ot);},[me]),qe=useCallback(async z=>{let Ot=await $o({external_user_id:o,destination_chain_type:z.destinationChainType,destination_chain_id:z.destinationChainId,destination_token_address:z.destinationTokenAddress,recipient_address:z.recipientAddress,action_type:"withdraw"},r),St=qo(Ot.data,x??"");if(!St)throw new Error(`No deposit wallet found for chain type: ${x}`);return je(St.id),{id:St.id,address:St.address}},[o,r,x]),yr=useCallback(z=>{Pe(z),w("confirming");},[]),xt=useCallback(z=>{ct(z),ce.setValue(Dimensions.get("window").width),Animated.timing(ce,{toValue:0,duration:280,useNativeDriver:true}).start();},[ce]),xr=useCallback(()=>{Animated.timing(ce,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>ct(null));},[ce]),$=be||zt,re=de?.isSupported??null,et=T==="confirming"?"Withdrawal Status":p,pe=C?.globalBorderTopLeftRadius,Me=C?.globalBorderTopRightRadius,M=C?.main?.borderTopLeftRadius??pe,ee=C?.main?.borderTopRightRadius??Me,ke=C?.tokenSelector?.borderTopLeftRadius??pe,fe=C?.tokenSelector?.borderTopRightRadius??Me,_t=C?.chainSelector?.borderTopLeftRadius??pe,V=C?.chainSelector?.borderTopRightRadius??Me,Or=(()=>{if(T!=="form"||!Je||se||!ue)return;let z=N||ue.symbol,Ot=ue.balanceUsd;if(Ot!=null){let er=`$${parseFloat(Ot).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return z?`Balance: ${er} ${z}`:`Balance: ${er}`}let St=ue.balanceHuman;if(!(!St||St==="0"))return z?`Balance: ${St} ${z}`:`Balance: ${St}`})();return jsx(ut,{visible:e,onClose:wt,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:ee,children:T==="confirming"&&oe?jsx(Ql,{txInfo:oe,executions:ye,onClose:wt,onViewTracker:()=>{X("confirming"),w("tracker");}}):T==="details"&&oe?jsx(Jd,{execution:ye.length>0?ye[ye.length-1]:null,txInfo:oe,onClose:wt,onViewHistory:()=>{X("details"),w("tracker");},onHeaderClose:()=>w("form")}):T==="tracker"?jsxs(View,{style:zo.trackerContainer,children:[jsx(Pr,{title:"Withdrawal History",onClose:()=>w(Re)}),ot.length===0?jsx(View,{style:zo.emptyState,children:jsx(Text,{style:[zo.emptyText,{color:R.foregroundMuted,fontFamily:_.regular}],children:"No withdrawals to track yet"})}):jsx(Vi,{data:ot,keyExtractor:z=>z.id,contentContainerStyle:zo.listContent,showsVerticalScrollIndicator:false,renderItem:({item:z})=>jsx(ql,{execution:z,onPress:()=>xt(z)})}),Fe&&jsx(Animated.View,{style:[zo.historyDetailOverlay,{backgroundColor:R.background,transform:[{translateX:ce}]}],children:jsx(Jd,{execution:Fe,txInfo:Zy(Fe),onClose:wt,onBack:xr,onViewHistory:xr})})]}):jsxs(Fragment,{children:[jsx(Pr,{title:et,subtitle:Or,onClose:wt}),$?jsx(Xy,{}):re===false?jsxs(View,{style:zo.unsupportedContainer,children:[jsx(Text,{style:[zo.unsupportedTitle,{color:R.foreground,fontFamily:_.medium}],children:"Unsupported Token"}),jsx(Text,{style:[zo.unsupportedMessage,{color:R.foregroundMuted,fontFamily:_.regular}],children:de?.errorMessage})]}):jsx(eb,{publishableKey:r,sourceChainType:x??"",sourceChainId:D??"",sourceTokenAddress:v??"",sourceTokenSymbol:N,sourceChainName:ze,sourceTokenIconUrl:J,recipientAddressProp:a,destinationTokens:ie,selectedToken:me,selectedChain:Ne,selectedChainKey:Ne?qm(Ne.chain_id,Ne.chain_type):null,onTokenChange:dt,onChainChange:le,tokensLoading:be,balanceData:ue??null,isLoadingBalance:se,sourceValidation:de??null,onDepositWalletCreation:qe,onWithdraw:c,onWithdrawError:k,onWithdrawSubmitted:yr,onViewTracker:()=>{X("form"),w("tracker");},tokenSelectorLeft:ke,tokenSelectorRight:fe,chainSelectorLeft:_t,chainSelectorRight:V})]})})}function eb({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:p,selectedChain:c,selectedChainKey:h,onTokenChange:k,onChainChange:g,tokensLoading:C,balanceData:S,isLoadingBalance:y,sourceValidation:m,onDepositWalletCreation:b,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:R,onViewTracker:_,tokenSelectorLeft:T,tokenSelectorRight:w,chainSelectorLeft:x,chainSelectorRight:W}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(gt,{style:{flex:1,paddingTop:16},contentContainerStyle:zo.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:zo.doubleInputWrapper,children:jsx(ga,{tokens:l,selectedTokenSymbol:p?.symbol??null,selectedChainKey:h,onTokenChange:k,onChainChange:g,isLoading:C,tokenPickerBorderTopLeftRadius:T,tokenPickerBorderTopRightRadius:w,chainPickerBorderTopLeftRadius:x,chainPickerBorderTopRightRadius:W})}),jsx(Nl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:p,selectedChain:c,balanceData:S,isLoadingBalance:y,minimumWithdrawAmountUsd:m?.minimumAmountUsd??null,estimatedProcessingTime:m?.estimatedProcessingTime??null,maxSlippagePercent:m?.maxSlippagePercent??null,priceImpactPercent:m?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:b,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:R,onViewTracker:_})]})})}var zo=StyleSheet.create({scrollContent:{paddingBottom:32},doubleInputWrapper:{paddingHorizontal:16,paddingBottom:12,paddingTop:4},listContent:{paddingHorizontal:16,paddingBottom:32,gap:8},trackerContainer:{flex:1,overflow:"hidden"},historyDetailOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},emptyState:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:48},emptyText:{fontSize:14},unsupportedContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24,paddingVertical:48},unsupportedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},unsupportedMessage:{fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280}});StyleSheet.create({container:{paddingHorizontal:16,paddingTop:16,paddingBottom:24,gap:16},fieldGroup:{gap:8},fieldLabel:{fontSize:12},walletCard:{paddingHorizontal:12,paddingVertical:12,minHeight:48,justifyContent:"center"},walletAddress:{fontSize:13},primaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginTop:4},primaryButtonText:{fontSize:16},secondaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center"},secondaryButtonText:{fontSize:16}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Gm=createContext(null);function db({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new od({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,p]=useState(false),[c,h]=useState(null),k=useColorScheme(),g=useRef(false);g.current||(va({publishableKey:t}),g.current=true);let C=useMemo(()=>{let v=r?.appearance||"dark";return v==="auto"?k==="dark"?"dark":"light":v},[r?.appearance,k]);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(()=>()=>{y.current&&clearTimeout(y.current),_.current&&clearTimeout(_.current);},[]);let S=useRef(null),y=useRef(null),m=useCallback(v=>{y.current&&(clearTimeout(y.current),y.current=null),S.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),S.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),S.current=null);let q=new Promise((N,ae)=>{S.current={resolve:N,reject:ae};});return s(v),a(true),q},[]),b=useCallback(()=>{S.current&&(S.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),S.current=null),a(false),y.current=setTimeout(()=>{s(null),y.current=null;},200);},[]),d=useCallback(v=>{i?.onSuccess&&i.onSuccess(v),S.current&&(S.current.resolve(v),S.current=null);},[i]),f=useCallback(v=>{console.error("[UnifoldProvider] Deposit error:",v),i?.onError&&i.onError(v),S.current&&(S.current.reject(v),S.current=null);},[i]),R=useRef(null),_=useRef(null),T=useRef(void 0),w=useCallback(v=>{_.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,ae)=>{R.current={resolve:N,reject:ae};});return T.current=v.onClose,h(v),p(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,p(false),_.current=setTimeout(()=>{h(null),_.current=null;},200);},[]),W=useCallback(v=>{c?.onSuccess&&c.onSuccess(v),R.current&&(R.current.resolve(v),R.current=null);},[c]),D=useCallback(v=>{console.error("[UnifoldProvider] Withdraw error:",v),c?.onError&&c.onError(v),R.current&&(R.current.reject(v),R.current=null);},[c]),F=useMemo(()=>({publishableKey:t,beginDeposit:m,closeDeposit:b,beginWithdraw:w,closeWithdraw:x}),[t,m,b,w,x]);return jsx(sd,{client:o,children:jsx(Gm.Provider,{value:F,children:jsxs(Di,{mode:C,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(zl,{visible:n,onClose:b,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:i.externalUserId,destinationChainType:i.destinationChainType,destinationChainId:i.destinationChainId,destinationTokenSymbol:i.destinationTokenSymbol,recipientAddress:i.recipientAddress,destinationTokenAddress:i.destinationTokenAddress,defaultChainType:i.defaultChainType,defaultChainId:i.defaultChainId,defaultTokenAddress:i.defaultTokenAddress,showBalance:i.showBalance,stripeOnrampEmail:i.stripeOnrampEmail,stripeOnrampPhone:i.stripeOnrampPhone,stripeTheme:{mode:C,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:i.depositConfirmationMode??"auto_ui",initialScreen:i.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?sp():void 0,onDepositSuccess:d,onDepositError:f,theme:C,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Yl,{visible:l,onClose:x,publishableKey:t,externalUserId:c.externalUserId,senderAddress:c.senderAddress,recipientAddress:c.recipientAddress,sourceChainType:c.sourceChainType,sourceChainId:c.sourceChainId,sourceTokenAddress:c.sourceTokenAddress,sourceTokenSymbol:c.sourceTokenSymbol,defaultDestinationChainType:c.defaultDestinationChainType,defaultDestinationChainId:c.defaultDestinationChainId,defaultDestinationTokenAddress:c.defaultDestinationTokenAddress,onWithdraw:c.withdraw,onWithdrawSuccess:W,onWithdrawError:D,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function ub(){let e=useContext(Gm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
- export{qa as AmountScreen,ut as BottomSheet,Qa as KYCWizardScreen,Xa as OnrampScreen,el as StripeOnramp,np as StripeOnrampPreconfigure,db as UnifoldProvider,Ce as getPreferredIcon,Na as getStripePublishableKey,Va as getSupportedDestinationTokens,te as normalizeIconUrl,tl as registerStripeOnramp,cu as setDevApiUrl,Ha as setStripeOnrampApiUrl,Ua as setStripeOnrampPublishableKey,ma as useAllowedCountry,Ka as useStripeOnramp,O as useTheme,ub as useUnifold};
1
+ import*as An from'react';import An__default,{createContext,useContext,useState,useRef,useCallback,useEffect,useMemo,useId,Fragment as Fragment$1}from'react';import {StyleSheet,ScrollView,useWindowDimensions,Platform,PanResponder,Modal,View,Pressable,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Image,Easing,Dimensions,Clipboard,Linking,FlatList}from'react-native';import Nt,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Polyline,Line,SvgXml,SvgUri}from'react-native-svg';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import au,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Wc from'@react-native-async-storage/async-storage';import Gh from'expo-constants';import Fg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var tu=e=>{throw TypeError(e)};var tf=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ec=(e,t,r)=>t.has(e)||tu("Cannot "+r);var u=(e,t,r)=>(ec(e,t,"read from private field"),r?r.call(e):t.get(e)),Z=(e,t,r)=>t.has(e)?tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(ec(e,t,"write to private field"),t.set(e,r),r),Ae=(e,t,r)=>(ec(e,t,"access private method"),r);var Ts=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return u(e,t,o)}});var tc={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},dark:{background:"#2D2C2F",card:"#3A393C",cardHover:"#48474A",foreground:"#F8FAFC",foregroundMuted:"#94A3B8",foregroundSubtle:"#64748B",border:"#38383A",borderSecondary:"#48484A",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"rgba(34, 197, 94, 0.1)",warning:"#F59E0B",warningBackground:"rgba(245, 158, 11, 0.1)",error:"#EF4444",errorBackground:"rgba(239, 68, 68, 0.1)",overlay:"rgba(0, 0, 0, 0.7)"}},rc=tc;function ka(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function xs(e,t,r){let o=r?t?.[r]:void 0,n=(c,C,T)=>{let y=o?.[c]?.[C];if(y!==void 0)return y;let b=t?.[c]?.[C];return b!==void 0?b:T},a={backgroundColor:n("card","backgroundColor",e.card),titleColor:n("card","titleColor",e.foreground),subtitleColor:n("card","subtitleColor",e.foregroundMuted),labelColor:n("card","labelColor",e.foregroundMuted),headerColor:n("card","headerColor",e.foregroundMuted),labelRightColor:n("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:n("card","labelHighlightRightColor",e.warning),textRightColor:n("card","textRightColor",e.foreground),subtextRightColor:n("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:n("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:n("card","rowRightLabel",e.foreground),iconColor:n("card","iconColor",e.primary),iconBackgroundColor:n("card","iconBackgroundColor",e.primary+"26"),actionColor:n("card","actionColor",e.foregroundMuted),actionIcon:n("card","actionIcon",e.foregroundMuted),descriptionColor:n("card","descriptionColor",e.foregroundMuted),borderRadius:n("card","borderRadius",12),borderWidth:n("card","borderWidth",0),borderColor:n("card","borderColor",e.border),shadowColor:n("card","shadowColor","#000"),shadowOffset:n("card","shadowOffset",{width:0,height:-4}),shadowOpacity:n("card","shadowOpacity",0),shadowRadius:n("card","shadowRadius",12),elevation:n("card","elevation",0),iconContainerBorderRadius:n("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},i=(o?.depositMenu??t?.depositMenu)?.card,s=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,l=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,m=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:a,input:{backgroundColor:n("input","backgroundColor",n("search","backgroundColor",e.card)),textColor:n("input","textColor",n("search","inputColor",e.foreground)),placeholderColor:n("input","placeholderColor",n("search","placeholderColor",e.foregroundMuted)),borderColor:n("input","borderColor",e.border),borderRadius:n("input","borderRadius",n("search","borderRadius",8)),borderWidth:n("input","borderWidth",1)},button:{primaryBackground:n("button","primaryBackground",e.primary),primaryText:n("button","primaryText",e.primaryForeground),secondaryBackground:n("button","secondaryBackground",e.card),secondaryText:n("button","secondaryText",e.foreground),borderRadius:n("button","borderRadius",12),borderWidth:n("button","borderWidth",0),borderColor:n("button","borderColor",e.border)},container:{titleColor:n("container","titleColor",e.foreground),subtitleColor:n("container","subtitleColor",e.foregroundMuted),actionColor:n("container","actionColor",e.foregroundMuted),actionTitle:n("container","actionTitle",e.foregroundMuted),buttonColor:n("container","buttonColor",e.primary),buttonTitleColor:n("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:n("container","iconBackgroundColor",e.success),iconColor:n("container","iconColor",e.foreground)},search:{backgroundColor:n("search","backgroundColor",e.card),inputColor:n("search","inputColor",e.foreground),placeholderColor:n("search","placeholderColor",e.foregroundMuted),borderRadius:n("search","borderRadius",8)},list:{titleSectionColor:n("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:n("list","rowBorderRadius",12)},badge:{borderRadius:n("badge","borderRadius",8)},sheet:{shadowColor:n("sheet","shadowColor","#000"),shadowOffset:n("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:n("sheet","shadowOpacity",.1),shadowRadius:n("sheet","shadowRadius",12),elevation:n("sheet","elevation",16)},depositMenu:{card:ka(a,i)},transferCrypto:{depositAddress:{card:ka(a,s)}},depositCard:{quoteProvider:{card:ka(a,l)}},depositTracker:{executionRow:{card:ka(a,m)}}}}function oc(e,t,r){let n={...tc[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var nc=createContext(null);function F(){let e=useContext(nc);if(!e){let t=rc.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:xs(t,void 0,"dark"),isDark:true}}return e}function kt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=F(),l=a??s.warning,m=i??"#FBBF24",c=useRef(new Animated.Value(0)).current,C=useId(),T=useMemo(()=>`circularProgressGrad_${C.replace(/[^a-zA-Z0-9_-]/g,"")}`,[C]),y=(e-t)/2,b=2*Math.PI*y,k=e/2,h=o??Math.max(0,Math.round(e-t*2-8)),p=(e-h)/2;useEffect(()=>{let d=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return d.start(),()=>d.stop()},[c]);let g=c.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},n],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:g}]},children:jsxs(Nt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:T,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:m})]})}),jsx(Circle,{cx:k,cy:k,r:y,stroke:`url(#${T})`,strokeWidth:t,fill:"none",strokeDasharray:`${b*.75} ${b*.25}`,strokeLinecap:"round",rotation:-90,origin:`${k}, ${k}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:p+1.5,left:p,width:h,height:h},children:r}):null]})}function ac({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Pi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function zr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _s({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function at({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Fi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{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 At({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function No({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{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 Ue({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Rs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12.01",y2:"16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function lc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"2",x2:"12",y2:"6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"18",x2:"12",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"12",x2:"6",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"18",y1:"12",x2:"22",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ko({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function gn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function xa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function To({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function _a({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function yn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ra({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Is({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function iu({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M11 14h10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 10l4 4-4 4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Di({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:a,components:i}){let s=useColorScheme(),l=useMemo(()=>t==="auto"?s==="dark"?"dark":"light":t,[t,s]),m=useMemo(()=>{let y=o?.[l];return oc(l,y,r)},[l,o,r]),c=useMemo(()=>xs(m,i,l),[m,i,l]),C=useMemo(()=>a?{regular:a.regular||n,medium:a.medium||n,semibold:a.semibold||n,bold:a.bold||n}:n?{regular:n,medium:n,semibold:n,bold:n}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[n,a]),T=useMemo(()=>({mode:l,colors:m,fonts:C,components:c,isDark:l==="dark"}),[l,m,C,c]);return jsx(nc.Provider,{value:T,children:e})}var Os={damping:28,stiffness:300,mass:.8},Df=80,Vf=500;function ht({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:a=true,heightPercent:i,maxHeightPercent:s,startExpanded:l=false,noPadding:m=false,borderTopLeftRadius:c=24,borderTopRightRadius:C=24}){let{colors:T}=F(),{height:y}=useWindowDimensions(),[b,k]=useState(false),h=useRef(e);h.current=e;let p=useRef(0),g=i!=null&&i>=1,d=g||m?0:Platform.OS==="ios"?34:24,f=s!=null&&i!=null&&s>i,R=i!=null?(f?s:i)*y:void 0,x=f?(s-i)*y:0,S=l?0:x,w=useSharedValue(y),_=useRef(null),W=useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),h.current||k(false);},[]);useEffect(()=>{e?(_.current&&(clearTimeout(_.current),_.current=null),k(true),w.value=withSpring(S,Os)):b&&(w.value=withTiming(y,{duration:250},N=>{N&&runOnJS(W)();}),_.current=setTimeout(()=>{_.current=null,W();},350));},[e]),useEffect(()=>()=>{_.current&&clearTimeout(_.current);},[]),useEffect(()=>{b&&e&&(w.value=withSpring(S,Os));},[S]);let D=useCallback(()=>{o&&t();},[o,t]),O=useMemo(()=>{if(!(!n&&!f))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{p.current=w.value;},onPanResponderMove:(N,ae)=>{if(Math.abs(ae.dy)<4)return;let ze=p.current+ae.dy;w.value=Math.max(0,ze);},onPanResponderRelease:(N,ae)=>{if(!(Math.abs(ae.dy)<4)){if(n&&(ae.dy>Df||ae.vy>Vf)){t();return}if(f){let ze=x/2,ve=w.value<ze?0:x;w.value=withSpring(ve,Os);}else w.value=withSpring(S,Os);}},onPanResponderTerminate:()=>{w.value=withSpring(S,Os);}}).panHandlers},[n,f,x,S,w,t]),v=useAnimatedStyle(()=>({transform:[{translateY:w.value}]})),q=useAnimatedStyle(()=>({opacity:interpolate(w.value,[0,y*.5,y],[.5,.25,0],Extrapolation.CLAMP)}));return b?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:Kn.root,pointerEvents:e?"auto":"none",children:[jsx(au.View,{style:[Kn.backdrop,q],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:D})}),jsxs(au.View,{style:[Kn.sheet,v,{height:R,backgroundColor:T.background,borderTopLeftRadius:g?0:c,borderTopRightRadius:g?0:C}],children:[jsxs(GestureHandlerRootView,{style:Kn.gestureRoot,children:[a&&jsx(View,{style:Kn.handleContainer,pointerEvents:"none",children:jsx(View,{style:[Kn.handle,{backgroundColor:T.foreground+"33"}]})}),r,d>0&&jsx(View,{style:{height:d}})]}),O&&jsx(View,{...O,style:Kn.dragOverlay})]})]})}):null}var Kn=StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject,backgroundColor:"#000"},sheet:{overflow:"hidden"},gestureRoot:{flex:1},handleContainer:{alignItems:"center",paddingTop:10,paddingBottom:4,zIndex:1},dragOverlay:{position:"absolute",top:0,left:0,right:0,height:40,zIndex:2},handle:{width:36,height:5,borderRadius:2.5}}),gt=An__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));gt.displayName="BottomSheetScrollView";function Vi(e){return jsx(FlatList,{...e})}var Lf="https://api.unifold.io",mc="__UnifoldDevApiBaseUrl__",Rr="pk_test_123",Ia={};function Bf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[mc];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function tr(){return Bf()??Lf}function va(e){if(e.publishableKey!==void 0){if(!e.publishableKey||e.publishableKey.trim()==="")throw new Error("Unifold SDK: publishableKey cannot be empty. Please provide a valid publishable key.");!e.publishableKey.startsWith("pk_test_")&&!e.publishableKey.startsWith("pk_live_")&&console.warn('Unifold SDK: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),Rr=e.publishableKey;}e.defaultConfig&&(Ia=e.defaultConfig);}function cu(e){if(typeof __DEV__>"u"||!__DEV__){console.warn("[Unifold] setDevApiUrl() is only available in development mode");return}if(typeof globalThis>"u")return;let t=e.trim();t.length>0?globalThis[mc]=t:delete globalThis[mc];}function Ds(){return tr()}function Pa(){return Rr}function Ur(e){if(!e||e.trim()==="")throw new Error("Unifold SDK: No publishable key configured. Please provide a valid publishable key via setApiConfig() or pass it directly to the API function.");e==="pk_test_123"&&console.warn('Unifold SDK: Using default test key "pk_test_123". This should only be used for local development. Please use a real publishable key in production.');}function Yt(e){let t=e.startsWith("/")?e:`/${e}`;return `${tr()}/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+)?/,tr()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${tr()}${e}`:`${tr()}/api/public${e}`:""}async function $o(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||Ia.recipientAddress;if(!r)throw new Error("[Unifold] recipient_address is required for createDepositAddress. Pass recipientAddress in your beginDeposit() config.");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Ia.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Ia.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||Rr;Ur(n);let a=await fetch(`${tr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create deposit address: ${a.statusText}`);return await a.json()}function qo(e,t){return e.find(r=>r.chain_type===t)}async function Qo(e,t,r){let o=t||Rr;Ur(o);let n=await fetch(`${tr()}/v1/public/direct_executions/query`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify({external_user_id:e,...r&&{action_type:r}})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}async function Fa(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/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 Ce(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let r=e.icon_urls.find(o=>o.format===t);return r?r.url:e.icon_url}async function Gn(e,t){let r=e||Rr;Ur(r);let o=`${tr()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let a=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});o=`${o}?${a.toString()}`;}let n=await fetch(o,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch supported deposit tokens: ${n.statusText}`);return n.json()}async function fc(e,t){let r=t||Rr;Ur(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${tr()}/v1/public/tokens/token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch token metadata: ${n.statusText}`);return n.json()}function Oa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function hc(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to fetch onramp quotes: ${o.statusText}`);return o.json()}async function gc(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to create onramp session: ${o.statusText}`);return o.json()}async function yc(e,t){let r=t||Rr;Ur(r);let o=new URLSearchParams;e.country_code&&o.append("country_code",e.country_code),e.subdivision_code&&o.append("subdivision_code",e.subdivision_code),o.append("token_address",e.token_address),o.append("chain_id",e.chain_id),o.append("chain_type",e.chain_type);let n=await fetch(`${tr()}/v1/public/onramps/default_token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch default onramp token: ${n.statusText}`);return n.json()}async function bc(e){let t=e||Rr;Ur(t);let r=await fetch(`${tr()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch fiat currencies: ${r.statusText}`);return r.json()}function Li(e,t="png"){if(!e||e.length===0)return;let r=e.find(o=>o.format===t);return r?r.url:e[0]?.url}async function Vs(e){let t=e||Rr;Ur(t);let r=await fetch(`${tr()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch project config: ${r.statusText}`);return r.json()}async function Cc(){let e=await fetch(`${tr()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function Da(e,t,r){let o=e.find(a=>a.chain_id===r);if(o)return o.chain_name;let n=e.find(a=>a.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function Ls(){let e=await fetch(`${tr()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}async function Va(e){let t=e||Rr;Ur(t);let r=await fetch(`${tr()}/v1/public/tokens/supported_destination_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch supported destination tokens: ${r.statusText}`);return r.json()}async function wc(e,t){let r=t||Rr;Ur(r);let o=await fetch(`${tr()}/v1/public/addresses/verify`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":r},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to verify address: ${o.statusText}`);return o.json()}async function Sc(e,t){return Fa(e.deposit_wallet_id,t)}async function La(e,t,r,o,n){let a=n||Rr;Ur(a);let i=await fetch(`${tr()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":a},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!i.ok)throw new Error(`Failed to fetch address balance: ${i.statusText}`);return i.json()}function uu({size:e=28}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxs(G,{fillRule:"evenodd",children:[jsx(Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsx(Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function mu({size:e=28}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#eth_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsx(Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsx(Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsx(Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsx(Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsx(Defs,{children:jsx(ClipPath,{id:"eth_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function gu({size:e=28}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#btc_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsx(Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsx(Defs,{children:jsx(ClipPath,{id:"btc_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function yu({size:e=28}){return jsxs(Nt,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxs(Defs,{children:[jsxs(LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsx(Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxs(G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsx(Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsx(Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsx(Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function bu({size:e=28}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxs(G,{children:[jsx(Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsx(Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var Ba=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:uu},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:mu},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:gu},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:yu},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:bu}];function Aa(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Wa(e,t){let r=parseFloat(e);if(isNaN(r))return e;let o=t.toLowerCase(),n=["eth","btc"].includes(o)?4:2;return r.toFixed(n)}function Wi(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=Ba.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=Ba.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Jt({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:a}=F(),i=r==="back",s=i?jsx(Fi,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(at,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:bn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:i?"Back":"Close",children:s});return t?jsxs(View,{style:bn.headerWithTitle,children:[i?l:o??jsx(View,{style:bn.headerSide}),jsx(Text,{style:[bn.headerTitleText,{color:n.header.titleColor},...a.bold?[{fontFamily:a.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),i?jsx(View,{style:bn.headerSide}):l]}):jsxs(View,{style:i?bn.headerWithTitle:bn.header,children:[i?l:jsx(View,{style:bn.headerSpacer}),!i&&l]})}var Ea={paddingTop:8,paddingBottom:8},bn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ea},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ea},headerSpacer:{flex:1},headerSide:{width:28},headerTitleText:{flex:1,textAlign:"center",fontSize:17},closeBtn:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"}});function Ir({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=F();return e?jsx(Text,{style:[Cu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[Cu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var Cu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function fo({quote:e,label:t,value:r,last:o,hideDivider:n}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsx(Text,{style:[e.rowValue],children:r})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}function Ic({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=F(),m=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},c=Aa(r);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:c}),jsx(TouchableOpacity,{onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx(Ue,{size:14,color:s.success,strokeWidth:2.5}):jsx(No,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Ma={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function Es({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=F(),a=e.toLowerCase(),i=Ma[a]??n.primary,s=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:i,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:s,height:s,borderRadius:s/2,borderWidth:2,borderColor:n.background}}):null]})}function za({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=F(),m=Yt(`/icons/currencies/png/${e.toLowerCase()}.png`),c=Wi(r);return jsxs(View,{style:[eo.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:eo.step,children:[jsx(Image,{source:{uri:m},style:eo.iconImage}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(_r,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:eo.step,children:[jsxs(View,{style:eo.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:eo.tokenIcon}):jsx(View,{style:[eo.tokenIcon,{backgroundColor:Ma[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[eo.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var eo=StyleSheet.create({diagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",paddingVertical:20,paddingHorizontal:24,width:"100%"},step:{alignItems:"center"},iconImage:{width:24,height:24,borderRadius:12,marginBottom:4},iconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},tokenIcon:{width:24,height:24,borderRadius:12},networkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},label:{fontSize:10},value:{fontSize:14,fontWeight:"500",paddingTop:4}});function Ei(){let{colors:e,fonts:t,components:r}=F(),o=r.input,n=r.button,a=r.container,i=r.card,s=r.header;return useMemo(()=>{let l=i.borderRadius,m={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},content:{flex:1,paddingTop:16},title:{fontSize:28,color:s.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:e.foregroundSubtle,marginBottom:8,textTransform:"uppercase",letterSpacing:.5,...t.semibold?{fontFamily:t.semibold}:{}},input:{backgroundColor:o.backgroundColor,borderRadius:o.borderRadius,padding:16,fontSize:17,color:o.textColor,borderWidth:o.borderWidth,borderColor:o.borderColor,...t.regular?{fontFamily:t.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...t.regular?{fontFamily:t.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(l,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:a.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:a.buttonTitleColor,fontSize:17,...t.bold?{fontFamily:t.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...t.medium?{fontFamily:t.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},c={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...t.medium?{fontFamily:t.medium}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor},quickPillText:{fontSize:14,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},numpad:{gap:4,marginBottom:12},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:56,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...t.regular?{fontFamily:t.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...t.regular?{fontFamily:t.regular}:{}},paymentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,borderRadius:999,backgroundColor:"transparent",alignSelf:"flex-start",marginBottom:12},paymentRowHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:16,borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor,alignSelf:"center"},paymentLeft:{flexDirection:"row",alignItems:"center",gap:6},applePayIcon:{fontSize:20,color:e.foreground},paymentLabel:{fontSize:15,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},paymentHint:{fontSize:13,color:e.foregroundMuted,marginLeft:12,...t.regular?{fontFamily:t.regular}:{}},inlineError:{fontSize:13,color:e.error,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},inlineStatus:{fontSize:13,color:e.foregroundMuted,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},sheetContent:{flex:1,paddingHorizontal:24,paddingTop:8,paddingBottom:32,gap:12},sheetHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:4},sheetBackBtn:{width:32,height:32,borderRadius:16,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},sheetCloseBtn:{width:28,height:28,borderRadius:14,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitle:{fontSize:18,color:e.foreground,...t.bold?{fontFamily:t.bold}:{}},sheetOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border},sheetOptionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:12},sheetOptionIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},sheetOptionLabel:{fontSize:16,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},sheetOptionHint:{fontSize:13,color:e.foregroundMuted,marginTop:2,...t.regular?{fontFamily:t.regular}:{}},sheetLoading:{alignItems:"center",paddingVertical:32,gap:12},sheetStatusText:{fontSize:15,color:e.foregroundMuted,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},sheetError:{flex:1,justifyContent:"center",paddingVertical:20},sheetErrorText:{fontSize:14,color:e.error,textAlign:"center",lineHeight:20,...t.regular?{fontFamily:t.regular}:{}},addPaymentBtn:{marginTop:12,paddingVertical:14,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},C={heroBox:{backgroundColor:i.backgroundColor,borderRadius:l,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:i.borderWidth,borderColor:i.borderColor,gap:4},heroLabel:{fontSize:12,color:e.foregroundSubtle,letterSpacing:.5,textTransform:"uppercase",...t.semibold?{fontFamily:t.semibold}:{}},heroAmount:{fontSize:48,color:e.foreground,letterSpacing:-1,...t.bold?{fontFamily:t.bold}:{}},heroCurrency:{fontSize:22,color:e.primary,...t.medium?{fontFamily:t.medium}:{}},heroNetwork:{fontSize:15,color:e.foregroundSubtle,marginTop:2,...t.medium?{fontFamily:t.medium}:{}},card:{backgroundColor:i.backgroundColor,borderRadius:l,borderWidth:i.borderWidth,borderColor:i.borderColor,overflow:"hidden",marginBottom:12,marginTop:16},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},rowRight:{flex:1,minWidth:0,flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:8},rowDivider:{height:1,marginHorizontal:16,backgroundColor:e.border},rowLabel:{fontSize:14,color:i.rowLeftLabel,...t.regular?{fontFamily:t.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:i.rowRightLabel,...t.medium?{fontFamily:t.medium}:{}}},T=Math.max(16,Math.min(l,22)),y={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:T,borderTopRightRadius:T,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:T,borderBottomRightRadius:T,borderTopLeftRadius:10,borderTopRightRadius:10,marginTop:16},swapConnectorWrap:{alignSelf:"center",zIndex:3,marginTop:-24,marginBottom:-32},swapConnectorCircle:{width:48,height:48,borderRadius:24,backgroundColor:e.primary,alignItems:"center",justifyContent:"center",borderWidth:4,borderColor:e.background},swapRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginTop:8,gap:12},swapLeftCol:{flex:1,minWidth:0},swapSpendAmount:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceivePrimary:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceiveSub:{fontSize:13,color:e.foregroundMuted,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},swapPill:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:10,paddingHorizontal:14,borderRadius:999,backgroundColor:e.cardHover,borderWidth:i.borderWidth,borderColor:e.border},swapPillText:{fontSize:16,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},payHint:{fontSize:15,color:e.foregroundMuted,textAlign:"center",marginBottom:18,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},summaryLabel:{fontSize:12,color:e.foregroundSubtle,textTransform:"uppercase",letterSpacing:.3,...t.semibold?{fontFamily:t.semibold}:{}},applePayBtn:{backgroundColor:n.secondaryBackground,borderRadius:n.borderRadius,borderWidth:n.borderWidth>0?n.borderWidth:1,borderColor:n.borderWidth>0?n.borderColor:e.border,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:n.secondaryText,fontSize:17,...t.bold?{fontFamily:t.bold}:{}}},b={input:{fontSize:14,...t.regular?{fontFamily:t.regular}:{}},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),borderWidth:i.borderWidth,borderColor:e.border,backgroundColor:e.card},rowSelected:{borderColor:e.primary,backgroundColor:e.successBackground},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:e.foregroundMuted,...t.medium?{fontFamily:t.medium}:{}},rowTextSelected:{color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:e.primary,alignItems:"center",justifyContent:"center"}},k={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:e.successBackground,borderWidth:2,borderColor:e.success,alignItems:"center",justifyContent:"center",marginBottom:28},heading:{fontSize:28,color:s.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:m,quote:C,pm:y,wallet:b,flow:k,amount:c}},[e,t,o,n,a,i,s])}var ku="",Tu;function Ua(e){ku=e;}function Ha(e){Tu=e;}function Dr(){let e=ku||Pa();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Vr(){return Tu??Ds()}async function Na(){let e=`${Vr()}/v1/public/onramps/headless/stripe/config`,t=Dr(),r=await fetch(e,{method:"GET",headers:{"x-publishable-key":t,"Content-Type":"application/json"}});if(!r.ok)throw new Error(`Failed to load Stripe config: ${r.status}`);let o=await r.json();if(!o?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return o.publishable_key}async function vc(e){let t=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw new Error(`Failed to create auth intent: ${t.status}`);let r=await t.json();return r.auth_intent_id??r.id}async function xu(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e,...t&&{crypto_customer_id:t}})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function Pc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e,...t&&{crypto_customer_id:t}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.message??`Failed to refresh OAuth token: ${r.status}`);return o}async function _u(e,t){let r={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},o=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await o.text();if(!o.ok)throw new Error(`Failed to create onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Ru(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}}),o=await r.text();if(!r.ok)throw new Error(`Failed to confirm onramp session: ${r.status} ${o}`);return JSON.parse(o)}async function ja(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp customer: ${o.status} ${n}`);return JSON.parse(n)}async function Iu(e){let t=`${Vr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e}}),o=await r.text();if(!r.ok)throw new Error(`Failed to list onramp sessions: ${r.status} ${o}`);return JSON.parse(o)}async function vu(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Fc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}});if(!r.ok){let o=await r.text();throw new Error(`Failed to refresh quote: ${r.status} ${o}`)}return r.json()}async function Pu(e){let t=new URLSearchParams({destinationNetwork:e.destinationNetwork,walletAddress:e.walletAddress});e.destinationTag&&t.set("destinationTag",e.destinationTag),e.cryptoCustomerId&&t.set("crypto_customer_id",e.cryptoCustomerId);let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e.accessToken}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch transaction limits: ${r.status} ${o}`)}return r.json()}async function Oc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch payment tokens: ${r.status} ${o}`)}return r.json()}async function Fu(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let t={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},r=await fetch(`${Vr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.status}`);return r.json()}function Cn(e,t){if(e?.length){let r=e.find(n=>n.format==="png");if(r)return r.url;let o=e.find(n=>n.format==="svg");if(o)return o.url}return t}async function Ou(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Dr()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function lh({size:e=24}){let t=e,r=e*(471/750);return jsxs(Nt,{width:t,height:r,viewBox:"0 0 750 471",children:[jsx(Rect,{width:"750",height:"471",rx:"40",fill:"#1A1F71"}),jsx(Path,{fill:"#FFFFFF",d:"M278.198,334.228l33.36-195.763h53.358l-33.384,195.763H278.198z"}),jsx(Path,{fill:"#FFFFFF",d:"M524.307,142.687c-10.57-3.966-27.135-8.222-47.822-8.222c-52.725,0-89.863,26.551-90.18,64.604c-0.297,28.129,26.514,43.821,46.754,53.185c20.77,9.597,27.752,15.716,27.652,24.283c-0.133,13.123-16.586,19.116-31.924,19.116c-21.355,0-32.701-2.967-50.225-10.274l-6.877-3.112l-7.488,43.823c12.463,5.466,35.508,10.199,59.438,10.445c56.09,0,92.502-26.248,92.916-66.884c0.199-22.27-14.016-39.216-44.801-53.188c-18.65-9.056-30.072-15.099-29.951-24.269c0-8.137,9.668-16.838,30.559-16.838c17.447-0.271,30.088,3.534,39.936,7.5l4.781,2.259L524.307,142.687"}),jsx(Path,{fill:"#FFFFFF",d:"M661.615,138.464h-41.23c-12.773,0-22.332,3.486-27.941,16.234l-79.244,179.402h56.031c0,0,9.16-24.121,11.232-29.418c6.123,0,60.555,0.084,68.336,0.084c1.596,6.854,6.492,29.334,6.492,29.334h49.512L661.615,138.464z M596.198,264.872c4.414-11.279,21.26-54.724,21.26-54.724c-0.314,0.521,4.381-11.334,7.074-18.684l3.607,16.878c0,0,10.217,46.729,12.352,56.527h-44.293V264.872z"}),jsx(Path,{fill:"#FFFFFF",d:"M45.879,138.465l-0.682,4.073c21.093,5.106,39.932,12.496,56.426,21.689l47.346,169.688h56.455l83.004-195.45h-56.526l-52.238,133.496l-5.564-27.131c-0.261-0.838-0.544-1.678-0.834-2.52L156.106,154.992c-3.229-12.396-12.597-16.095-24.186-16.528H45.879z"})]})}function ch({size:e=24}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 24 24",children:jsxs(G,{fill:"none",fillRule:"evenodd",children:[jsx(Circle,{cx:"7",cy:"12",r:"7",fill:"#EA001B"}),jsx(Circle,{cx:"17",cy:"12",r:"7",fill:"#FFA200",fillOpacity:.8})]})})}function dh({size:e=24}){return jsx(Nt,{width:e,height:e,viewBox:"0 0 1152 1152",children:jsxs(G,{transform:"matrix(1.3333333,0,0,-1.3333333,0,1152)",children:[jsx(Path,{fill:"#006FCF",d:"M 0,0 H 863.998 V 864 H 0 Z"}),jsx(G,{transform:"translate(312.9867,136.7145)",children:jsx(Path,{fill:"#FFFFFF",d:"m 0,0 341.634,-0.725 53.654,59.858 54.038,-59.632 h 101.685 v 87.332 l -63.687,68.682 63.687,68.059 V 309.09 L 0,309.585 Z"})}),jsx(G,{transform:"translate(349.7917,170.655)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"m 0,0 v 241.575 h 204.832 v -55.65 H 66.318 V 148.15 H 201.529 V 93.423 H 66.318 V 56.319 H 204.832 V 10e-4 Z"})}),jsx(G,{transform:"translate(780.0408,412.227)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 -69.456,-76.568 -138.713,0 h -87.729 l 113.343,-120.647 -113.341,-120.925 h 85.343 l 69.764,77.335 70.487,-77.335 h 84.803 v 3.43 L -26.971,-120.647 83.957,-1.903 V 0 Z"})}),jsx(G,{transform:"translate(738.7857,721.0845)",children:jsx(Path,{fill:"#FFFFFF",d:"M 0,0 -28.373,-79.366 -56.65,0 H -220.625 V -105.93 L -267.278,0 H -400.1 l -136.414,-309.586 h 661.726 l 0,309.586 z"})}),jsx(G,{transform:"translate(373.0462,548.583)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"M 0,0 32.145,76.837 64.268,0 Z m -9.212,138.867 -107.187,-241.37 h 73.518 l 20.22,48.332 H 86.914 l 20.207,-48.332 h 75.345 L 75.723,138.867 Z"})}),jsx(G,{transform:"translate(554.5071,446.121)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 64.997,-0.001 V 165.796 L 126.661,-0.001 h 58.418 L 245.49,165.233 V -0.564 l 64,0.563 V 241.368 H 210.032 L 156.513,92.624 103.342,241.012 0,241.369 Z"})})]})})}function Vc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(lh,{size:t}):o.includes("mastercard")?jsx(ch,{size:t}):o.includes("amex")||o.includes("american express")?jsx(dh,{size:t}):jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75})}var mh=[50,100,500],fh=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Bu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hh(e){return e.card?`${Bu(e.card.brand)} ${Bu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Wu(e){if(!e)return "";let t=new Date(e*1e3);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true})}var Eu={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function Mu(e,t){switch(e){case "fulfillment_complete":return "#22C55E";case "fulfillment_processing":case "requires_payment":return "#f59e0b";case "rejected":return "#ef4444";default:return t.foregroundMuted}}function gh({status:e,colors:t}){let r=Mu(e,t);return jsx(View,{style:{paddingHorizontal:8,paddingVertical:2,borderRadius:6,backgroundColor:r+"20"},children:jsx(Text,{style:{fontSize:11,color:r},children:Eu[e]??e})})}function yh({session:e,onBack:t}){let{colors:r,components:o,fonts:n}=F(),[a,i]=useState(false),s=()=>{Clipboard.setString(e.id),i(true),setTimeout(()=>i(false),2e3);},l=e.transaction_details,m=e.status!=="fulfillment_complete"&&e.status!=="rejected",c=Mu(e.status,r),C=l?.source_amount?`$${parseFloat(l.source_amount).toFixed(2)}`:"\u2014",T=l?.destination_amount?parseFloat(l.destination_amount).toFixed(2):"\u2014",y=(l?.destination_currency??"").toUpperCase(),b=e.destination_token_metadata,k=Cn(b?.icon_urls,b?.icon_url),h=Cn(b?.chain?.icon_urls,b?.chain?.icon_url),p=Wi(l?.destination_network??""),g=l?.wallet_address?Aa(l.wallet_address):null,d=l?.fees?.network_fee_amount?`$${parseFloat(l.fees.network_fee_amount).toFixed(2)}`:null,f=l?.fees?.transaction_fee_amount?`$${parseFloat(l.fees.transaction_fee_amount).toFixed(2)}`:null,R=e.payment_method?e.payment_method.replace(/_/g," ").replace(/\b\w/g,S=>S.toUpperCase()):null,x=[{label:"Amount",value:C},{label:"Received",value:`${T} ${y}`},...R?[{label:"Payment",value:R}]:[],{label:"Network",value:p},...g?[{label:"Wallet",value:g}]:[],...d?[{label:"Network Fee",value:d}]:[],...f?[{label:"Transaction Fee",value:f}]:[]];return jsxs(Fragment,{children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(Jt,{onPress:t,title:"Purchase Details",variant:"back"})}),jsxs(gt,{style:rr.scroll,contentContainerStyle:rr.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:rr.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(Es,{currency:y||"USD",tokenIconUrl:k,networkIconUrl:h,size:64}),jsx(View,{style:[rr.statusBadge,{backgroundColor:c,borderColor:o.card.backgroundColor??r.background}],children:m?jsx(zr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):e.status==="rejected"?jsx(at,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx(Ue,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:rr.statusRow,children:[jsx(View,{style:[rr.statusDot,{backgroundColor:c}]}),jsx(Text,{style:[rr.statusText,{color:o.container.titleColor,fontFamily:n.semibold}],children:Eu[e.status]??e.status})]}),e.created?jsx(Text,{style:[rr.dateText,{color:o.container.subtitleColor,fontFamily:n.regular}],children:Wu(e.created)}):null]}),jsxs(View,{style:[rr.card,{backgroundColor:o.card.backgroundColor,borderRadius:o.card.borderRadius,borderWidth:o.card.borderWidth,borderColor:o.card.borderColor}],children:[jsxs(View,{style:rr.cardRow,children:[jsx(Text,{style:[rr.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:[rr.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(Ue,{size:14,color:r.primary,strokeWidth:2}):jsx(No,{size:14,color:r.foregroundMuted,strokeWidth:2})]})]}),x.map((S,w)=>jsxs(An__default.Fragment,{children:[jsx(View,{style:[rr.cardDivider,{backgroundColor:r.border}]}),jsxs(View,{style:rr.cardRow,children:[jsx(Text,{style:[rr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:S.label}),jsx(Text,{style:[rr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium}],selectable:true,children:S.value})]})]},S.label))]}),l?.last_error?jsx(View,{style:[rr.card,{backgroundColor:"#ef444415",borderRadius:o.card.borderRadius}],children:jsxs(View,{style:rr.cardRow,children:[jsx(Text,{style:[rr.cardLabel,{color:"#ef4444",fontFamily:n.regular}],children:"Error"}),jsx(Text,{style:[rr.cardValue,{color:"#ef4444",fontFamily:n.medium,flex:1,textAlign:"right"}],selectable:true,children:l.last_error})]})}):null]})]})}var rr=StyleSheet.create({scroll:{flex:1,paddingTop:8},scrollContent:{paddingHorizontal:24,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},statusBadge:{position:"absolute",bottom:-4,right:-4,width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center",borderWidth:2},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14,marginBottom:2},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"}});function bh({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,a=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:Mi.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[Mi.row,{backgroundColor:t.card,borderRadius:a,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:Mi.left,children:[jsx(Animated.View,{style:[Mi.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[Mi.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[Mi.badgeBar,{backgroundColor:n,opacity:o}]})]},s))})}var Mi=StyleSheet.create({list:{gap:8},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16},left:{flex:1,gap:6},amountBar:{height:16,width:"40%",borderRadius:8},subtitleBar:{height:12,width:"55%",borderRadius:6},badgeBar:{height:20,width:80,borderRadius:6,marginLeft:12}});function Qa({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:a="inline",onCollectPayment:i,paymentLoading:s=false,paymentStatus:l,paymentError:m,paymentTokens:c=[],onAddPaymentMethod:C,onConfirm:T,onCancel:y,sheetBorderTopLeftRadius:b,sheetBorderTopRightRadius:k,accessToken:h}){let p=Ei(),{colors:g,components:d}=F(),f=b??d.card.borderRadius,R=k??d.card.borderRadius,[x,S]=useState(e),[w,_]=useState(r?"apple_pay":c.length>0?c[0].id:null),W=useRef(false),D=$=>{W.current=true,_($);};useEffect(()=>{W.current||r||c.length>0&&_(c[0].id);},[c,r]);let[O,v]=useState(false),[q,N]=useState("select"),[ae,ze]=useState(null),ve=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&N("card");},[s,l]);let J=w==="apple_pay",Ve=1e3,me=J?Ve:n,_e=me!=null&&me>0,Ne=useMemo(()=>{if(o)return [];let $=mh.map(re=>({label:`$${re}`,amount:String(re),disabled:false}));return J?$.push({label:`$${Ve}`,amount:String(Ve),disabled:false}):$.push({label:"MAX",amount:_e?String(me):"0",disabled:!_e}),$},[o,_e,me,J]),Se=$=>{if($==="\u232B"){S(re=>re.slice(0,-1));return}if($==="."){if(x.includes("."))return;S(re=>re===""?"0.":re+".");return}S(re=>{let et=re.indexOf(".");return et!==-1&&re.length-et>2?re:re==="0"&&$!=="."?$:re+$});},oe=x===""?"0":x,Pe=parseFloat(x),rt=x!==""&&!isNaN(Pe)&&Pe>0,je=r||c.length>0,ot=a==="header",$e=useMemo(()=>{let $=[];r&&$.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let re of c)$.push({id:re.id,label:hh(re),hint:re.card?`Expires ${re.card.exp_month}/${re.card.exp_year}`:re.type,brand:re.card?.brand,isApplePay:false});return $},[r,c]),Fe=$e.find($=>$.id===w),Re=w!=null&&w!=="apple_pay",X=Fe?Fe.label:Re&&ae?ae:Re?"Card":"Pay With",ce=Fe?!Fe.isApplePay:Re,st=Fe?.brand??ae??void 0,[Je,Le]=useState(false),[be,ie]=useState([]),[de,zt]=useState(false),[ue,se]=useState(null),[ye,yt]=useState(null),dt=useRef(null);dt.current=ye;let le=useRef(false);le.current=Je;let qe=useCallback(async($=false)=>{if(h){$||(zt(true),se(null));try{let re=await Iu(h);if(!le.current)return;let et=Array.isArray(re.data)?re.data:Array.isArray(re)?re:[];ie(et),$||se(null);let pe=dt.current?.id;if(pe){let Me=et.find(M=>M.id===pe);Me&&yt(Me);}}catch(re){if(!le.current)return;$||se(re?.message??"Failed to load history");}finally{!$&&le.current&&zt(false);}}},[h]),yr=useCallback(()=>{Le(true),qe();},[qe]);useEffect(()=>{if(!Je||!h)return;let $=setInterval(()=>qe(true),15e3);return ()=>clearInterval($)},[Je,h,qe]);let xt=h?jsx(TouchableOpacity,{style:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},onPress:yr,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"History",children:jsx(zr,{size:20,color:g.foreground,strokeWidth:2})}):void 0,xr=je?jsx(TouchableOpacity,{style:[ot?p.amount.paymentRowHeader:p.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(N("select"),v(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:p.amount.paymentLeft,children:[Fe?.isApplePay?jsx(Text,{style:p.amount.applePayIcon,children:"\uF8FF"}):ce?jsx(Vc,{sublabel:st,size:20}):null,jsx(Text,{style:p.amount.paymentLabel,children:X}),jsx(At,{size:12,color:p.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:p.form.screen,children:[jsx(Jt,{onPress:y,title:"Enter amount",leftAction:xt}),ot&&xr,jsxs(View,{style:p.form.content,children:[jsxs(View,{style:p.amount.amountContainer,children:[jsxs(Text,{style:[p.amount.amountText,oe==="0"&&p.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",oe]}),jsx(Text,{style:p.amount.currencyLabel,children:t.toUpperCase()})]}),!ot&&xr,Ne.length>0&&jsx(View,{style:p.amount.quickRow,children:Ne.map($=>{let re=!$.disabled&&x===$.amount&&x!=="";return jsx(TouchableOpacity,{style:[p.amount.quickPill,re&&{backgroundColor:g.primary},$.disabled&&{opacity:.4}],activeOpacity:.7,disabled:$.disabled||s,onPress:()=>S($.amount),children:jsx(Text,{style:[p.amount.quickPillText,re&&{color:g.primaryForeground}],children:$.label})},$.label)})}),jsx(View,{style:p.amount.numpad,children:fh.map(($,re)=>jsx(View,{style:p.amount.numpadRow,children:$.map(et=>jsx(TouchableOpacity,{style:[p.amount.numpadKey,s&&{opacity:.3}],onPress:()=>Se(et),activeOpacity:.6,disabled:s,children:jsx(Text,{style:et==="\u232B"?p.amount.backspaceText:p.amount.numpadKeyText,children:et})},et))},re))}),jsx(TouchableOpacity,{style:[p.form.continueBtn,(!rt||s)&&p.form.continueBtnDisabled],onPress:()=>rt&&!s&&T(x,w),disabled:!rt||s,children:s?jsx(ActivityIndicator,{size:"small",color:g.primaryForeground}):jsx(Text,{style:[p.form.continueBtnText,!rt&&p.form.continueBtnTextDisabled],children:"Continue"})}),!O&&m?jsx(Text,{style:p.amount.inlineError,children:m}):!O&&s&&l&&__DEV__?jsx(Text,{style:p.amount.inlineStatus,children:l}):null]}),jsx(ht,{visible:O,onClose:()=>{s||(v(false),N("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:!s,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:f,borderTopRightRadius:R,children:jsx(View,{style:p.amount.sheetContent,children:q==="select"?jsxs(Fragment,{children:[jsxs(View,{style:p.amount.sheetTitleRow,children:[jsx(Text,{style:p.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>v(false),activeOpacity:.7,style:p.amount.sheetCloseBtn,children:jsx(at,{size:16,color:g.foregroundMuted,strokeWidth:2.5})})]}),jsxs(gt,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[$e.map($=>{let re=w===$.id;return jsxs(TouchableOpacity$1,{style:[p.amount.sheetOption,re&&{borderColor:g.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{D($.id),ze($.isApplePay?null:$.label),v(false);},children:[jsxs(View,{style:p.amount.sheetOptionLeft,children:[jsx(View,{style:p.amount.sheetOptionIcon,children:$.isApplePay?jsx(Text,{style:p.amount.applePayIcon,children:"\uF8FF"}):jsx(Vc,{sublabel:$.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:p.amount.sheetOptionLabel,children:$.label}),jsx(Text,{style:p.amount.sheetOptionHint,children:$.hint})]})]}),re&&jsx(Ue,{size:18,color:g.primary,strokeWidth:2.5})]},$.id)}),jsx(TouchableOpacity$1,{style:p.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!ve.current){ve.current=true;try{let $=await C?.();$&&(D($.token),ze($.sublabel),v(!1));}finally{ve.current=false;}}},children:jsx(Text,{style:p.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:p.amount.sheetHeader,children:[jsx(TouchableOpacity$1,{onPress:()=>{s||N("select");},activeOpacity:.7,style:p.amount.sheetBackBtn,children:jsx(Fi,{size:20,color:g.foreground,strokeWidth:2})}),jsx(Text,{style:p.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:p.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),__DEV__?jsx(Text,{style:p.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):m?jsxs(Fragment,{children:[jsx(View,{style:p.amount.sheetError,children:jsx(Text,{style:p.amount.sheetErrorText,children:m})}),jsx(TouchableOpacity$1,{style:p.form.continueBtn,onPress:()=>{i&&rt&&i(false,x);},children:jsx(Text,{style:p.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:p.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),__DEV__?jsx(Text,{style:p.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(ht,{visible:Je,onClose:()=>{Le(false),yt(null);},closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:f,borderTopRightRadius:R,children:ye?jsx(yh,{session:ye,onBack:()=>yt(null)}):jsxs(View,{style:p.amount.sheetContent,children:[jsx(Jt,{onPress:()=>Le(false),title:"Purchase History"}),de?jsx(bh,{}):ue?jsx(View,{style:p.amount.sheetError,children:jsx(Text,{style:p.amount.sheetErrorText,children:ue})}):be.length===0?jsx(View,{style:p.amount.sheetLoading,children:jsx(Text,{style:[p.amount.sheetStatusText,{color:g.foregroundMuted}],children:"No purchases yet"})}):jsx(gt,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:be.map($=>{let re=$.transaction_details,et=re?.source_amount?`$${parseFloat(re.source_amount).toFixed(2)}`:"\u2014",pe=(re?.destination_currency??"").toUpperCase(),Me=re?.destination_amount?`${parseFloat(re.destination_amount).toFixed(2)} ${pe}`:"",M=Wu($.created),ee=$.destination_token_metadata,ke=Cn(ee?.icon_urls,ee?.icon_url),fe=Cn(ee?.chain?.icon_urls,ee?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:p.amount.sheetOption,activeOpacity:.7,onPress:()=>yt($),children:[jsx(Es,{currency:pe||"USD",tokenIconUrl:ke,networkIconUrl:fe,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:p.amount.sheetOptionLabel,children:et}),Me?jsx(Text,{style:p.amount.sheetOptionHint,children:Me}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx(gh,{status:$.status,colors:g}),M?jsx(Text,{style:{fontSize:11,color:g.foregroundMuted},children:M}):null]}),jsx(_r,{size:14,color:g.foregroundMuted,strokeWidth:2})]})]},$.id)})})]})})]})}var Us=4;function Ka({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Ei(),{colors:a,fonts:i,components:s}=F(),l=s.input.placeholderColor,[m,c]=useState(1),[C,T]=useState(e.firstName??""),[y,b]=useState(e.lastName??""),[k,h]=useState(e.dobMonth??""),[p,g]=useState(e.dobDay??""),[d,f]=useState(e.dobYear??""),[R,x]=useState(e.addressLine1??""),[S,w]=useState(e.addressLine2??""),[_,W]=useState(e.city??""),[D,O]=useState(e.state??""),[v,q]=useState(e.postalCode??""),[N,ae]=useState(e.country??"US"),[ze,ve]=useState(e.idNumber??""),J=useRef(null),Ve=useRef(null),me=useRef(null),_e=useRef(null),Ne=useRef(null),Se=useRef(null),oe=useRef(null),Pe=useRef(null),rt=()=>{switch(m){case 1:return C.trim().length>0&&y.trim().length>0;case 2:return k.length===2&&p.length===2&&d.length===4;case 3:return R.trim().length>0&&_.trim().length>0&&D.trim().length>0&&v.trim().length>0;case 4:return ze.trim().length>0;default:return false}},je=()=>{rt()&&(m<Us?c(Re=>Re+1):r({firstName:C,lastName:y,idNumber:ze,dobMonth:k,dobDay:p,dobYear:d,addressLine1:R,addressLine2:S,city:_,state:D,postalCode:v,country:N}));},ot=()=>{m>1?c(Re=>Re-1):o();},$e=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Fe=["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."],ct=[jt.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:jt.header,children:[jsx(View,{style:jt.headerSide,children:jsx(TouchableOpacity,{style:jt.iconButton,onPress:ot,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:m>1?"Back":"Cancel",children:jsx(_s,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:jt.headerCenter,children:jsxs(Text,{style:ct,children:[m," of ",Us]})}),jsx(View,{style:jt.headerSide,children:jsx(TouchableOpacity,{style:jt.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(at,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:jt.progressTrack,children:Array.from({length:Us}).map((Re,X)=>jsx(View,{style:[jt.progressSegment,{backgroundColor:X<m||X+1===m?a.primary:a.border}]},X))}),jsxs(gt,{style:n.form.flex,contentContainerStyle:jt.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:$e[m-1]}),jsx(Text,{style:n.form.subtitle,children:Fe[m-1]}),m===1&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:C,onChangeText:T,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>J.current?.focus()})}),jsx(Ko,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:J,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:y,onChangeText:b,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:je})})]}),m===2&&jsxs(View,{style:jt.dobRow,children:[jsxs(View,{style:jt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,jt.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,jt.dobInput],placeholder:"MM",placeholderTextColor:l,value:k,onChangeText:Re=>{let X=Re.replace(/\D/g,"").slice(0,2);h(X),X.length===2&&Ve.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:jt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,jt.dobLabel],children:"Day"}),jsx(TextInput,{ref:Ve,style:[n.form.input,jt.dobInput],placeholder:"DD",placeholderTextColor:l,value:p,onChangeText:Re=>{let X=Re.replace(/\D/g,"").slice(0,2);g(X),X.length===2&&me.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:jt.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,jt.dobLabel],children:"Year"}),jsx(TextInput,{ref:me,style:[n.form.input,jt.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:d,onChangeText:Re=>{let X=Re.replace(/\D/g,"").slice(0,4);f(X);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:je})]})]}),m===3&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:R,onChangeText:x,returnKeyType:"next",onSubmitEditing:()=>_e.current?.focus()})}),jsx(Ko,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:_e,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:S,onChangeText:w,returnKeyType:"next",onSubmitEditing:()=>Ne.current?.focus()})}),jsx(Ko,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ne,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:_,onChangeText:W,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Se.current?.focus()})}),jsxs(View,{style:jt.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx(Ko,{form:n.form,label:"State",children:jsx(TextInput,{ref:Se,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:D,onChangeText:Re=>O(Re.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>oe.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx(Ko,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:oe,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:v,onChangeText:q,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Pe.current?.focus()})})})]}),jsx(Ko,{form:n.form,label:"Country",children:jsx(TextInput,{ref:Pe,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:N,onChangeText:Re=>ae(Re.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:je})})]}),m===4&&jsxs(Ko,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:ze,onChangeText:ve,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:je}),jsx(Text,{style:[n.form.hint,jt.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&m===Us?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!rt()&&n.form.continueBtnDisabled],onPress:je,disabled:!rt(),children:jsx(Text,{style:[n.form.continueBtnText,!rt()&&n.form.continueBtnTextDisabled],children:m===Us?"Submit":"Continue"})})})]})})}function Ko({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var jt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:16},headerSide:{width:40,alignItems:"center"},headerCenter:{flex:1,alignItems:"center",justifyContent:"center"},iconButton:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"},stepCounter:{fontSize:15},progressTrack:{flexDirection:"row",gap:4,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{marginTop:10,lineHeight:18}});var Ec="@unifold/stripe_oauth";async function Uu(){try{let e=await Wc.getItem(Ec);return e?JSON.parse(e):null}catch{return null}}async function Mc(e){try{await Wc.setItem(Ec,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function Tn(){try{await Wc.removeItem(Ec);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Rh=5,_n=null,Hu={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Ga(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:a,authorize:i,attachKycInfo:s,presentKycInfoVerification:l,verifyIdentity:m,registerWalletAddress:c,collectPaymentMethod:C,createCryptoPaymentToken:T}=useOnramp(),[y,b]=useState(r),[k,h]=useState(!!e?.externalUserId),[p,g]=useState(false),[d,f]=useState(""),[R,x]=useState(null),[S,w]=useState(e?.email??""),[_,W]=useState(e?.phone??""),[D,O]=useState(""),[v,q]=useState("US"),[N,ae]=useState(""),[ze,ve]=useState(""),J=useRef(""),Ve=useRef(""),me=useRef(""),[_e,Ne]=useState(false),[Se,oe]=useState(false),Pe=useRef(0),rt=useRef(false),je=useRef(false),ot=useRef(false),$e=useRef(""),Fe=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),ct=useRef(null),[Re,X]=useState(Hu),[ce,st]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[Je,Le]=useState(""),[be,ie]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[de,zt]=useState(e?.defaultSourceAmount??"100"),[ue,se]=useState(e?.defaultSourceCurrency??"usd"),[ye,yt]=useState(e?.defaultDestinationCurrency??"usdc"),[dt,le]=useState(null),[qe,yr]=useState(),[xt,xr]=useState(),[$,re]=useState(false),et=useRef(null),pe=useRef(false),Me=useRef(0),M=useRef(e?.onComplete),ee=useRef(e?.onError),ke=useRef(e?.onStepChange),fe=useRef(r);useEffect(()=>{M.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{ee.current=e?.onError;},[e?.onError]),useEffect(()=>{ke.current=e?.onStepChange;},[e?.onStepChange]);let _t=useRef(r);useEffect(()=>{y!==_t.current&&(ke.current?.(y,_t.current),_t.current=y),fe.current=y;},[y]),useEffect(()=>{k&&y!==r&&h(false);},[k,y,r]);let V=useCallback((I,P,H)=>{let K={code:I,message:P,step:fe.current,stripeErrorCode:H};x(K),f(""),ee.current?.(K);},[]),Or=useCallback(I=>{let P={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?.(P),P},[]),z=useCallback(()=>x(null),[]),Ot=I=>I.refresh_token??I.refresh?.refresh_token??"",St=useCallback((I,P,H,K,xe)=>{Ve.current=P,J.current=H,e?.externalUserId&&Mc({accessToken:P,refreshToken:H,customerId:I,externalUserId:e.externalUserId,email:xe||S,expiresAt:Date.now()+K*1e3});},[e?.externalUserId,S]),Mr=useCallback(async()=>{let I=J.current;if(!I)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let P=await Pc(I,me.current??void 0),H=P.access_token,K=Ot(P)||I;return ve(H),St(me.current,H,K,P.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),H}catch(P){return console.error("[tryRefreshAccessToken] refresh failed:",P?.message),await Tn(),_n=null,Ve.current="",J.current="",me.current="",ve(""),ae(""),null}},[St]),er=useCallback(async I=>{try{return await I(Ve.current)}catch(P){let H=P?.message??"";if(H.includes("stripe_onramp_forbidden")||H.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let K=await Mr();if(!K)throw V("authorization_error","Session expired. Please sign in again."),b("email"),P;return await I(K)}throw P}},[Mr,V]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){re(false);return}let P=false;return isPlatformPaySupported().then(H=>{P||re(H);}),()=>{P=true;}},[e?.merchantIdentifier]),useEffect(()=>(pe.current=false,()=>{pe.current=true,et.current&&clearTimeout(et.current);}),[]);let Ii=useRef(false);useEffect(()=>{if(Ii.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),Tn(),_n=null,h(false);return}let I=false;return (async()=>{try{let P=await Uu();if(I||!P){I||h(!1);return}if(P.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",P.externalUserId,"current:",e.externalUserId),await Tn(),_n=null,I||h(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",P.customerId);let H=Date.now()>=P.expiresAt,K=P.accessToken,xe=P.refreshToken;if(H){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Qe=await Pc(P.refreshToken,P.customerId);if(I)return;K=Qe.access_token,xe=Qe.refresh_token??Qe.refresh?.refresh_token??P.refreshToken,await Mc({accessToken:K,refreshToken:xe,customerId:P.customerId,externalUserId:e.externalUserId,email:P.email,expiresAt:Date.now()+(Qe.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Qe){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Qe?.message),await Tn(),_n=null,I||h(!1);return}}if(I)return;if(Ii.current=!0,ae(P.customerId),me.current=P.customerId,ve(K),Ve.current=K,J.current=xe,P.email&&w(P.email),_n===P.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",P.customerId,"\u2014 skipping configure()"),ct.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",P.customerId);let Qe=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});Qe.error?console.error("[useStripeOnramp] restore configureSDK error:",Qe.error.message):_n=P.customerId,ct.current=Promise.resolve(Qe);}if(I)return;let bt=()=>new Promise(Qe=>{let br=()=>{ot.current&&$e.current?Qe():setTimeout(br,200);};br();});try{if(await Promise.race([bt(),new Promise((br,Ut)=>setTimeout(()=>Ut(new Error("timeout")),1e4))]),I)return;let Qe=$e.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Qe,"network:",Fe.current),await c(Qe,Fe.current);}catch(Qe){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Qe?.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||_e||Se)return;let I=false;oe(true);async function P(){try{let[H,K]=await Promise.all([Fu({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?Ou({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Ht=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Ht?.message),null)):Promise.resolve(null)]);if(I)return;let xe=e?.destinationChainType??"ethereum",bt=H.data.find(Ht=>Ht.chain_type===xe);if(bt?.address){let Ht=bt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Ht,"recipient:",bt.recipient_address),st(Ht),$e.current=Ht,bt.recipient_address&&Le(bt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",xe,"in",H.data?.length,"wallets");let Qe={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"},Ut=K?.destination_network,pr="none";if(Ut&&Qe[Ut])ie(Qe[Ut]),Fe.current=Qe[Ut],pr=Ut+" (from default_token API)";else if(e?.destinationChainId&&br[e.destinationChainId]){let Ht=br[e.destinationChainId];Qe[Ht]&&(ie(Qe[Ht]),Fe.current=Qe[Ht]),pr=Ht+" (from chain_id "+e.destinationChainId+")";}else Qe[xe]&&(ie(Qe[xe]),Fe.current=Qe[xe],pr=xe+" (from chain_type fallback)");K?.destination_currency&&yt(K.destination_currency.toLowerCase());let ar=K?.destination_token_metadata,Jr=Cn(ar?.icon_urls,ar?.icon_url),Zr=Cn(ar?.chain?.icon_urls,ar?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",Jr,"network:",Zr),Jr&&yr(Jr),Zr&&xr(Zr),Ne(!0),ot.current=!0;}catch(H){console.error("[useStripeOnramp] Failed to resolve wallet:",H?.message),Ne(true),ot.current=true;}finally{I||oe(false);}}return P(),()=>{I=true;}},[e?.publishableKey,e?.externalUserId]);let uo=useCallback(async()=>{if(ct.current)return ct.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(P=>(P.error&&(console.error("[useStripeOnramp] configureSDK error:",P.error.message,P.error.code),ct.current=null),P)).catch(P=>{throw console.error("[useStripeOnramp] configureSDK threw:",P?.message??P),ct.current=null,P});return ct.current=I,I},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||uo();},[]);let Ho=useCallback(async I=>{if(!rt.current){rt.current=true,g(true),z(),f("Creating auth intent...");try{let P=await vc(I);f("Waiting for authorization...");let H=await i(P);if(H?.error){console.log("[proceedToAuthorize] authorize error:",H.error.message),V("authorization_error","Something went wrong during authorization. Please try again."),b("email");return}if(H?.status==="Denied"){V("authorization_error","Authorization denied by user."),b("email");return}if(H?.status!=="Consented"||!H.customerId){V("authorization_error","Authorization was canceled."),b("email");return}f("Exchanging tokens...");let K=H.customerId,xe=await xu(P,K),bt=xe.access_token,Qe=Ot(xe);console.log("[useStripeOnramp] customerId:",K),console.log("[useStripeOnramp] accessToken acquired, length:",bt.length),ae(K),me.current=K,_n=K,ve(bt),St(K,bt,Qe,xe.expires_in??3600),f("Checking verification status...");try{let br=await ja(K,bt),Ut=br.verifications.find(hn=>hn.name==="kyc_verified"),pr=br.verifications.find(hn=>hn.name==="id_document_verified"),ar=Ut?.status==="verified",Jr=Ut?.status==="rejected",Zr=pr?.status==="verified",Ht=br.provided_fields.includes("first_name");if(f(""),Jr&&!Ht)V("kyc_error","KYC was previously rejected. Please submit with correct info."),b("kyc");else if(Jr&&Ht)b(Zr?"wallet":"identity");else if(!ar&&!Ht)b("kyc");else if(!Zr)b("identity");else if(ot.current&&$e.current)try{let hn=$e.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",hn,"network:",be);let Sa=await c(hn,be);Sa?.error?(console.warn("[proceedToAuthorize] wallet registration error:",Sa.error.message),V("wallet_error",Sa.error.message,Sa.error.code),b("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),b("session_params"));}catch(hn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",hn?.message),b("wallet");}else b("wallet");}catch(br){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",br?.message),f(""),b("kyc");}}catch(P){V("authorization_error",P?.message??String(P)),b("email");}finally{rt.current=false,g(false);}}},[i,z,V,St,c,be]),Q=useCallback(async()=>{if(Keyboard.dismiss(),!S){V("validation_error","Please enter an email address.");return}g(true),z(),f("");try{f("Configuring...");let I=await uo();if(I.error){V("configuration_error",I.error.message,I.error.code);return}f("Checking Link account...");let P=await n(S);if(P.error){V("authorization_error",P.error.message,P.error.code);return}P.hasLinkAccount?await Ho(S):(f(""),b("register"));}catch(I){V("unknown_error",I?.message??String(I));}finally{g(false);}},[z,uo,S,V,n,Ho]),ge=useCallback(async()=>{if(!_){V("validation_error","Please enter your phone number.");return}g(true),z(),f("");try{f("Creating Link account...");let I=await a({email:S,phone:_,fullName:D||S,country:v||"US"});if(I.error){V("registration_error",I.error.message,I.error.code);return}await Ho(S);}catch(I){V("registration_error",I?.message??String(I));}finally{g(false);}},[z,v,S,V,D,_,a,Ho]);useEffect(()=>{if(y!=="email"||!e?.email||k)return;let I=++Pe.current,P=false,H=()=>P||Pe.current!==I;return e?.phone?(async()=>{g(true),z();try{f("Configuring...");let K=await uo();if(H())return;if(K.error){V("configuration_error",K.error.message,K.error.code);return}f("Checking Link account...");let xe=await n(e.email);if(H())return;if(xe.error){V("authorization_error",xe.error.message,xe.error.code);return}if(xe.hasLinkAccount){if(H())return;await Ho(e.email);}else {f("Creating Link account...");let bt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(H())return;if(bt.error){V("registration_error",bt.error.message,bt.error.code);return}if(H())return;await Ho(e.email);}}catch(K){H()||V("unknown_error",K?.message??String(K));}finally{g(false);}})():(async()=>{g(true),z();try{f("Configuring...");let K=await uo();if(H())return;if(K.error){V("configuration_error",K.error.message,K.error.code);return}f("Checking Link account...");let xe=await n(e.email);if(H())return;if(xe.error){V("authorization_error",xe.error.message,xe.error.code);return}if(xe.hasLinkAccount){if(H())return;await Ho(e.email);}else {if(H())return;f(""),b("register");}}catch(K){H()||V("unknown_error",K?.message??String(K));}finally{g(false);}})(),()=>{P=true;}},[y,e?.email,e?.phone,k]);let Bt=useCallback(async I=>{g(true),z(),f(""),X(I);try{let P={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}},H=await s(P);if(H?.error){if(H.error.stripeErrorCode==="consumer_person_already_verified"){f(""),b("identity");return}V("kyc_error",H.error.message,H.error.stripeErrorCode??H.error.code),b("kyc");return}f("Please review your KYC information...");let K=await l(null);if(K?.error){V("kyc_error",K.error.message,K.error.stripeErrorCode??K.error.code),b("kyc");return}if(K?.status==="UpdateAddress"){V("kyc_error","Please update your address and resubmit."),b("kyc");return}f(""),b("identity");}catch(P){V("kyc_error",P?.message??String(P)),b("kyc");}finally{g(false);}},[s,z,V,l]),po=useCallback(async()=>{if(!je.current){je.current=true,g(true),z(),f("Launching identity verification...");try{let I=await m();if(I?.error){V("identity_error",I.error.message,I.error.code);return}f(""),b("wallet");}catch(I){V("identity_error",I?.message??String(I));}finally{je.current=false,g(false);}}},[z,V,m]);useEffect(()=>{y==="identity"&&!p&&po();},[y]);let ks=useCallback(async()=>{if(!ce){V("validation_error","Please enter a wallet address.");return}g(true),z(),f("");try{let I=ce.toLowerCase();console.log("[registerWallet] registering wallet:",I,"network:",be);let P=await c(I,be);if(P?.error){console.warn("[registerWallet] error:",P.error.message),V("wallet_error",P.error.message,P.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),b("session_params");}catch(I){V("wallet_error",I?.message??String(I));}finally{g(false);}},[z,V,ce,be,c]);useEffect(()=>{y==="wallet"&&_e&&ce&&ks();},[y,_e,ce]);let mo=useCallback(I=>{pe.current=false,Me.current=0;let P=0,H=async()=>{P+=1;let K=Ve.current;try{let xe=await vu(I,K);if(console.log(`[pollSessionStatus] poll #${P} session=${I} status="${xe.status}"`),pe.current)return;Me.current=0,xe.status==="fulfillment_complete"?(le(xe),b("success")):et.current=setTimeout(H,3e3);}catch(xe){if(pe.current)return;let bt=xe?.message??"";if((bt.includes("stripe_onramp_forbidden")||bt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Mr()&&!pe.current)){et.current=setTimeout(H,1e3);return}if(Me.current+=1,console.error(`[pollSessionStatus] poll #${P} error:`,bt),Me.current>=Rh){V("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}et.current=setTimeout(H,5e3);}};et.current=setTimeout(H,3e3);},[V,Mr]),fn=useCallback(()=>{if(fe.current==="processing"&&dt?.id){if(!Ve.current){V("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}z(),Me.current=0,et.current&&(clearTimeout(et.current),et.current=null),mo(dt.id);}},[z,V,mo,dt?.id]),wa=useCallback(async I=>{g(true),z(),f("");try{f("Confirming purchase...");let P=await er(H=>Ru(I,H));console.log("[finalizeOnrampSession] confirmed session:",P.id,"status:",P.status),le(P),b("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",P.id),mo(P.id);}finally{g(false);}},[z,mo,er]),Xl=useRef(false),Ym=useCallback(async()=>{if(!(!dt||Xl.current)){Xl.current=true;try{g(!0),z(),f("Refreshing quote...");let I=await er(P=>Fc(dt.id,P));le(I),await wa(I.id);}catch(I){console.log("[confirmCheckout] error:",I?.message),V("session_error","Something went wrong. Please try again."),b("quote");}finally{g(false),Xl.current=false;}}},[z,V,wa,dt,er]),eu=useCallback(async()=>{let I=S;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 P=await vc(I),H=await i(P);return H?.status==="Consented"&&H.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",H.customerId),me.current=H.customerId,ae(H.customerId),_n=H.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",H?.status),!1)}catch(P){return console.warn("[reauthorizeLink] failed:",P?.message),false}},[i,S]),Jm=useCallback(async(I=false,P,H)=>{let K=P??de;if(console.log("[collectPaymentMethod] called:",{useApplePay:I,amt:K,amountOverride:P,sourceAmount:de,hasSavedToken:!!H}),!K||isNaN(Number(K))||Number(K)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),V("validation_error","Please enter a valid amount.");return}P&&zt(P),g(true),z(),f("");try{let xe=await uo();if(xe.error){V("configuration_error",xe.error.message,xe.error.code);return}let bt;if(H)console.log("[collectPaymentMethod] using saved payment token"),bt=H;else if(I){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),V("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),b("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Ut={applePay:{merchantCountryCode:"US",currencyCode:ue.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${ye.toUpperCase()} purchase + fees`,amount:K}]}},pr=await C("PlatformPay",Ut);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!pr?.error),pr?.error){let Jr=pr.error.message??"",Zr=pr.error.code??"",Ht=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",pr.error,"isCancellation:",Ht),Ht||(V("payment_error",Jr,Zr),b("session_params"));return}if(!pr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let ar=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),b("session_params");return}bt=ar.cryptoPaymentToken;}else {f("Select a payment method...");let Ut=await C("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Ut?.error),Ut?.error){let Jr=Ut.error.message??"",Zr=Ut.error.code??"",Ht=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",Ut.error,"isCancellation:",Ht),Ht||(V("payment_error",Jr,Zr),b("session_params"));return}if(!Ut?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let pr=Ut.displayData;console.log("[collectPaymentMethod] displayData:",{type:pr.type,label:pr.label,sublabel:pr.sublabel,hasIcon:!!pr.icon}),f("Creating payment token...");let ar=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),b("session_params");return}bt=ar.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",ce,"walletAddressRef:",$e.current);let Qe=$e.current||ce.toLowerCase(),br=await er(Ut=>_u({cryptoCustomerId:me.current,paymentToken:bt,sourceAmount:Number(K),sourceCurrency:ue,destinationCurrency:ye,walletAddress:Qe,destinationNetwork:be},Ut));console.log("[collectPaymentMethod] session created:",br?.id,"useApplePay:",I),le(br),f(""),I?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await wa(br.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):b("quote");}catch(xe){console.log("[collectPaymentMethod] error caught:",xe?.message),V("session_error","Something went wrong. Please try again."),b("session_params");}finally{g(false),f("");}},[z,uo,C,T,ye,V,wa,zt,de,ue,ce,be,er,e?.merchantIdentifier]),Zm=useCallback(async()=>{g(true),z(),f("Select a payment method...");try{let I=await uo();if(I.error)return V("configuration_error",I.error.message,I.error.code),null;let P=await C("Card");if(console.log("[addPaymentMethod] Card result ok:",!P?.error),P?.error?.message&&/no active link consumer/i.test(P.error.message)){if(console.log("[addPaymentMethod] no active Link consumer \u2014 attempting re-authorization"),!await eu())return V("authorization_error","Please verify your identity to add a payment method."),null;P=await C("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!P?.error);}if(P?.error){let xe=P.error.message??"",bt=P.error.code??"",Qe=/cancel/i.test(xe)||/cancel/i.test(bt);return console.log("[addPaymentMethod] pmResult error:",P.error,"isCancellation:",Qe),Qe||V("payment_error",xe,bt),null}if(!P?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let H=P.displayData;console.log("[addPaymentMethod] displayData:",{type:H.type,label:H.label,sublabel:H.sublabel,hasIcon:!!H.icon}),f("Saving payment method...");let K=await T();return console.log("[addPaymentMethod] tokenResult ok:",!K?.error),K?.error?(V("payment_error",K.error.message,K.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:K.cryptoPaymentToken,sublabel:H.sublabel??""})}catch(I){return console.log("[addPaymentMethod] error:",I?.message),V("session_error",I?.message??String(I)),null}finally{g(false),f("");}},[z,uo,C,T,V,eu]),Xm=useCallback(async()=>{if(dt){g(true),z(),f("");try{let I=await er(P=>Fc(dt.id,P));le(I);}catch(I){console.log("[refreshQuote] error:",I?.message),V("session_error","Something went wrong. Please try again.");}finally{g(false);}}},[z,V,dt,er]),ef=useCallback(()=>{pe.current=true,Me.current=0,et.current&&(clearTimeout(et.current),et.current=null),b(r),g(false),f(""),x(null),w(e?.email??""),W(e?.phone??""),O(""),q("US"),ae(""),me.current="",ve(""),Ve.current="",J.current="",Ne(false),oe(false),X(Hu),st(e?.recipientAddress??""),$e.current="",ot.current=false,ie(Onramp.CryptoNetwork.ethereum),zt(e?.defaultSourceAmount??"100"),se(e?.defaultSourceCurrency??"usd"),yt(e?.defaultDestinationCurrency??"usdc"),Le(""),yr(void 0),xr(void 0),le(null),Pe.current+=1,rt.current=false,je.current=false;},[e,r]);return {step:y,restoring:k,loading:p,status:d,error:R,email:S,phone:_,fullName:D,country:v,customerId:N,accessToken:ze,session:dt,kycData:Re,walletAddress:ce,resolvedRecipientAddress:Je,walletNetwork:be,sourceAmount:de,sourceCurrency:ue,destinationCurrency:ye,tokenIconUrl:qe,networkIconUrl:xt,applePaySupported:$,walletReady:_e,walletLoading:Se,setStep:b,setStatus:f,setEmail:w,setPhone:W,setFullName:O,setCountry:q,setWalletAddress:st,setWalletNetwork:ie,setSourceAmount:zt,setSourceCurrency:se,setDestinationCurrency:yt,checkEmail:Q,register:ge,attachKyc:Bt,verifyIdentity:po,registerWallet:ks,collectPaymentMethod:Jm,addPaymentMethod:Zm,refreshQuote:Xm,confirmCheckout:Ym,reset:ef,clearError:z,emitComplete:Or,resumeFulfillmentPolling:fn,amountFirst:t}}function Nu({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:a,email:i,setEmail:s,checkEmail:l,onClose:m}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(Ir,{error:n,progress:a,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your email"}),jsx(Text,{style:e.form.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Email address"}),jsx(TextInput,{style:e.form.input,placeholder:"jane@example.com",placeholderTextColor:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:s,autoFocus:true,returnKeyType:"done",onSubmitEditing:l})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Ir,{error:n,progress:a,loading:o})]})]})})}function $u({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(kt,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:r||"Preparing identity verification..."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Text,{style:e.flow.idIcon,children:"\u{1FAAA}"})}),jsx(Text,{style:e.flow.heading,children:"Identity verification"}),jsx(Text,{style:e.flow.sub,children:r||"Tap below to continue verification."})]}),jsx(Ir,{error:o,progress:r,loading:false})]}),!t&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:n,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function Qu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:m,onRetryStatusCheck:c}){let{colors:C}=F(),T=!!t;return jsxs(View,{style:e.form.screen,children:[T?jsx(Jt,{onPress:m}):jsx(View,{style:Ea}),jsx(View,{style:e.flow.centered,children:t?jsxs(Fragment,{children:[jsx(Text,{style:e.flow.heading,children:"Could not confirm status"}),jsx(Text,{style:e.flow.sub,children:"Your payment may still be completing. Try checking again, or close this screen and verify your wallet balance."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(kt,{size:48,strokeWidth:3,gradientFrom:C.primary,gradientTo:C.primary})}),jsx(Text,{style:e.flow.heading,children:"Processing your purchase"}),jsxs(Text,{style:e.flow.sub,children:["Your payment has been confirmed.",`
2
+ `,"We're sending your crypto \u2014 this usually takes less than a minute."]}),n&&a&&i&&jsx(za,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(Ir,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:c,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Ku({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:m}){let{colors:c}=F(),C=t.transaction_details,T=Wa(C.destination_amount,C.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m??l,title:"Review your purchase",variant:m?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(Es,{currency:C.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(fo,{quote:e.quote,label:"You pay",value:`${C.source_amount} ${C.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You receive",value:`${T} ${C.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network fee",value:`$${C.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction fee",value:`$${C.fees.transaction_fee_amount}`,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(Ir,{error:o,progress:n,loading:r})]})]})}function Gu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:m}){let c=F();return t?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(Ir,{error:o,progress:n,loading:r})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your phone"}),jsx(Text,{style:e.form.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Phone number"}),jsx(TextInput,{style:e.form.input,placeholder:"+12125551234",placeholderTextColor:c.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:C=>s(C.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:l}),jsx(Text,{style:e.form.hint,children:"Include country code, e.g. +12125551234"})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:a})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Ir,{error:o,progress:n,loading:r})]})]})})}function Hh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=F(),n=e.toLowerCase(),a=Ma[n]??o.primary,i=Math.round(r*.36);return jsxs(View,{style:{width:r,height:r,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:r,height:r,borderRadius:r/2}}):jsx(View,{style:[Io.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[Io.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[Io.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(Ue,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Yu({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:m}=F(),c=t.transaction_details,C=Wa(c.destination_amount,c.destination_currency),T=r||o||"";Wi(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(gt,{style:e.form.flex,contentContainerStyle:Io.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Io.iconSection,children:[jsx(Hh,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:Io.statusRow,children:[jsx(View,{style:[Io.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[Io.statusText,{color:s.foreground,fontFamily:m.semibold}],children:"Completed"})]}),jsx(Text,{style:[Io.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(za,{sourceCurrency:c.source_currency,destinationCurrency:c.destination_currency,destinationNetwork:c.destination_network,tokenIconUrl:n,networkIconUrl:a,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor},Io.detailCard],children:[jsx(fo,{quote:e.quote,label:"You Paid",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You Received",value:`${C} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(Ic,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),T?jsx(Ic,{quote:e.quote,label:"Recipient Address",address:T,last:true}):jsx(fo,{quote:e.quote,label:"Session",value:t.id.slice(0,8)+"..."+t.id.slice(-6),last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var Io=StyleSheet.create({scrollContent:{paddingBottom:24,alignItems:"center"},iconSection:{alignItems:"center",marginTop:24,marginBottom:24},tokenCircle:{alignItems:"center",justifyContent:"center"},tokenLetter:{color:"#FFFFFF",fontWeight:"700",letterSpacing:.5},checkBadge:{position:"absolute",bottom:0,right:0,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",marginTop:16,gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16},subtitle:{fontSize:14,marginTop:4},detailCard:{width:"100%"}});function Ju({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:m,registerWallet:c,onClose:C}){let{components:T}=F();if(t){let y=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:C}),jsxs(View,{style:e.flow.centered,children:[!y&&jsx(kt,{size:56,strokeWidth:3}),jsx(Ir,{error:o,progress:n,loading:r})]}),y&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:c,children:jsx(Text,{style:e.form.continueBtnText,children:"Retry"})})})]})}return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:C}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Your crypto wallet"}),jsx(Text,{style:e.form.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[e.form.input,e.wallet.input],placeholder:"0x...",placeholderTextColor:T.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:a,onChangeText:s})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:Ba.map(y=>{let b=i===y.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,b&&e.wallet.rowSelected],onPress:()=>{l(y.value),m(y.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(y.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,b&&e.wallet.rowTextSelected],children:y.label}),b&&jsx(View,{style:e.wallet.checkCircle,children:jsx(Ue,{size:14,color:T.container.buttonTitleColor,strokeWidth:2.5})})]},y.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:c,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Ir,{error:o,progress:n,loading:r})]})]})})}function el({config:e,onClose:t}){let r=F(),o=Ei(),{step:n,restoring:a,loading:i,status:s,error:l,email:m,phone:c,session:C,kycData:T,walletAddress:y,resolvedRecipientAddress:b,walletNetwork:k,sourceAmount:h,sourceCurrency:p,destinationCurrency:g,tokenIconUrl:d,networkIconUrl:f,applePaySupported:R,setStep:x,setEmail:S,setPhone:w,setWalletAddress:_,setWalletNetwork:W,setSourceAmount:D,setDestinationCurrency:O,checkEmail:v,register:q,attachKyc:N,verifyIdentity:ae,registerWallet:ze,collectPaymentMethod:ve,addPaymentMethod:J,confirmCheckout:Ve,reset:me,emitComplete:_e,resumeFulfillmentPolling:Ne,amountFirst:Se,customerId:oe,accessToken:Pe}=Ga(e),rt=!!e?.email,je=!!e?.phone,ot=!!e?.publishableKey&&!!e?.externalUserId,[$e,Fe]=useState(void 0),[ct,Re]=useState([]);useEffect(()=>{if(a||n!=="session_params"||!oe||!Pe)return;console.log("[OnrampScreen] customerId:",oe);let Le=ie=>{let de=ie?.message??"";return de.includes("stripe_onramp_forbidden")||de.includes("403")},be=ie=>{Le(ie)&&(Tn(),me());};ja(oe,Pe).then(ie=>{console.log("[OnrampScreen] customer fetched, id:",ie?.id);}).catch(ie=>{console.warn("[OnrampScreen] customer fetch error:",ie?.message),be(ie);}),Oc(oe,Pe).then(ie=>{console.log("[OnrampScreen] payment_tokens fetched, count:",ie.data?.length??0),Re(ie.data??[]);}).catch(ie=>{console.warn("[OnrampScreen] payment_tokens error:",ie?.message),be(ie);}),console.log("[OnrampScreen] walletAddress:",y,"walletNetwork:",k),y&&(console.log("[OnrampScreen] calling getTransactionLimits..."),Pu({destinationNetwork:k||"ethereum",walletAddress:y,accessToken:Pe,cryptoCustomerId:oe}).then(ie=>{console.log("[OnrampScreen] transaction_limits fetched");let de=ie.limits?.usd;if(de?.card?.length){let zt=Math.max(...de.card.map(ue=>ue.limit));Fe(zt),console.log("[OnrampScreen] card max amount:",zt);}}).catch(ie=>{console.warn("[OnrampScreen] transaction_limits error:",ie?.message),be(ie);}));},[a,n,oe,Pe,y,k,me]);let X=async()=>{if(!(!oe||!Pe))try{let Le=await Oc(oe,Pe);console.log("[OnrampScreen] payment_tokens refreshed, count:",Le.data?.length??0),Re(Le.data??[]);}catch(Le){console.warn("[OnrampScreen] payment_tokens refresh error:",Le?.message);let be=Le?.message??"";(be.includes("stripe_onramp_forbidden")||be.includes("403"))&&(Tn(),me());}},ce=async()=>{let Le=await J();return Le&&await X(),Le},st=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&st&&C&&(_e(C),me(),t?.());},[n,st,C,_e,me,t]);let Je=()=>{me(),t?.();};return a?jsx(View,{style:[Kh.container,{backgroundColor:r.colors.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})}):n==="email"?jsx(Nu,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:rt,loading:i,error:l,status:s,email:m,setEmail:S,checkEmail:v,onClose:Je}):n==="register"?jsx(Gu,{styles:o,hasPrefilledPhone:je,loading:i,error:l,status:s,email:m,phone:c,setPhone:w,register:q,onClose:Je}):n==="kyc"?jsx(Ka,{initialData:T,loading:i,onComplete:N,onCancel:()=>x("email")}):n==="identity"?jsx($u,{styles:o,loading:i,status:s,error:l,verifyIdentity:ae,onClose:Je}):n==="wallet"?jsx(Ju,{styles:o,hasAutoWallet:ot,loading:i,error:l,status:s,walletAddress:y,walletNetwork:k,setWalletAddress:_,setWalletNetwork:W,setDestinationCurrency:O,registerWallet:ze,onClose:Je}):n==="session_params"?jsx(Qa,{initialAmount:h,currency:p,applePaySupported:R,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:$e,paymentTokens:ct,onAddPaymentMethod:ce,onCollectPayment:(Le,be)=>{ve(Le,be);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(Le,be)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:Le,selectedMethod:be,amountFirst:Se}),Se&&!oe)D(Le),x("email");else {let ie=be==="apple_pay",de=!ie&&be?be:void 0;console.log("[OnrampScreen] isApplePay:",ie,"hasSavedToken:",!!de),ve(ie,Le,de);}},onCancel:Je,accessToken:Pe}):n==="quote"&&C?jsx(Ku,{styles:o,session:C,loading:i,error:l,status:s,confirmCheckout:Ve,tokenIconUrl:d,networkIconUrl:f,onClose:Je,onBack:()=>x("session_params")}):n==="processing"?jsx(Qu,{styles:o,error:l,status:s,loading:i,sourceCurrency:C?.transaction_details.source_currency,destinationCurrency:C?.transaction_details.destination_currency??g,destinationNetwork:C?.transaction_details.destination_network??"base",tokenIconUrl:d,networkIconUrl:f,onClose:Je,onRetryStatusCheck:Ne}):n==="success"&&C&&!st?jsx(Yu,{styles:o,session:C,resolvedRecipientAddress:b,recipientFromConfig:e?.recipientAddress,tokenIconUrl:d,networkIconUrl:f,onDone:()=>{_e(C),me(),t?.();}}):null}var Kh=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function ep(){try{let e=Gh.expoConfig?.plugins;if(!Array.isArray(e))return;for(let t of e){if(!Array.isArray(t))continue;let[r,o]=t;if(r!=="@stripe/stripe-react-native"||!o||typeof o!="object")continue;let n=o.merchantIdentifier;if(typeof n=="string"){let a=n.trim();if(a.length>0)return a}}}catch{}}function tl({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:m,onError:c,onStepChange:C,onClose:T,merchantIdentifier:y="",urlScheme:b="unifoldOnramp",paymentSelectorPosition:k,skipSuccessConfirmation:h=false}){let{colors:p,fonts:g,components:d}=F(),f=e||Pa(),R=useMemo(()=>{let D=y.trim();return D.length>0?D:ep()??""},[y]),[x,S]=useState("loading"),[w,_]=useState(null);useEffect(()=>{let D=false;async function O(){try{f&&(Ua(f),Ha(Ds()));let v=await Na();if(D)return;let q=R.trim();if(await initStripe({publishableKey:v,urlScheme:b,...q?{merchantIdentifier:q}:{}}),D)return;S("ready");}catch(v){if(D)return;console.error("[StripeOnramp] Init failed:",v),_(v?.message??"Failed to load Stripe configuration"),S("error");}}return O(),()=>{D=true;}},[f,R,b]);let W=useMemo(()=>{let D={publishableKey:f,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:m,onError:c,onStepChange:C};return s&&(D.destinationTokenAddress=s),l&&(D.recipientAddress=l),t&&(D.email=t),r&&(D.phone=r),n&&(D.flowOrder=n),k&&(D.paymentSelectorPosition=k),D.skipSuccessConfirmation=h,D.merchantIdentifier=R,D},[f,o,a,i,s,l,t,r,n,k,h,R,m,c,C]);return x==="error"?jsxs(View,{style:[ji.centered,{backgroundColor:p.background}],children:[jsx(Text,{style:[ji.errorText,{color:p.error,fontFamily:g.medium}],children:"Unable to initialize"}),jsx(Text,{style:[ji.errorDetail,{color:p.foregroundMuted,fontFamily:g.regular}],children:w}),T&&jsx(TouchableOpacity,{style:[ji.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:T,children:jsx(Text,{style:[ji.retryBtnText,{color:d.button.primaryText,fontFamily:g.medium}],children:"Go Back"})})]}):x==="loading"?jsx(View,{style:[ji.centered,{backgroundColor:p.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:p.primary,gradientTo:p.primary})}):jsx(el,{config:W,onClose:T})}var ji=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",paddingHorizontal:24},errorText:{fontSize:18,marginBottom:8},errorDetail:{fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{paddingVertical:14,paddingHorizontal:32},retryBtnText:{fontSize:16}});function np(){let{configure:e}=useOnramp(),t=useRef(false);return useEffect(()=>{t.current||(t.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(r=>{r.error&&console.error("[StripeOnrampPreconfigure] error:",r.error.message);}).catch(r=>{console.error("[StripeOnrampPreconfigure] threw:",r?.message);}));},[e]),null}var ip="__unifold_stripe_onramp__";function rl(e){globalThis[ip]=e;}function sp(){return globalThis[ip]}rl(tl);var vo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this);}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe();}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var oi,vn,$i,ap,ng=(ap=class extends vo{constructor(){super();Z(this,oi);Z(this,vn);Z(this,$i);A(this,$i,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){u(this,vn)||this.setEventListener(u(this,$i));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,vn))==null||t.call(this),A(this,vn,void 0));}setEventListener(t){var r;A(this,$i,t),(r=u(this,vn))==null||r.call(this),A(this,vn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){u(this,oi)!==t&&(A(this,oi,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof u(this,oi)=="boolean"?u(this,oi):globalThis.document?.visibilityState!=="hidden"}},oi=new WeakMap,vn=new WeakMap,$i=new WeakMap,ap),qi=new ng;var ig={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Po,ni,lp,sg=(lp=class{constructor(){Z(this,Po,ig);Z(this,ni,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&u(this,ni)&&e!==u(this,Po)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:u(this,Po),provider:e}),A(this,Po,e),process.env.NODE_ENV!=="production"&&A(this,ni,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setTimeout(e,t)}clearTimeout(e){u(this,Po).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setInterval(e,t)}clearInterval(e){u(this,Po).clearInterval(e);}},Po=new WeakMap,ni=new WeakMap,lp),Fo=new sg;function cp(e){setTimeout(e,0);}var Nc=typeof window>"u"||"Deno"in globalThis;function nr(){}function pp(e,t){return typeof e=="function"?e(t):e}function qs(e){return typeof e=="number"&&e>=0&&e!==1/0}function nl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bo(e,t){return typeof e=="function"?e(t):e}function Br(e,t){return typeof e=="function"?e(t):e}function il(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Qs(i,t.options))return false}else if(!ai(t.queryKey,i))return false}if(r!=="all"){let l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return false}return !(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||a&&!a(t))}function sl(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(ii(t.options.mutationKey)!==ii(a))return false}else if(!ai(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Qs(e,t){return (t?.queryKeyHashFn||ii)(e)}function ii(e){return JSON.stringify(e,(t,r)=>Hc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ai(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ai(e[r],t[r])):false}var ag=Object.prototype.hasOwnProperty;function ol(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=dp(e)&&dp(t);if(!o&&!(Hc(e)&&Hc(t)))return t;let a=(o?e:Object.keys(e)).length,i=o?t:Object.keys(t),s=i.length,l=o?new Array(s):{},m=0;for(let c=0;c<s;c++){let C=o?c:i[c],T=e[C],y=t[C];if(T===y){l[C]=T,(o?c<a:ag.call(e,C))&&m++;continue}if(T===null||y===null||typeof T!="object"||typeof y!="object"){l[C]=y;continue}let b=ol(T,y,r+1);l[C]=b,b===T&&m++;}return a===s&&m===a?e:l}function al(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return false;for(let r in e)if(e[r]!==t[r])return false;return true}function dp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Hc(e){if(!up(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!up(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function up(e){return Object.prototype.toString.call(e)==="[object Object]"}function mp(e){return new Promise(t=>{Fo.setTimeout(t,e);})}function Ks(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==false){if(process.env.NODE_ENV!=="production")try{return ol(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return ol(e,t)}return t}function fp(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function hp(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var si=Symbol();function ll(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===si&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cl(e,t){return typeof e=="function"?e(...t):!!e}function gp(e,t,r){let o=false,n;return Object.defineProperty(e,"signal",{enumerable:true,get:()=>(n??(n=t()),o||(o=true,n.aborted?r():n.addEventListener("abort",r,{once:true})),n)}),e}var Oo=(()=>{let e=()=>Nc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function Gs(){let e,t,r=new Promise((n,a)=>{e=n,t=a;});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject;}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n);},r.reject=n=>{o({status:"rejected",reason:n}),t(n);},r}var yp=cp;function lg(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=yp,a=s=>{t?e.push(s):n(()=>{r(s);});},i=()=>{let s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(l);});});});};return {batch:s=>{let l;t++;try{l=s();}finally{t--,t||i();}return l},batchCalls:s=>(...l)=>{a(()=>{s(...l);});},schedule:a,setNotifyFunction:s=>{r=s;},setBatchNotifyFunction:s=>{o=s;},setScheduler:s=>{n=s;}}}var vt=lg();var Qi,Pn,Ki,bp,cg=(bp=class extends vo{constructor(){super();Z(this,Qi,true);Z(this,Pn);Z(this,Ki);A(this,Ki,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t(true),o=()=>t(false);return window.addEventListener("online",r,false),window.addEventListener("offline",o,false),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o);}}});}onSubscribe(){u(this,Pn)||this.setEventListener(u(this,Ki));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,Pn))==null||t.call(this),A(this,Pn,void 0));}setEventListener(t){var r;A(this,Ki,t),(r=u(this,Pn))==null||r.call(this),A(this,Pn,t(this.setOnline.bind(this)));}setOnline(t){u(this,Qi)!==t&&(A(this,Qi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return u(this,Qi)}},Qi=new WeakMap,Pn=new WeakMap,Ki=new WeakMap,bp),Gi=new cg;function dg(e){return Math.min(1e3*2**e,3e4)}function jc(e){return (e??"online")==="online"?Gi.isOnline():true}var dl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function ul(e){let t=false,r=0,o,n=Gs(),a=()=>n.status!=="pending",i=k=>{if(!a()){let h=new dl(k);T(h),e.onCancel?.(h);}},s=()=>{t=true;},l=()=>{t=false;},m=()=>qi.isFocused()&&(e.networkMode==="always"||Gi.isOnline())&&e.canRun(),c=()=>jc(e.networkMode)&&e.canRun(),C=k=>{a()||(o?.(),n.resolve(k));},T=k=>{a()||(o?.(),n.reject(k));},y=()=>new Promise(k=>{o=h=>{(a()||m())&&k(h);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),b=()=>{if(a())return;let k,h=r===0?e.initialPromise:void 0;try{k=h??e.fn();}catch(p){k=Promise.reject(p);}Promise.resolve(k).then(C).catch(p=>{if(a())return;let g=e.retry??(Oo.isServer()?0:3),d=e.retryDelay??dg,f=typeof d=="function"?d(r,p):d,R=g===true||typeof g=="number"&&r<g||typeof g=="function"&&g(r,p);if(t||!R){T(p);return}r++,e.onFail?.(r,p),mp(f).then(()=>m()?void 0:y()).then(()=>{t?T(p):b();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?b():y().then(b),n)}}var li,Cp,pl=(Cp=class{constructor(){Z(this,li);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),qs(this.gcTime)&&A(this,li,Fo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Oo.isServer()?1/0:300*1e3));}clearGcTimeout(){u(this,li)!==void 0&&(Fo.clearTimeout(u(this,li)),A(this,li,void 0));}},li=new WeakMap,Cp);var ci,Yi,so,di,cr,Ys,ui,Qr,xp,Yo,kp,Tp=(kp=class extends pl{constructor(t){super();Z(this,Qr);Z(this,ci);Z(this,Yi);Z(this,so);Z(this,di);Z(this,cr);Z(this,Ys);Z(this,ui);A(this,ui,false),A(this,Ys,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,di,t.client),A(this,so,u(this,di).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,ci,Sp(this.options)),this.state=t.state??u(this,ci),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return u(this,cr)?.promise}setOptions(t){if(this.options={...u(this,Ys),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Sp(this.options);r.data!==void 0&&(this.setState(wp(r.data,r.dataUpdatedAt)),A(this,ci,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&u(this,so).remove(this);}setData(t,r){let o=Ks(this.state.data,t,this.options);return Ae(this,Qr,Yo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Ae(this,Qr,Yo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=u(this,cr)?.promise;return u(this,cr)?.cancel(t),r?r.then(nr).catch(nr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return u(this,ci)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Br(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===si||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bo(t.options.staleTime,this)==="static"):false}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?true:t==="static"?false:this.state.isInvalidated?true:!nl(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),u(this,so).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(u(this,cr)&&(u(this,ui)||Ae(this,Qr,xp).call(this)?u(this,cr).cancel({revert:true}):u(this,cr).cancelRetry()),this.scheduleGc()),u(this,so).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Qr,Yo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&u(this,cr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(u(this,cr))return u(this,cr).continueRetry(),u(this,cr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(m=>m.options.queryFn);l&&this.setOptions(l.options);}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));let o=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:true,get:()=>(A(this,ui,true),o.signal)});},a=()=>{let l=ll(this.options,r),c=(()=>{let C={client:u(this,di),queryKey:this.queryKey,meta:this.meta};return n(C),C})();return A(this,ui,false),this.options.persister?this.options.persister(l,c,this):l(c)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:u(this,di),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),A(this,Yi,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Ae(this,Qr,Yo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),A(this,cr,ul({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof dl&&l.revert&&this.setState({...u(this,Yi),fetchStatus:"idle"}),o.abort();},onFail:(l,m)=>{Ae(this,Qr,Yo).call(this,{type:"failed",failureCount:l,error:m});},onPause:()=>{Ae(this,Qr,Yo).call(this,{type:"pause"});},onContinue:()=>{Ae(this,Qr,Yo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await u(this,cr).start();if(l===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(l),u(this,so).config.onSuccess?.(l,this),u(this,so).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof dl){if(l.silent)return u(this,cr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Ae(this,Qr,Yo).call(this,{type:"error",error:l}),u(this,so).config.onError?.(l,this),u(this,so).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ci=new WeakMap,Yi=new WeakMap,so=new WeakMap,di=new WeakMap,cr=new WeakMap,Ys=new WeakMap,ui=new WeakMap,Qr=new WeakSet,xp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Yo=function(t){let r=o=>{switch(t.type){case "failed":return {...o,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case "pause":return {...o,fetchStatus:"paused"};case "continue":return {...o,fetchStatus:"fetching"};case "fetch":return {...o,...$c(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...wp(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,Yi,t.manual?n:void 0),n;case "error":let a=t.error;return {...o,error:a,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:true};case "invalidate":return {...o,isInvalidated:true};case "setState":return {...o,...t.state}}};this.state=r(this.state),vt.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),u(this,so).notify({query:this,type:"updated",action:t});});},kp);function $c(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function wp(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Sp(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return {data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:false,status:r?"success":"pending",fetchStatus:"idle"}}var Ar,Ke,Zs,vr,pi,Ji,Jo,Fn,Xs,Zi,Xi,mi,fi,On,es,pt,Js,qc,Qc,Kc,Gc,Yc,Jc,Zc,vp,Ip,ed=(Ip=class extends vo{constructor(t,r){super();Z(this,pt);Z(this,Ar);Z(this,Ke);Z(this,Zs);Z(this,vr);Z(this,pi);Z(this,Ji);Z(this,Jo);Z(this,Fn);Z(this,Xs);Z(this,Zi);Z(this,Xi);Z(this,mi);Z(this,fi);Z(this,On);Z(this,es,new Set);this.options=r,A(this,Ar,t),A(this,Fn,null),A(this,Jo,Gs()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(u(this,Ke).addObserver(this),_p(u(this,Ke),this.options)?Ae(this,pt,Js).call(this):this.updateResult(),Ae(this,pt,Gc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Xc(u(this,Ke),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xc(u(this,Ke),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,pt,Yc).call(this),Ae(this,pt,Jc).call(this),u(this,Ke).removeObserver(this);}setOptions(t){let r=this.options,o=u(this,Ke);if(this.options=u(this,Ar).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Br(this.options.enabled,u(this,Ke))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,pt,Zc).call(this),u(this,Ke).setOptions(this.options),r._defaulted&&!al(this.options,r)&&u(this,Ar).getQueryCache().notify({type:"observerOptionsUpdated",query:u(this,Ke),observer:this});let n=this.hasListeners();n&&Rp(u(this,Ke),o,this.options,r)&&Ae(this,pt,Js).call(this),this.updateResult(),n&&(u(this,Ke)!==o||Br(this.options.enabled,u(this,Ke))!==Br(r.enabled,u(this,Ke))||bo(this.options.staleTime,u(this,Ke))!==bo(r.staleTime,u(this,Ke)))&&Ae(this,pt,qc).call(this);let a=Ae(this,pt,Qc).call(this);n&&(u(this,Ke)!==o||Br(this.options.enabled,u(this,Ke))!==Br(r.enabled,u(this,Ke))||a!==u(this,On))&&Ae(this,pt,Kc).call(this,a);}getOptimisticResult(t){let r=u(this,Ar).getQueryCache().build(u(this,Ar),t),o=this.createResult(r,t);return pg(this,o)&&(A(this,vr,o),A(this,Ji,this.options),A(this,pi,u(this,Ke).state)),o}getCurrentResult(){return u(this,vr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&u(this,Jo).status==="pending"&&u(this,Jo).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){u(this,es).add(t);}getCurrentQuery(){return u(this,Ke)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=u(this,Ar).defaultQueryOptions(t),o=u(this,Ar).getQueryCache().build(u(this,Ar),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Ae(this,pt,Js).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),u(this,vr)))}createResult(t,r){let o=u(this,Ke),n=this.options,a=u(this,vr),i=u(this,pi),s=u(this,Ji),m=t!==o?t.state:u(this,Zs),{state:c}=t,C={...c},T=false,y;if(r._optimisticResults){let _=this.hasListeners(),W=!_&&_p(t,r),D=_&&Rp(t,o,r,n);(W||D)&&(C={...C,...$c(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(C.fetchStatus="idle");}let{error:b,errorUpdatedAt:k,status:h}=C;y=C.data;let p=false;if(r.placeholderData!==void 0&&y===void 0&&h==="pending"){let _;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(_=a.data,p=true):_=typeof r.placeholderData=="function"?r.placeholderData(u(this,Xi)?.state.data,u(this,Xi)):r.placeholderData,_!==void 0&&(h="success",y=Ks(a?.data,_,r),T=true);}if(r.select&&y!==void 0&&!p)if(a&&y===i?.data&&r.select===u(this,Xs))y=u(this,Zi);else try{A(this,Xs,r.select),y=r.select(y),y=Ks(a?.data,y,r),A(this,Zi,y),A(this,Fn,null);}catch(_){A(this,Fn,_);}u(this,Fn)&&(b=u(this,Fn),y=u(this,Zi),k=Date.now(),h="error");let g=C.fetchStatus==="fetching",d=h==="pending",f=h==="error",R=d&&g,x=y!==void 0,w={status:h,fetchStatus:C.fetchStatus,isPending:d,isSuccess:h==="success",isError:f,isInitialLoading:R,isLoading:R,data:y,dataUpdatedAt:C.dataUpdatedAt,error:b,errorUpdatedAt:k,failureCount:C.fetchFailureCount,failureReason:C.fetchFailureReason,errorUpdateCount:C.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:C.dataUpdateCount>m.dataUpdateCount||C.errorUpdateCount>m.errorUpdateCount,isFetching:g,isRefetching:g&&!d,isLoadingError:f&&!x,isPaused:C.fetchStatus==="paused",isPlaceholderData:T,isRefetchError:f&&x,isStale:td(t,r),refetch:this.refetch,promise:u(this,Jo),isEnabled:Br(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let _=w.data!==void 0,W=w.status==="error"&&!_,D=q=>{W?q.reject(w.error):_&&q.resolve(w.data);},O=()=>{let q=A(this,Jo,w.promise=Gs());D(q);},v=u(this,Jo);switch(v.status){case "pending":t.queryHash===o.queryHash&&D(v);break;case "fulfilled":(W||w.data!==v.value)&&O();break;case "rejected":(!W||w.error!==v.reason)&&O();break}}return w}updateResult(){let t=u(this,vr),r=this.createResult(u(this,Ke),this.options);if(A(this,pi,u(this,Ke).state),A(this,Ji,this.options),u(this,pi).data!==void 0&&A(this,Xi,u(this,Ke)),al(r,t))return;A(this,vr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!u(this,es).size)return true;let i=new Set(a??u(this,es));return this.options.throwOnError&&i.add("error"),Object.keys(u(this,vr)).some(s=>{let l=s;return u(this,vr)[l]!==t[l]&&i.has(l)})};Ae(this,pt,vp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,pt,Gc).call(this);}},Ar=new WeakMap,Ke=new WeakMap,Zs=new WeakMap,vr=new WeakMap,pi=new WeakMap,Ji=new WeakMap,Jo=new WeakMap,Fn=new WeakMap,Xs=new WeakMap,Zi=new WeakMap,Xi=new WeakMap,mi=new WeakMap,fi=new WeakMap,On=new WeakMap,es=new WeakMap,pt=new WeakSet,Js=function(t){Ae(this,pt,Zc).call(this);let r=u(this,Ke).fetch(this.options,t);return t?.throwOnError||(r=r.catch(nr)),r},qc=function(){Ae(this,pt,Yc).call(this);let t=bo(this.options.staleTime,u(this,Ke));if(Oo.isServer()||u(this,vr).isStale||!qs(t))return;let o=nl(u(this,vr).dataUpdatedAt,t)+1;A(this,mi,Fo.setTimeout(()=>{u(this,vr).isStale||this.updateResult();},o));},Qc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(u(this,Ke)):this.options.refetchInterval)??false},Kc=function(t){Ae(this,pt,Jc).call(this),A(this,On,t),!(Oo.isServer()||Br(this.options.enabled,u(this,Ke))===false||!qs(u(this,On))||u(this,On)===0)&&A(this,fi,Fo.setInterval(()=>{(this.options.refetchIntervalInBackground||qi.isFocused())&&Ae(this,pt,Js).call(this);},u(this,On)));},Gc=function(){Ae(this,pt,qc).call(this),Ae(this,pt,Kc).call(this,Ae(this,pt,Qc).call(this));},Yc=function(){u(this,mi)!==void 0&&(Fo.clearTimeout(u(this,mi)),A(this,mi,void 0));},Jc=function(){u(this,fi)!==void 0&&(Fo.clearInterval(u(this,fi)),A(this,fi,void 0));},Zc=function(){let t=u(this,Ar).getQueryCache().build(u(this,Ar),this.options);if(t===u(this,Ke))return;let r=u(this,Ke);A(this,Ke,t),A(this,Zs,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},vp=function(t){vt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(u(this,vr));}),u(this,Ar).getQueryCache().notify({query:u(this,Ke),type:"observerResultsUpdated"});});},Ip);function ug(e,t){return Br(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function _p(e,t){return ug(e,t)||e.state.data!==void 0&&Xc(e,t,t.refetchOnMount)}function Xc(e,t,r){if(Br(t.enabled,e)!==false&&bo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&td(e,t)}return false}function Rp(e,t,r,o){return (e!==t||Br(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&td(e,r)}function td(e,t){return Br(t.enabled,e)!==false&&e.isStaleByTime(bo(t.staleTime,e))}function pg(e,t){return !al(e.getCurrentResult(),t)}function rd(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],i=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},l=0,m=async()=>{let c=false,C=b=>{gp(b,()=>t.signal,()=>c=true);},T=ll(t.options,t.fetchOptions),y=async(b,k,h)=>{if(c)return Promise.reject();if(k==null&&b.pages.length)return Promise.resolve(b);let g=(()=>{let x={client:t.client,queryKey:t.queryKey,pageParam:k,direction:h?"backward":"forward",meta:t.options.meta};return C(x),x})(),d=await T(g),{maxPages:f}=t.options,R=h?hp:fp;return {pages:R(b.pages,d,f),pageParams:R(b.pageParams,k,f)}};if(n&&a.length){let b=n==="backward",k=b?mg:Pp,h={pages:a,pageParams:i},p=k(o,h);s=await y(h,p,b);}else {let b=e??a.length;do{let k=l===0?i[0]??o.initialPageParam:Pp(o,s);if(l>0&&k==null)break;s=await y(s,k),l++;}while(l<b)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=m;}}}function Pp(e,{pages:t,pageParams:r}){let o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function mg(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ea,Do,wr,hi,Vo,Dn,Fp,Op=(Fp=class extends pl{constructor(t){super();Z(this,Vo);Z(this,ea);Z(this,Do);Z(this,wr);Z(this,hi);A(this,ea,t.client),this.mutationId=t.mutationId,A(this,wr,t.mutationCache),A(this,Do,[]),this.state=t.state||fg(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){u(this,Do).includes(t)||(u(this,Do).push(t),this.clearGcTimeout(),u(this,wr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Do,u(this,Do).filter(r=>r!==t)),this.scheduleGc(),u(this,wr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){u(this,Do).length||(this.state.status==="pending"?this.scheduleGc():u(this,wr).remove(this));}continue(){return u(this,hi)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Ae(this,Vo,Dn).call(this,{type:"continue"});},o={client:u(this,ea),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,hi,ul({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Ae(this,Vo,Dn).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Ae(this,Vo,Dn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>u(this,wr).canRun(this)}));let n=this.state.status==="pending",a=!u(this,hi).canStart();try{if(n)r();else {Ae(this,Vo,Dn).call(this,{type:"pending",variables:t,isPaused:a}),u(this,wr).config.onMutate&&await u(this,wr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Ae(this,Vo,Dn).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await u(this,hi).start();return await u(this,wr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await u(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),Ae(this,Vo,Dn).call(this,{type:"success",data:i}),i}catch(i){try{await u(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 u(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 Ae(this,Vo,Dn).call(this,{type:"error",error:i}),i}finally{u(this,wr).runNext(this);}}},ea=new WeakMap,Do=new WeakMap,wr=new WeakMap,hi=new WeakMap,Vo=new WeakSet,Dn=function(t){let r=o=>{switch(t.type){case "failed":return {...o,failureCount:t.failureCount,failureReason:t.error};case "pause":return {...o,isPaused:true};case "continue":return {...o,isPaused:false};case "pending":return {...o,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case "success":return {...o,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:false};case "error":return {...o,data:void 0,error:t.error,failureCount:o.failureCount+1,failureReason:t.error,isPaused:false,status:"error"}}};this.state=r(this.state),vt.batch(()=>{u(this,Do).forEach(o=>{o.onMutationUpdate(t);}),u(this,wr).notify({mutation:this,type:"updated",action:t});});},Fp);function fg(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Zo,Co,ta,Dp,Vp=(Dp=class extends vo{constructor(t={}){super();Z(this,Zo);Z(this,Co);Z(this,ta);this.config=t,A(this,Zo,new Set),A(this,Co,new Map),A(this,ta,0);}build(t,r,o){let n=new Op({client:t,mutationCache:this,mutationId:++Ts(this,ta)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){u(this,Zo).add(t);let r=ml(t);if(typeof r=="string"){let o=u(this,Co).get(r);o?o.push(t):u(this,Co).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(u(this,Zo).delete(t)){let r=ml(t);if(typeof r=="string"){let o=u(this,Co).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&u(this,Co).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=ml(t);if(typeof r=="string"){let n=u(this,Co).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=ml(t);return typeof r=="string"?u(this,Co).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){vt.batch(()=>{u(this,Zo).forEach(t=>{this.notify({type:"removed",mutation:t});}),u(this,Zo).clear(),u(this,Co).clear();});}getAll(){return Array.from(u(this,Zo))}find(t){let r={exact:true,...t};return this.getAll().find(o=>sl(r,o))}findAll(t={}){return this.getAll().filter(r=>sl(t,r))}notify(t){vt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return vt.batch(()=>Promise.all(t.map(r=>r.continue().catch(nr))))}},Zo=new WeakMap,Co=new WeakMap,ta=new WeakMap,Dp);function ml(e){return e.options.scope?.id}var Lo,Lp,Bp=(Lp=class extends vo{constructor(t={}){super();Z(this,Lo);this.config=t,A(this,Lo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Qs(n,r),i=this.get(a);return i||(i=new Tp({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){u(this,Lo).has(t.queryHash)||(u(this,Lo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=u(this,Lo).get(t.queryHash);r&&(t.destroy(),r===t&&u(this,Lo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){vt.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return u(this,Lo).get(t)}getAll(){return [...u(this,Lo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>il(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>il(t,o)):r}notify(t){vt.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){vt.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){vt.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Lo=new WeakMap,Lp);var Qt,Vn,Ln,ts,rs,Bn,os,ns,Ap,od=(Ap=class{constructor(e={}){Z(this,Qt);Z(this,Vn);Z(this,Ln);Z(this,ts);Z(this,rs);Z(this,Bn);Z(this,os);Z(this,ns);A(this,Qt,e.queryCache||new Bp),A(this,Vn,e.mutationCache||new Vp),A(this,Ln,e.defaultOptions||{}),A(this,ts,new Map),A(this,rs,new Map),A(this,Bn,0);}mount(){Ts(this,Bn)._++,u(this,Bn)===1&&(A(this,os,qi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,Qt).onFocus());})),A(this,ns,Gi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,Qt).onOnline());})));}unmount(){var e,t;Ts(this,Bn)._--,u(this,Bn)===0&&((e=u(this,os))==null||e.call(this),A(this,os,void 0),(t=u(this,ns))==null||t.call(this),A(this,ns,void 0));}isFetching(e){return u(this,Qt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return u(this,Vn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,Qt).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=u(this,Qt).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(bo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return u(this,Qt).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),a=u(this,Qt).get(o.queryHash)?.state.data,i=pp(t,a);if(i!==void 0)return u(this,Qt).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return vt.batch(()=>u(this,Qt).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,Qt).get(t.queryHash)?.state}removeQueries(e){let t=u(this,Qt);vt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=u(this,Qt);return vt.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=vt.batch(()=>u(this,Qt).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(nr).catch(nr)}invalidateQueries(e,t={}){return vt.batch(()=>(u(this,Qt).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=vt.batch(()=>u(this,Qt).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(nr)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(nr)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=u(this,Qt).build(this,t);return r.isStaleByTime(bo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(nr).catch(nr)}fetchInfiniteQuery(e){return e.behavior=rd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(nr).catch(nr)}ensureInfiniteQueryData(e){return e.behavior=rd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Gi.isOnline()?u(this,Vn).resumePausedMutations():Promise.resolve()}getQueryCache(){return u(this,Qt)}getMutationCache(){return u(this,Vn)}getDefaultOptions(){return u(this,Ln)}setDefaultOptions(e){A(this,Ln,e);}setQueryDefaults(e,t){u(this,ts).set(ii(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...u(this,ts).values()],r={};return t.forEach(o=>{ai(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){u(this,rs).set(ii(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...u(this,rs).values()],r={};return t.forEach(o=>{ai(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...u(this,Ln).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Qs(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===si&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...u(this,Ln).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){u(this,Qt).clear(),u(this,Vn).clear();}},Qt=new WeakMap,Vn=new WeakMap,Ln=new WeakMap,ts=new WeakMap,rs=new WeakMap,Bn=new WeakMap,os=new WeakMap,ns=new WeakMap,Ap);var nd=An.createContext(void 0),id=e=>{let t=An.useContext(nd);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},sd=({client:e,children:t})=>(An.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(nd.Provider,{value:e,children:t}));var Wp=An.createContext(false),Ep=()=>An.useContext(Wp);Wp.Provider;function gg(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var yg=An.createContext(gg()),Mp=()=>An.useContext(yg);var Up=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?cl(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Hp=e=>{An.useEffect(()=>{e.clearReset();},[e]);},Np=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||cl(r,[e.error,o]));var jp=e=>{if(e.suspense){let r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3));}},$p=(e,t)=>e.isLoading&&e.isFetching&&!t,qp=(e,t)=>e?.suspense&&t.isPending,ad=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Qp(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let o=Ep(),n=Mp(),a=id(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);let s=a.getQueryCache().get(i.queryHash);process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=o?"isRestoring":"optimistic",jp(i),Up(i,n,s),Hp(n);let l=!a.getQueryCache().get(i.queryHash),[m]=An.useState(()=>new t(a,i)),c=m.getOptimisticResult(i),C=!o&&e.subscribed!==false;if(An.useSyncExternalStore(An.useCallback(T=>{let y=C?m.subscribe(vt.batchCalls(T)):nr;return m.updateResult(),y},[m,C]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),An.useEffect(()=>{m.setOptions(i);},[i,m]),qp(i,c))throw ad(i,m,n);if(Np({result:c,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,c),i.experimental_prefetchInRender&&!Oo.isServer()&&$p(c,o)&&(l?ad(i,m,n):s?.promise)?.catch(nr).finally(()=>{m.updateResult();}),i.notifyOnChangeProps?c:m.trackResult(c)}function Xo(e,t){return Qp(e,ed)}var as=new Map;function Kp({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let a=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return a.start(),()=>a.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function En({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=F(),[m,c]=useState(false),[C,T]=useState(false),[y,b]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let R=as.get(e);return R?{uri:e,xml:R}:null}),k=e?.toLowerCase().endsWith(".svg"),h=k&&e&&y?.uri===e?y.xml:null;useEffect(()=>{c(false),T(false);},[e]),useEffect(()=>{if(!k||!e)return;if(as.has(e)){b({uri:e,xml:as.get(e)});return}let R=false;return fetch(e).then(x=>{if(!x.ok)throw new Error(`HTTP ${x.status}`);return x.text()}).then(x=>{R||(as.set(e,x),b({uri:e,xml:x}));}).catch(()=>{R||c(true);}),()=>{R=true;}},[e,k]);let p=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:p},s]});let g={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},d=t-n*2,f=r-n*2;return m?jsx(View,{style:[g,{backgroundColor:i||p}]}):k?jsxs(View,{style:g,children:[!!!h&&jsx(Kp,{width:d,height:f,borderRadius:o,color:p}),h?jsx(SvgXml,{xml:h,width:d,height:f,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:d,height:f,onError:()=>c(true)})]}):jsxs(View,{style:g,children:[!C&&jsx(Kp,{width:d,height:f,borderRadius:o,color:p}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:d,height:f},resizeMode:"contain",onLoad:()=>T(true),onError:()=>c(true)})]})}function dd(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(as.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{as.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Pr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:m,balanceChainId:c,balanceTokenAddress:C,publishableKey:T,projectName:y,leftIcon:b,onLeftAction:k}){let{colors:h,fonts:p,components:g}=F(),[d,f]=useState(null),[R,x]=useState(false),S=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!R)return;let _=Animated.loop(Animated.sequence([Animated.timing(S,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(S,{toValue:0,duration:700,useNativeDriver:true})]));return _.start(),()=>_.stop()},[R,S]),useEffect(()=>{if(!s||!l||!m||!c||!C||!T){f(null),x(false);return}let _=false;return x(true),La(l,m,c,C,T).then(W=>{if(_)return;let D=W.balance,O=null;D&&(D.amount_usd!=null&&D.amount_usd!==""?O=`$${D.amount_usd}`:O="$0.00"),f(O);}).catch(()=>{_||f(null);}).finally(()=>{_||x(false);}),()=>{_=true;}},[s,l,m,c,C,T]);let w=S.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(_s,{size:20,color:g.header.buttonColor,strokeWidth:2})}):b&&k?jsx(TouchableOpacity,{onPress:k,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:g.header.titleColor,fontFamily:p.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:p.regular}],children:i.count})})]}),t?jsx(Text,{style:[Sr.balanceText,{color:h.foregroundMuted,fontFamily:p.regular}],children:t}):null,s&&(R?jsx(Animated.View,{style:[Sr.balanceSkeleton,{backgroundColor:h.cardHover,opacity:w}]}):d!=null?jsxs(Text,{style:[Sr.balanceText,{color:h.foregroundMuted,fontFamily:p.regular}],children:[y?`${y} `:"","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(at,{size:20,color:g.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 ir({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=F(),s=a??i.card,l=s.backShadowColor!=="transparent",m={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},c=[Zp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],C=[m,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[Zp.backShadow,{top:s.backShadowOffset.top,left:s.backShadowOffset.left,right:s.backShadowOffset.right,bottom:s.backShadowOffset.bottom,backgroundColor:s.backShadowColor,borderRadius:s.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:C,children:e}):jsx(View,{style:C,children:e})]})}var Zp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function oa({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card,s=o?[...o].sort((l,m)=>l.position-m.position):[];return jsxs(ir,{cardTokens:i,onPress:e,style:Bo.wrapper,contentStyle:Bo.container,children:[jsxs(View,{style:Bo.leftContent,children:[jsx(View,{style:[Bo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(ac,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Bo.textContainer,children:[jsx(Text,{style:[Bo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Bo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Bo.rightContent,children:jsx(View,{style:Bo.networkIcons,children:s.map((l,m)=>{let c=l.icon_urls.find(C=>C.format==="png")?.url||l.icon_urls.find(C=>C.format==="svg")?.url;return jsx(View,{style:[Bo.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:s.length-m}],children:jsx(En,{uri:te(c),width:20,height:20})},l.name)})})})]})}var Bo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},networkIcons:{flexDirection:"row",alignItems:"center"},networkIconWrapper:{}});function ia({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsxs(ir,{cardTokens:i,onPress:e,style:en.wrapper,contentStyle:en.container,children:[jsxs(View,{style:en.leftContent,children:[jsx(View,{style:[en.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Pi,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:en.textContainer,children:[jsx(Text,{style:[en.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[en.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:en.rightContent,children:jsx(View,{style:en.paymentIcons,children:o?.map(s=>{let l=s.icon_urls.find(m=>m.format==="png")?.url||s.icon_urls.find(m=>m.format==="svg")?.url;return jsx(En,{uri:te(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var en=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},paymentIcons:{flexDirection:"row",alignItems:"center",gap:6}});function sa({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsx(ir,{cardTokens:i,onPress:e,style:tn.wrapper,contentStyle:tn.container,children:jsxs(View,{style:tn.leftContent,children:[jsxs(View,{style:[tn.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(zr,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[tn.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[tn.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:tn.textContainer,children:[jsx(Text,{style:[tn.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[tn.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var tn=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,alignItems:"center",justifyContent:"center",paddingHorizontal:4},badgeText:{color:"#FFFFFF",fontSize:10,fontWeight:"600"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"}});function la({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=F(),a=n.depositMenu.card;return jsxs(ir,{cardTokens:a,onPress:e,style:Ao.wrapper,contentStyle:Ao.container,children:[jsxs(View,{style:Ao.leftContent,children:[jsx(View,{style:[Ao.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(Ra,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Ao.textContainer,children:[jsx(Text,{style:[Ao.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Ao.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Ao.rightContent,children:jsx(View,{style:Ao.badge,children:jsx(Text,{style:[Ao.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Ao=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var rm=1e4,om=2500,nm=3e3,im=6e4;function ca(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:m,setDepositExecutions:c,setTrackedExecutions:C,setLatestExecution:T,setShowStatusSheet:y,onDepositSuccess:b,onExecutionsChange:k,onDepositError:h}=e,[p,g]=useState(false),[d,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;g(false),t==="auto_ui"&&f(false);let x=setTimeout(()=>{g(true),t==="auto_ui"&&f(true);},rm);return ()=>clearTimeout(x)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let x=new Date(i.getTime()-im),S=setInterval(async()=>{try{let W=[...(await Qo(n,a)).data??[]].sort((O,v)=>{let q=O.created_at?new Date(O.created_at).getTime():0;return (v.created_at?new Date(v.created_at).getTime():0)-q}),D=null;for(let O of W){let v=O.created_at?new Date(O.created_at):null;if(!v||v<=x)continue;let q=m.get(O.id);if(!q){D=O;break}if(["pending","waiting","delayed"].includes(q)&&O.status==="succeeded"){D=O;break}}if(D){let O=D;c(v=>{let q=v.findIndex(N=>N.id===O.id);if(q>=0){let N=[...v];return N[q]=O,N}return [...v,O]}),C(v=>{let q=new Map(v);return q.set(O.id,O.status),q}),T(O),y(!0),O.status==="succeeded"&&b?.({message:"Deposit completed successfully",executionId:O.id}),k?.([...l,O]);}}catch(w){h?.({message:"Failed to check deposit status",error:w});}},om);return ()=>clearInterval(S)},[n,a,i,m,l,k,b,h]),useEffect(()=>{if(!p||!s)return;let x=async()=>{try{await Fa(s,a);}catch{}};x();let S=setInterval(x,nm);return ()=>clearInterval(S)},[p,s,a]),{pollingEnabled:p,showWaitingUi:d,handleIveDeposited:()=>{g(true),f(true);}}}function us({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=F(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",m=n||s;return jsxs(View,{style:[am.container,{width:t,height:t}],children:[jsx(Fg,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[am.logoContainer,{width:o+12,height:o+12,backgroundColor:m,borderRadius:(o+12)/2}],children:jsx(En,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var am=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function dm(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function Lg(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),a=e.getHours(),i=e.getMinutes(),s=a>=12?"pm":"am";a=a%12,a=a||12;let l=i<10?`0${i}`:i;return `${r} ${o}, ${n} at ${a}:${l}${s}`}function ps({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:m}){let{colors:c,fonts:C,components:T}=F(),[y,b]=useState(false),k=t==="pending"||t==="waiting"||t==="delayed",h=t==="succeeded",p=()=>{o&&Linking.openURL(o);},g=()=>{n&&Linking.openURL(n);};return jsx(ht,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:m,children:jsxs(View,{style:Wt.container,children:[jsx(TouchableOpacity,{style:Wt.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:T.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Wt.iconContainer,children:k?jsx(kt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:te(r)},style:Wt.tokenIconFill}):jsx(View,{style:[Wt.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:te(r)},style:Wt.tokenIconLarge}):jsx(View,{style:[Wt.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[Wt.statusBadge,{backgroundColor:T.container.iconBackgroundColor}],children:jsx(Ue,{size:16,color:T.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Wt.title,{color:T.container.titleColor,fontFamily:C.semibold}],children:k?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Wt.amount,{color:T.container.titleColor,fontFamily:C.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[Wt.date,{color:T.container.subtitleColor,fontFamily:C.regular}],children:Lg(a)}),jsx(Text,{style:[Wt.subtitle,{color:T.container.subtitleColor,fontFamily:C.regular}],children:k?"This usually takes less than a minute.":"Your account has been credited successfully!"}),h&&(o||n)&&jsxs(View,{style:Wt.detailsSection,children:[jsx(View,{style:[Wt.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:Wt.detailsToggle,onPress:()=>b(!y),children:[jsx(Text,{style:[Wt.detailsToggleText,{color:T.container.actionTitle,fontFamily:C.medium}],children:y?"See less":"See more details"}),y?jsx(To,{size:18,color:T.container.actionColor,strokeWidth:2}):jsx(At,{size:18,color:T.container.actionColor,strokeWidth:2})]}),y&&jsxs(View,{style:Wt.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Wt.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:p,children:[jsx(Text,{style:[Wt.txLabel,{color:T.card.titleColor,fontFamily:C.medium}],children:"Deposit tx"}),jsx(Text,{style:[Wt.txHash,{color:T.card.subtitleColor,fontFamily:C.regular}],children:dm(o)}),jsx(ko,{size:16,color:T.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Wt.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:g,children:[jsx(Text,{style:[Wt.txLabel,{color:T.card.titleColor,fontFamily:C.medium}],children:"Completion tx"}),jsx(Text,{style:[Wt.txHash,{color:T.card.subtitleColor,fontFamily:C.regular}],children:dm(n)}),jsx(ko,{size:16,color:T.card.actionColor,strokeWidth:2})]})]})]})]})})}var Wt=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});function wl({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=F();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[bi.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[bi.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[bi.processingCard,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor,shadowColor:s.card.shadowOpacity>0?s.card.shadowColor:void 0,shadowOffset:s.card.shadowOpacity>0?s.card.shadowOffset:void 0,shadowOpacity:s.card.shadowOpacity,shadowRadius:s.card.shadowRadius,elevation:s.card.elevation}],children:[jsx(View,{style:[bi.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(lc,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:bi.processingCardText,children:[jsx(Text,{style:[bi.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[bi.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var bi=StyleSheet.create({iveDepositedButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginBottom:12},iveDepositedButtonText:{fontSize:16},processingCard:{flexDirection:"row",alignItems:"center",padding:12,marginBottom:12,gap:12},processingCardText:{flex:1,gap:4},processingCardTitle:{fontSize:14},processingCardSubtitle:{fontSize:12,lineHeight:18},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"}});var da=(e,t)=>`${t}:${e}`,Ng=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function kl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:c="auto_ui",onExecutionsChange:C,onDepositSuccess:T,onDepositError:y,borderTopLeftRadius:b,borderTopRightRadius:k,sheetBorderRadius:h}){let{colors:p,fonts:g,components:d}=F(),f=s&&l?`${s}:${l}`:"solana:mainnet",[R,x]=useState("USDC"),[S,w]=useState(f),[_,W]=useState([]),[D,O]=useState(true),[v,q]=useState([]),[N,ae]=useState(true),[ze,ve]=useState(false),[J,Ve]=useState(false),[me,_e]=useState(false),[Ne,Se]=useState(false),[oe,Pe]=useState([]),[rt,je]=useState(new Map),[ot]=useState(()=>new Date),[$e,Fe]=useState(null),[ct,Re]=useState(false),[X,ce]=useState(null),[st,Je]=useState(false),Le=new Map;v.forEach(M=>{M.chains.forEach(ee=>{let ke=`${ee.chain_type}:${ee.chain_id}`;Le.has(ke)||Le.set(ke,ee);});});let be=Array.from(Le.values()),ie=Ng(S),zt=be.find(M=>M.chain_type===ie.chainType&&M.chain_id===ie.chainId)?.chain_type||"ethereum",ue=qo(_,zt),se=ue?.address||"",ye=useRef(false);useEffect(()=>{async function M(){try{ae(!0),Fe(null);let ke=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(q(ke.data),ke.data.length>0&&!ye.current){ye.current=!0;let fe,_t;if(s&&l)if(m)for(let V of ke.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l&&z.token_address.toLowerCase()===m.toLowerCase());if(Or){fe=V,_t=Or;break}}else for(let V of ke.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l);if(Or){fe=V,_t=Or;break}}if(!fe&&a)for(let V of ke.data){let Or=V.chains.find(z=>z.token_address.toLowerCase()===a.toLowerCase());if(Or){fe=V,_t=Or;break}}fe||(fe=ke.data.find(V=>V.symbol==="USDC"),fe&&fe.chains.length>0&&(_t=fe.chains[0])),fe||(fe=ke.data.find(V=>V.symbol==="USDT"),fe&&fe.chains.length>0&&(_t=fe.chains[0])),fe||(fe=ke.data[0],fe.chains.length>0&&(_t=fe.chains[0])),fe&&x(fe.symbol),_t&&w(da(_t.chain_id,_t.chain_type));}}catch(ee){console.error("Error fetching supported tokens:",ee),Fe("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:ee});}finally{ae(false);}}M();},[t,y,s,l,m,a,n,o]),useEffect(()=>{async function M(){try{O(!0),Fe(null);let ee=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);W(ee.data);}catch(ee){console.error("Error fetching wallets:",ee),Fe("Failed to load wallets"),y?.({message:"Failed to load wallets",error:ee});}finally{O(false);}}M();},[e,r,o,n,a,t,y]);let yt=ue?.id??"",{showWaitingUi:dt,handleIveDeposited:le}=ca({depositConfirmationMode:c,depositAddress:se,chain:S,externalUserId:e,publishableKey:t,modalOpenedAt:ot,depositWalletId:yt,depositExecutions:oe,trackedExecutions:rt,setDepositExecutions:Pe,setTrackedExecutions:je,setLatestExecution:ce,setShowStatusSheet:Re,onDepositSuccess:T,onExecutionsChange:C,onDepositError:y});useEffect(()=>{if(!v.length)return;let M=v.find(ke=>ke.symbol===R);if(!M||M.chains.length===0)return;if(!M.chains.some(ke=>da(ke.chain_id,ke.chain_type)===S)){let ke=M.chains[0];w(da(ke.chain_id,ke.chain_type));}},[R,v,S]);let qe=v.find(M=>M.symbol===R),yr=qe?.chains||[],xt=yr.find(M=>da(M.chain_id,M.chain_type)===S),xr=async()=>{if(se)try{Clipboard.setString(se),ve(!0),setTimeout(()=>ve(!1),2e3);}catch(M){console.error("Failed to copy:",M);}},$=xt?.estimated_price_impact_percent??0,re=xt?.max_slippage_percent??.25,et=xt?.minimum_deposit_amount_usd??3;if(N)return jsxs(View,{style:L.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:p.primary}),jsx(Text,{style:[L.loadingText,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Loading currencies..."})]});if($e&&v.length===0)return jsxs(View,{style:L.errorContainer,children:[jsx(Text,{style:[L.errorText,{color:p.error,fontFamily:g.regular}],children:$e}),jsx(Text,{style:[L.errorHint,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Please check your network connection and try again."})]});let pe=()=>jsxs(ht,{visible:me,onClose:()=>_e(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.tokenSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.tokenSelector?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>_e(false),style:L.sheetCloseButton,children:jsx(at,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(gt,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:v.map(M=>jsxs(TouchableOpacity$1,{onPress:()=>{x(M.symbol),_e(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:R===M.symbol?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:te(Ce(M,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:M.symbol}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:g.regular}],children:[M.chains.length," network",M.chains.length!==1?"s":""," available"]})]}),R===M.symbol&&jsx(Ue,{size:20,color:p.primary,strokeWidth:2})]},M.symbol))})]}),Me=()=>jsxs(ht,{visible:Ne,onClose:()=>Se(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.chainSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.chainSelector?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>Se(false),style:L.sheetCloseButton,children:jsx(at,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(gt,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:yr.map(M=>{let ee=da(M.chain_id,M.chain_type),ke=S===ee;return jsxs(TouchableOpacity$1,{onPress:()=>{w(ee),Se(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:ke?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:te(Ce(M,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:M.chain_name}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:g.regular}],children:["Min deposit: $",M.minimum_deposit_amount_usd]})]}),ke&&jsx(Ue,{size:20,color:p.primary,strokeWidth:2})]},ee)})})]});return jsxs(View,{style:L.container,children:[jsxs(View,{style:L.selectorSection,children:[jsx(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:g.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>_e(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[qe&&jsx(Image,{source:{uri:te(Ce(qe,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:g.medium}],children:R}),jsx(At,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:L.selectorSection,children:[jsxs(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:g.regular}],children:["Network"," ",jsxs(Text,{style:[L.minDeposit,{fontFamily:g.regular}],children:["($",et," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>Se(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[xt&&jsx(Image,{source:{uri:te(Ce(xt,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:g.medium}],numberOfLines:1,children:xt?.chain_name||"Select network"}),jsx(At,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:L.qrContainer,children:jsx(View,{style:[L.qrWrapper,{backgroundColor:p.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:D?jsxs(View,{style:L.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:p.primary}),jsx(Text,{style:[L.loadingText,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Loading..."})]}):se?jsx(us,{value:se,size:160,logoUri:te(Ce(xt,"png")||Yt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:L.qrLoading,children:jsx(Text,{style:[L.errorText,{color:p.error,fontFamily:g.regular}],children:"No address available"})})})}),jsxs(View,{style:L.addressSection,children:[jsxs(View,{style:L.addressHeader,children:[jsx(Text,{style:[L.addressLabel,{color:d.card.labelColor,fontFamily:g.medium}],children:"Deposit Address"}),ze&&jsxs(View,{style:L.copiedIndicator,children:[jsx(Ue,{size:14,color:p.success,strokeWidth:2}),jsx(Text,{style:[L.copiedText,{color:p.success,fontFamily:g.regular}],children:"Copied"})]})]}),jsxs(ir,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!D&&se?xr:void 0,contentStyle:L.addressBox,children:[jsx(Text,{style:[L.addressText,{color:d.card.titleColor,fontFamily:g.regular}],numberOfLines:2,children:D?"Loading...":se||"No address available"}),jsx(View,{style:L.addressCopyIcon,children:jsx(No,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[L.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Ve(!J),style:L.detailsHeader,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:L.chevronContainer,children:J?jsx(To,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(At,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),J&&jsxs(View,{style:L.detailsContent,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Price impact: ",$.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Slippage: Auto \u2022 ",re.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(wl,{depositConfirmationMode:c,depositAddress:se,showWaitingUi:dt,latestExecution:X,onIveDeposited:le}),jsx(TouchableOpacity$1,{style:L.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[L.termsText,{color:p.primary,fontFamily:g.regular}],children:"Terms apply"})}),pe(),Me(),jsxs(ht,{visible:st,onClose:()=>Je(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:h?.infoSheet?.borderTopLeftRadius??b,borderTopRightRadius:h?.infoSheet?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Je(false),style:L.sheetCloseButton,children:jsx(at,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:L.infoSheetContent,children:[jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:"Price Impact"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:g.medium}],children:[$.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:g.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:"Max Slippage"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:g.medium}],children:[re.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:g.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),X&&jsx(ps,{visible:ct,status:X.status,tokenIconUrl:X.destination_token_metadata?.icon_urls?.find(M=>M.format==="png")?.url||X.destination_token_metadata?.icon_url||Ce(qe,"png"),explorerUrl:X.explorer_url,completionExplorerUrl:X.destination_explorer_url,date:X.created_at?new Date(X.created_at):void 0,amountUsd:X.source_amount_usd?parseFloat(X.source_amount_usd):void 0,onClose:()=>Re(false),borderTopLeftRadius:h?.depositStatus?.borderTopLeftRadius??b,borderTopRightRadius:h?.depositStatus?.borderTopRightRadius??k})]})}var L=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{flex:1,paddingTop:8},sheetListContent:{paddingBottom:56},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function Tl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=F();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ci.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:Ci.leftContent,children:[jsx(View,{style:[Ci.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:te(Ce(e,"png"))},style:Ci.icon})}),jsxs(View,{style:Ci.textContainer,children:[jsx(Text,{style:[Ci.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ci.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(Ue,{size:16,color:o.primary,strokeWidth:2})]})}var Ci=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,marginHorizontal:8,marginVertical:4},leftContent:{flexDirection:"row",alignItems:"center",gap:12},iconContainer:{width:40,height:40,borderRadius:20,overflow:"hidden",alignItems:"center",justifyContent:"center"},icon:{width:40,height:40,borderRadius:20},textContainer:{gap:2},name:{fontSize:14,fontWeight:"400"},code:{fontSize:12,fontWeight:"300"}});function pa({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=F();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:fm.headerContainer,children:jsx(Text,{style:[fm.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(Tl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var fm=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function _l({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:c}=F(),[C,T]=useState(""),y=o.map(f=>r.find(R=>R.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),b=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),k=f=>{if(!C)return f;let R=C.toLowerCase();return f.filter(x=>x.name.toLowerCase().includes(R)||x.currency_code.toLowerCase().includes(R))},h=k(y),p=k(b),g=f=>{a(f),t(false),T("");},d=()=>{t(false),T("");};return jsxs(ht,{visible:e,onClose:d,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(Pr,{title:"Currency",showBack:false,onClose:d}),jsx(View,{style:wi.searchContainer,children:jsx(TextInput,{style:[wi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:m.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:C,onChangeText:T,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(gt,{style:wi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:wi.listContent,children:[jsx(pa,{title:"Popular currencies",currencies:h,selectedCurrency:n,onSelect:g}),h.length>0&&p.length>0&&jsx(View,{style:wi.sectionSpacer}),jsx(pa,{title:"All currencies",currencies:p,selectedCurrency:n,onSelect:g}),h.length===0&&p.length===0&&jsx(View,{style:wi.noResultsContainer,children:jsx(Text,{style:[wi.noResultsText,{color:c.container.subtitleColor,fontFamily:m.regular}],children:"No currencies found"})})]})})]})}var wi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:72},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function Od(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e.toUpperCase(),minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/\d/g,"").trim()}catch{return e.toUpperCase()}}function vl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:m,onDepositError:c,borderTopLeftRadius:C,borderTopRightRadius:T,sheetBorderRadius:y}){let{colors:b,fonts:k,components:h}=F(),[p,g]=useState(""),[d,f]=useState("usd"),[R,x]=useState(false),[S,w]=useState(false),[_,W]=useState([]),[D,O]=useState(false),[v,q]=useState(null),[N,ae]=useState(null),[ze,ve]=useState("amount"),[J,Ve]=useState(null),[me,_e]=useState(true),[Ne,Se]=useState(null),[oe,Pe]=useState(false),rt=useRef(null),je=useRef(false);useEffect(()=>{rt.current=J;},[J]),useEffect(()=>{je.current=oe;},[oe]);let[ot,$e]=useState([]),[Fe,ct]=useState(true),[Re,X]=useState(60),[ce,st]=useState([]),[Je,Le]=useState([]),[be,ie]=useState(null),[de,zt]=useState(null),[ue,se]=useState(true),[ye,yt]=useState(null),[dt,le]=useState(false),[qe,yr]=useState(null),[xt,xr]=useState(false),[$,re]=useState(false),[et,pe]=useState(false),[Me,M]=useState(null),ee=r??ze,ke=useRef(null),fe=ce.find(Q=>Q.currency_code.toLowerCase()===d.toLowerCase()),_t=useCallback(Q=>{ve(Q),Q==="quotes"?o?.(Q,_.length):o?.(Q);},[_.length,o]);useEffect(()=>{async function Q(){try{let ge=await Ls();zt(ge);}catch(ge){console.error("Error fetching user IP:",ge);}finally{se(false);}}Q();},[]),useEffect(()=>{async function Q(){try{let ge=await $o({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);$e(ge.data);}catch(ge){console.error("Error fetching wallets:",ge),q("Failed to load wallet addresses");}finally{ct(false);}}Q();},[e,a,i,s,l,t]);let V=n||be?.symbol.toUpperCase()||"USDC",Or=Li(be?.icon_urls,"png")||be?.icon_url,z=Li(be?.chain_icon_urls,"png")||be?.chain_icon_url;useEffect(()=>{async function Q(){try{let ge=await bc(t);st(ge.data),Le(ge.preferred||[]);}catch(ge){console.error("Error fetching fiat currencies:",ge);}}Q();},[t]),useEffect(()=>{if(R||ce.length===0||!de?.alpha2)return;let Q=de.alpha2.toUpperCase(),ge=ce.find(Bt=>Bt.country_codes.includes(Q));if(ge)f(ge.currency_code.toLowerCase()),!p&&!S&&g(String(ge.default_amount??100));else if(!p&&!S){let Bt=ce.find(po=>po.currency_code.toLowerCase()==="usd");Bt&&g(String(Bt.default_amount??100));}},[ce,de,R,p,S]),useEffect(()=>{if(ce.length!==0){if(ke.current!==null&&ke.current!==d){let Q=ce.find(ge=>ge.currency_code.toLowerCase()===d.toLowerCase());Q&&g(String(Q.default_amount??100));}ke.current=d;}},[d,ce]),useEffect(()=>{async function Q(){try{let ge=await fc({chain_type:i||"",chain_id:s||"",token_address:l||""},t);ie(ge);}catch(ge){console.error("Error fetching supported tokens:",ge);}}Q();},[i,s,l,t]),useEffect(()=>{async function Q(){if(!(!l||!s||!i)&&!ue){le(true);try{let ge=await yc({country_code:de?.alpha2?.toUpperCase()||"US",subdivision_code:de?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);yt(ge);}catch(ge){console.error("Error fetching default onramp token:",ge);}finally{le(false);}}}Q();},[l,s,i,de,ue,t]),useEffect(()=>{let Q=parseFloat(p);if(isNaN(Q)||Q<=0){W([]),ae(null);return}if(!ye||dt){W([]),Ve(null);return}let ge=ce.find(po=>po.currency_code.toLowerCase()===d.toLowerCase());if(ge){if(Q<ge.minimum_amount){W([]),Ve(null),ae(`Minimum amount is ${Od(d)}${ge.minimum_amount.toLocaleString()}`);return}if(Q>ge.maximum_amount){W([]),Ve(null),ae(`Maximum amount is ${Od(d)}${ge.maximum_amount.toLocaleString()}`);return}}ae(null);let Bt=setTimeout(()=>{Ot(Q);},500);return ()=>clearTimeout(Bt)},[p,d,t,ye,dt,ce]);let Ot=async Q=>{if(!ye){q("Loading token information...");return}O(true),q(null);try{let ge={country_code:de?.alpha2?.toUpperCase()||"US",source_amount:Q.toString(),source_currency:d.toLowerCase(),destination_currency:ye.destination_currency,destination_network:ye.destination_network,subdivision_code:de?.state||void 0},Bt=await hc(ge,t);W(Bt.data);let po=je.current,ks=rt.current;if(po&&ks){let mo=Bt.data.find(fn=>fn.service_provider===ks.service_provider);if(mo){if(Ve(mo),Bt.data.length>0){let fn=Bt.data[0];Ne||Se(fn.service_provider),_e(mo.service_provider===Ne);}}else if(Bt.data.length>0){let fn=Bt.data[0];Ve(fn),Se(fn.service_provider),_e(!0),Pe(!1);}}else if(Bt.data.length>0){let mo=Bt.data[0];Ve(mo),Se(mo.service_provider),_e(!0);}X(60);}catch(ge){console.error("Failed to fetch quotes:",ge),q("Failed to fetch quotes. Please try again."),W([]);}finally{O(false);}};useEffect(()=>{if(_.length===0)return;let Q=setInterval(()=>{X(ge=>{if(ge<=1){let Bt=parseFloat(p);return !isNaN(Bt)&&Bt>0&&Ot(Bt),60}return ge-1});},1e3);return ()=>clearInterval(Q)},[_.length,p]);let St=Q=>{(/^\d*\.?\d{0,2}$/.test(Q)||Q==="")&&(g(Q),w(true));},Mr=Q=>{g(Q.toString()),w(true);},er=async()=>{if(J&&ye)try{let Q=ye.destination_token_metadata.chain_type,ge=qo(ot,Q);if(!ge?.address){q("Wallet address not available");return}let Bt={service_provider:J.service_provider,country_code:J.country_code?.toUpperCase()||de?.alpha2?.toUpperCase()||"US",source_currency:J.source_currency,source_amount:p,destination_currency:J.destination_currency,destination_network:J.destination_network,wallet_address:ge.address,subdivision_code:de?.state||void 0},po=await gc(Bt,t);yr({provider:J,sourceCurrency:d,sourceAmount:p,sessionUrl:po.url}),M(po.url),pe(!0);}catch(Q){console.error("Failed to create session:",Q),q("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:Q});}},Ii=Od(d),uo=()=>{pe(false),_t("onramp"),m?.({message:"Payment flow completed"});},Ho=()=>jsx(oy,{visible:et,onClose:uo,url:Me,providerName:J?.service_provider_display_name||"Complete Payment",colors:b,fonts:k,borderTopLeftRadius:y?.webView?.borderTopLeftRadius??C,borderTopRightRadius:y?.webView?.borderTopRightRadius??T});return ee==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:j.amountViewContainer,children:[jsxs(gt,{style:j.scrollContainer,contentContainerStyle:j.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:j.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>xr(true),style:[j.currencyButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.input.borderRadius,borderWidth:h.input.borderWidth,borderColor:h.input.borderColor}],children:[fe&&jsx(Image,{source:{uri:te(Ce(fe,"png"))},style:j.currencyIcon}),jsx(Text,{style:[j.currencyText,{color:h.card.titleColor,fontFamily:k.medium}],children:d.toUpperCase()}),jsx(At,{size:16,color:h.card.actionColor,strokeWidth:2})]})}),jsx(_l,{open:xt,onOpenChange:xr,currencies:ce,preferredCurrencyCodes:Je,selectedCurrency:d,onSelectCurrency:Q=>{f(Q.toLowerCase()),x(true);},borderTopLeftRadius:y?.currencyModal?.borderTopLeftRadius??C,borderTopRightRadius:y?.currencyModal?.borderTopRightRadius??T}),jsx(View,{style:j.amountContainer,children:jsxs(View,{style:j.amountInputRow,children:[jsx(Text,{style:[j.currencySymbol,{color:h.container.titleColor,fontFamily:k.medium}],children:Ii}),jsx(TextInput,{style:[j.amountInput,{color:h.container.titleColor,fontFamily:k.medium}],value:p,onChangeText:St,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:b.foregroundMuted})]})}),fe?.suggested_amounts&&fe.suggested_amounts.length>0&&jsx(View,{style:j.quickAmounts,children:fe.suggested_amounts.map(Q=>jsx(TouchableOpacity$1,{onPress:()=>Mr(Q),style:[j.quickAmountButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.button.borderRadius,borderWidth:parseFloat(p)===Q?2:h.button.borderWidth,borderColor:parseFloat(p)===Q?b.primary:h.button.borderColor}],children:jsxs(Text,{style:[j.quickAmountText,{color:h.card.titleColor,fontFamily:k.medium}],children:[Ii,Q.toLocaleString()]})},Q))}),N&&jsx(Text,{style:[j.validationError,{color:b.error,fontFamily:k.regular}],children:N}),jsxs(View,{style:j.providerSection,children:[jsxs(View,{style:j.providerHeader,children:[jsx(Text,{style:[j.providerLabel,{color:h.card.labelColor,fontFamily:k.medium}],children:"Provider"}),_.length>0&&!D&&jsxs(Text,{style:[j.refreshText,{color:h.card.labelRightColor,fontFamily:k.regular}],children:["Refreshing in ",Re,"s"]})]}),jsx(ir,{cardTokens:h.depositCard.quoteProvider.card,onPress:D||_.length===0?void 0:()=>re(true),contentStyle:StyleSheet.flatten([j.providerButton,(D||_.length===0)&&j.disabled]),children:D?jsxs(View,{style:j.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[j.loadingText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"Finding best rates..."})]}):J?jsxs(View,{style:j.providerContent,children:[jsxs(View,{style:j.providerInfo,children:[me&&jsx(Text,{style:[j.autoPickedText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"Auto-picked for you"}),jsxs(View,{style:j.providerRow,children:[jsx(Image,{source:{uri:te(Oa(J.icon_urls,"png",J.icon_url))},style:j.providerIconImage},`provider-${J.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[j.providerName,{color:h.card.titleColor,fontFamily:k.medium}],children:J.service_provider_display_name}),jsxs(Text,{style:[j.bestPriceText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:[J.destination_amount.toFixed(2)," ",V]})]})]})]}),jsx(_r,{size:20,color:h.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[j.noProviderText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:parseFloat(p)>0?"No providers available":"Enter an amount to see providers"})}),v&&jsx(Text,{style:[j.errorText,{color:b.error,fontFamily:k.regular}],children:v})]}),jsxs(ht,{visible:$,onClose:()=>re(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:y?.providerModal?.borderTopLeftRadius??C,borderTopRightRadius:y?.providerModal?.borderTopRightRadius??T,children:[jsx(Pr,{title:"Select Provider",showBack:false,onClose:()=>re(false)}),jsx(gt,{style:j.providerModalList,contentContainerStyle:j.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:j.quotesList,children:_.map(Q=>{let ge=J?.service_provider===Q.service_provider;return jsxs(ir,{cardTokens:h.depositCard.quoteProvider.card,onPress:()=>{Ve(Q),Pe(true),_e(Q.service_provider===Ne),re(false);},contentStyle:StyleSheet.flatten([j.quoteItem,ge&&{borderWidth:2,borderColor:b.primary}]),children:[jsxs(View,{style:j.quoteLeft,children:[jsx(Image,{source:{uri:te(Oa(Q.icon_urls,"png",Q.icon_url))},style:j.providerIconImage}),jsx(View,{children:jsx(Text,{style:[j.quoteName,{color:h.card.titleColor,fontFamily:k.medium}],children:Q.service_provider_display_name})})]}),jsxs(View,{style:j.quoteRight,children:[jsxs(Text,{style:[j.quoteAmount,{color:h.card.textRightColor,fontFamily:k.medium}],children:[Q.destination_amount.toFixed(2)," ",V]}),jsxs(Text,{style:[j.quoteSource,{color:h.card.subtextRightColor,fontFamily:k.regular}],children:["Fee: ",Ii,Q.total_fee.toFixed(2)]})]})]},Q.service_provider)})})})]})]}),jsx(View,{style:[j.continueButtonContainer,{backgroundColor:b.background}],children:jsx(View,{style:{opacity:D||Fe||!J||parseFloat(p)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:er,disabled:D||Fe||!J||parseFloat(p)<=0,style:[j.continueButton,{backgroundColor:h.container.buttonColor,borderRadius:h.button.borderRadius,borderWidth:h.button.borderWidth,borderColor:h.button.borderColor}],children:jsx(Text,{style:[j.continueButtonText,{color:h.container.buttonTitleColor,fontFamily:k.medium}],children:Fe?"Loading...":"Continue"})})})})]}),Ho()]}):ee==="onramp"&&qe?jsxs(View,{style:j.onrampContainer,children:[jsx(Image,{source:{uri:te(Oa(qe.provider.icon_urls,"png",qe.provider.icon_url))},style:j.onrampProviderIcon}),jsxs(Text,{style:[j.onrampTitle,{color:h.container.titleColor,fontFamily:k.medium}],children:["Complete transaction with ",qe.provider.service_provider_display_name]}),jsx(Text,{style:[j.onrampSubtitle,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"You can close this modal."}),jsxs(View,{style:[j.flowDiagram,{backgroundColor:h.card.backgroundColor}],children:[jsxs(View,{style:j.flowStep,children:[jsx(Image,{source:{uri:Yt(`/icons/currencies/png/${qe.sourceCurrency.toLowerCase()}.png`)},style:j.flowIconImage}),jsx(Text,{style:[j.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You use"}),jsx(Text,{style:[j.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:qe.sourceCurrency.toUpperCase()})]}),jsx(_r,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:j.flowStep,children:[jsxs(View,{style:j.flowIconWithBadge,children:[jsx(Image,{source:{uri:Li(ye?.destination_token_metadata?.icon_urls,"png")||ye?.destination_token_metadata?.icon_url||Yt("/icons/tokens/png/usdc.png")},style:j.flowIconImageNoBadge}),jsx(Image,{source:{uri:Li(ye?.destination_token_metadata?.chain?.icon_urls,"png")||ye?.destination_token_metadata?.chain?.icon_url||Yt("/icons/networks/png/polygon.png")},style:[j.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[j.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You buy"}),jsx(Text,{style:[j.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:"USDC"})]}),jsx(_r,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:j.flowStep,children:[jsxs(View,{style:j.flowIconWithBadge,children:[jsx(Image,{source:{uri:Or||Yt("/icons/tokens/png/usdc.png")},style:j.flowIconImageNoBadge}),jsx(Image,{source:{uri:z||Yt("/icons/networks/png/polygon.png")},style:[j.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[j.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You receive"}),jsx(Text,{style:[j.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:V})]})]}),jsx(View,{style:[j.onrampInfoBox,{backgroundColor:h.card.backgroundColor,borderRadius:h.card.borderRadius,borderWidth:h.card.borderWidth,borderColor:h.card.borderColor}],children:jsx(Text,{style:[j.onrampInfoText,{color:h.card.descriptionColor,fontFamily:k.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function oy({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(ht,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:Si.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:Si.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ue,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Si.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:Si.headerSpacer})]}),r&&jsx(View,{style:Si.container,children:jsx(WebView,{source:{uri:r},style:Si.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Si.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var Si=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),j=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8},currencyText:{fontSize:14,fontWeight:"500"},currencyIcon:{width:24,height:24,borderRadius:12},amountContainer:{alignItems:"center",marginBottom:24},amountInputRow:{flexDirection:"row",alignItems:"center",marginBottom:8},currencySymbol:{fontSize:48,fontWeight:"300"},amountInput:{fontSize:48,fontWeight:"300",minWidth:50},usdcPreview:{fontSize:14},quickAmounts:{flexDirection:"row",justifyContent:"center",gap:12,marginBottom:24},quickAmountButton:{paddingHorizontal:20,paddingVertical:10},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:48},continueButton:{paddingVertical:16,alignItems:"center"},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{flex:1,paddingHorizontal:12,marginTop:8},providerModalListContent:{paddingBottom:72},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function ay(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function ly(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ol({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=F(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=te(Ce(e.destination_token_metadata,"png")||Yt("/icons/tokens/png/usdc.png")),m=i?"Deposit Processing":"Deposit Completed",c=ay(e.created_at||new Date().toISOString()),C=ly(e.source_amount_usd);return jsxs(ir,{cardTokens:a,onPress:t,contentStyle:sn.container,children:[jsxs(View,{style:sn.iconContainer,children:[jsx(Image,{source:{uri:l},style:sn.tokenIcon}),jsx(View,{style:[sn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Ue,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:sn.textContainer,children:[jsx(Text,{style:[sn.title,{color:a.titleColor,fontFamily:o.medium}],children:m}),jsx(Text,{style:[sn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:sn.rightContainer,children:[jsx(Text,{style:[sn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:C}),jsx(_r,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var sn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});function bm(e,t){let r={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||r[e]||e:r[e]||e}function Cm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function dy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var wm=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Sm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function uy(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function py({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,a=t.cardHover;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:ki.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[ki.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[ki.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:ki.textBlock,children:[jsx(Animated.View,{style:[ki.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[ki.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[ki.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var ki=StyleSheet.create({list:{paddingTop:16,paddingHorizontal:16,gap:12},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},icon:{width:40,height:40,borderRadius:20,marginRight:12},textBlock:{flex:1,gap:6},titleBar:{height:14,width:"65%",borderRadius:7},subtitleBar:{height:11,width:"45%",borderRadius:5.5},amountBar:{height:14,width:50,borderRadius:7,marginLeft:12}});function Ld({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=F(),[l,m]=useState(r),[c,C]=useState(false),[T,y]=useState(null),[b,k]=useState(false),h=useRef(null);useEffect(()=>{if(!e||!o)return;let S=async()=>{C(true);try{let W=[...(await Qo(o,n)).data].sort((D,O)=>{let v=D.created_at?new Date(D.created_at).getTime():0;return (O.created_at?new Date(O.created_at).getTime():0)-v});m(W);}catch(_){console.error("Failed to fetch executions:",_),m(r);}finally{C(false);}};S();let w=setInterval(S,1e4);return ()=>clearInterval(w)},[e,o,n,r]),useEffect(()=>{r.length>0&&m(S=>{let w=new Set(S.map(W=>W.id)),_=r.filter(W=>!w.has(W.id));return _.length>0?[..._,...S]:S});},[r]),useEffect(()=>{e||y(null);},[e]);let p=S=>{y(S);},g=()=>{y(null),k(false);},d=()=>{y(null),t();},f=()=>{if(!T)return null;let S=T,w=S.status==="pending"||S.status==="waiting"||S.status==="delayed",_=S.status==="succeeded",W=te(Ce(S.destination_token_metadata,"png")||Yt("/icons/tokens/png/usdc.png")),D=S.provider_metadata?.details,O=D?.currencyIn,v=D?.currencyOut;O?.currency?.symbol||"USDC";v?.currency?.symbol||"USDC";let ae=Cm(S.source_amount_base_unit,S.source_token_metadata?.decimals),ze=Cm(S.destination_amount_base_unit,S.destination_token_metadata?.decimals),ve=dy(S.source_amount_usd),J=bm(S.source_chain_type,S.source_chain_id),Ve=bm(S.destination_chain_type,S.destination_chain_id),me=()=>{S.explorer_url&&Linking.openURL(S.explorer_url);},_e=()=>{S.destination_explorer_url&&Linking.openURL(S.destination_explorer_url);};return jsxs(gt,{ref:h,style:he.scrollContainer,contentContainerStyle:he.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:he.iconSection,children:[jsxs(View,{style:he.iconWrapper,children:[jsx(Image,{source:{uri:W},style:he.tokenIcon}),jsx(View,{style:[he.statusBadge,{backgroundColor:w?a.warning:a.success,borderColor:a.background}],children:w?jsx(At,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(Ue,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:he.statusRow,children:[jsx(View,{style:[he.statusDot,{backgroundColor:w?a.warning:a.success}]}),jsx(Text,{style:[he.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:w?"Processing":"Completed"})]}),jsx(Text,{style:[he.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:uy(S.created_at||new Date().toISOString())})]}),jsxs(View,{style:[he.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ae," ",Sm(S.source_currency)]})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ze," ",Sm(S.destination_currency)]})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:ve})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:J})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Ve})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ne=!b;k(Ne),Ne?setTimeout(()=>{h.current?.scrollToEnd({animated:true});},100):h.current?.scrollTo({y:0,animated:true});},style:he.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[he.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:b?"See less":"See more details"}),b?jsx(To,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(At,{size:14,color:s.container.actionColor,strokeWidth:2})]}),b&&jsxs(View,{style:[he.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[S.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:me,style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:he.cardRowRight,children:[jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(S.transaction_hash)}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[he.cardDivider,{backgroundColor:a.border}]})]}),S.destination_explorer_url&&_&&jsxs(TouchableOpacity,{onPress:_e,style:he.cardRow,children:[jsx(Text,{style:[he.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:he.cardRowRight,children:[jsx(Text,{style:[he.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(S.destination_transaction_hashes[0])}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},R=c&&l.length===0;return jsxs(Fragment,{children:[jsx(Pr,{title:T?"Deposit Details":"Deposit Tracker",onClose:d,showClose:!T,showBack:!!T,onBack:g}),T?f():R?jsx(py,{}):jsx(gt,{style:he.scrollContainer,contentContainerStyle:he.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:he.emptyContainer,children:[jsx(Text,{style:[he.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[he.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:he.executionsList,children:l.map(S=>jsx(Ol,{execution:S,onPress:()=>p(S)},S.id))})})]})}var he=StyleSheet.create({scrollContainer:{flex:1,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:40},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function ma(e,t=true){let[r,o]=useState(null),[n,a]=useState(null),[i,s]=useState(false),[l,m]=useState(false),[c,C]=useState(null),[T,y]=useState(null);useEffect(()=>{!t||r||(s(true),Ls().then(p=>{o(p),C(null);}).catch(p=>{C(p instanceof Error?p:new Error(String(p)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(m(true),Vs(e).then(p=>{a(p),y(null);}).catch(p=>{y(p instanceof Error?p:new Error(String(p)));}).finally(()=>{m(false);}));},[t,e,n]);let b=i||l,k=c||T||null,h=null;if(r&&n){let p=n.blocked_country_codes||[],g=r.alpha2.toUpperCase();h=!p.some(d=>d.toUpperCase()===g);}return {isAllowed:h,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:b,error:k}}var Wd="unifold_recent_tokens",yy=5,Im=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function Al(){try{let e=await Wc.getItem(Wd);return e?JSON.parse(e):[]}catch{return []}}async function by(e){try{let r=(await Al()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,yy);await Wc.setItem(Wd,JSON.stringify(o));}catch{}}async function Cy(e){try{let r=(await Al()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Wc.setItem(Wd,JSON.stringify(r)),r}catch{return []}}function Ed({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:c}=F(),[C,T]=useState(""),[y,b]=useState([]);useEffect(()=>{e&&Al().then(b);},[e]),useEffect(()=>{e||T("");},[e]);let k=useMemo(()=>{let R=[];return r.forEach(x=>{x.chains.forEach(S=>{R.push({token:x,chain:S});});}),R},[r]),h=useMemo(()=>{let R=[],x=new Set,S=(w,_,W,D)=>{let O=`${w}-${_}:${W}`;if(x.has(O))return;let v=r.find(N=>N.symbol===w);if(!v)return;let q=v.chains.find(N=>N.chain_type===_&&N.chain_id===W);q&&(x.add(O),R.push({token:v,chain:q,isRecent:D}));};return y.forEach(w=>{S(w.symbol,w.chainType,w.chainId,true);}),Im.forEach(w=>{S(w.symbol,w.chainType,w.chainId,false);}),R},[r,y]),p=useMemo(()=>{if(!C.trim())return k;let R=C.toLowerCase();return k.filter(({token:x,chain:S})=>x.symbol.toLowerCase().includes(R)||x.name.toLowerCase().includes(R)||S.chain_name.toLowerCase().includes(R))},[k,C]),g=(R,x,S)=>Im.some(w=>w.symbol===R&&w.chainType===x&&w.chainId===S),d=async(R,x)=>{let S=`${x.chain_type}:${x.chain_id}`;if(!g(R.symbol,x.chain_type,x.chain_id)){await by({symbol:R.symbol,chainType:x.chain_type,chainId:x.chain_id});let w=await Al();b(w);}T(""),a(R.symbol,S),t();},f=async(R,x)=>{let S=await Cy({symbol:R.symbol,chainType:x.chain_type,chainId:x.chain_id});b(S);};return jsxs(ht,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:ft.header,children:[jsx(View,{style:ft.headerSpacer}),jsx(Text,{style:[ft.headerTitle,{color:c.header.titleColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:ft.closeButton,children:jsx(at,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:ft.searchContainer,children:jsx(TextInput,{style:[ft.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:m.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:C,onChangeText:T,autoCapitalize:"none",autoCorrect:false})}),h.length>0&&!C&&jsxs(View,{style:ft.quickSelectSection,children:[jsx(Text,{style:[ft.sectionLabel,{color:c.list.titleSectionColor,fontFamily:m.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:ft.quickSelectScroll,children:h.map(({token:R,chain:x,isRecent:S})=>{let w=`${x.chain_type}:${x.chain_id}`;R.symbol===o&&w===n;return jsxs(View,{children:[S&&jsx(TouchableOpacity$1,{onPress:()=>f(R,x),style:ft.removeButton,children:jsx(at,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>d(R,x),activeOpacity:.7,style:[ft.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:ft.tokenIconContainer,children:[jsx(Image,{source:{uri:te(Ce(R,"png"))},style:ft.quickSelectIcon}),jsx(Image,{source:{uri:te(Ce(x,"png"))},style:[ft.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:ft.quickSelectText,children:[jsx(Text,{style:[ft.quickSelectSymbol,{color:c.card.titleColor,fontFamily:m.medium}],children:R.symbol}),jsx(Text,{style:[ft.quickSelectChain,{color:c.card.subtitleColor,fontFamily:m.regular}],children:x.chain_name})]})]})]},`quick-${R.symbol}-${w}`)})})]}),jsx(Text,{style:[ft.sectionLabel,{color:c.list.titleSectionColor,fontFamily:m.regular}],children:"All supported tokens"}),jsx(gt,{style:ft.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:ft.tokenListContent,children:p.length===0?jsx(View,{style:ft.emptyState,children:jsx(Text,{style:[ft.emptyText,{color:l.foregroundMuted,fontFamily:m.regular}],children:"No tokens found"})}):p.map(({token:R,chain:x})=>{let S=`${x.chain_type}:${x.chain_id}`,w=R.symbol===o&&S===n;return jsxs(TouchableOpacity$1,{onPress:()=>d(R,x),activeOpacity:.7,style:[ft.tokenItem,{backgroundColor:w?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:ft.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:te(Ce(R,"png"))},style:ft.tokenIcon}),jsx(Image,{source:{uri:te(Ce(x,"png"))},style:[ft.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:ft.tokenInfo,children:[jsx(Text,{style:[ft.tokenSymbol,{color:c.card.titleColor,fontFamily:m.medium}],children:R.symbol}),jsx(Text,{style:[ft.tokenChainName,{color:c.card.subtitleColor,fontFamily:m.regular}],children:x.chain_name})]}),jsxs(Text,{style:[ft.minDeposit,{color:c.card.labelColor,fontFamily:m.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:m.regular},children:["$",x.minimum_deposit_amount_usd]})]})]},`${R.symbol}-${S}`)})})]})}var ft=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:72,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var El=(e,t)=>`${t}:${e}`,xy=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Md({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:c="auto_ui",onExecutionsChange:C,onDepositSuccess:T,onDepositError:y,wallets:b,borderTopLeftRadius:k,borderTopRightRadius:h,sheetBorderRadius:p}){let{colors:g,fonts:d,components:f}=F(),R=s&&l?`${s}:${l}`:"solana:mainnet",[x,S]=useState("USDC"),[w,_]=useState(R),[W,D]=useState([]),[O,v]=useState(!b?.length),q=b?.length?b:W,[N,ae]=useState([]),[ze,ve]=useState(true),[J,Ve]=useState(false),[me,_e]=useState(false),[Ne,Se]=useState(false),[oe,Pe]=useState([]),[rt,je]=useState(new Map),[ot]=useState(()=>new Date),[$e,Fe]=useState(null),[ct,Re]=useState(false),[X,ce]=useState(null),[st,Je]=useState(false),Le=new Map;N.forEach(pe=>{pe.chains.forEach(Me=>{let M=`${Me.chain_type}:${Me.chain_id}`;Le.has(M)||Le.set(M,Me);});});let be=Array.from(Le.values()),ie=xy(w),de=be.find(pe=>pe.chain_type===ie.chainType&&pe.chain_id===ie.chainId),zt=de?.chain_type||"ethereum",ue=qo(q,zt),se=ue?.address||"",ye=useRef(false);useEffect(()=>{async function pe(){try{ve(!0),Fe(null);let M=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(ae(M.data),M.data.length>0&&!ye.current){ye.current=!0;let ee,ke;if(s&&l)if(m)for(let fe of M.data){let _t=fe.chains.find(V=>V.chain_type===s&&V.chain_id===l&&V.token_address.toLowerCase()===m.toLowerCase());if(_t){ee=fe,ke=_t;break}}else for(let fe of M.data){let _t=fe.chains.find(V=>V.chain_type===s&&V.chain_id===l);if(_t){ee=fe,ke=_t;break}}if(!ee&&a)for(let fe of M.data){let _t=fe.chains.find(V=>V.token_address.toLowerCase()===a.toLowerCase());if(_t){ee=fe,ke=_t;break}}ee||(ee=M.data.find(fe=>fe.symbol==="USDC"),ee&&ee.chains.length>0&&(ke=ee.chains[0])),ee||(ee=M.data.find(fe=>fe.symbol==="USDT"),ee&&ee.chains.length>0&&(ke=ee.chains[0])),ee||(ee=M.data[0],ee.chains.length>0&&(ke=ee.chains[0])),ee&&S(ee.symbol),ke&&_(El(ke.chain_id,ke.chain_type));}}catch(Me){console.error("Error fetching supported tokens:",Me),Fe("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:Me});}finally{ve(false);}}pe();},[t,a,n,o,s,l,m,y]),useEffect(()=>{C&&C(oe);},[oe,C]),useEffect(()=>{if(b?.length){v(false);return}if(W.length>0){v(false);return}let pe=null,Me=false,M=async()=>{if(!Me){v(true);try{let ee=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);Me||(D(ee.data),Fe(null),v(!1));}catch(ee){console.error("Error fetching wallets, retrying in 5s:",ee),Me||(Fe(ee instanceof Error?ee.message:"Failed to load wallets"),v(false),pe=setTimeout(M,5e3));}}};return M(),()=>{Me=true,pe&&clearTimeout(pe);}},[e,r,o,n,a,t,b,W.length]);let yt=ue?.id??"",{showWaitingUi:dt,handleIveDeposited:le}=ca({depositConfirmationMode:c,depositAddress:se,chain:w,externalUserId:e,publishableKey:t,modalOpenedAt:ot,depositWalletId:yt,depositExecutions:oe,trackedExecutions:rt,setDepositExecutions:Pe,setTrackedExecutions:je,setLatestExecution:ce,setShowStatusSheet:Re,onDepositSuccess:T,onExecutionsChange:C,onDepositError:y});useEffect(()=>{if(!N.length)return;let pe=N.find(M=>M.symbol===x);if(!pe||pe.chains.length===0)return;if(!pe.chains.some(M=>El(M.chain_id,M.chain_type)===w)){let M=pe.chains[0];_(El(M.chain_id,M.chain_type));}},[x,N,w]);let qe=N.find(pe=>pe.symbol===x),xt=(qe?.chains||[]).find(pe=>El(pe.chain_id,pe.chain_type)===w),xr=async()=>{if(se)try{Clipboard.setString(se),Ve(!0),setTimeout(()=>Ve(!1),2e3);}catch(pe){console.error("Failed to copy:",pe);}},$=xt?.estimated_price_impact_percent??0,re=xt?.max_slippage_percent??.25,et=xt?.minimum_deposit_amount_usd??3;return ze?jsxs(View,{style:U.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:g.primary}),jsx(Text,{style:[U.loadingText,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Loading currencies..."})]}):$e&&N.length===0?jsxs(View,{style:U.errorContainer,children:[jsx(Text,{style:[U.errorText,{color:g.error,fontFamily:d.regular}],children:$e}),jsx(Text,{style:[U.errorHint,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:U.container,children:[jsxs(View,{style:U.selectorSection,children:[jsx(Text,{style:[U.selectorLabel,{color:f.card.labelColor,fontFamily:d.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>Se(true),disabled:ze||N.length===0,style:[U.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:ze?jsxs(View,{style:U.tokenSelectorLoading,children:[jsx(View,{style:[U.loadingIcon,{backgroundColor:g.cardHover}]}),jsxs(View,{style:U.loadingTextContainer,children:[jsx(View,{style:[U.loadingLine,{backgroundColor:g.cardHover,width:60}]}),jsx(View,{style:[U.loadingLine,{backgroundColor:g.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:U.tokenIconWrapper,children:[qe&&jsx(Image,{source:{uri:te(Ce(qe,"png"))},style:U.tokenMainIcon}),(xt||de)&&jsx(Image,{source:{uri:te(Ce(xt||de,"png"))},style:[U.tokenChainBadge,{borderColor:f.card.backgroundColor,borderRadius:f.badge.borderRadius}]})]}),jsxs(View,{style:U.tokenSelectorInfo,children:[jsx(Text,{style:[U.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:d.semibold}],children:qe?.symbol||x}),jsx(Text,{style:[U.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:d.regular}],numberOfLines:1,children:xt?.chain_name||de?.chain_name||"Select network"})]}),jsxs(View,{style:U.tokenSelectorRight,children:[jsxs(Text,{style:[U.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:d.medium}],children:["$",et," min"]}),jsx(_r,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Ed,{visible:Ne,onClose:()=>Se(false),tokens:N,selectedToken:x,selectedChainKey:w,onSelect:(pe,Me)=>{S(pe),_(Me);},borderTopLeftRadius:p?.tokenSelector?.borderTopLeftRadius??k,borderTopRightRadius:p?.tokenSelector?.borderTopRightRadius??h}),jsx(View,{style:U.qrContainer,children:jsx(View,{style:[U.qrWrapper,{backgroundColor:g.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:O?jsxs(View,{style:U.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),jsx(Text,{style:[U.loadingText,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Loading..."})]}):se?jsx(us,{value:se,size:180,logoUri:te(Ce(xt,"png")||Yt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:U.qrLoading,children:jsx(Text,{style:[U.errorText,{color:g.error,fontFamily:d.regular}],children:"No address available"})})})}),jsxs(View,{style:U.addressSection,children:[jsxs(View,{style:U.addressHeader,children:[jsx(Text,{style:[U.addressLabel,{color:f.card.labelColor,fontFamily:d.medium}],children:"Deposit Address"}),J&&jsxs(View,{style:U.copiedIndicator,children:[jsx(Ue,{size:14,color:g.success,strokeWidth:2}),jsx(Text,{style:[U.copiedText,{color:g.success,fontFamily:d.regular}],children:"Copied"})]})]}),jsxs(ir,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!O&&se?xr:void 0,contentStyle:U.addressBox,children:[jsx(Text,{style:[U.addressText,{color:f.card.titleColor,fontFamily:d.regular}],numberOfLines:2,children:O?"Loading...":se||"No address available"}),jsx(View,{style:U.addressCopyIcon,children:jsx(No,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[U.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>_e(!me),style:U.detailsHeader,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:U.chevronContainer,children:me?jsx(To,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(At,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),me&&jsxs(View,{style:U.detailsContent,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Price impact: ",$.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Slippage: Auto \u2022 ",re.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Je(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(wl,{depositConfirmationMode:c,depositAddress:se,showWaitingUi:dt,latestExecution:X,onIveDeposited:le}),jsx(TouchableOpacity$1,{style:U.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[U.termsText,{color:g.primary,fontFamily:d.regular}],children:"Terms apply"})}),jsxs(ht,{visible:st,onClose:()=>Je(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:p?.infoSheet?.borderTopLeftRadius??k,borderTopRightRadius:p?.infoSheet?.borderTopRightRadius??h,children:[jsxs(View,{style:[U.sheetHeader,{borderBottomColor:g.border}],children:[jsx(View,{style:U.sheetHeaderSpacer}),jsx(Text,{style:[U.sheetTitle,{color:f.header.titleColor,fontFamily:d.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Je(false),style:U.sheetCloseButton,children:jsx(at,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:U.infoSheetContent,children:[jsxs(View,{style:[U.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Price Impact"}),jsxs(Text,{style:[U.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[$.toFixed(2),"%"]})]}),jsx(Text,{style:[U.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:[U.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Max Slippage"}),jsxs(Text,{style:[U.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[re.toFixed(2),"%"]})]}),jsx(Text,{style:[U.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."})]})]})]}),X&&jsx(ps,{visible:ct,status:X.status,tokenIconUrl:X.destination_token_metadata?.icon_urls?.find(pe=>pe.format==="png")?.url||X.destination_token_metadata?.icon_url||Ce(qe,"png"),explorerUrl:X.explorer_url,completionExplorerUrl:X.destination_explorer_url,date:X.created_at?new Date(X.created_at):void 0,amountUsd:X.source_amount_usd?parseFloat(X.source_amount_usd):void 0,onClose:()=>Re(false),borderTopLeftRadius:p?.depositStatus?.borderTopLeftRadius??k,borderTopRightRadius:p?.depositStatus?.borderTopRightRadius??h})]})}var U=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var cn={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},stripeLinkPay:{title:"Pay with Stripe Link",subtitle:"Apple Pay or Card"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Py(){let{colors:e,components:t}=F(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[r]);let a=({rightIcons:i=2})=>jsxs(View,{style:[$n.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[$n.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:$n.textBlock,children:[jsx(Animated.View,{style:[$n.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[$n.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:$n.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[$n.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:$n.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var $n=StyleSheet.create({container:{paddingTop:8,paddingBottom:24,gap:8},card:{marginHorizontal:16,flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:12,gap:12},leftIcon:{width:36,height:36},textBlock:{flex:1,gap:6},titleBar:{height:12,width:"70%",borderRadius:6},subtitleBar:{height:10,width:"50%",borderRadius:5},rightIcons:{flexDirection:"row",alignItems:"center",gap:4},rightIcon:{width:20,height:20,borderRadius:10}});function Fy({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,showBalance:y=false,hideDepositTracker:b=false,enableStripeLinkPay:k=false,StripeOnrampComponent:h,stripeOnrampEmail:p,stripeOnrampPhone:g,stripeMerchantIdentifier:d,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:R,stripeTheme:x,depositConfirmationMode:S="auto_ui",transferInputVariant:w="double_input",initialScreen:_="main",onDepositSuccess:W,onDepositError:D,sheetBorderRadius:O}){let v=O?.globalBorderTopLeftRadius,q=O?.globalBorderTopRightRadius,{colors:N,fonts:ae}=F(),[ze,ve]=useState([]),[J,Ve]=useState(null),[me,_e]=useState("amount"),Ne=_==="tracker"&&!b?"tracker":_==="transfer"?"transfer":_==="card"?"card":"main",Se=Ne==="main",[oe,Pe]=useState(Ne),{isAllowed:rt,isLoading:je}=ma(o,e);useEffect(()=>{if(!e||J)return;let ue=false;return Vs(o).then(async se=>{if(ue)return;let ye=[];for(let yt of se?.transfer_crypto?.networks??[]){let dt=yt.icon_urls.find(le=>le.format==="png")?.url||yt.icon_urls.find(le=>le.format==="svg")?.url;dt&&ye.push(te(dt));}for(let yt of se?.payment_networks?.networks??[]){let dt=yt.icon_urls.find(le=>le.format==="png")?.url||yt.icon_urls.find(le=>le.format==="svg")?.url;dt&&ye.push(te(dt));}ye.length>0&&await dd(ye),ue||Ve(se);}).catch(console.error),()=>{ue=true;}},[e,J,o]);let ot=()=>{t();};useEffect(()=>{e&&(Pe(Ne),_e("amount"));},[e,Ne]);let $e=useCallback(()=>{Se?(Pe("main"),_e("amount")):ot();},[Se,ot]),Fe=ze.filter(ue=>ue.status==="pending"||ue.status==="waiting").length,Re=!!(i&&s&&l&&m&&o)&&y!==false&&!!J,X=je||e&&!J,ce=rt===false,st=null;if(oe==="stripe"&&h){let ue=jsx(h,{publishableKey:o,email:p,phone:g,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,merchantIdentifier:d,paymentSelectorPosition:f,skipSuccessConfirmation:R,onClose:$e});st=x?jsx(Di,{...x,children:ue}):ue;}let Je=oe==="stripe"?.9:oe==="transfer"||oe==="card"?.94:oe==="tracker"?.6:oe==="main"?.5:void 0,Le=oe==="tracker"||oe==="main"?.9:void 0,ie={main:O?.main,transfer:O?.transferCrypto,card:O?.buyWithCard,stripe:O?.stripeLinkPay,tracker:O?.depositsTracker}[oe],de=ie?.borderTopLeftRadius??v,zt=ie?.borderTopRightRadius??q;return jsxs(ht,{visible:e,onClose:oe==="main"?ot:$e,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:Je,maxHeightPercent:Le,borderTopLeftRadius:de,borderTopRightRadius:zt,children:[oe==="main"&&jsxs(Fragment,{children:[jsx(Pr,{title:n,showBack:false,onClose:ot,showBalance:Re,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:J?.project_name}),X&&jsx(Py,{}),!X&&ce&&jsxs(View,{style:Tr.centeredContainer,children:[jsx(View,{style:[Tr.iconContainer,{backgroundColor:N.cardHover}],children:jsx(Is,{size:32,color:N.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Tr.blockedTitle,{color:N.foreground,fontFamily:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tr.blockedDescription,{color:N.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!X&&!ce&&jsxs(View,{style:Tr.optionsContainer,children:[jsx(oa,{onPress:()=>Pe("transfer"),title:cn.transferCrypto.title,subtitle:cn.transferCrypto.subtitle,featuredTokens:J?.transfer_crypto?.networks}),jsx(ia,{onPress:()=>Pe("card"),title:cn.depositWithCard.title,subtitle:cn.depositWithCard.subtitle,paymentNetworks:J?.payment_networks?.networks}),k&&h&&jsx(la,{onPress:()=>Pe("stripe"),title:cn.stripeLinkPay.title,subtitle:cn.stripeLinkPay.subtitle}),!b&&jsx(sa,{onPress:()=>Pe("tracker"),title:cn.depositTracker.title,subtitle:cn.depositTracker.subtitle,badge:Fe>0?Fe:void 0})]})]}),oe==="transfer"&&jsxs(Fragment,{children:[jsx(Pr,{title:cn.transferCrypto.title,showBack:false,onClose:$e,showBalance:Re,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:J?.project_name}),je&&jsx(View,{style:[Tr.centeredContainer,Tr.centeredFlex],children:jsx(ActivityIndicator,{color:N.primary})}),!je&&ce&&jsxs(View,{style:[Tr.centeredContainer,Tr.centeredFlex],children:[jsx(View,{style:[Tr.iconContainer,{backgroundColor:N.cardHover}],children:jsx(Is,{size:32,color:N.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Tr.blockedTitle,{color:N.foreground,fontFamily:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Tr.blockedDescription,{color:N.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!je&&!ce&&jsx(gt,{style:Tr.transferScrollContainer,contentContainerStyle:Tr.scrollContent,showsVerticalScrollIndicator:false,children:w==="single_input"?jsx(Md,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,depositConfirmationMode:S,onExecutionsChange:ve,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:v,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(kl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,depositConfirmationMode:S,onExecutionsChange:ve,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:v,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),oe==="card"&&jsxs(Fragment,{children:[jsx(Pr,{title:`Deposit ${a||"USDC"}`,showBack:me==="onramp",onBack:()=>_e("amount"),onClose:$e,showBalance:Re,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:J?.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:D,view:me,onViewChange:ue=>_e(ue),borderTopLeftRadius:v,borderTopRightRadius:q,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),oe==="stripe"&&st&&jsx(View,{style:Tr.stripeLinkPayContainer,children:st}),oe==="tracker"&&jsx(Ld,{active:oe==="tracker",onClose:$e,executions:ze,externalUserId:r,publishableKey:o})]})}function Ul({theme:e="auto",...t}){return jsx(Fy,{...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 Hl(e,t=true){return Xo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Va(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Hd(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await Gn(a),m=null,c=null,C=null,T=null,y,b,k,h=l.data.some(p=>p.chains.some(g=>{let d=g.chain_type===t&&g.chain_id===r&&g.token_address.toLowerCase()===o.toLowerCase();return d&&(m=g.minimum_deposit_amount_usd,c=g.estimated_processing_time,C=g.max_slippage_percent,T=g.estimated_price_impact_percent,k=g.chain_name,b=p),d}));if(b){let p=Ce(b,"png");p&&(y=te(p));}return {isSupported:h,minimumAmountUsd:m,estimatedProcessingTime:c,maxSlippagePercent:C,priceImpactPercent:T,errorMessage:h?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:y,chainName:k}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Nd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await La(t,r,o,n,a);if(l.balance){let m=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",C=l.balance.amount,T=BigInt(C),y=BigInt(10**m),b=T/y,h=(T%y).toString().padStart(m,"0").replace(/0+$/,""),p=h?`${b}.${h}`:b.toString();return {balanceBaseUnit:C,balanceHuman:p,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:m,symbol:c}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:i&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var Dy=2500,Vy=3e3,Ly=6e4;function jd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,m]=useState(false),c=useRef(new Date),C=useRef(new Map),T=useRef(false),y=useRef(n),b=useRef(a);return useEffect(()=>{y.current=n;},[n]),useEffect(()=>{b.current=a;},[a]),useEffect(()=>{o&&!T.current&&(c.current=new Date,C.current.clear()),o||C.current.clear(),T.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let k=c.current,h=async()=>{try{let g=await Qo(e,t,"withdraw"),d=new Date(k.getTime()-Ly),f=[...g.data].sort((w,_)=>{let W=w.created_at?new Date(w.created_at).getTime():0;return (_.created_at?new Date(_.created_at).getTime():0)-W}),R=["pending","waiting","delayed"],x=["succeeded","failed"],S=null;for(let w of f){let _=w.created_at?new Date(w.created_at):null;if(!_||_<d)continue;let W=C.current.get(w.id);if(!W){S=w;break}if(R.includes(W)&&x.includes(w.status)){S=w;break}}if(S){let w=S,_=w.created_at?new Date(w.created_at):null;if(!_||_<c.current)return;let W=C.current.get(w.id);C.current.set(w.id,w.status),s(D=>{let O=D.findIndex(v=>v.id===w.id);if(O>=0){let v=[...D];return v[O]=w,v}return [...D,w]}),w.status==="succeeded"&&(!W||R.includes(W))?y.current?.({message:"Withdrawal completed successfully",transaction:w}):w.status==="failed"&&W!=="failed"&&b.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:w});}}catch(g){console.error("Failed to fetch withdraw executions:",g),b.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:g});}};h();let p=setInterval(h,Dy);return m(true),()=>{clearInterval(p),m(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let k=async()=>{try{await Sc({deposit_wallet_id:r},t);}catch{}};k();let h=setInterval(k,Vy);return ()=>clearInterval(h)},[o,r,t]),{executions:i,isPolling:l}}var $d=(e,t)=>`${t}:${e}`;function ga({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:a=false,tokenLabel:i="Receive token",chainLabel:s="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:m,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:C}){let{colors:T,fonts:y,components:b}=F(),[k,h]=useState(false),[p,g]=useState(false),d=b.card,f=t?e.find(w=>w.symbol===t):void 0,R=f?.chains||[],x=r?R.find(w=>$d(w.chain_id,w.chain_type)===r):void 0,S={backgroundColor:d.backgroundColor,borderRadius:d.borderRadius,borderWidth:d.borderWidth||1,borderColor:d.borderColor};return jsxs(View,{style:Xe.row,children:[jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:y.medium}],children:i}),jsxs(TouchableOpacity,{style:[Xe.selectButton,S],onPress:()=>!a&&e.length>0&&h(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Loading..."}):f?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:te(Ce(f,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:y.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Select receive token"}),jsx(At,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:y.medium}],children:s}),jsxs(TouchableOpacity,{style:[Xe.selectButton,S,(!f||R.length===0)&&Xe.disabled],onPress:()=>!a&&f&&R.length>0&&g(true),activeOpacity:.7,disabled:a||!f||R.length===0,children:[x?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:te(Ce(x,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:y.medium}],numberOfLines:1,children:x.chain_name})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Chain"}),jsx(At,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(ht,{visible:k,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:m,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:T.foreground,fontFamily:y.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>h(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:e,keyExtractor:w=>w.symbol,contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:w})=>jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:w.symbol===t?T.cardHover:"transparent"}],onPress:()=>{o(w.symbol),h(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:te(Ce(w,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:T.foreground,fontFamily:y.medium}],children:w.symbol}),jsx(Text,{style:[Xe.pickerItemSub,{color:T.foregroundMuted,fontFamily:y.regular}],children:w.name}),w.symbol===t&&jsx(Ue,{size:18,color:T.primary,strokeWidth:2.5})]})})]}),jsxs(ht,{visible:p,onClose:()=>g(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c,borderTopRightRadius:C,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:T.foreground,fontFamily:y.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>g(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:R,keyExtractor:w=>$d(w.chain_id,w.chain_type),contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:w})=>{let _=$d(w.chain_id,w.chain_type);return jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:_===r?T.cardHover:"transparent"}],onPress:()=>{n(_),g(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:te(Ce(w,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:T.foreground,fontFamily:y.medium}],children:w.chain_name}),_===r&&jsx(Ue,{size:18,color:T.primary,strokeWidth:2.5})]})}})]})]})}var Xe=StyleSheet.create({row:{flexDirection:"column",gap:10},col:{},label:{fontSize:12,marginBottom:6},selectButton:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:12,gap:6,minHeight:48},selectedItem:{flex:1,flexDirection:"row",alignItems:"center",gap:6},icon:{width:20,height:20,borderRadius:10},selectedText:{fontSize:13,flexShrink:1},placeholder:{flex:1,fontSize:13},disabled:{opacity:.4},pickerHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:16,paddingBottom:12},pickerHeaderSpacer:{width:28},pickerHeaderClose:{width:28,alignItems:"flex-end"},pickerTitle:{flex:1,fontSize:16,textAlign:"center"},listContent:{paddingHorizontal:16,paddingVertical:8},pickerItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:12,borderRadius:10,gap:10},pickerIcon:{width:32,height:32,borderRadius:16},pickerItemText:{fontSize:15,flex:1},pickerItemSub:{fontSize:13}});function qd(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:a,enabled:i=true}=e,s=n?.trim()||"",l=!!t&&!!r&&!!o&&s.length>0;return Xo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>wc({chain_type:t,chain_id:r,token_address:o,recipient_address:s},a),enabled:i&&l,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function Ey(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function My(e,t){if(e<=0)return "0";if(t===0)return BigInt(Math.round(e)).toString();let r=e.toFixed(t),[o,n=""]=r.split("."),a=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(a)).toString()}function zy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function jl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:m,balanceData:c,isLoadingBalance:C,minimumWithdrawAmountUsd:T,estimatedProcessingTime:y,maxSlippagePercent:b,priceImpactPercent:k,canWithdraw:h,onDepositWalletCreation:p,onWithdraw:g,onWithdrawError:d,onWithdrawSubmitted:f,onViewTracker:R}){let x="https://unifold.io/terms",S="https://unifold.io/support",{colors:w,fonts:_,components:W}=F(),[D,O]=useState(s||""),[v,q]=useState(""),[N,ae]=useState(false),[ze,ve]=useState(null),[J,Ve]=useState(false),[me,_e]=useState(""),Ne=useRef(null);useEffect(()=>{O(s||""),q(""),ve(null);},[s]);let Se=D.trim();useEffect(()=>{let le=setTimeout(()=>_e(Se),500);return ()=>clearTimeout(le)},[Se]);let{data:oe,isLoading:Pe,error:rt}=qd({chainType:m?.chain_type,chainId:m?.chain_id,tokenAddress:m?.token_address,recipientAddress:me,publishableKey:e,enabled:me.length>5&&!!m}),je=Se!==me,ot=useMemo(()=>!Se||Se.length<=5||je||Pe?null:rt?"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,[Se,je,Pe,rt,oe,m,l]),$e=!je&&!!oe?.valid&&!ot,Fe=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),ct=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),Re=n||c?.symbol||"TOKEN",X=c?.decimals??6,ce=useMemo(()=>{let le=parseFloat(v);return !le||le<=0?0:le},[v]),st=useMemo(()=>{let le=parseFloat(v);return !le||le<=0?0:le*Fe},[v,Fe]),Je=useCallback(async()=>{try{let qe=await tf("expo-clipboard").getStringAsync();qe&&(O(qe.trim()),ve(null));}catch{}},[]),Le=useCallback(()=>{ct<=0||q(c?.balanceHuman??"0");},[ct,c]),be=T!==null&&st>0&&st<T,ie=ce>0&&ct>0&&ce>ct,de=Se.length>0&&v.trim().length>0&&ce>0&&$e&&!be&&!ie&&!!c,zt=useCallback(async()=>{if(!(!l||!m||!de||!h)){ae(true),ve(null);try{let le=await p({destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,recipientAddress:Se}),qe=My(ce,X),yr=zy(ce,X),xt={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:Re,sourceTokenIconUrl:i,destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,destinationTokenSymbol:l.symbol,destinationChainName:m.chain_name,destinationTokenIconUrl:l?te(Ce(l,"png")):void 0,amount:yr,amountBaseUnit:qe,submittedAt:new Date,withdrawIntentAddress:le.address,recipientAddress:Se};await g(xt),f(xt);}catch(le){let qe=le instanceof Error?le.message:"Withdrawal failed. Please try again.",yr=qe.length>120?"Withdrawal failed. Please try again.":qe;ve(yr),d?.({message:qe,error:le,code:"WITHDRAW_FAILED"});}finally{ae(false);}}},[l,m,de,h,Se,t,r,o,Re,i,v,ct,c,ce,X,st,p,g,d,f]),ue=W.input,se=W.card,ye=W.button,yt=ot?w.error:ue.borderColor,dt=useMemo(()=>N?"Processing...":ie?"Insufficient balance":be?`Minimum $${T?.toFixed(2)}`:ze?"Withdrawal failed \u2014 try again":"Withdraw",[N,ie,be,T,ze]);return jsxs(View,{style:Ye.container,children:[jsxs(View,{children:[jsxs(View,{style:Ye.labelRow,children:[jsx(Text,{style:[Ye.label,{color:se.labelColor,fontFamily:_.medium}],children:"Recipient address"}),(je||Pe)&&Se.length>5?jsx(ActivityIndicator,{size:"small",color:w.primary}):jsx(TouchableOpacity,{onPress:Je,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(iu,{size:16,color:w.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Ye.inputRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:yt}],children:jsx(TextInput,{style:[Ye.textInput,{color:ue.textColor,fontFamily:_.regular}],placeholder:"Enter wallet address",placeholderTextColor:ue.placeholderColor,value:D,onChangeText:le=>{O(le),ve(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Ne.current?.focus()})}),ot?jsx(Text,{style:[Ye.errorText,{color:w.error,fontFamily:_.regular}],children:ot}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Ye.label,{color:se.labelColor,fontFamily:_.medium,paddingBottom:8}],children:["Amount",T!=null&&T>0&&jsx(Text,{style:{color:w.warning,fontFamily:_.regular},children:` ($${T.toFixed(2)} min)`})]}),jsxs(View,{style:[Ye.amountRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:ue.borderColor}],children:[jsx(TextInput,{ref:Ne,style:[Ye.amountInput,{color:ue.textColor,fontFamily:_.regular}],placeholder:"0.00",placeholderTextColor:ue.placeholderColor,value:v,onChangeText:le=>{(le===""||/^\d*\.?\d*$/.test(le))&&(q(le),ve(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[Ye.unitLabel,{color:w.foregroundMuted,fontFamily:_.medium}],children:Re}),jsx(TouchableOpacity,{style:[Ye.maxButton,{backgroundColor:`${w.primary}20`}],onPress:Le,activeOpacity:.7,children:jsx(Text,{style:[Ye.maxText,{color:w.primary,fontFamily:_.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Ye.detailsCard,{marginTop:24,backgroundColor:se.backgroundColor,borderRadius:se.borderRadius,borderWidth:se.borderWidth||1,borderColor:se.borderColor}],children:[jsx(TouchableOpacity,{style:Ye.detailsToggle,onPress:()=>Ve(!J),activeOpacity:.7,children:jsxs(View,{style:Ye.detailsRow,children:[jsx(View,{style:[Ye.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ye.detailsLabel,{color:se.titleColor,fontFamily:_.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:_.medium},children:Ey(y)})]}),jsx(View,{style:{transform:[{rotate:J?"180deg":"0deg"}]},children:jsx(At,{size:16,color:se.actionColor,strokeWidth:2})})]})}),J&&jsxs(View,{style:Ye.detailsExpanded,children:[jsxs(View,{style:Ye.detailsRow,children:[jsx(View,{style:[Ye.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ye.detailsLabel,{color:se.titleColor,fontFamily:_.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:_.medium},children:["Auto \u2022 ",(b??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Ye.detailsRow,children:[jsx(View,{style:[Ye.detailIcon,{backgroundColor:se.iconBackgroundColor,borderRadius:se.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:se.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Ye.detailsLabel,{color:se.titleColor,fontFamily:_.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:_.medium},children:[(k??0).toFixed(2),"%"]})]})]})]})]}),ze&&jsx(Text,{style:[Ye.errorText,{color:w.error,fontFamily:_.regular,textAlign:"center"}],children:ze}),jsxs(View,{style:Ye.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Ye.withdrawButton,{backgroundColor:ye.primaryBackground,borderRadius:ye.borderRadius,borderWidth:ye.borderWidth,borderColor:ye.borderColor,opacity:!de||!h||N?.5:1}],onPress:zt,disabled:!de||!h||N,activeOpacity:.8,children:[N&&jsx(ActivityIndicator,{size:"small",color:ye.primaryText}),jsx(Text,{style:[Ye.withdrawButtonText,{color:ye.primaryText,fontFamily:_.medium}],children:dt})]}),jsxs(View,{style:Ye.footerRow,children:[jsxs(TouchableOpacity,{style:Ye.historyLink,onPress:R,activeOpacity:.7,children:[jsx(zr,{size:14,color:w.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Ye.historyText,{color:w.foregroundMuted,fontFamily:_.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Ye.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(x),activeOpacity:.7,children:jsx(Text,{style:[Ye.legalText,{color:w.foregroundMuted,fontFamily:_.regular}],children:"Terms"})}),jsx(Text,{style:[Ye.legalSeparator,{color:w.foregroundMuted,fontFamily:_.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(S),activeOpacity:.7,children:jsx(Text,{style:[Ye.legalText,{color:w.foregroundMuted,fontFamily:_.regular}],children:"Help"})})]})]})]})]})}var Ye=StyleSheet.create({container:{gap:12,paddingHorizontal:16,paddingBottom:16},label:{fontSize:12},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:6},inputRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48,gap:8},amountInput:{flex:1,fontSize:14,paddingVertical:8},unitLabel:{fontSize:14,flexShrink:0},maxButton:{paddingHorizontal:8,paddingVertical:4,borderRadius:6},maxText:{fontSize:12,fontWeight:"600"},withdrawRow:{gap:12},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},historyLink:{flexDirection:"row",alignItems:"center",gap:6},historyText:{fontSize:13},legalLinks:{flexDirection:"row",alignItems:"center",gap:6},legalText:{fontSize:13},legalSeparator:{fontSize:13},detailsCard:{paddingHorizontal:12,overflow:"hidden"},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13,flex:1},detailsExpanded:{gap:10,paddingBottom:12},withdrawButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:15,gap:8},withdrawButtonText:{fontSize:16,fontWeight:"600"}});function Ny(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function jy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ql({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=F(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed",s=e.status==="failed"||e.status==="refunded",l=s?r.error:i?r.warning:r.success,m=te(Ce(e.destination_token_metadata,"png")||Yt("/icons/tokens/png/usdc.png")),c=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",C=Ny(e.created_at||new Date().toISOString()),T=jy(e.source_amount_usd);return jsxs(ir,{cardTokens:a,onPress:t,contentStyle:un.container,children:[jsxs(View,{style:un.iconContainer,children:[jsx(Image,{source:{uri:m},style:un.tokenIcon}),jsx(View,{style:[un.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Rs,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Ue,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:un.textContainer,children:[jsx(Text,{style:[un.title,{color:a.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[un.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:C})]}),jsxs(View,{style:un.rightContainer,children:[jsx(Text,{style:[un.amount,{color:a.textRightColor,fontFamily:o.medium}],children:T}),jsx(_r,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var un=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function Gd(e){try{let t=new Date(e),o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=t.getDate(),a=t.getFullYear(),i=t.getHours(),s=t.getMinutes(),l=i>=12?"PM":"AM";i=i%12||12;let m=s<10?`0${s}`:`${s}`;return `${o} ${n}, ${a} at ${i}:${m} ${l}`}catch{return e}}function Hm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function qy(e,t){if(e)try{return `$${Number(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}if(t)try{return `$${(Number(t)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}return "$0.00"}function Nm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function jm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function ya({label:e,value:t,isLast:r}){let{fonts:o,components:n}=F(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Ee.detailRow,children:[jsx(Text,{style:[Ee.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Ee.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Ee.divider,{backgroundColor:a.borderColor}]})]})}function Jd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=F(),[m,c]=useState([]),[C,T]=useState(!!n),y=l.card,b=l.button,k=l.header,h=l.container;useEffect(()=>{Cc().then(ae=>c(ae.data)).catch(()=>{});},[]),useEffect(()=>{T(!!n);},[e?.id]);let p=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,g=e?e.status==="failed"||e.status==="refunded":false,d=g?i.error:p?i.warning:i.success,f=g?"Failed":p?"Processing":"Completed",R=e?.destination_token_metadata?te(Ce(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?te(t.destinationTokenIconUrl):te(Yt("/icons/tokens/png/usdc.png")),x=e?.created_at?Gd(e.created_at):t.submittedAt?Gd(t.submittedAt.toISOString()):Gd(new Date().toISOString()),S=e?`${Hm(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Nm(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,w=e?`${Hm(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Nm(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,_=e?qy(e.source_amount_usd,e.source_amount_base_unit):"$0.00",W=e?Da(m,e.source_chain_type,e.source_chain_id):t.sourceChainId,D=e?Da(m,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,v=e?.explorer_url,q=e?.destination_transaction_hashes?.[0],N=e?.destination_explorer_url;return jsxs(gt,{style:Ee.scroll,contentContainerStyle:Ee.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Ee.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Fi,{size:22,color:k.buttonColor,strokeWidth:2})}):jsx(View,{style:Ee.headerSpacer}),jsx(Text,{style:[Ee.headerTitle,{color:k.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Ee.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(at,{size:20,color:k.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Ee.iconContainer,children:[jsx(Image,{source:{uri:R},style:Ee.tokenIcon}),jsx(View,{style:[Ee.statusBadge,{backgroundColor:d}],children:g?jsx(Rs,{size:10,color:"#FFFFFF",strokeWidth:3}):p?jsx(View,{style:Ee.spinnerDot}):jsx(Ue,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Ee.statusRow,children:[jsx(View,{style:[Ee.statusDot,{backgroundColor:d}]}),jsx(Text,{style:[Ee.statusText,{color:d,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Ee.dateText,{color:h.subtitleColor,fontFamily:s.regular}],children:x}),jsxs(View,{style:[Ee.detailsCard,{backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,borderWidth:y.borderWidth??1,borderColor:y.borderColor}],children:[jsx(ya,{label:"Amount Sent",value:S}),jsx(ya,{label:"Amount Received",value:w}),jsx(ya,{label:"USD Value",value:_}),jsx(ya,{label:"Source Network",value:W}),jsx(ya,{label:"Destination Network",value:D,isLast:true})]}),jsxs(TouchableOpacity,{style:Ee.moreDetailsRow,onPress:()=>T(ae=>!ae),activeOpacity:.7,children:[jsx(Text,{style:[Ee.moreDetailsText,{color:h.actionTitle,fontFamily:s.regular}],children:C?"See less":n?"See more":"See more details"}),C?jsx(To,{size:16,color:h.actionColor,strokeWidth:2}):jsx(At,{size:16,color:h.actionColor,strokeWidth:2})]}),C&&jsx(View,{style:[Ee.detailsCard,{backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,borderWidth:y.borderWidth??1,borderColor:y.borderColor}],children:O&&v?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(v),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Ee.txHash,{color:y.titleColor,fontFamily:s.regular}],children:jm(O)}),jsx(ko,{size:14,color:y.actionColor,strokeWidth:2})]}),!p&&q&&N&&jsxs(Fragment,{children:[jsx(View,{style:[Ee.divider,{backgroundColor:y.borderColor}]}),jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(N),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Ee.txHash,{color:y.titleColor,fontFamily:s.regular}],children:jm(q)}),jsx(ko,{size:14,color:y.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Ee.detailRow,children:jsx(Text,{style:[Ee.detailLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Ee.buttonRow,children:[jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:b.secondaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:b.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:b.primaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:b.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Ee=StyleSheet.create({scroll:{flex:1},container:{alignItems:"center",paddingHorizontal:20,paddingTop:8,paddingBottom:32,gap:12},headerRow:{flexDirection:"row",alignItems:"center",width:"100%",paddingTop:16,marginBottom:4},headerSpacer:{width:28},headerTitle:{flex:1,fontSize:16,textAlign:"center"},iconContainer:{position:"relative",marginTop:8},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center"},spinnerDot:{width:10,height:10,borderRadius:5,borderWidth:2,borderColor:"#FFFFFF",borderTopColor:"transparent"},statusRow:{flexDirection:"row",alignItems:"center",gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:15},dateText:{fontSize:13,marginTop:-4},detailsCard:{width:"100%",paddingHorizontal:16,overflow:"hidden"},detailRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailLabel:{fontSize:13,flex:1},detailValue:{fontSize:13,flexShrink:0,maxWidth:"55%",textAlign:"right"},divider:{height:StyleSheet.hairlineWidth,opacity:.5},moreDetailsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingHorizontal:4},moreDetailsText:{fontSize:14},txRow:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:12},txLabel:{fontSize:13},txHash:{fontSize:13,flex:1,textAlign:"right"},buttonRow:{flexDirection:"row",gap:10,width:"100%",marginTop:4},button:{paddingVertical:14,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:14}});function $m(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Kl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=F(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",m=s?.status==="failed",c={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:It.container,children:[jsx(TouchableOpacity,{style:It.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[It.iconRing,{backgroundColor:n.successBackground}],children:jsx(Ue,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[It.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[It.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]}),jsxs(View,{style:It.buttonRow,children:[jsx(TouchableOpacity,{style:[It.button,It.halfButton,c,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[It.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[It.button,It.halfButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[It.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):m?jsxs(View,{style:It.container,children:[jsx(TouchableOpacity,{style:It.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[It.iconRing,{backgroundColor:n.errorBackground}],children:jsx(at,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[It.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[It.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[It.button,It.fullButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[It.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:It.container,children:[jsx(TouchableOpacity,{style:It.closeButton,onPress:r,children:jsx(at,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(kt,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:te(e.sourceTokenIconUrl)},style:It.tokenIconFill}):jsx(View,{style:[It.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[It.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[It.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]})]})}var It=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:48,paddingBottom:24},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconRing:{width:80,height:80,borderRadius:40,alignItems:"center",justifyContent:"center",marginBottom:20},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},title:{fontSize:20,marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,marginBottom:24},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,alignItems:"center",justifyContent:"center",borderRadius:12},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:15}});function Zy(e){let t=e.source_token_metadata?.decimals??6,r=e.source_amount_base_unit??"0",o=Number(r)/Math.pow(10,t),n=o>=1?o.toFixed(2):o.toPrecision(4).replace(/\.?0+$/,"");return {sourceChainType:e.source_chain_type,sourceChainId:e.source_chain_id,sourceTokenAddress:e.source_token_address,sourceTokenSymbol:e.source_currency?.toUpperCase()??"",sourceTokenIconUrl:te(Ce(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(Ce(e.destination_token_metadata,"png")),amount:n,amountBaseUnit:r,submittedAt:e.created_at?new Date(e.created_at):void 0,withdrawIntentAddress:e.deposit_wallet?.address??"",recipientAddress:e.recipient_address??""}}var qm=(e,t)=>`${t}:${e}`;function Xy(){let{colors:e}=F(),t=useRef(new Animated.Value(.5)).current,r=e.cardHover;return useEffect(()=>{let o=Animated.loop(Animated.sequence([Animated.timing(t,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(t,{toValue:.5,duration:800,useNativeDriver:true})]));return o.start(),()=>o.stop()},[t]),jsx(View,{style:{gap:12,paddingHorizontal:16},children:[1,2,3].map(o=>jsx(Animated.View,{style:{height:48,borderRadius:12,backgroundColor:r,opacity:t}},o))})}function Jl({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,defaultDestinationChainType:i,defaultDestinationChainId:s,defaultDestinationTokenAddress:l,modalTitle:m="Withdraw Crypto",onWithdraw:c,onWithdrawSuccess:C,onWithdrawError:T,heightPercent:y=.94,sheetBorderRadius:b,sourceChainType:k,sourceChainId:h,sourceTokenAddress:p,sourceTokenSymbol:g,sourceChainName:d,sourceTokenIconUrl:f}){let{colors:R,fonts:x}=F(),[S,w]=useState("form"),[_,W]=useState(k),[D,O]=useState(h),[v,q]=useState(p),[N,ae]=useState(g),[ze,ve]=useState(d),[J,Ve]=useState(f),[me,_e]=useState(null),[Ne,Se]=useState(null),[oe,Pe]=useState(null),[rt,je]=useState(),[ot,$e]=useState([]),[Fe,ct]=useState(null),[Re,X]=useState("form"),ce=useRef(new Animated.Value(Dimensions.get("window").width)).current,st=useRef(null),Je=!!_&&!!D&&!!v,{data:Le,isLoading:be}=Hl(r,e&&S==="form"),ie=Le?.data??[],{data:de,isLoading:zt}=Hd({sourceChainType:_,sourceChainId:D,sourceTokenAddress:v,sourceTokenSymbol:N,publishableKey:r,enabled:e&&Je&&S==="form"}),{data:ue,isLoading:se}=Nd({address:n,chainType:_,chainId:D,tokenAddress:v,publishableKey:r,enabled:e&&Je}),{executions:ye}=jd({userId:o,publishableKey:r,depositWalletId:rt,enabled:!!rt&&e,onWithdrawSuccess:C,onWithdrawError:T});useEffect(()=>{if(!e||S!=="tracker")return;let z=false;return Qo(o,r,"withdraw").then(Ot=>{z||$e(Ot.data);}).catch(console.error),()=>{z=true;}},[e,S,o,r]),useEffect(()=>{e&&(st.current&&(clearTimeout(st.current),st.current=null),w("form"),W(k),O(h),q(p),ae(g),ve(d),Ve(f),_e(null),Se(null),Pe(null),je(void 0),$e([]),ct(null),X("form"),ce.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{st.current&&clearTimeout(st.current);},[]),useEffect(()=>{J||de?.iconUrl&&Ve(de.iconUrl);},[de?.iconUrl,J]),useEffect(()=>{ze||de?.chainName&&ve(de.chainName);},[de?.chainName,ze]),useEffect(()=>{if(!ie.length||me)return;let z,Ot;if(i&&s)if(l)for(let St of ie){let Mr=St.chains.find(er=>er.chain_type===i&&er.chain_id===s&&er.token_address.toLowerCase()===l.toLowerCase());if(Mr){z=St,Ot=Mr;break}}else for(let St of ie){let Mr=St.chains.find(er=>er.chain_type===i&&er.chain_id===s);if(Mr){z=St,Ot=Mr;break}}z||(z=ie[0]),z&&(_e(z),Se(Ot??z.chains[0]??null));},[ie,me,i,s,l]),useEffect(()=>{S==="confirming"&&ye.length>0&&w("details");},[S,ye]);let yt=useCallback(()=>{t(),st.current=setTimeout(()=>{w("form"),W(k),O(h),q(p),ae(g),ve(d),Ve(f),_e(null),Se(null),Pe(null),je(void 0),$e([]),ct(null),X("form"),st.current=null;},300);},[t,k,h,p,g,d,f]),dt=useCallback(z=>{let Ot=ie.find(St=>St.symbol===z);Ot&&(_e(Ot),Ot.chains.length>0&&Se(Ot.chains[0]));},[ie]),le=useCallback(z=>{if(!me)return;let Ot=me.chains.find(St=>qm(St.chain_id,St.chain_type)===z);Ot&&Se(Ot);},[me]),qe=useCallback(async z=>{let Ot=await $o({external_user_id:o,destination_chain_type:z.destinationChainType,destination_chain_id:z.destinationChainId,destination_token_address:z.destinationTokenAddress,recipient_address:z.recipientAddress,action_type:"withdraw"},r),St=qo(Ot.data,_??"");if(!St)throw new Error(`No deposit wallet found for chain type: ${_}`);return je(St.id),{id:St.id,address:St.address}},[o,r,_]),yr=useCallback(z=>{Pe(z),w("confirming");},[]),xt=useCallback(z=>{ct(z),ce.setValue(Dimensions.get("window").width),Animated.timing(ce,{toValue:0,duration:280,useNativeDriver:true}).start();},[ce]),xr=useCallback(()=>{Animated.timing(ce,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>ct(null));},[ce]),$=be||zt,re=de?.isSupported??null,et=S==="confirming"?"Withdrawal Status":m,pe=b?.globalBorderTopLeftRadius,Me=b?.globalBorderTopRightRadius,M=b?.main?.borderTopLeftRadius??pe,ee=b?.main?.borderTopRightRadius??Me,ke=b?.tokenSelector?.borderTopLeftRadius??pe,fe=b?.tokenSelector?.borderTopRightRadius??Me,_t=b?.chainSelector?.borderTopLeftRadius??pe,V=b?.chainSelector?.borderTopRightRadius??Me,Or=(()=>{if(S!=="form"||!Je||se||!ue)return;let z=N||ue.symbol,Ot=ue.balanceUsd;if(Ot!=null){let er=`$${parseFloat(Ot).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return z?`Balance: ${er} ${z}`:`Balance: ${er}`}let St=ue.balanceHuman;if(!(!St||St==="0"))return z?`Balance: ${St} ${z}`:`Balance: ${St}`})();return jsx(ht,{visible:e,onClose:yt,closeOnBackdropPress:false,enablePanDownToClose:S==="tracker"||S==="form",showHandle:S==="tracker"||S==="form",heightPercent:S==="confirming"?.3:S==="details"?.7:S==="tracker"?.6:y,maxHeightPercent:S==="tracker"?.9:void 0,borderTopLeftRadius:M,borderTopRightRadius:ee,children:S==="confirming"&&oe?jsx(Kl,{txInfo:oe,executions:ye,onClose:yt,onViewTracker:()=>{X("confirming"),w("tracker");}}):S==="details"&&oe?jsx(Jd,{execution:ye.length>0?ye[ye.length-1]:null,txInfo:oe,onClose:yt,onViewHistory:()=>{X("details"),w("tracker");},onHeaderClose:()=>w("form")}):S==="tracker"?jsxs(View,{style:zo.trackerContainer,children:[jsx(Pr,{title:"Withdrawal History",onClose:()=>w(Re)}),ot.length===0?jsx(View,{style:zo.emptyState,children:jsx(Text,{style:[zo.emptyText,{color:R.foregroundMuted,fontFamily:x.regular}],children:"No withdrawals to track yet"})}):jsx(Vi,{data:ot,keyExtractor:z=>z.id,contentContainerStyle:zo.listContent,showsVerticalScrollIndicator:false,renderItem:({item:z})=>jsx(Ql,{execution:z,onPress:()=>xt(z)})}),Fe&&jsx(Animated.View,{style:[zo.historyDetailOverlay,{backgroundColor:R.background,transform:[{translateX:ce}]}],children:jsx(Jd,{execution:Fe,txInfo:Zy(Fe),onClose:yt,onBack:xr,onViewHistory:xr})})]}):jsxs(Fragment,{children:[jsx(Pr,{title:et,subtitle:Or,onClose:yt}),$?jsx(Xy,{}):re===false?jsxs(View,{style:zo.unsupportedContainer,children:[jsx(Text,{style:[zo.unsupportedTitle,{color:R.foreground,fontFamily:x.medium}],children:"Unsupported Token"}),jsx(Text,{style:[zo.unsupportedMessage,{color:R.foregroundMuted,fontFamily:x.regular}],children:de?.errorMessage})]}):jsx(eb,{publishableKey:r,sourceChainType:_??"",sourceChainId:D??"",sourceTokenAddress:v??"",sourceTokenSymbol:N,sourceChainName:ze,sourceTokenIconUrl:J,recipientAddressProp:a,destinationTokens:ie,selectedToken:me,selectedChain:Ne,selectedChainKey:Ne?qm(Ne.chain_id,Ne.chain_type):null,onTokenChange:dt,onChainChange:le,tokensLoading:be,balanceData:ue??null,isLoadingBalance:se,sourceValidation:de??null,onDepositWalletCreation:qe,onWithdraw:c,onWithdrawError:T,onWithdrawSubmitted:yr,onViewTracker:()=>{X("form"),w("tracker");},tokenSelectorLeft:ke,tokenSelectorRight:fe,chainSelectorLeft:_t,chainSelectorRight:V})]})})}function eb({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:m,selectedChain:c,selectedChainKey:C,onTokenChange:T,onChainChange:y,tokensLoading:b,balanceData:k,isLoadingBalance:h,sourceValidation:p,onDepositWalletCreation:g,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:R,onViewTracker:x,tokenSelectorLeft:S,tokenSelectorRight:w,chainSelectorLeft:_,chainSelectorRight:W}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(gt,{style:{flex:1,paddingTop:16},contentContainerStyle:zo.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:zo.doubleInputWrapper,children:jsx(ga,{tokens:l,selectedTokenSymbol:m?.symbol??null,selectedChainKey:C,onTokenChange:T,onChainChange:y,isLoading:b,tokenPickerBorderTopLeftRadius:S,tokenPickerBorderTopRightRadius:w,chainPickerBorderTopLeftRadius:_,chainPickerBorderTopRightRadius:W})}),jsx(jl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:m,selectedChain:c,balanceData:k,isLoadingBalance:h,minimumWithdrawAmountUsd:p?.minimumAmountUsd??null,estimatedProcessingTime:p?.estimatedProcessingTime??null,maxSlippagePercent:p?.maxSlippagePercent??null,priceImpactPercent:p?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:g,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:R,onViewTracker:x})]})})}var zo=StyleSheet.create({scrollContent:{paddingBottom:32},doubleInputWrapper:{paddingHorizontal:16,paddingBottom:12,paddingTop:4},listContent:{paddingHorizontal:16,paddingBottom:32,gap:8},trackerContainer:{flex:1,overflow:"hidden"},historyDetailOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},emptyState:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:48},emptyText:{fontSize:14},unsupportedContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24,paddingVertical:48},unsupportedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},unsupportedMessage:{fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280}});StyleSheet.create({container:{paddingHorizontal:16,paddingTop:16,paddingBottom:24,gap:16},fieldGroup:{gap:8},fieldLabel:{fontSize:12},walletCard:{paddingHorizontal:12,paddingVertical:12,minHeight:48,justifyContent:"center"},walletAddress:{fontSize:13},primaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginTop:4},primaryButtonText:{fontSize:16},secondaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center"},secondaryButtonText:{fontSize:16}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Gm=createContext(null);function db({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new od({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,m]=useState(false),[c,C]=useState(null),T=useColorScheme(),y=useRef(false);y.current||(va({publishableKey:t}),y.current=true);let b=useMemo(()=>{let v=r?.appearance||"dark";return v==="auto"?T==="dark"?"dark":"light":v},[r?.appearance,T]);useEffect(()=>{if(!t||t.trim()===""){console.error("Unifold: publishableKey is required. Please provide a valid publishable key.");return}!t.startsWith("pk_test_")&&!t.startsWith("pk_live_")&&console.warn('Unifold: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),va({publishableKey:t});},[t]),useEffect(()=>()=>{h.current&&clearTimeout(h.current),x.current&&clearTimeout(x.current);},[]);let k=useRef(null),h=useRef(null),p=useCallback(v=>{h.current&&(clearTimeout(h.current),h.current=null),k.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),k.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),k.current=null);let q=new Promise((N,ae)=>{k.current={resolve:N,reject:ae};});return s(v),a(true),q},[]),g=useCallback(()=>{k.current&&(k.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),k.current=null),a(false),h.current=setTimeout(()=>{s(null),h.current=null;},200);},[]),d=useCallback(v=>{i?.onSuccess&&i.onSuccess(v),k.current&&(k.current.resolve(v),k.current=null);},[i]),f=useCallback(v=>{console.error("[UnifoldProvider] Deposit error:",v),i?.onError&&i.onError(v),k.current&&(k.current.reject(v),k.current=null);},[i]),R=useRef(null),x=useRef(null),S=useRef(void 0),w=useCallback(v=>{x.current&&(clearTimeout(x.current),x.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,ae)=>{R.current={resolve:N,reject:ae};});return S.current=v.onClose,C(v),m(true),q},[]),_=useCallback(()=>{R.current&&(R.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),R.current=null),S.current?.(),S.current=void 0,m(false),x.current=setTimeout(()=>{C(null),x.current=null;},200);},[]),W=useCallback(v=>{c?.onSuccess&&c.onSuccess(v),R.current&&(R.current.resolve(v),R.current=null);},[c]),D=useCallback(v=>{console.error("[UnifoldProvider] Withdraw error:",v),c?.onError&&c.onError(v),R.current&&(R.current.reject(v),R.current=null);},[c]),O=useMemo(()=>({publishableKey:t,beginDeposit:p,closeDeposit:g,beginWithdraw:w,closeWithdraw:_}),[t,p,g,w,_]);return jsx(sd,{client:o,children:jsx(Gm.Provider,{value:O,children:jsxs(Di,{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Ul,{visible:n,onClose:g,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:i.externalUserId,destinationChainType:i.destinationChainType,destinationChainId:i.destinationChainId,destinationTokenSymbol:i.destinationTokenSymbol,recipientAddress:i.recipientAddress,destinationTokenAddress:i.destinationTokenAddress,defaultChainType:i.defaultChainType,defaultChainId:i.defaultChainId,defaultTokenAddress:i.defaultTokenAddress,showBalance:i.showBalance,stripeOnrampEmail:i.stripeOnrampEmail,stripeOnrampPhone:i.stripeOnrampPhone,stripeTheme:{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:i.depositConfirmationMode??"auto_ui",initialScreen:i.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?sp():void 0,onDepositSuccess:d,onDepositError:f,theme:b,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Jl,{visible:l,onClose:_,publishableKey:t,externalUserId:c.externalUserId,senderAddress:c.senderAddress,recipientAddress:c.recipientAddress,sourceChainType:c.sourceChainType,sourceChainId:c.sourceChainId,sourceTokenAddress:c.sourceTokenAddress,sourceTokenSymbol:c.sourceTokenSymbol,defaultDestinationChainType:c.defaultDestinationChainType,defaultDestinationChainId:c.defaultDestinationChainId,defaultDestinationTokenAddress:c.defaultDestinationTokenAddress,onWithdraw:c.withdraw,onWithdrawSuccess:W,onWithdrawError:D,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function ub(){let e=useContext(Gm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
+ export{Qa as AmountScreen,ht as BottomSheet,Ka as KYCWizardScreen,el as OnrampScreen,tl as StripeOnramp,np as StripeOnrampPreconfigure,db as UnifoldProvider,Ce as getPreferredIcon,Na as getStripePublishableKey,Va as getSupportedDestinationTokens,te as normalizeIconUrl,rl as registerStripeOnramp,cu as setDevApiUrl,Ha as setStripeOnrampApiUrl,Ua as setStripeOnrampPublishableKey,ma as useAllowedCountry,Ga as useStripeOnramp,F as useTheme,ub as useUnifold};