@vechain/vechain-kit 2.8.1 → 2.8.2

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
@@ -118,13 +118,13 @@ import{$ as e,C as t,D as n,G as r,H as i,J as a,Q as o,S as s,T as c,U as l,V a
118
118
  opacity: 0.5 !important;
119
119
  }
120
120
  `),d.length>0&&(u.textContent=d.join(`
121
- `))}let Mo=null;function No(){return Mo||=new or({defaultOptions:{queries:{queryKeyHashFn:fr,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Mo}const Po=({children:e})=>{try{if(V.useContext(sr))return q(K,{children:e})}catch(e){console.log(e)}return q(cr,{client:No(),children:e})},Fo=({onClick:e,...t})=>q(Tt,{"aria-label":`Back`,icon:q(P,{as:Dr,fontSize:`20px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,onClick:e,lineHeight:`0`,...t}),Io=({wallet:e,label:t,style:n,showHumanAddress:r=!0,setCurrentContent:i,onLogout:a})=>{let{t:o}=Y(),[s,c]=G(!1),[l,u]=G(!1),f=B(`colors`,`vechain-kit-text-primary`),p=B(`colors`,`vechain-kit-text-secondary`),m=mn(`#ebebeb`,`#ffffff0a`),h=mn(`#ffffff`,`transparent`),g=async(e,t)=>{await D(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))},_=()=>{i&&(e?.domain?i({type:`choose-name-search`,props:{name:``,setCurrentContent:i,initialContentSource:`profile`}}):i({type:`choose-name`,props:{setCurrentContent:i,initialContentSource:`profile`,onBack:()=>i(`profile`)}}))};return q(z,{w:`full`,justifyContent:`center`,...n,children:J(z,{w:`full`,spacing:4,children:[t&&q(R,{fontSize:`sm`,color:p,children:t}),J(z,{spacing:2,w:`full`,children:[e?.domain&&J(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[q(P,{as:li,color:p}),q(R,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:l?o(`Copied!`):e.domain}),J(N,{spacing:2,children:[i&&q(Tt,{icon:q(Qr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:_,"aria-label":`Edit domain`}),q(Tt,{icon:q(l?Tr:Pr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:()=>g(e.domain||``,u),"aria-label":`Copy domain`})]})]}),J(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[q(P,{as:pi,color:p}),q(R,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:s?o(`Copied!`):r?d(e?.address??``,8,7):e?.address}),J(N,{spacing:2,children:[q(Tt,{icon:q(Yr,{}),onClick:()=>i?.({type:`disconnect-confirm`,props:{onDisconnect:()=>a?.(),onBack:()=>i?.(`profile`)}}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`}),q(Tt,{icon:q(s?Tr:Pr,{}),onClick:()=>g(e?.address??``,c),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`})]})]})]})]})})};var Lo=`2.8.1`,Ro={"@adraffy/ens-normalize":`^1.11.0`,"@chakra-ui/react":`^2.8.2`,"@emotion/styled":`^11.14.1`,"@privy-io/cross-app-connect":`0.2.2`,"@privy-io/react-auth":`2.25.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.3.0`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.6.0-rc`,"@wagmi/core":`^2.17.2`,"bignumber.js":`^9.1.2`,"browser-image-compression":`^2.0.2`,dotenv:`^16.4.7`,ethers:`^6.13.5`,"framer-motion":`^11.15.0`,i18next:`^24.2.1`,"i18next-browser-languagedetector":`^8.0.2`,net:`^1.0.2`,process:`^0.11.10`,react:`^18.2.0`,"react-device-detect":`^2.2.3`,"react-hook-form":`^7.54.2`,"react-i18next":`^15.4.0`,"react-icons":`^5.4.0`,"react-qrcode-logo":`^3.0.0`,vaul:`^1.1.2`,viem:`^2.29.3`,wagmi:`^2.15.4`},zo={"@chakra-ui/react":`^2.8.2`,"@emotion/react":`^11.0.0`,"@emotion/styled":`^11.0.0`,"@tanstack/react-query":`^5.64.2`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const Bo=({...e})=>{let{darkMode:t}=$();return J(N,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[q(ye,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),J(jt,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Lo}`,isExternal:!0,pt:`1px`,children:[`v`,Lo]})]})},Vo=yn({hasContentBelow:!1}),Ho=()=>bn(Vo),Z=({children:e})=>{let[t,n]=G(!1),r=xn(null),i=xn(null),a=xn(null),o=xn(!0),{tokens:s}=_p(),c=s?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return U(()=>{let e=e=>{if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t);if(e.overflowY===`auto`||e.overflowY===`scroll`||e.overflow===`auto`||e.overflow===`scroll`)return t;t=t.parentElement}return null},t=([e])=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{if(o.current){o.current=!1,n(!1);return}n(!e.isIntersecting)},50)},s=e(i.current),c={threshold:0};s&&(c.root=s,c.rootMargin=`0px`);let l=new IntersectionObserver(t,c),u=setTimeout(()=>{r.current&&l.observe(r.current)},200);return()=>{clearTimeout(u),a.current&&clearTimeout(a.current),l.disconnect()}},[]),J(Vo.Provider,{value:{hasContentBelow:t},children:[q(j,{ref:i,position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?c:`none`,style:{WebkitBackdropFilter:t?c:`none`},zIndex:1e3,boxShadow:t?`0px 2px 4px 1px rgb(0 0 0 / 10%)`:`none`,transition:`box-shadow 0.2s ease-in-out`,children:e}),q(`div`,{ref:r,style:{height:`1px`,width:`100%`,pointerEvents:`none`,visibility:`hidden`,marginTop:`-1px`}})]})},Uo=({children:e})=>q(j,{position:`absolute`,bottom:`0`,left:`0`,right:`0`,bg:B(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,w:`full`,children:e}),Wo=({scrollableContainerRef:e,observerRef:t})=>{let n=B(`colors`,`vechain-kit-border`),{tokens:r}=_p(),i=r?.effects?.backdropFilter?.stickyHeader??`blur(20px)`,[a,o]=G(!1),s=xn(null),c=xn(!0);return U(()=>{let n=([e])=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{if(c.current){c.current=!1,o(!1);return}o(!e.isIntersecting)},50)},r={threshold:0};e.current&&(r.root=e.current,r.rootMargin=`0px`);let i=new IntersectionObserver(n,r),a=setTimeout(()=>{t.current&&i.observe(t.current)},200);return()=>{clearTimeout(a),s.current&&clearTimeout(s.current),i.disconnect()}},[e,t]),q(j,{position:`sticky`,top:`0`,w:`full`,backdropFilter:a?i:`none`,style:{WebkitBackdropFilter:a?i:`none`},zIndex:999,transition:`backdrop-filter 0.2s ease-in-out`,children:q(j,{mx:`auto`,w:`34px`,h:`5px`,bg:n,mt:4,rounded:`full`})})},Go=({isOpen:e,onClose:t,children:n,ariaTitle:r,ariaDescription:i,isDismissable:a=!0,minHeight:o,maxHeight:s=`68vh`,closeThreshold:c=.5})=>{let l=B(`colors`,`vechain-kit-modal`),u=B(`colors`,`vechain-kit-overlay`),d=xn(null),f=xn(null),{tokens:p}=_p(),m=p?.effects?.backdropFilter?.overlay,h=p?.colors?.border?.modal||`none`;return q(gi.Root,{dismissible:a,shouldScaleBackground:!0,repositionInputs:!1,open:e,closeThreshold:c,onOpenChange:e=>{e||t()},children:J(gi.Portal,{children:[q(gi.Overlay,{style:{zIndex:100,position:`fixed`,top:0,right:0,bottom:0,left:0,backgroundColor:u,backdropFilter:m,WebkitBackdropFilter:m}}),J(gi.Content,{"aria-description":i,style:{zIndex:101,backgroundColor:l,borderRadius:`24px 24px 0 0`,border:h,position:`fixed`,bottom:0,left:0,right:0,...o&&{minHeight:o},maxHeight:s,display:`flex`,flexDirection:`column`},children:[q(gi.Title,{style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:0},children:r}),J(j,{ref:d,flex:`1`,overflowY:`auto`,children:[q(Wo,{scrollableContainerRef:d,observerRef:f}),q(`div`,{ref:f,style:{height:`1px`,width:`100%`,visibility:`hidden`,marginTop:`-1px`}}),n]})]})]})})},Ko=({isOpen:e,onClose:t,children:n,size:r=`sm`,isCentered:i=!0,motionPreset:a=`slideInBottom`,closeOnOverlayClick:o=!0,blockScrollOnMount:s=!1,allowExternalFocus:c=!1,backdropFilter:l,isCloseable:u=!0,useBottomSheetOnMobile:d,mobileMinHeight:f,mobileMaxHeight:p=`57vh`,desktopMinHeight:m,desktopMaxHeight:h})=>{let[g]=gn(`(min-width: 768px)`),{portalRootRef:_,themeConfig:v,tokens:y}=_p(),b=d??v?.modal?.useBottomSheetOnMobile??!1,x=B(`colors`,`vechain-kit-modal`),S=B(`colors`,`vechain-kit-overlay`),C=y?.effects?.backdropFilter?.overlay,w=y?.effects?.backdropFilter?.modal,ee=l??C??`blur(3px)`,T=g?{minHeight:m,maxHeight:h}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`,minHeight:f,maxHeight:p},E=J(Pt,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:_},trapFocus:!c,autoFocus:!c,variant:`vechainKitBase`,children:[q(Lt,{bg:S,backdropFilter:ee}),q(Ft,{role:`dialog`,"aria-modal":!c,bg:x,sx:{backdropFilter:w,WebkitBackdropFilter:w},...T,children:n})]});return q(K,{children:!g&&b?q(Pt,{isOpen:e,onClose:t,size:r,blockScrollOnMount:!1,trapFocus:!1,children:q(Go,{isOpen:e,onClose:t,ariaTitle:`Dialog`,ariaDescription:`Dialog content area`,isDismissable:u,minHeight:f,maxHeight:p,children:n})}):E})},qo=async e=>{let t=new URL(`/api/v1/apps/${e}`,ze),n=await fetch(t,{headers:{"privy-app-id":e}});if(!n.ok)throw Error(`Failed to fetch Privy app info`);return n.json()},Jo=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],Yo=e=>{let t=Array.isArray(e)?e:[e];return X({queryKey:Jo(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>qo(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=f.find(e=>e.id===r);return[r,{...e,website:i?.website}]}))},enabled:t.length>0,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Xo=async()=>{try{let e=new URL(`summary.json`,Re),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch Privy status`);return(await t.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},Zo=()=>X({queryKey:[`PRIVY_STATUS`],queryFn:Xo,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60}),Qo=e=>[`VECHAIN_KIT_DOMAIN`,e],$o=e=>{let{network:t}=$();return X({queryKey:Qo(e),queryFn:async()=>{if(!e)throw Error(`Address or domain is required`);if(t.type!==`main`&&t.type!==`test`){let t=T(e);return{address:t?e:void 0,domain:void 0,isValidAddressOrDomain:t,isPrimaryDomain:!1}}let n=await wi(e,{networkUrl:t.nodeUrl}),r=T(e);if(!n&&!r)throw Error(`Input must be a valid domain or address`);let i=null,a=null,o=!1;return n?(i=await yi(e,{networkUrl:t.nodeUrl}),a=e,i&&(o=await Ci(e,i,{networkUrl:t.nodeUrl}))):(a=await _i(e,{networkUrl:t.nodeUrl}),i=e,a&&(o=await Ci(a,e,{networkUrl:t.nodeUrl}))),{address:i||void 0,domain:a||void 0,isValidAddressOrDomain:n||r,isPrimaryDomain:o}},enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address or domain is required`||e===`input must be a valid domain or address`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},es=async(e,t,n)=>{let r=qi(Bi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,qi(Zi(n))])),i=await e.contracts.load(v(t).vetDomainsContractAddress,Pi.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},ts=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],ns=e=>{let t=nr(),{network:n}=$();return X({queryKey:ts(e),queryFn:()=>es(t,n.type,e),enabled:!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},rs=(e,t)=>{let n=dr(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:Ss(e??``,r.type)}),n.invalidateQueries({queryKey:Es(e,r.type)}),n.invalidateQueries({queryKey:Fs(t)})])}}},is=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:Qo(t)}),e.invalidateQueries({queryKey:Qo(n)}),e.invalidateQueries({queryKey:ts(r)}),e.invalidateQueries({queryKey:bs(t,`.vet`)}),e.invalidateQueries({queryKey:bs(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Es(n)})]),await Promise.all([e.refetchQueries({queryKey:Qo(t)}),e.refetchQueries({queryKey:Qo(n)}),e.refetchQueries({queryKey:bs(t,`.vet`)}),e.refetchQueries({queryKey:bs(t,`.veworld.vet`)}),e.refetchQueries({queryKey:Ss(r+`.`+i,a)}),e.refetchQueries({queryKey:Es(n)}),e.refetchQueries({queryKey:ts(r)}),e.refetchQueries({queryKey:Fs(t)})])},as=Ii.createInterface(),os=Fi.createInterface(),ss=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:v(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:os.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:os.getFunction(`setName`)}),n){a.push({to:v(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:os.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:os.getFunction(`setName`)});let e=new wn.Interface([`function setAddr(bytes32 node, address addr)`]),t=wn.namehash(o);a.push({to:v(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${d(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(ls(t))a.push({to:v(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:as.encodeFunctionData(`claim`,[e,v(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:as.getFunction(`claim`)}),a.push({to:v(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:os.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:os.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},cs=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=dr(),{account:o}=Q(),{network:s}=$(),{refresh:c}=rs(e+`.`+t,o?.address??``),l=H(()=>ss(e,t,i,o,s),[e,t,i,o,s]),u=H(async()=>{let r=`${e}.${t}`;await is(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=Cl({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e}.${t} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:u,onTxFailedOrCancelled:()=>{r?.()}});return{...d,clauses:l,sendTransaction:async()=>d.sendTransaction(l())}},ls=e=>e.endsWith(`veworld.vet`),us=Fi.createInterface(),ds=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:v(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:us.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:us.getFunction(`setName`)});let t=new wn.Interface([`function setAddr(bytes32 node, address addr)`]),a=wn.namehash(e);i.push({to:v(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${d(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},fs=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=dr(),{account:o}=Q(),{refresh:s}=rs(e,o?.address??``),c=H(()=>ds(e,r,o,i),[e,r,o,i]),l=H(async()=>{await is(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=Cl({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:l,onTxFailedOrCancelled:n});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c())}},ps=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],ms=jn.ofAbi(Ii.abi),hs=async(e,t,n)=>{let r=v(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,ms.abi).read.isDomainProtected(n))[0]},gs=(e,t=!0)=>{let n=nr(),{network:r}=$();return X({queryKey:ps(e),queryFn:()=>hs(n,r.type,e),enabled:!!e&&t&&!!r.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},_s=$i.object({name:$i.string()}),vs=$i.object({domains:$i.array(_s)}),ys=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=v(e).graphQlIndexerUrl,i=`query Registrations {
121
+ `))}let Mo=null;function No(){return Mo||=new or({defaultOptions:{queries:{queryKeyHashFn:fr,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Mo}const Po=({children:e})=>{try{if(V.useContext(sr))return q(K,{children:e})}catch(e){console.log(e)}return q(cr,{client:No(),children:e})},Fo=({onClick:e,...t})=>q(Tt,{"aria-label":`Back`,icon:q(P,{as:Dr,fontSize:`20px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,onClick:e,lineHeight:`0`,...t}),Io=({wallet:e,label:t,style:n,showHumanAddress:r=!0,setCurrentContent:i,onLogout:a})=>{let{t:o}=Y(),[s,c]=G(!1),[l,u]=G(!1),f=B(`colors`,`vechain-kit-text-primary`),p=B(`colors`,`vechain-kit-text-secondary`),m=mn(`#ebebeb`,`#ffffff0a`),h=mn(`#ffffff`,`transparent`),g=async(e,t)=>{await D(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))},_=()=>{i&&(e?.domain?i({type:`choose-name-search`,props:{name:``,setCurrentContent:i,initialContentSource:`profile`}}):i({type:`choose-name`,props:{setCurrentContent:i,initialContentSource:`profile`,onBack:()=>i(`profile`)}}))};return q(z,{w:`full`,justifyContent:`center`,...n,children:J(z,{w:`full`,spacing:4,children:[t&&q(R,{fontSize:`sm`,color:p,children:t}),J(z,{spacing:2,w:`full`,children:[e?.domain&&J(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[q(P,{as:li,color:p}),q(R,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:l?o(`Copied!`):e.domain}),J(N,{spacing:2,children:[i&&q(Tt,{icon:q(Qr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:_,"aria-label":`Edit domain`}),q(Tt,{icon:q(l?Tr:Pr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:()=>g(e.domain||``,u),"aria-label":`Copy domain`})]})]}),J(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[q(P,{as:pi,color:p}),q(R,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:s?o(`Copied!`):r?d(e?.address??``,8,7):e?.address}),J(N,{spacing:2,children:[q(Tt,{icon:q(Yr,{}),onClick:()=>i?.({type:`disconnect-confirm`,props:{onDisconnect:()=>a?.(),onBack:()=>i?.(`profile`)}}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`}),q(Tt,{icon:q(s?Tr:Pr,{}),onClick:()=>g(e?.address??``,c),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`})]})]})]})]})})};var Lo=`2.8.2`,Ro={"@adraffy/ens-normalize":`^1.11.0`,"@chakra-ui/react":`^2.8.2`,"@emotion/styled":`^11.14.1`,"@privy-io/cross-app-connect":`0.2.2`,"@privy-io/react-auth":`2.25.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.3.0`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.6.0-rc`,"@wagmi/core":`^2.17.2`,"bignumber.js":`^9.1.2`,"browser-image-compression":`^2.0.2`,dotenv:`^16.4.7`,ethers:`^6.13.5`,"framer-motion":`^11.15.0`,i18next:`^24.2.1`,"i18next-browser-languagedetector":`^8.0.2`,net:`^1.0.2`,process:`^0.11.10`,react:`^18.2.0`,"react-device-detect":`^2.2.3`,"react-hook-form":`^7.54.2`,"react-i18next":`^15.4.0`,"react-icons":`^5.4.0`,"react-qrcode-logo":`^3.0.0`,vaul:`^1.1.2`,viem:`^2.29.3`,wagmi:`^2.15.4`},zo={"@chakra-ui/react":`^2.8.2`,"@emotion/react":`^11.0.0`,"@emotion/styled":`^11.0.0`,"@tanstack/react-query":`^5.64.2`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const Bo=({...e})=>{let{darkMode:t}=$();return J(N,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[q(ye,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),J(jt,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Lo}`,isExternal:!0,pt:`1px`,children:[`v`,Lo]})]})},Vo=yn({hasContentBelow:!1}),Ho=()=>bn(Vo),Z=({children:e})=>{let[t,n]=G(!1),r=xn(null),i=xn(null),a=xn(null),o=xn(!0),{tokens:s}=_p(),c=s?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return U(()=>{let e=e=>{if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t);if(e.overflowY===`auto`||e.overflowY===`scroll`||e.overflow===`auto`||e.overflow===`scroll`)return t;t=t.parentElement}return null},t=([e])=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{if(o.current){o.current=!1,n(!1);return}n(!e.isIntersecting)},50)},s=e(i.current),c={threshold:0};s&&(c.root=s,c.rootMargin=`0px`);let l=new IntersectionObserver(t,c),u=setTimeout(()=>{r.current&&l.observe(r.current)},200);return()=>{clearTimeout(u),a.current&&clearTimeout(a.current),l.disconnect()}},[]),J(Vo.Provider,{value:{hasContentBelow:t},children:[q(j,{ref:i,position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?c:`none`,style:{WebkitBackdropFilter:t?c:`none`},zIndex:1e3,boxShadow:t?`0px 2px 4px 1px rgb(0 0 0 / 10%)`:`none`,transition:`box-shadow 0.2s ease-in-out`,children:e}),q(`div`,{ref:r,style:{height:`1px`,width:`100%`,pointerEvents:`none`,visibility:`hidden`,marginTop:`-1px`}})]})},Uo=({children:e})=>q(j,{position:`absolute`,bottom:`0`,left:`0`,right:`0`,bg:B(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,w:`full`,children:e}),Wo=({scrollableContainerRef:e,observerRef:t})=>{let n=B(`colors`,`vechain-kit-border`),{tokens:r}=_p(),i=r?.effects?.backdropFilter?.stickyHeader??`blur(20px)`,[a,o]=G(!1),s=xn(null),c=xn(!0);return U(()=>{let n=([e])=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{if(c.current){c.current=!1,o(!1);return}o(!e.isIntersecting)},50)},r={threshold:0};e.current&&(r.root=e.current,r.rootMargin=`0px`);let i=new IntersectionObserver(n,r),a=setTimeout(()=>{t.current&&i.observe(t.current)},200);return()=>{clearTimeout(a),s.current&&clearTimeout(s.current),i.disconnect()}},[e,t]),q(j,{position:`sticky`,top:`0`,w:`full`,backdropFilter:a?i:`none`,style:{WebkitBackdropFilter:a?i:`none`},zIndex:999,transition:`backdrop-filter 0.2s ease-in-out`,children:q(j,{mx:`auto`,w:`34px`,h:`5px`,bg:n,mt:4,rounded:`full`})})},Go=({isOpen:e,onClose:t,children:n,ariaTitle:r,ariaDescription:i,isDismissable:a=!0,minHeight:o,maxHeight:s=`68vh`,closeThreshold:c=.5})=>{let l=B(`colors`,`vechain-kit-modal`),u=B(`colors`,`vechain-kit-overlay`),d=xn(null),f=xn(null),{tokens:p}=_p(),m=p?.effects?.backdropFilter?.overlay,h=p?.colors?.border?.modal||`none`;return q(gi.Root,{dismissible:a,shouldScaleBackground:!0,repositionInputs:!1,open:e,closeThreshold:c,onOpenChange:e=>{e||t()},children:J(gi.Portal,{children:[q(gi.Overlay,{style:{zIndex:100,position:`fixed`,top:0,right:0,bottom:0,left:0,backgroundColor:u,backdropFilter:m,WebkitBackdropFilter:m}}),J(gi.Content,{"aria-description":i,style:{zIndex:101,backgroundColor:l,borderRadius:`24px 24px 0 0`,border:h,position:`fixed`,bottom:0,left:0,right:0,...o&&{minHeight:o},maxHeight:s,display:`flex`,flexDirection:`column`},children:[q(gi.Title,{style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:0},children:r}),J(j,{ref:d,flex:`1`,overflowY:`auto`,children:[q(Wo,{scrollableContainerRef:d,observerRef:f}),q(`div`,{ref:f,style:{height:`1px`,width:`100%`,visibility:`hidden`,marginTop:`-1px`}}),n]})]})]})})},Ko=({isOpen:e,onClose:t,children:n,size:r=`sm`,isCentered:i=!0,motionPreset:a=`slideInBottom`,closeOnOverlayClick:o=!0,blockScrollOnMount:s=!1,allowExternalFocus:c=!1,backdropFilter:l,isCloseable:u=!0,useBottomSheetOnMobile:d,mobileMinHeight:f,mobileMaxHeight:p=`57vh`,desktopMinHeight:m,desktopMaxHeight:h})=>{let[g]=gn(`(min-width: 768px)`),{portalRootRef:_,themeConfig:v,tokens:y}=_p(),b=d??v?.modal?.useBottomSheetOnMobile??!1,x=B(`colors`,`vechain-kit-modal`),S=B(`colors`,`vechain-kit-overlay`),C=y?.effects?.backdropFilter?.overlay,w=y?.effects?.backdropFilter?.modal,ee=l??C??`blur(3px)`,T=g?{minHeight:m,maxHeight:h}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`,minHeight:f,maxHeight:p},E=J(Pt,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:_},trapFocus:!c,autoFocus:!c,variant:`vechainKitBase`,children:[q(Lt,{bg:S,backdropFilter:ee}),q(Ft,{role:`dialog`,"aria-modal":!c,bg:x,sx:{backdropFilter:w,WebkitBackdropFilter:w},...T,children:n})]});return q(K,{children:!g&&b?q(Pt,{isOpen:e,onClose:t,size:r,blockScrollOnMount:!1,trapFocus:!1,children:q(Go,{isOpen:e,onClose:t,ariaTitle:`Dialog`,ariaDescription:`Dialog content area`,isDismissable:u,minHeight:f,maxHeight:p,children:n})}):E})},qo=async e=>{let t=new URL(`/api/v1/apps/${e}`,ze),n=await fetch(t,{headers:{"privy-app-id":e}});if(!n.ok)throw Error(`Failed to fetch Privy app info`);return n.json()},Jo=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],Yo=e=>{let t=Array.isArray(e)?e:[e];return X({queryKey:Jo(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>qo(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=f.find(e=>e.id===r);return[r,{...e,website:i?.website}]}))},enabled:t.length>0,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Xo=async()=>{try{let e=new URL(`summary.json`,Re),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch Privy status`);return(await t.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},Zo=()=>X({queryKey:[`PRIVY_STATUS`],queryFn:Xo,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60}),Qo=e=>[`VECHAIN_KIT_DOMAIN`,e],$o=e=>{let{network:t}=$();return X({queryKey:Qo(e),queryFn:async()=>{if(!e)throw Error(`Address or domain is required`);if(t.type!==`main`&&t.type!==`test`){let t=T(e);return{address:t?e:void 0,domain:void 0,isValidAddressOrDomain:t,isPrimaryDomain:!1}}let n=await wi(e,{networkUrl:t.nodeUrl}),r=T(e);if(!n&&!r)throw Error(`Input must be a valid domain or address`);let i=null,a=null,o=!1;return n?(i=await yi(e,{networkUrl:t.nodeUrl}),a=e,i&&(o=await Ci(e,i,{networkUrl:t.nodeUrl}))):(a=await _i(e,{networkUrl:t.nodeUrl}),i=e,a&&(o=await Ci(a,e,{networkUrl:t.nodeUrl}))),{address:i||void 0,domain:a||void 0,isValidAddressOrDomain:n||r,isPrimaryDomain:o}},enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address or domain is required`||e===`input must be a valid domain or address`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},es=async(e,t,n)=>{let r=qi(Bi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,qi(Zi(n))])),i=await e.contracts.load(v(t).vetDomainsContractAddress,Pi.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},ts=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],ns=e=>{let t=nr(),{network:n}=$();return X({queryKey:ts(e),queryFn:()=>es(t,n.type,e),enabled:!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},rs=(e,t)=>{let n=dr(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:Ss(e??``,r.type)}),n.invalidateQueries({queryKey:Es(e,r.type)}),n.invalidateQueries({queryKey:Fs(t)})])}}},is=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:Qo(t)}),e.invalidateQueries({queryKey:Qo(n)}),e.invalidateQueries({queryKey:ts(r)}),e.invalidateQueries({queryKey:bs(t,`.vet`)}),e.invalidateQueries({queryKey:bs(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Es(n)})]),await Promise.all([e.refetchQueries({queryKey:Qo(t)}),e.refetchQueries({queryKey:Qo(n)}),e.refetchQueries({queryKey:bs(t,`.vet`)}),e.refetchQueries({queryKey:bs(t,`.veworld.vet`)}),e.refetchQueries({queryKey:Ss(r+`.`+i,a)}),e.refetchQueries({queryKey:Es(n)}),e.refetchQueries({queryKey:ts(r)}),e.refetchQueries({queryKey:Fs(t)})])},as=Ii.createInterface(),os=Fi.createInterface(),ss=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:v(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:os.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:os.getFunction(`setName`)}),n){a.push({to:v(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:os.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:os.getFunction(`setName`)});let e=new wn.Interface([`function setAddr(bytes32 node, address addr)`]),t=wn.namehash(o);a.push({to:v(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${d(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(ls(t))a.push({to:v(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:as.encodeFunctionData(`claim`,[e,v(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:as.getFunction(`claim`)}),a.push({to:v(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:os.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:os.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},cs=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=dr(),{account:o}=Q(),{network:s}=$(),{refresh:c}=rs(e+`.`+t,o?.address??``),l=H(()=>ss(e,t,i,o,s),[e,t,i,o,s]),u=H(async()=>{let r=`${e}.${t}`;await is(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=Cl({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e}.${t} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:u,onTxFailedOrCancelled:()=>{r?.()}});return{...d,clauses:l,sendTransaction:async()=>d.sendTransaction(l())}},ls=e=>e.endsWith(`veworld.vet`),us=Fi.createInterface(),ds=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:v(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:us.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:us.getFunction(`setName`)});let t=new wn.Interface([`function setAddr(bytes32 node, address addr)`]),a=wn.namehash(e);i.push({to:v(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${d(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},fs=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=dr(),{account:o}=Q(),{refresh:s}=rs(e,o?.address??``),c=H(()=>ds(e,r,o,i),[e,r,o,i]),l=H(async()=>{await is(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=Cl({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:l,onTxFailedOrCancelled:n});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c())}},ps=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],ms=jn.ofAbi(Ii.abi),hs=async(e,t,n)=>{let r=v(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,ms.abi).read.isDomainProtected(n))[0]},gs=(e,t=!0)=>{let n=nr(),{network:r}=$();return X({queryKey:ps(e),queryFn:()=>hs(n,r.type,e),enabled:!!e&&t&&!!r.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},_s=$i.object({name:$i.string()}),vs=$i.object({domains:$i.array(_s)}),ys=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=v(e).graphQlIndexerUrl,i=`query Registrations {
122
122
  domains(
123
123
  where: ${n?`{owner: "${t.toLowerCase()}", parent_: {name: "${n}"}}`:`{owner: "${t.toLowerCase()}"}`}
124
124
  ) {
125
125
  name
126
126
  }
127
- }`,a=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({operationName:`Registrations`,query:i,extensions:{}})});if(!a.ok)throw Error(`Failed to fetch domains`);let o=await a.json();return o.data&&o.data.domains&&(o.data.domains=o.data.domains.filter(e=>!e.name.endsWith(`addr.reverse`))),vs.parse(o.data)},bs=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],xs=(e,t)=>{let{network:n}=$();return X({queryKey:bs(e,t),queryFn:()=>ys(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Ss=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],Cs=e=>{let{network:t}=$();return X({queryKey:Ss(e??``,t.type),queryFn:async()=>e?vi(e,{networkUrl:t.nodeUrl}):null,enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ws=new Cn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),Ts=async(e,t,n)=>{if(!n)return{};let r=En(n);try{let n=new URL(`accounts/*`,e),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:v(t).vetDomainsContractAddress,data:ws.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return{};let{resolverAddress:o}=ws.decodeFunctionResult(`resolver`,i);return(await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:s.map(e=>({to:o,data:ws.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=ws.decodeFunctionResult(`text`,t)[0];n&&(e[s[r]]=n)}catch(e){console.error(`Failed to decode text record for ${s[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},Es=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],Ds=e=>{let{network:t}=$(),n=t.nodeUrl??v(t.type).nodeUrl;return X({queryKey:Es(e,t.type),queryFn:()=>Ts(n,t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Os=new Cn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),ks=(e,t)=>{let n=[];for(let{domain:r,key:i,value:a}of t){if(!r)throw Error(`Domain is required`);if(!e)throw Error(`Resolver address is required`);let t=En(r);n.push({to:e,data:Os.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},As=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=H(e=>{if(!r)throw Error(`Resolver address is required`);return ks(r,e)},[r]),a=Cl({signerAccountAddress:n,onTxConfirmed:async()=>{await e?.()},onTxFailedOrCancelled:async()=>{await t?.()},privyUIOptions:{title:`Update Profile Information`,description:`Update the profile information associated with your domain`,buttonText:`Sign to continue`}});return{...a,clauses:i,sendTransaction:async e=>a.sendTransaction(i(e))}},js=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Ms=e=>{let{network:t}=$();return ym({address:v(t.type).vetDomainsContractAddress,abi:Pi.abi,method:`resolver`,args:[e?Ji(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},Ns={Mugshot:new URL(`mugshot.png`,Ye).toString(),Greencart:new URL(`greencart.png`,Ye).toString(),Cleanify:new URL(`cleanify.png`,Ye).toString(),EVearn:new URL(`evearn.png`,Ye).toString()},Ps=()=>{let e=b(`vechain_kit_cross_app_connection`);if(!e)return null;try{let t=JSON.parse(e)?.ecosystemApp?.name;return t?Ns[t]??null:null}catch{return null}},Fs=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],Is=e=>{let{network:t}=$();return X({queryKey:Fs(e),queryFn:async()=>{if(!e||!t.nodeUrl)return Ps()??l(e??``);if(t.type!==`main`&&t.type!==`test`)return Ps()??l(e);let n=await _i(e,{networkUrl:t.nodeUrl});return n&&await vi(n,{networkUrl:t.nodeUrl})||(Ps()??l(e??``))},enabled:!!e&&!!t.nodeUrl,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Ls=new Cn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),Rs=new Cn([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),zs=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=En(n);try{let n=new URL(`accounts/*`,t),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:v(e).vetDomainsContractAddress,data:Ls.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return null;let{resolverAddress:o}=Ls.decodeFunctionResult(`resolver`,i),[{data:s,reverted:c}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:o,data:Ls.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(c||s===`0x`)return null;try{let{avatar:n}=Ls.decodeFunctionResult(`text`,s),r=n===``?null:n;return r?Vs(r,e,t):null}catch(e){return console.error(`Failed to decode avatar data:`,e),null}}catch(e){throw console.error(`Error fetching avatar using legacy API:`,e),e}},Bs=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function Vs(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return S(e,t)||null;let r=e.match(/eip155:(\d+)\/(?:erc721|erc1155):([^/]+)\/(\d+)/);if(r){let[,i,a,o]=r,s=e.includes(`erc1155`);if(!i||!a||o===void 0)return null;let c=[{to:a,data:Rs.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],l=new URL(`accounts/*`,n),[{data:u,reverted:d}]=await fetch(l,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(d)return console.error(`Failed to fetch tokenURI`),null;let f=``;try{f=Rs.decodeFunctionResult(s?`uri`:`tokenURI`,u)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),f=kn(u)}f=S(f,t)||f,s&&(f=f.replace(`{id}`,An(On(BigInt(o||0)),32).slice(2)));let p=await fetch(f);if(!p.ok)return console.error(`Failed to fetch metadata`),null;let m=await p.json(),h=m.image||m.image_url||m.image_data;return h?S(h,t)||h:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const Hs=e=>{let{network:t}=$(),n=t.nodeUrl??v(t.type).nodeUrl;return X({queryKey:Bs(e??``,t.type),queryFn:async()=>e?zs(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},Us=Fi.createInterface(),Ws=(e,t)=>{let n=[];return n.push({to:v(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:Us.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(e?.address??``,4,4)}`,abi:Us.getFunction(`setName`)}),n},Gs=({onSuccess:e,onError:t})=>{let n=dr(),{account:r}=Q(),{network:i}=$(),a=H(()=>Ws(r,i),[r,i]),o=H(async()=>{await is(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=Cl({signerAccountAddress:r?.address??``,privyUIOptions:{title:`Sign to unset your VeChain nickname`,description:`Unset your current VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:o,onTxFailedOrCancelled:t});return{...s,clauses:a,sendTransaction:async()=>s.sendTransaction(a())}},Ks=e=>{let{network:t,allowCommunityTokens:n}=$(),r=Eg(),{data:i,isLoading:a}=km(e),{data:o,isLoading:s}=jc(e),{data:c,isLoading:l}=Bc(e),{data:u,isLoading:d}=Fc(r.veDelegateTokenContractAddress,e),{data:f,isLoading:p}=Fc(r.vvetContractAddress,e,{enabled:!!r.vvetContractAddress}),{data:m,isLoading:h}=Fc(r.sassContractAddress,e,{enabled:n}),g=Nc(e),_=g.map(e=>e.data).filter(Boolean),v=g.some(e=>e.isLoading);return{balances:W(()=>{if(!e)return[];let t={vet:`0x`,vtho:r.vthoContractAddress,b3tr:r.b3trContractAddress,vot3:r.vot3ContractAddress,veDelegate:r.veDelegate,vvet:r.vvetContractAddress},a=[{address:t.vet,symbol:`VET`,balance:i?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:i?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:o?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:c?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:u?.scaled??`0`}];t.vvet&&a.push({address:t.vvet,symbol:`VVET`,balance:f?.scaled??`0`});let s=_.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`})),l=n?[{address:r.sassContractAddress,symbol:`SASS`,balance:m?.scaled??`0`}]:[];return[...a,...s,...l]},[e,i,o,c,u,f,_,n,m,r.sassContractAddress,r.vvetContractAddress,t.type]),isLoading:a||s||l||d||!!r.vvetContractAddress&&p||n&&h||v}},qs={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},Js=async(e,t,n)=>{let r=await e.contracts.load(v(n).oracleContractAddress,Ei.abi).read.getLatestValue(qs[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new Sn(r[0].toString()).div(0xe8d4a51000).toNumber()},Ys=e=>Ba.price.token(e),Xs=e=>{let t=nr(),{network:n}=$();return X({queryKey:Ys(e),queryFn:async()=>Js(t,e,n.type),enabled:!!t&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Zs=1e3,Qs=async({thor:e,order:t=`asc`,offset:n=0,limit:r=Zs,from:i=0,to:a=e.blocks.getHeadBlock()?.number,filterCriteria:o})=>{let s=await e.logs.filterEventLogs({range:{from:i,to:a,unit:`block`},options:{offset:n,limit:r},order:t,criteriaSet:o});if(!s)throw Error(`Failed to fetch events`);return s},$s=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await Qs({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:Zs,order:n,offset:s});if(o.push(...c),c.length<Zs)return o;s+=Zs}},ec=e=>new Sn(e.toString()).shiftedBy(-12).toNumber(),tc=()=>{let e=nr(),{network:t}=$(),n=v(t.type).oracleContractAddress;return X({queryKey:[`VECHAIN_KIT`,`ORACLE_HISTORY_24H`,t.type,n],enabled:!!e&&!!n,staleTime:300*1e3,gcTime:1800*1e3,retry:1,queryFn:async()=>{let r=await e.blocks.getBestBlockExpanded();if(!r)return{history:{},latest:{}};let i=e.contracts.load(n,Ei.abi),a=Object.entries(qs),o=await Promise.all(a.map(async([e,t])=>{try{let n=(await i.read.getLatestValue(t))[0];return[e,ec(n)]}catch{return[e,null]}})),s={};for(let[e,t]of o)t!=null&&(s[e]=t);let c=Math.max(0,r.number-8640),l=i.getEventAbi(`ValueUpdate`),u=await Qs({thor:e,nodeUrl:t.nodeUrl,from:c,to:r.number,order:`asc`,limit:256,filterCriteria:[{criteria:{address:n},eventAbi:l}]}),d=new Map;for(let e of u)try{let t=Vi({abi:Ei.abi,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});if(t.eventName!==`ValueUpdate`)continue;let n=t.args,r=n.id.toLowerCase(),i=d.get(r)??[];i.push({timestamp:Number(e.meta.blockTimestamp),value:ec(n.value)}),d.set(r,i)}catch{}let f={},p=Math.floor(Date.now()/1e3);for(let[e,t]of a){let n=d.get(t.toLowerCase())??[],r=s[e],i=r==null?null:{timestamp:p,value:r},a=i?[...n,i]:n;a.length&&(f[e]=a)}return{history:f,latest:s}}})},nc=()=>{let{data:e}=tc(),t={};if(e?.history)for(let[n,r]of Object.entries(e.history)){if(!r||r.length<2)continue;let e=r[0].value,i=r[r.length-1].value;if(!e)continue;let a=(i-e)/e*100;Number.isFinite(a)&&(t[n]=a)}return{data:t}},rc=e=>{let{data:t,isLoading:n}=tc();return{points:e?t?.history?.[e]??[]:[],isLoading:n}},ic=()=>{let e=Eg(),{data:t,isLoading:n}=Xs(`VET`),{data:r,isLoading:i}=Xs(`VTHO`),{data:a,isLoading:o}=Xs(`B3TR`),{data:s,isLoading:c}=Xs(`EUR`),{data:l,isLoading:u}=Xs(`GBP`),{data:d}=nc();return{prices:W(()=>{let n={vet:`0x`,vtho:e.vthoContractAddress,b3tr:e.b3trContractAddress,vot3:e.vot3ContractAddress,veDelegate:e.veDelegate,SASS:e.sassContractAddress,vvet:e.vvetContractAddress},i={[n.vet]:t||0,[n.vtho]:r||0,[n.b3tr]:a||0,[n.vot3]:a||0,[n.veDelegate]:a||0,[n.SASS]:0};n.vvet&&(i[n.vvet]=t||0);for(let e of Object.keys(i)){let t=e.toLowerCase();t!==e&&i[t]===void 0&&(i[t]=i[e])}return i},[t,r,a,e.vthoContractAddress,e.b3trContractAddress,e.vot3ContractAddress,e.veDelegate,e.sassContractAddress,e.vvetContractAddress]),priceChanges:W(()=>{let t={};if(!d)return t;let n=d.VET,r=d.VTHO,i=d.B3TR;n!==void 0&&(t[`0x`]=n),r!==void 0&&(t[e.vthoContractAddress]=r),i!==void 0&&(t[e.b3trContractAddress]=i,t[e.vot3ContractAddress]=i,t[e.veDelegate]=i),n!==void 0&&e.vvetContractAddress&&(t[e.vvetContractAddress]=n);for(let e of Object.keys(t)){let n=e.toLowerCase();n!==e&&t[n]===void 0&&(t[n]=t[e])}return t},[d,e.vthoContractAddress,e.b3trContractAddress,e.vot3ContractAddress,e.veDelegate,e.vvetContractAddress]),exchangeRates:W(()=>({eurUsdPrice:s||1,gbpUsdPrice:l||1}),[s,l]),isLoading:n||i||o||c||u}},ac=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},oc=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(so[t],r).format(e)},sc=(e,t)=>oc(e,lo.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),cc=[`usd`,`eur`,`gbp`],lc=()=>{let{currentCurrency:e,setCurrency:t}=$();return U(()=>{ue(`vechain_kit_currency`,e)},[e]),{currentCurrency:e,allCurrencies:cc,changeCurrency:e=>{if(!cc.includes(e)){console.error(`Invalid currency: ${e}`);return}t(e)}}},uc=({address:e=``})=>{let{balances:t,isLoading:n}=Ks(e),{prices:r,priceChanges:i,exchangeRates:a,isLoading:o}=ic(),{currentCurrency:s}=lc(),c=W(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,o=ac(n,s,a),c=i?.[e.address];return{...e,priceUsd:t,valueUsd:n,valueInCurrency:o,priceChange24hPct:c}}),[t,r,i,s,a]),l=W(()=>[...c].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[c]);return{tokens:c,sortedTokens:l,tokensWithBalance:W(()=>l.filter(e=>Number(e.balance)>0),[l]),isLoading:n||o}},dc=e=>{let t=nr(),{network:n}=$(),r=Eg(),i=r.stargateContractAddress,a=r.stargateNftContractAddress,{prices:o,exchangeRates:s}=ic(),{currentCurrency:c}=lc(),l=o[`0x`]||0,u=!!e&&!!i&&!!a&&!!t,d=X({queryKey:[`VECHAIN_KIT`,`STARGATE_POSITIONS`,n.type,e?.toLowerCase()],enabled:u,staleTime:6e4,queryFn:async()=>{if(!e)return[];let n=ki.abi,r=Ai.abi,o=await t.contracts.load(a,n).read.balanceOf(e),u=Number(o[0]??o);if(!u)return[];let d=(await A({thor:t,calls:Array.from({length:u},(e,t)=>BigInt(t)).map(t=>({abi:n,functionName:`tokenOfOwnerByIndex`,address:a,args:[e,t]}))})).map(e=>e);if(!d.length)return[];let f=await A({thor:t,calls:d.flatMap(e=>[{abi:n,functionName:`getToken`,address:a,args:[e]},{abi:r,functionName:`getDelegationStatus`,address:i,args:[e]}])}),p=[];for(let e=0;e<d.length;e++){let t=f[e*2],n=Number(f[e*2+1]),r=t.vetAmountStaked.toString(),i=Number(Tn(t.vetAmountStaked,18)),a=i*l,o=ac(a,c,s);p.push({tokenId:t.tokenId.toString(),levelId:Number(t.levelId),vetAmountStaked:r,vetAmountFormatted:i,valueUsd:a,valueInCurrency:o,isDelegated:n!==0})}return p}}),f=d.data??[];return{positions:f,totalVet:f.reduce((e,t)=>e+t.vetAmountFormatted,0),totalValueUsd:f.reduce((e,t)=>e+t.valueUsd,0),totalValueInCurrency:f.reduce((e,t)=>e+t.valueInCurrency,0),isLoading:d.isLoading,error:d.error}},fc=[{inputs:[],name:`getReservesList`,outputs:[{name:``,type:`address[]`}],stateMutability:`view`,type:`function`},{inputs:[{name:`user`,type:`address`}],name:`getUserAccountData`,outputs:[{name:`totalCollateralBase`,type:`uint256`},{name:`totalDebtBase`,type:`uint256`},{name:`availableBorrowsBase`,type:`uint256`},{name:`currentLiquidationThreshold`,type:`uint256`},{name:`ltv`,type:`uint256`},{name:`healthFactor`,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{name:`asset`,type:`address`}],name:`getReserveData`,outputs:[{components:[{components:[{name:`data`,type:`uint256`}],name:`configuration`,type:`tuple`},{name:`liquidityIndex`,type:`uint128`},{name:`currentLiquidityRate`,type:`uint128`},{name:`variableBorrowIndex`,type:`uint128`},{name:`currentVariableBorrowRate`,type:`uint128`},{name:`currentStableBorrowRate`,type:`uint128`},{name:`lastUpdateTimestamp`,type:`uint40`},{name:`id`,type:`uint16`},{name:`aTokenAddress`,type:`address`},{name:`stableDebtTokenAddress`,type:`address`},{name:`variableDebtTokenAddress`,type:`address`},{name:`interestRateStrategyAddress`,type:`address`},{name:`accruedToTreasury`,type:`uint128`},{name:`unbacked`,type:`uint128`},{name:`isolationModeTotalDebt`,type:`uint128`}],name:``,type:`tuple`}],stateMutability:`view`,type:`function`}],pc=[{inputs:[{name:`account`,type:`address`}],name:`isNavigator`,outputs:[{name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[{name:`navigator`,type:`address`}],name:`getStake`,outputs:[{name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{name:`citizen`,type:`address`}],name:`isDelegated`,outputs:[{name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[{name:`citizen`,type:`address`}],name:`getDelegatedAmount`,outputs:[{name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{name:`citizen`,type:`address`}],name:`getNavigator`,outputs:[{name:``,type:`address`}],stateMutability:`view`,type:`function`}],mc=e=>{let t=nr(),{network:n}=$(),r=Eg(),i=r.navigatorRegistryContractAddress,a=r.b3trContractAddress,{prices:o,exchangeRates:s}=ic(),{currentCurrency:c}=lc(),l=o[a]||0,u=!!e&&!!i&&!!t,d=X({queryKey:[`VECHAIN_KIT`,`NAVIGATOR_POSITION`,n.type,e?.toLowerCase()],enabled:u,staleTime:6e4,queryFn:async()=>{if(!e)return{isNavigator:!1,isDelegated:!1,stakedB3TR:`0`,delegatedAmount:`0`,navigatorAddress:void 0};let[n,r,a,o,s]=await A({thor:t,calls:[{abi:pc,functionName:`isNavigator`,address:i,args:[e]},{abi:pc,functionName:`getStake`,address:i,args:[e]},{abi:pc,functionName:`isDelegated`,address:i,args:[e]},{abi:pc,functionName:`getDelegatedAmount`,address:i,args:[e]},{abi:pc,functionName:`getNavigator`,address:i,args:[e]}]});return{isNavigator:!!n,isDelegated:!!a,stakedB3TR:r.toString(),delegatedAmount:o.toString(),navigatorAddress:s}}}),f=d.data,p=f?Number(Tn(f.stakedB3TR,18)):0,m=f?Number(Tn(f.delegatedAmount,18)):0,h=p+m,g=h*l,_=ac(g,c,s),v=f?.navigatorAddress,y=v&&v!==`0x0000000000000000000000000000000000000000`?v:void 0;return{isNavigator:!!f?.isNavigator,isDelegated:!!f?.isDelegated,stakedB3TR:p,stakedB3TRRaw:f?.stakedB3TR??`0`,delegatedAmount:m,delegatedAmountRaw:f?.delegatedAmount??`0`,navigatorAddress:y,totalB3TR:h,totalValueUsd:g,totalValueInCurrency:_,isLoading:d.isLoading,error:d.error}},hc=[{inputs:[],name:`symbol`,outputs:[{name:``,type:`string`}],stateMutability:`view`,type:`function`}],gc=e=>{let t=nr(),{network:n}=$();return X({queryKey:[`VECHAIN_KIT`,`BETTERSWAP_PAIRS`,n.type,e],enabled:!!e&&!!t,staleTime:1440*60*1e3,queryFn:async()=>{if(!e)return[];let n=ji.abi,r=await t.contracts.load(e,n).read.allPairsLength(),i=Number(r[0]??r);return i?(await A({thor:t,calls:Array.from({length:i},(e,t)=>BigInt(t)).map(t=>({abi:n,functionName:`allPairs`,address:e,args:[t]}))})).map(e=>e):[]}})},_c=e=>{let t=nr(),{network:n}=$(),r=Eg().betterSwapFactoryAddress,{prices:i,exchangeRates:a}=ic(),{currentCurrency:o}=lc(),{data:s=[],isLoading:c}=gc(r),l=!!e&&Ki(e)&&!!r&&Ki(r)&&!!t&&s.length>0,u=s.length?`${s[0]}-${s[s.length-1]}-${s.length}`:`empty`,d=X({queryKey:[`VECHAIN_KIT`,`BETTERSWAP_LP_POSITIONS`,n.type,e?.toLowerCase(),u],enabled:l,staleTime:6e4,queryFn:async()=>{if(!e||!s.length)return[];let n=Mi.abi,r=s.filter(e=>Ki(e));if(!r.length)return[];let c=await A({thor:t,calls:r.map(t=>({abi:n,functionName:`balanceOf`,address:t,args:[e]}))}),l=[];if(c.forEach((e,t)=>{let n=e;n&&n>0n&&l.push(t)}),!l.length)return[];let u=await A({thor:t,calls:l.flatMap(e=>{let t=r[e];return[{abi:n,functionName:`totalSupply`,address:t,args:[]},{abi:n,functionName:`getReserves`,address:t,args:[]},{abi:n,functionName:`token0`,address:t,args:[]},{abi:n,functionName:`token1`,address:t,args:[]}]})}),d=new Set;for(let e=0;e<l.length;e++){let t=u[e*4+2],n=u[e*4+3];d.add(t.toLowerCase()),d.add(n.toLowerCase())}let f=Array.from(d),p=new Map;f.length&&(await A({thor:t,calls:f.map(e=>({abi:hc,functionName:`symbol`,address:e,args:[]}))})).forEach((e,t)=>{let n=e;p.set(f[t],n??``)});let m=[];for(let e=0;e<l.length;e++){let t=l[e],n=r[t],s=c[t],d=u[e*4],f=u[e*4+1],h=f[0],g=f[1],_=u[e*4+2],v=u[e*4+3],y=Number(Tn(s,18)),b=d>0n?Number(s*1000000n/d)/1e6:0,x=Number(Tn(h,18))*b,S=Number(Tn(g,18))*b,C=i[_.toLowerCase()]||0,w=i[v.toLowerCase()]||0,ee=x*C+S*w,T=ac(ee,o,a);m.push({pairAddress:n,lpBalance:y,sharePct:b*100,token0:{address:_,symbol:p.get(_.toLowerCase())??``,amount:x},token1:{address:v,symbol:p.get(v.toLowerCase())??``,amount:S},valueUsd:ee,valueInCurrency:T})}return m}}),f=d.data??[];return{positions:f,totalValueUsd:f.reduce((e,t)=>e+t.valueUsd,0),totalValueInCurrency:f.reduce((e,t)=>e+t.valueInCurrency,0),isLoading:c||d.isLoading,error:d.error}},vc=async(e,t)=>Si(e,{networkUrl:t}),yc=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],bc=e=>{let{network:t}=$();return X({queryKey:yc(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return vc(e,t.nodeUrl)},enabled:!!t.type&&!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`token address is required`||e===`network node url is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},xc=[{inputs:[{name:`account`,type:`address`}],name:`balanceOf`,outputs:[{name:``,type:`uint256`}],stateMutability:`view`,type:`function`}],Sc=(1n<<256n)-1n,Cc=e=>{let t=nr(),{network:n}=$(),r=Eg().juicyPoolAddress,{prices:i,exchangeRates:a}=ic(),{currentCurrency:o}=lc(),s=!!e&&!!r&&!!t,c=X({queryKey:[`VECHAIN_KIT`,`JUICY_POSITION`,n.type,e?.toLowerCase(),r],enabled:s,staleTime:6e4,queryFn:async()=>{if(!e||!r)return{supplied:[],borrowed:[],healthFactor:null};let s=t.contracts.load(r,fc),c=await s.read.getReservesList(),l=c[0]??c,u=Array.from(l);if(!u.length)return{supplied:[],borrowed:[],healthFactor:null};let d=await A({thor:t,calls:u.map(e=>({abi:fc,functionName:`getReserveData`,address:r,args:[e]}))}),f=u.map((e,t)=>{let n=d[t];return{asset:e,aTokenAddress:n.aTokenAddress,stableDebtTokenAddress:n.stableDebtTokenAddress,variableDebtTokenAddress:n.variableDebtTokenAddress}}),p=await A({thor:t,calls:f.flatMap(t=>[{abi:xc,functionName:`balanceOf`,address:t.aTokenAddress,args:[e]},{abi:xc,functionName:`balanceOf`,address:t.variableDebtTokenAddress,args:[e]},{abi:xc,functionName:`balanceOf`,address:t.stableDebtTokenAddress,args:[e]}])}),m=await s.read.getUserAccountData(e),h=m[5],g=m[1],_=[],v=Array(f.length).fill(0n),y=Array(f.length).fill(0n),b=Array(f.length).fill(0n);for(let e=0;e<f.length;e++){let t=p[e*3],n=p[e*3+1],r=p[e*3+2];v[e]=t,y[e]=n,b[e]=r,(t>0n||n>0n||r>0n)&&_.push(f[e].asset.toLowerCase())}let x=new Map;await Promise.all(_.map(async e=>{try{let t=await vc(e,n.nodeUrl),r=Number(t.decimals);x.set(e,{symbol:t.symbol??e.slice(0,6),decimals:Number.isFinite(r)?r:18})}catch{x.set(e,{symbol:e.slice(0,6),decimals:18})}}));let S=[],C=[];for(let e=0;e<f.length;e++){let t=f[e].asset,n=t.toLowerCase(),r=x.get(n)??{symbol:t.slice(0,6),decimals:18},s=i[n]??i[t]??0,c=v[e];if(c>0n){let e=Number(Tn(c,r.decimals)),n=e*s;S.push({asset:t,symbol:r.symbol,decimals:r.decimals,amount:e,valueUsd:n,valueInCurrency:ac(n,o,a)})}let l=y[e]+b[e];if(l>0n){let e=Number(Tn(l,r.decimals)),n=e*s;C.push({asset:t,symbol:r.symbol,decimals:r.decimals,amount:e,valueUsd:n,valueInCurrency:ac(n,o,a)})}}let w=null;return g>0n&&h<Sc&&(w=Number(Tn(h,18))),{supplied:S,borrowed:C,healthFactor:w}}}),l=c.data,u=l?.supplied??[],d=l?.borrowed??[],f=u.reduce((e,t)=>e+t.valueUsd,0),p=u.reduce((e,t)=>e+t.valueInCurrency,0),m=d.reduce((e,t)=>e+t.valueUsd,0),h=d.reduce((e,t)=>e+t.valueInCurrency,0);return{supplied:u,borrowed:d,totalSuppliedUsd:f,totalSuppliedInCurrency:p,totalBorrowedUsd:m,totalBorrowedInCurrency:h,healthFactor:l?.healthFactor??null,netValueUsd:f-m,netValueInCurrency:p-h,hasPosition:u.length>0||d.length>0,isLoading:c.isLoading,error:c.error}},wc=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=uc({address:e}),{currentCurrency:r}=lc(),i=dc(e),a=mc(e),o=_c(e),s=Cc(e),c=W(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]),l=W(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),u=W(()=>{let e=0,n=0;for(let r of t)typeof r.priceChange24hPct==`number`&&(e+=r.valueUsd*r.priceChange24hPct,n+=r.valueUsd);if(n!==0)return e/n},[t]),d=i.totalValueInCurrency+a.totalValueInCurrency+o.totalValueInCurrency+s.netValueInCurrency,f=i.totalValueUsd+a.totalValueUsd+o.totalValueUsd+s.netValueUsd,p=c+d;return{totalBalanceInCurrency:p,totalBalanceUsd:l+f,liquidBalanceInCurrency:c,liquidBalanceUsd:l,stakingInCurrency:d,stakingUsd:f,priceChange24hPct:u,formattedBalance:W(()=>sc(p,{currency:r}),[p,r]),isLoading:n||i.isLoading||a.isLoading||o.isLoading||s.isLoading,hasAnyBalance:t.length>0||f>0}},Tc=zi.abi,Ec=`currentRoundId`,Dc=e=>gm({abi:Tc,address:e,method:Ec}),Oc=()=>{let{network:e}=$(),t=v(e.type).xAllocationVotingContractAddress;return ym({abi:Tc,address:t,method:Ec,args:[],queryOptions:{select:e=>e[0].toString()}})},kc=()=>{let[e,t]=jh(Ah.CUSTOM_TOKENS,[]),{network:n}=$(),r=Eg(),i=async r=>{if(!o(r)&&!s(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await vc(r,n.nodeUrl),address:r};t([...e,i])}},a=n=>{t(e.filter(e=>e.address!==n))},o=t=>e.some(e=>E(e.address,t)),s=e=>{let t={vet:`0x`,vtho:r.vthoContractAddress,b3tr:r.b3trContractAddress,vot3:r.vot3ContractAddress,veDelegate:r.veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:i,removeToken:a,isTokenIncluded:o,isDefaultToken:s}},Ac=e=>Ba.balance.b3tr(e),jc=e=>{let{network:t}=$(),{b3trContractAddress:n}=Eg();return X({queryKey:Ac(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let r=await bi(n,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get b3tr balance`);let a=r[0];return i(a)},enabled:!!e&&!!t.type})},Mc=(e,t,n)=>Ba.balance.customToken(e,t,Number.isFinite(n)?n:18),Nc=e=>{let{network:t}=$(),{customTokens:n}=kc();return ur({queries:n.map(n=>({queryKey:Mc(n.address,e,Number(n.decimals)),queryFn:async()=>{if(!n.address)throw Error(`Token address is required`);if(!e)throw Error(`Address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);let r=await bi(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let a=i(r[0],Number(n.decimals));return{...n,...a}},enabled:!!e&&T(e)&&!!n.address&&T(n.address)&&!!t.nodeUrl}))})},Pc=(e,t)=>Ba.balance.erc20(e,t),Fc=(e,t,n)=>{let{network:r}=$(),a=!!t&&!!r.type;return X({queryKey:Pc(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let n=await bi(e,t,{networkUrl:r.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let a=n[0];return i(a)},enabled:a&&(n?.enabled??!0)})},Ic=e=>Number(e??`0`)||0,Lc=(e,t)=>{let n=t.vet??[],r=t.vtho??[],i=t.b3tr??[];if(!n.length&&!r.length&&!i.length)return[];let a=Array.from(new Set([...n.map(e=>e.timestamp),...r.map(e=>e.timestamp),...i.map(e=>e.timestamp)])).sort((e,t)=>e-t),o=0,s=0,c=0,l=n[0]?.value??0,u=r[0]?.value??0,d=i[0]?.value??0,f=[];for(let t of a){for(;o<n.length&&n[o].timestamp<=t;)l=n[o].value,o++;for(;s<r.length&&r[s].timestamp<=t;)u=r[s].value,s++;for(;c<i.length&&i[c].timestamp<=t;)d=i[c].value,c++;let a=e.vet*l+e.vtho*u+e.b3tr*d+e.flatUsdOffset;f.push({timestamp:t,value:a})}return f},Rc=e=>{let t=Eg(),{data:n,isLoading:r}=tc(),{balances:i,isLoading:a}=Ks(e),o=dc(e),s=mc(e),c=Cc(e),l=_c(e),u=W(()=>{let e=e=>i.find(t=>t.address.toLowerCase()===e.toLowerCase())?.balance,n=Ic(e(`0x`)),r=Ic(e(t.vthoContractAddress)),a=Ic(e(t.vvetContractAddress)),u=Ic(e(t.b3trContractAddress)),d=Ic(e(t.vot3ContractAddress)),f=Ic(e(t.veDelegate)),p=o.positions.reduce((e,t)=>e+t.vetAmountFormatted,0),m=(s.isNavigator?s.stakedB3TR:0)+(s.isDelegated?s.delegatedAmount:0),h=t.vvetContractAddress.toLowerCase(),g=t.vthoContractAddress.toLowerCase(),_=t.b3trContractAddress.toLowerCase(),v={vet:0,vtho:0,b3tr:0};for(let e of c.supplied){let t=e.asset.toLowerCase();t===h?v.vet+=e.amount:t===g?v.vtho+=e.amount:t===_&&(v.b3tr+=e.amount)}for(let e of c.borrowed){let t=e.asset.toLowerCase();t===h?v.vet-=e.amount:t===g?v.vtho-=e.amount:t===_&&(v.b3tr-=e.amount)}let y=l.totalValueUsd;return{vet:n+a+p+v.vet,vtho:r+v.vtho,b3tr:u+d+f+m+v.b3tr,flatUsdOffset:y}},[i,t.vthoContractAddress,t.vvetContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,o.positions,s.isNavigator,s.isDelegated,s.stakedB3TR,s.delegatedAmount,c.supplied,c.borrowed,l.totalValueUsd]);return{points:W(()=>Lc(u,{vet:n?.history?.VET,vtho:n?.history?.VTHO,b3tr:n?.history?.B3TR}),[u,n?.history]),isLoading:r||a||o.isLoading||s.isLoading||c.isLoading||l.isLoading}},zc=e=>Ba.balance.vot3(e),Bc=e=>{let{network:t}=$(),{vot3ContractAddress:n}=Eg();return X({queryKey:zc(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let r=await bi(n,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get vot3 balance`);let a=r[0];return i(a)},enabled:!!e&&!!t.type})},Vc=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],Hc=e=>{let{network:t}=$();return X({queryKey:Vc(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return xi(e,{networkUrl:t.nodeUrl})},enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`user address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Uc=zi.abi,Wc=`getAppsOfRound`,Gc=(e,t)=>vm({abi:Uc,address:v(t).xAllocationVotingContractAddress,method:Wc,args:[BigInt(e??0)]}),Kc=e=>{let{network:t}=$(),n=v(t.type).xAllocationVotingContractAddress;return ym({abi:Uc,address:n,method:Wc,args:[BigInt(e??0)],queryOptions:{enabled:!!e,select:e=>e[0].map(e=>({id:e.id.toString(),teamWalletAddress:e.teamWalletAddress,name:e.name,metadataURI:e.metadataURI,createdAtTimestamp:e.createdAtTimestamp.toString()}))}})},qc=Ri.abi,Jc=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Yc=(e,t)=>{let n=nr(),{network:r}=$(),i=v(r.type).xAllocationPoolContractAddress;return X({queryKey:Jc(t),queryFn:async()=>(await A({thor:n,calls:e.map(e=>({abi:qc,functionName:`getAppShares`,address:i,args:[t,e]}))})).map((t,n)=>({app:e[n],share:Number(t[0]||0)/100,unallocatedShare:Number(t[1]||0)/100})),enabled:!!t&&!!e.length})},Xc=e=>{let{data:t}=Kc(e),n=Yc(t?.map(e=>e.id)??[],e);return{data:W(()=>n.data?.map(e=>({percentage:e.share+e.unallocatedShare,id:t?.find(t=>t.id===e.app)?.id??``,app:t?.find(t=>t.id===e.app)??{}})).sort((e,t)=>Number(t.percentage)-Number(e.percentage))??[],[n.data,t]),isLoading:n.isLoading}},Zc=()=>{let e=dr();return{refresh:async()=>{await Promise.all([e.invalidateQueries({queryKey:Ba.balance.all}),e.invalidateQueries({queryKey:Ba.price.all})])}}},Qc=({error:e,mobileBrowserPopupMessage:t=`Mobile browser blocked the window. Please try again.`,rejectedMessage:n=`Request was cancelled.`,defaultMessage:r=`Operation failed`})=>{let i=e?.message;return la&&i&&!h(i)?Error(t):i&&h(i)?Error(n):e instanceof Error?e:Error(r)},$c=Hi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[me]}},blockExplorers:{default:{name:`Vechain Explorer`,url:De},vechainStats:{name:`Vechain Stats`,url:Ie}}}),el=()=>ca({id:g,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),tl=({privyEcosystemAppIDS:e,children:t})=>q(ea,{config:xn(ta({chains:[$c],ssr:!0,connectors:[el(),...e.map(e=>ca({id:e,name:``,iconUrl:``}))],transports:{[$c.id]:na()},multiInjectedProviderDiscovery:!1})).current,children:t}),nl=()=>{let{connectAsync:e,connectors:t}=ia(),{signTypedDataAsync:n}=sa(),{signMessageAsync:r}=oa(),{disconnectAsync:i}=aa(),{isConnected:a}=ra(),[o,s]=G(!1),[c,l]=G(null),u=H(async()=>{try{a&&(await i(),O()&&window.dispatchEvent(new Event(`wallet_disconnected`)))}catch(e){throw console.error(`Error during logout:`,e),e}},[i,a]);return{login:H(async n=>{try{s(!0),l(null);let r=t.find(e=>e.id===(n||g));if(!r)throw Error(`Connector not found`);return await e({connector:r})}catch(e){throw l(e),e}finally{s(!1)}},[e,t]),logout:u,signMessage:H(async e=>{try{return await r({message:e})}catch(e){throw Qc({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing a message. Please try again or contact support.`})}},[r]),signTypedData:H(async e=>{try{return await n(e)}catch(e){throw Qc({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing typed data. Please try again or contact support.`})}},[n]),isConnecting:o,connectionError:c}},rl=(e,t)=>{let{data:n,isLoading:r}=$o(e??``),{data:i,isLoading:a}=Is(e??``),{data:o,isLoading:s}=Ds(n?.domain??``),c=o?.header?S(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},il=()=>{let{network:e}=$(),t=H(e=>({wallets:`vechain_kit_wallets_${e}`,activeWallet:`vechain_kit_active_wallet_${e}`}),[]),n=H(()=>{if(!O())return[];let n=b(t(e.type).wallets);return n?JSON.parse(n):[]},[e.type,t]),r=H(()=>O()?b(t(e.type).activeWallet):null,[e.type,t]),i=H(r=>{if(!O())return;let i=t(e.type),a=n(),o=a.findIndex(e=>e.address.toLowerCase()===r.toLowerCase()),s={address:r,connectedAt:o>=0?a[o].connectedAt:Date.now(),isActive:!1};o>=0?a[o]=s:a.push(s),ue(i.wallets,JSON.stringify(a))},[e.type,t,n]),a=H(r=>{if(!O())return;let i=t(e.type),a=n().map(e=>({...e,isActive:e.address.toLowerCase()===r.toLowerCase()}));ue(i.wallets,JSON.stringify(a)),ue(i.activeWallet,r)},[e.type,t,n]);return{getStoredWallets:n,getActiveWallet:r,saveWallet:i,setActiveWallet:a,removeWallet:H(i=>{if(!O())return;let a=t(e.type),o=n().filter(e=>e.address.toLowerCase()!==i.toLowerCase());ue(a.wallets,JSON.stringify(o));let s=r();s&&s.toLowerCase()===i.toLowerCase()&&C(a.activeWallet),O()&&window.dispatchEvent(new CustomEvent(`wallet_removed`,{detail:{address:i}}))},[e.type,t,n,r]),initializeCurrentWallet:H(e=>{O()&&n().length===0&&(i(e),a(e))},[n,i,a])}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=ra(),{logout:i}=nl(),{loading:a}=Kn({}),{feeDelegation:o,network:s,privy:c}=$(),{user:l,authenticated:u,logout:d,ready:f}=Xn(),{data:p}=ph(),{account:m,disconnect:h}=rr(),{getConnectionCache:_,clearConnectionCache:v}=om(),y=_(),{initializeCurrentWallet:b,getActiveWallet:x,saveWallet:S,getStoredWallets:C}=il(),w=wm(),ee=W(()=>O()?!!window.vechain?.isInAppBrowser:!1,[]),T=!!m,D=u&&!!l,k=D||t,te=D&&c?.appId===g||t&&y?.ecosystemApp?.appId===g,A=n||r||a||!f,[ne,re]=G(!1),ie=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:T?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};U(()=>{let e=T||D||t;ne!==e&&(re(e),e||(v(),O()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[T,D,t,v,ne]);let ae=l?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,oe=T?m:t?e:ae,[se,ce]=G(()=>T&&!ee?x():null);U(()=>{ce(T&&!ee?x():null)},[T,ee,x]);let[le,ue]=G(!1);U(()=>{if(!O()||!T||ee)return;let e=e=>{ue(!0),ce(e.detail.address),setTimeout(()=>{ue(!1)},1e3)};return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[T,ee]);let de=C().some(e=>e.address.toLowerCase()===oe?.toLowerCase()),fe=T&&!ee?x():null,pe=le&&fe||fe&&de?fe:oe,{data:me}=$m(pe??``),he=T?pe:me?.address,ge=rl(he??``,s.type),_e=rl(pe??``,s.type),ve=rl(me?.address??``,s.type),{setActiveWallet:ye}=il(),be=xn(new Set);U(()=>{if(!O()||!T||ee)return;let e=e=>{be.current.add(e.detail.address.toLowerCase()),setTimeout(()=>{be.current.delete(e.detail.address.toLowerCase())},5e3)};return window.addEventListener(`wallet_removed`,e),()=>{window.removeEventListener(`wallet_removed`,e)}},[T,ee]),U(()=>{if(T&&!ee&&oe&&ge&&!ge.isLoading){if(be.current.has(oe.toLowerCase()))return;let e=!C().some(e=>e.address.toLowerCase()===oe.toLowerCase());b(oe),S(oe);let t=!se,n=se&&se.toLowerCase()===oe.toLowerCase();(e||t||n)&&!le&&ye(oe)}},[T,ee,oe,ge?.domain,ge?.image,ge?.isLoading,b,S,ye,se,C]),U(()=>{T&&!ee&&se&&se.toLowerCase()===pe?.toLowerCase()&&S(se)},[T,ee,se,pe,S]);let xe=he?{address:he,domain:ge.domain,image:ge.image,isLoadingMetadata:ge.isLoading,metadata:ge.records}:null,Se=oe?{address:oe,domain:_e.domain,image:_e.image,isLoadingMetadata:_e.isLoading,metadata:_e.records}:null,{data:Ce}=Vm(me?.address??``,Se?.address??``),we=!!me?.address&&!!xe?.address&&E(me?.address,xe?.address),Te=H(async()=>{try{re(!1),T?h():D?await d():t&&await i(),v(),O()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[T,h,D,d,t,i,v]);return{account:xe,smartAccount:{address:me?.address??``,domain:ve.domain,image:ve.image,isDeployed:me?.isDeployed??!1,isActive:we,version:Ce?.version??null,isLoadingMetadata:ve.isLoading,metadata:ve.records},connectedWallet:Se,privyUser:l,connection:{isLoading:A,isConnected:ne,isConnectedWithSocialLogin:D,isConnectedWithDappKit:T,isConnectedWithCrossApp:t,isConnectedWithPrivy:k,isConnectedWithVeChain:te,source:ie,isInAppBrowser:ee,nodeUrl:w,delegatorUrl:o?.delegatorUrl,chainId:p,network:s.type},disconnect:Te}},al=()=>{let{switchWallet:e}=rr(),{connection:t}=Q(),[n,r]=G(!1),{getStoredWallets:i,setActiveWallet:a,removeWallet:o}=il(),s=t.isInAppBrowser;return{switchWallet:H(async()=>{if(s){if(!e)return;r(!0);try{await e()}catch{}finally{r(!1)}}else return Promise.resolve()},[e,s]),isSwitching:n,getStoredWallets:i,setActiveWallet:H(e=>{a(e),O()&&window.dispatchEvent(new CustomEvent(`wallet_switched`,{detail:{address:e}}))},[a]),removeWallet:o,isInAppBrowser:s}},ol=async(e,t)=>{let n=S(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},sl=Li.abi,cl=e=>{let t=nr(),{network:n}=$();return X({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=v(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,sl),a=(await i.read.app(e))[0][3]?.toString()||``,[o]=await i.read.baseURI();return await ol(`${o}${a}`,n.type)},enabled:!!e})},ll=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=S(t,e);if(!r)throw Error(`Invalid URI`);let i=await(await fetch(r,{headers:{"X-Project-Id":`vechain-kit`}})).text();return n?JSON.parse(i):i},ul=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],dl=(e,t=!1)=>{let{network:n}=$();return X({queryKey:ul(n.type,e),queryFn:()=>ll(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0})},fl=1024*1024*10,pl=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(S(t,e)??``,{headers:{"X-Project-Id":`vechain-kit`}});if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.blob();if(![`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/bmp`,`image/tiff`,`image/webp`,`image/svg+xml`].includes(r.type))throw Error(`Unsupported MIME type: ${r.type}`);if(r.size>fl)throw Error(`Image size exceeds maximum allowed size`);return new Promise((e,t)=>{let n=new FileReader;n.readAsDataURL(r),n.onloadend=()=>{e({image:n.result,mime:r.type,mediaType:m(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},ml=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],hl=e=>{let{network:t}=$();return X({queryKey:ml(t.type,e),queryFn:()=>pl(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0})},gl=e=>{let{network:t}=$();return ur({queries:e.map(e=>({queryKey:ml(t.type,e),queryFn:()=>pl(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0}))})},_l=(e,t=!1)=>{let{network:n}=$();return ur({queries:e.map(e=>({queryKey:ul(n.type,e),queryFn:async()=>ll(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0}))})},vl={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},yl=async e=>{let t=[];try{for(let n of e){let e=await ua(n.file,vl);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},bl=({compressImages:e,defaultImages:t})=>{let[n,r]=G(t??[]);U(()=>{t&&r(t)},[t]);let[i,a]=G([]),o=H(e=>r(t=>t.filter((t,n)=>n!==e)),[]);return{uploadedImages:n,setUploadedImages:r,onUpload:H(async(t,n=!0)=>{a([]);let i=[];for(let n of t){let t=n;e&&(t=await ua(n,vl));let r={file:t,image:URL.createObjectURL(n)};i.push(r)}r(e=>[...i,...n?e.filter(e=>!i.some(t=>t.file.name===e.file.name)):[]])},[e]),onRemove:o,invalidDateError:i}},xl=({compressImage:e,defaultImage:t})=>{let[n,r]=G(t);U(()=>{t&&r(t)},[t]);let i=H(()=>r(void 0),[]);return{uploadedImage:n,setUploadedImage:r,onUpload:H(async t=>{let n=t;e&&(n=await ua(n,vl));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},Sl=async(e,t,n,r)=>{let i=await e.transactions.estimateGas(t,n,r);if(i.reverted)throw Error(`Failed to estimate gas`);let a=i?.totalGas??0;return(!a||Number.isNaN(a))&&(a=0),Math.ceil(a)},Cl=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o,delegationUrl:s})=>{let c=nr(),{signer:l,requestTransaction:u}=ir(),{connection:d}=Q(),{feeDelegation:f}=$(),p=wm(),m=wg(),h=H(async(t,n,r)=>{let a=typeof t==`function`?await t():t??[];if(d.isConnectedWithPrivy)return await m.sendTransaction({txClauses:a,...r,delegationUrl:n});if(!e)throw Error(`signerAccountAddress is required`);let s=0;try{s=await Sl(c,[...a],e,{revision:In.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}return(await u(a,{signer:d.isConnectedWithDappKit&&!d.isInAppBrowser&&e?e:l.address,gas:i??s,...f?.delegateAllTransactions||n?{delegator:{url:n??f?.delegatorUrl??``,signer:e}}:{}})).txid},[e,i,p,m,a,f,c,l,o,s,u,d.isConnectedWithDappKit,d.isInAppBrowser]),[g,_]=G(null),[v,y]=G(!1),[b,x]=G(null),S=H(async(e,n)=>{if(!e&&!t)throw Error(`clauses are required`);try{_(null),y(!0),x(null),D(void 0),_(await h(e??[],n,{...a}))}catch(e){x(e&&typeof e==`object`&&`message`in e?e.message:String(e)),r?.(e instanceof Error?e:Error(String(e)))}finally{y(!1)}},[h,t,a,s]),{data:C,isLoading:w,error:ee}=Sh(g??``),T=H(async e=>{if(!(!e.reverted||!e.meta.txID))return await c.transactions.getRevertReason(e.meta.txID)},[c]),[E,D]=G(),O=W(()=>{if(v)return`pending`;if(b)return`error`;if(g){if(w)return`waitingConfirmation`;if(ee)return`error`;if(C)return C.reverted?`error`:`success`}return`ready`},[w,b,v,g,C,ee]);U(()=>{if(O===`success`||O===`error`){if(b&&!E){D({type:`UserRejectedError`,reason:b});return}if(C?.reverted&&!E?.type){(async()=>{let e=await T(C);D({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}C&&!C.reverted&&n?.()}},[O,C,n,T,b]);let k=H(()=>{_(null),y(!1),x(null),D(void 0)},[]);return{sendTransaction:S,isTransactionPending:W(()=>v||w||O===`pending`||O===`waitingConfirmation`,[v,w,O]),isWaitingForWalletConfirmation:W(()=>O===`pending`,[v,O]),txReceipt:C??null,status:O,resetStatus:k,error:E}},wl=(e,t)=>{let{account:n}=Q(),{t:r}=Y(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=Cl({signerAccountAddress:n?.address??``,privyUIOptions:{title:r(`ConfirmSwapTitle`,{defaultValue:`Confirm Swap`}),description:r(`ConfirmSwapDescription`,{defaultValue:`Please confirm the swap transaction in your wallet`}),buttonText:r(`Confirm`,{defaultValue:`Confirm`})}});return{executeSwap:H(async()=>{if(!e||!t)throw Error(`Missing swap parameters or quote`);if(!t.aggregator)throw Error(`Aggregator not found for quote from ${t.aggregatorName}`);let n=await t.aggregator.buildSwapTransaction(e,t);if(n.length===0)throw Error(`Failed to build swap transaction`);await i(n)},[e,t,i]),isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}},Tl=e=>e===`0x`||e===Qi,El=(e,t,n,r)=>{let i={},a=r.toLowerCase();for(let t of e)try{let e=Vi({abi:Pn,eventName:`Transfer`,topics:t.topics,data:t.data}),n=e.args.from.toLowerCase(),r=e.args.to.toLowerCase(),o=e.args.value,s=typeof o==`bigint`?o:BigInt(o);if(n!==a&&r!==a)continue;let c=t.address.toLowerCase(),l=i[c]??{inflow:0n,outflow:0n};n===a&&(l.outflow+=s),r===a&&(l.inflow+=s),i[c]=l}catch{continue}if(n!==void 0){let e=BigInt(n);if(e>0n){let t=i[Qi]??{inflow:0n,outflow:0n};t.outflow+=e,i[Qi]=t}}for(let e of t){if(e.recipient.toLowerCase()!==a)continue;let t=BigInt(e.amount);if(t<=0n)continue;let n=i[Qi]??{inflow:0n,outflow:0n};n.inflow+=t,i[Qi]=n}return i},Dl=async(e,t,n,r)=>{try{if(n.length===0)return{gasCostVTHO:0,success:!1,error:`No clauses found for simulation`};let i=await r.transactions.simulateTransaction(n,{caller:e.userAddress}),a=!1,o,s=2e5,c={};for(let t=0;t<i.length;t++){let r=i[t];r.reverted&&(a=!0,o=r.vmError||`Transaction reverted`),s+=r.gasUsed;let l=n[t],u=El(r.events,r.transfers,l?.value,e.userAddress);for(let[e,t]of Object.entries(u)){let n=c[e]??{inflow:0n,outflow:0n};c[e]={inflow:n.inflow+t.inflow,outflow:n.outflow+t.outflow}}}if(a)return{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`};let l=s/1e5,u=Tl(e.fromTokenAddress),d=Tl(e.toTokenAddress),f=BigInt(e.amountIn);if(u){let e=c[Qi]??{inflow:0n,outflow:0n};if(e.outflow>f)return{gasCostVTHO:l,success:!1,error:`VET outflow mismatch: expected ${f.toString()}, got ${e.outflow.toString()}`};for(let[e,t]of Object.entries(c))if(e!==Qi&&t.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: token ${e} has outflow ${t.outflow.toString()}, expected 0`}}else{let t=e.fromTokenAddress.toLowerCase(),n=c[t]??{inflow:0n,outflow:0n};if(n.outflow>f)return{gasCostVTHO:l,success:!1,error:`Token outflow mismatch: expected ${f.toString()}, got ${n.outflow.toString()}`};for(let[e,n]of Object.entries(c))if(e!==t&&n.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: ${e===Qi?`VET`:e} has outflow ${n.outflow.toString()}, expected 0`}}if(t.minimumOutputAmount&&t.minimumOutputAmount>0n)if(d){let e=c[Qi]??{inflow:0n,outflow:0n};if(e.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`VET inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${e.inflow.toString()}`}}else{let n=c[e.toTokenAddress.toLowerCase()]??{inflow:0n,outflow:0n};if(n.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`Token inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${n.inflow.toString()}`}}return{gasCostVTHO:l,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},Ol=e=>e.startsWith(`0x`)?BigInt(e).toString():e,kl=(e,t)=>({name:e,type:`function`,inputs:t.map(e=>({name:e.name,type:e.type,internalType:e.internalType,components:e.components})),outputs:[],stateMutability:`nonpayable`}),Al=(e,t)=>{if(Array.isArray(e)&&e.length>0){let n=e[0];if(typeof n==`object`&&`name`in n&&`type`in n&&n.type===`function`)return e;if(typeof n==`object`&&`name`in n&&`type`in n&&!(`stateMutability`in n||`outputs`in n))return[kl(t,e)]}return e},jl=e=>{try{let t=e.functionName||e.name;if(!t)throw Error(`Function name is required (either functionName or name must be provided)`);return Ui({abi:Al(e.abi,t),functionName:t,args:e.args})}catch(t){console.error(`Failed to encode function call:`,t);let n=e.functionName||e.name||`unknown`;throw Error(`Failed to encode function call ${n}: ${t instanceof Error?t.message:`Unknown error`}`)}},Ml=e=>{let t=jl(e.functionCall);return{to:e.to,value:Ol(e.value),data:t,comment:e.comment||`Swap on aggregator`}},Nl=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){try{let r=new URLSearchParams({fromAddress:n.fromTokenAddress,toAddress:n.toTokenAddress,amountIn:n.amountIn,recipient:n.userAddress,slippageBps:String((n.slippageTolerance||1)*100),network:e.network}),i=new URL(e.apiBaseUrl);i.search=r.toString();let a=await fetch(i);if(!a.ok)throw Error(`API request failed: ${a.status} ${a.statusText}`);let o=await a.json(),s=o.clauses.map(Ml),c=BigInt(o.amountOut),l=BigInt(o.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:c,minimumOutputAmount:l,priceImpact:0,data:{clauses:s,path:o.path}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{clauses:[],path:[]}}}},async simulateSwap(e,t,n){try{return Dl(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Failed to build swap transaction for simulation`}}},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`clauses`in n.data))throw Error(`Invalid quote data: clauses not found`);let r=n.data.clauses;if(r.length===0)throw Error(`No clauses found in quote`);if(e.supportedAddresses&&e.supportedAddresses.length>0){let t=e.supportedAddresses.map(e=>e.toLowerCase());if(r=r.filter(e=>e.to?t.includes(e.to.toLowerCase()):!1),r.length===0)throw Error(`No clauses found matching supported addresses`)}if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);return r}};return t},Pl={main:{supportedAddresses:[`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,`0x7C755EC0165fCD926cC6faB10E7BB16a72E9f34A`]},test:{supportedAddresses:[]},solo:{supportedAddresses:[]}},Fl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,Il=e=>new URL(`api/quote/vck`,we).toString(),Ll=e=>{let t=Pl[e]??Pl.main,n=Nl({name:`VeTrade.vet`,apiBaseUrl:Il(e),network:e,getIcon:(e=`20px`)=>V.createElement(qe,{boxSize:e}),supportedAddresses:t.supportedAddresses});return{...n,async simulateSwap(e,t,n){try{return Dl(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(e,r){let i=[],a=await n.buildSwapTransaction(e,r);if(!a||a.length===0)throw Error(`Failed to build swap transaction`);if(Fl(e.fromTokenAddress))a[0].value=e.amountIn;else{if(t.supportedAddresses.length===0)throw Error(`No supported addresses configured for VeTrade on this network`);let n=jn.ofAbi(Ti.abi),o=Mn.of(e.fromTokenAddress),s=BigInt(e.amountIn);i.push(Nn.callFunction(o,n.getFunction(`approve`),[a[0].to,s.toString()],zn.of(0n,Rn.wei),{comment:`Approve ${r.aggregatorName} to access ${e.fromTokenAddress}`}))}return i.push(...a),i}}},Rl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,zl=()=>BigInt(Math.floor(Date.now()/1e3)+1200),Bl=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[Rl(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,Rl(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,Ni.abi).read.getAmountsOut(a,i),s=Array.isArray(o)?o:[o],c=s[s.length-1];if(!c||c===0n)throw Error(`Output amount is zero or invalid`);if(typeof c!=`bigint`)throw Error(`Output amount is not a valid bigint`);let l=n.slippageTolerance||1,u=c*BigInt(1e4-l*100)/BigInt(1e4);return{aggregatorName:e.name,aggregator:t,outputAmount:c,priceImpact:0,minimumOutputAmount:u,data:{path:i,routerAddress:e.routerAddress}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{path:i,routerAddress:e.routerAddress}}}},async simulateSwap(e,t,n){return Dl(e,t,await this.buildSwapTransaction(e,t),n)},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`path`in n.data))throw Error(`Invalid quote data`);let r=zl();if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);let i=n.minimumOutputAmount,a=BigInt(t.amountIn);if(i===0n)throw Error(`Invalid quote: minimumOutputAmount is zero`);let o=Rl(t.fromTokenAddress),s=Rl(t.toTokenAddress),c=jn.ofAbi(Ni.abi),l=[];if(o)l.push(Nn.callFunction(Mn.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],zn.of(a,Rn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=jn.ofAbi(Ti.abi),u=Mn.of(t.fromTokenAddress),d=Mn.of(e.routerAddress);l.push(Nn.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],zn.of(0n,Rn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(Nn.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],zn.of(0n,Rn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(Nn.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],zn.of(0n,Rn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},Vl={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Qi,wrappedVET:Qi},solo:{routerAddress:Qi,wrappedVET:Qi}},Hl=e=>{let t=Vl[e]??Vl.main;return Bl({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Ue,{boxSize:e})})},Ul=e=>[Ll(e),Hl(e)],Wl=(e,t,n,r,i=1,a=!0)=>{let o=nr(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=bc(c===`0x`||c===Qi||!c?``:c),{data:d}=bc(l===`0x`||l===Qi||!l?``:l),f=W(()=>!c||c===`0x`||c===Qi||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=W(()=>!l||l===`0x`||l===Qi||!d?18:Number(d?.decimals??18),[l,d?.decimals]),m=W(()=>{if(!c||!l||!n||!r)return null;let e;try{e=Xi(n,f)}catch(e){return console.error(`Failed to parse amount:`,n,e),null}return e<=0n?null:{fromTokenAddress:c,toTokenAddress:l,amountIn:e.toString(),userAddress:r,slippageTolerance:i}},[c,l,n,r,i,f]),{data:h,isLoading:g,error:_}=X({queryKey:[`unified-swap-quotes`,m,s.network],queryFn:async()=>{if(!m||!o||!s.network)return{quotes:[],best:null};let e=Ul(s.network).map(async e=>{try{let t=await e.getQuote(m,o);try{let n=await e.simulateSwap(m,t,o);return{...t,aggregator:e,reverted:!n.success,revertReason:n.error,gasCostVTHO:n.gasCostVTHO}}catch(n){return console.error(`Failed to simulate swap for ${e.name}:`,n),{...t,aggregator:e,reverted:!0,revertReason:n instanceof Error?n.message:`Simulation failed`,gasCostVTHO:0}}}catch(t){return console.error(`Failed to get quote from ${e.name}:`,t),null}}),t=(await Promise.all(e)).filter(e=>e!==null&&e.outputAmount!==0n),n=null;if(t.length>0){let e=t.filter(e=>!(e.reverted??!1));n=(e.length>0?e:t).reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e})}return{quotes:t,best:n}},enabled:a&&m!==null&&o!=null,refetchInterval:1e4});return{bestQuote:h?.best??null,quotes:h?.quotes??[],isLoading:g,error:_,from:e?{...e,address:c??``,decimals:f}:null,to:t?{...t,address:l??``,decimals:p}:null}},Gl=`0x`,Kl=`0x0000000000000000000000000000456e65726779`,ql=(e,t)=>(e??``).toLowerCase()===(t??``).toLowerCase(),Jl=(e,t,n)=>[`VECHAIN_KIT`,`TRANSFER_HISTORY`,t,e?.toLowerCase(),n?n.toLowerCase():`all`],Yl=(e,{tokenAddress:t,enabled:n=!0}={})=>{let{network:r}=$(),i=Eg(),{balances:a}=Ks(e),o=new Map,s=new Set([`0x`,Kl,i.b3trContractAddress,i.vot3ContractAddress,i.veDelegateTokenContractAddress,i.vvetContractAddress].filter(Boolean).map(e=>e.toLowerCase()));o.set(`0x`,{symbol:`VET`,decimals:18}),o.set(`0x0000000000000000000000000000456e65726779`,{symbol:`VTHO`,decimals:18});for(let e of a)!e.address||!e.symbol||s.has(e.address.toLowerCase())&&o.set(e.address.toLowerCase(),{symbol:e.symbol,decimals:18});let c=i.indexerUrl,l=t===`0x`,u=!!c&&r.type!==`solo`,d=lr({queryKey:Jl(e,r.type,t??null),initialPageParam:0,getNextPageParam:(e,t)=>e.hasNext?t.length:void 0,queryFn:async({pageParam:n=0})=>{if(!e)return{items:[],hasNext:!1};let i=new URLSearchParams({address:e.toLowerCase(),page:String(n)});l?i.set(`eventType`,`VET`):t&&i.set(`tokenAddress`,t.toLowerCase());let a=await fetch(`${c}/transfers?${i.toString()}`);if(!a.ok)throw Error(`Indexer request failed: ${a.status}`);let s=await a.json(),u=(s.data??[]).filter(e=>e.eventType!==`NFT`).filter(e=>t?l?e.eventType===`VET`:ql(e.tokenAddress,t):!0),d=new Set;for(let e of u){if(e.eventType!==`FUNGIBLE_TOKEN`||!e.tokenAddress)continue;let t=e.tokenAddress.toLowerCase();o.has(t)||d.add(t)}if(d.size&&r.nodeUrl){let e=Array.from(d);(await Promise.allSettled(e.map(e=>vc(e,r.nodeUrl)))).forEach((t,n)=>{if(t.status!==`fulfilled`||!t.value)return;let r=t.value;if(!r.symbol)return;let i=Number(r.decimals);o.set(e[n],{symbol:r.symbol,decimals:Number.isFinite(i)?i:18})})}return{items:u.map(t=>{let n=t.eventType===`VET`,r=n?`0x`:(t.tokenAddress??``).toLowerCase(),i=o.get(r),a=i?.decimals??18,s=i?.symbol??(n?`VET`:t.tokenAddress?.slice(0,6)??``),c=ql(t.from,e)?`sent`:`received`,l=0;try{l=Number(Tn(BigInt(t.value),a))}catch{l=0}return{id:t.id,txId:t.txId,blockNumber:t.blockNumber,timestamp:t.blockTimestamp,direction:c,from:t.from,to:t.to,tokenAddress:n?null:t.tokenAddress??null,tokenSymbol:s,tokenDecimals:a,rawValue:t.value,amount:l,eventType:t.eventType}}),hasNext:!!s.pagination?.hasNext}},enabled:n&&!!e&&u,staleTime:3e4});return{transfers:d.data?.pages.flatMap(e=>e.items)??[],isLoading:d.isLoading,isFetching:d.isFetching,isFetchingNextPage:d.isFetchingNextPage,hasNextPage:!!d.hasNextPage,fetchNextPage:d.fetchNextPage,isUnsupportedNetwork:!u,error:d.error}},Xl=(e,t,n={})=>Yl(e,{tokenAddress:t??void 0,enabled:n.enabled}),Zl=({email:e,onResend:t,isLoading:n,isOpen:r,onClose:i})=>{let{t:a}=Y(),{darkMode:o}=$(),s=B(`colors`,`vechain-kit-text-secondary`),[c,l]=G(``),[u,d]=G(null),{createWallet:f}=Wn(),{loginWithCode:p}=Gn({onComplete:async({isNewUser:e})=>{e&&await f()}});return U(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),J(Ko,{isOpen:r,onClose:i,trapFocus:!1,children:[J(Z,{children:[q(L,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),q(I,{})]}),J(_t,{maxW:`container.lg`,children:[q(F,{children:J(z,{spacing:2,children:[q(P,{as:Xr,w:`48px`,h:`48px`,color:s}),q(R,{fontSize:`xs`,color:s,textAlign:`center`,children:a(`Please check {{email}} for an email from privy.io and enter your code below.`,{email:e})}),q(N,{spacing:2,justify:`center`,mt:4,children:J(Rt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`})]})}),u&&q(R,{color:`#ef4444`,fontSize:`xs`,children:u})]})}),q(It,{children:J(R,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,q(M,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},Ql=()=>{let{t:e}=Y(),{darkMode:t}=$(),[n,r]=G(``),{sendCode:i,state:a}=Gn({}),o=hn(),s=async()=>{await i({email:n}),o.onOpen()};return J(K,{children:[q(Ct,{colSpan:4,w:`full`,children:q(z,{spacing:3,w:`full`,children:J(Ot,{size:`lg`,w:`full`,children:[q(kt,{pointerEvents:`none`,height:`100%`,pl:4,children:q(P,{as:Xr,color:t?`whiteAlpha.600`:`blackAlpha.700`,w:`20px`,h:`20px`})}),q(Dt,{placeholder:e(`your@email.com`),value:n,onChange:e=>r(e.target.value),fontSize:`16px`,fontWeight:`400`,backgroundColor:t?`transparent`:`#ffffff`,border:`1px solid ${t?`#ffffff0a`:`#ebebeb`}`,p:6,borderRadius:16,w:`full`,pl:12}),q(M,{"aria-label":`Send code`,position:`absolute`,right:2,top:`50%`,transform:`translateY(-50%)`,zIndex:2,variant:`ghost`,size:`sm`,px:6,borderRadius:`full`,isLoading:a.status===`sending-code`,onClick:s,children:e(`Submit`)})]})})}),q(Zl,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},$l=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=am(),[i,a,o]=B(`colors`,[`vechain-kit-border-button`,`vechain-kit-border-hover`,`vechain-kit-button-secondary-bg`]);return q(Ct,{colSpan:t??4,w:`full`,children:q(jf,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:ha,iconWidth:`24px`,text:n(`Continue with Google`),style:{bg:`transparent`,border:`1px solid ${i}`,_hover:{bg:o,borderColor:a,opacity:1}}})})},eu=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=am(),[i,a,o,s]=B(`colors`,[`vechain-kit-border-button`,`vechain-kit-border-hover`,`vechain-kit-button-secondary-bg`,`vechain-kit-text-primary`]);return q(Ct,{colSpan:t??4,w:`full`,children:q(jf,{isDark:e,onClick:async()=>{await r({provider:`apple`})},customIcon:q(P,{as:ga,w:`24px`,h:`24px`,color:s}),text:n(`Continue with Apple`),style:{bg:`transparent`,border:`1px solid ${i}`,_hover:{bg:o,borderColor:a,opacity:1}}})})},tu=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=am();return q(Ct,{colSpan:t??4,w:`full`,children:q(jf,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:Hr,text:n(`Continue with Github`)})})},nu=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=Yn();return q(Ct,{colSpan:t||4,w:`full`,children:q(jf,{isDark:e,onClick:r,icon:e?be:Ge,text:n(`Login with social`),variant:`loginWithVechain`,rightIcon:q(Lf,{})})})},ru=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=Y(),{login:i}=sm(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting to VeChain`),loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:a}});try{await i()}catch(e){console.error(r(`Login failed:`),e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with VeChain`),onTryAgain:a}})}};return q(Ct,{colSpan:t||4,w:`full`,children:q(jf,{isDark:e,onClick:a,icon:e?be:Ge,text:r(`Login with social`),variant:`loginWithVechain`,rightIcon:q(Lf,{})})})},iu=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=Y(),{loginWithPasskey:i}=rm(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting with Passkey`),loadingText:r(`Please complete the passkey authentication...`),onTryAgain:a}});try{await i()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&console.error(e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with Passkey`),onTryAgain:a}})}};return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:a,icon:zr,text:t&&t>=2?r(`Passkey`):void 0})})},au=({isDark:e,gridColumn:t=2})=>{let{t:n}=Y(),{open:r,onConnectionStatusChange:i}=ar(),{dappKit:a}=$(),{source:o}=ir(),s=a?.allowedWallets?.includes(`sync2`)?n(`Connect wallet`):n(`Connect with VeWorld wallet`);return U(()=>{i((e,t)=>{if(!e)return t?.message&&console.error(t?.message),{...o&&{source:o}}})},[i,o]),q(Ct,{colSpan:t||2,w:`full`,children:q(jf,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?pi:e?Se:Ve,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&q(P,{as:vr})||void 0})})},ou=`#16a34a`,su=()=>q(j,{w:`6px`,h:`6px`,borderRadius:`full`,bg:ou,boxShadow:`0 0 0 3px ${ou}2e`,mr:`3px`,flexShrink:0,"aria-hidden":!0}),cu=({isDark:e,gridColumn:t=4,setCurrentContent:n})=>{let{t:r}=Y(),{connect:i}=um(`veworld`,n),a=e?`#ffffff`:`#0E0D18`,o=e?`#0E0D18`:`#ffffff`;return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:i,customIcon:q(e?Ve:Se,{w:`24px`,h:`24px`}),text:t>=2?r(`Continue with VeWorld`):void 0,rightIcon:q(su,{}),style:{bg:a,color:o,border:`none`,_hover:{bg:a,opacity:.92}}})})},lu=({isDark:e,gridColumn:t=4,setCurrentContent:n})=>{let{t:r}=Y(),{connect:i}=um(`sync2`,n);return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:i,icon:pi,text:t>=2?r(`Continue with Sync2`):void 0})})},uu=({isDark:e,gridColumn:t=4,setCurrentContent:n})=>{let{t:r}=Y(),{connect:i}=um(`wallet-connect`,n);return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:i,icon:ti,text:t>=2?r(`Continue with WalletConnect`):void 0})})},du=({setCurrentContent:e})=>{let{t}=Y(),{loginMethods:n,darkMode:r}=$(),{showGoogleLogin:i,showAppleLogin:a,showEmailLogin:o,showPasskey:s,showVeChainLogin:c,showDappKit:l,showVeWorld:u,showSync2:d,showWalletConnect:f,showMoreLogin:p,showGithubLogin:m,isOfficialVeChainApp:h}=Jp(),g=(n,g)=>{switch(n){case`email`:return o&&q(Ql,{},`email`);case`google`:return i&&q($l,{isDark:r,gridColumn:g},`google`);case`apple`:return a&&q(eu,{isDark:r,gridColumn:g},`apple`);case`github`:return m&&q(tu,{isDark:r,gridColumn:g},`github`);case`vechain`:return c&&(h?q(nu,{isDark:r,gridColumn:g},`vechain`):q(ru,{isDark:r,gridColumn:g,setCurrentContent:e},`vechain`));case`passkey`:return s&&q(iu,{isDark:r,gridColumn:g,setCurrentContent:e},`passkey`);case`dappkit`:return l&&q(au,{isDark:r,gridColumn:g},`dappkit`);case`veworld`:return u&&q(cu,{isDark:r,gridColumn:g??4,setCurrentContent:e},`veworld`);case`sync2`:return d&&q(lu,{isDark:r,gridColumn:g??4,setCurrentContent:e},`sync2`);case`wallet-connect`:return f&&q(uu,{isDark:r,gridColumn:g??4,setCurrentContent:e},`wallet-connect`);case`more`:return p&&q(Ct,{colSpan:g??4,w:`full`,display:`flex`,justifyContent:`center`,pt:3,children:q(M,{variant:`link`,size:`sm`,fontWeight:500,rightIcon:q(P,{as:Er,ml:`-1`}),onClick:()=>e({type:`more`,props:{}}),children:t(`More options`)})},`more`);default:return null}};return q(Jt,{spacing:4,w:`full`,align:`center`,children:q(St,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:n?.map(({method:e,gridColumn:t})=>g(e,t))})})},fu=({appsInfo:e,isLoading:t,setCurrentContent:n})=>{let{t:r}=Y();return q(M,{fontSize:`sm`,variant:`link`,onClick:()=>n({type:`ecosystem`,props:{appsInfo:e,isLoading:t}}),children:r(`Already have an x2earn app wallet?`)})},pu=({setCurrentContent:e})=>{let{t}=Y(),{loginModalUI:n,darkMode:r}=$(),{loginMethods:i,privyEcosystemAppIDS:a}=$(),{data:o,isLoading:s}=Yo(a),c=B(`colors`,`vechain-kit-text-secondary`),l=()=>{e(`faq`)},u=i?.some(({method:e})=>e===`ecosystem`);return J(K,{children:[J(Z,{children:[q(Jh,{onClick:l}),q(L,{children:t(`Log in or sign up`)}),q(I,{})]}),n?.logo&&q(N,{justify:`center`,children:q(Et,{src:n.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),J(F,{children:[n?.description&&q(N,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:q(R,{color:c,fontSize:`sm`,textAlign:`center`,children:n?.description})}),q(du,{setCurrentContent:e})]}),u?q(It,{children:q(N,{justify:`center`,w:`full`,children:q(fu,{isDark:r,appsInfo:Object.values(o||{}),isLoading:s,setCurrentContent:e})})}):q(It,{pt:0,pb:`5px`})]})},mu=({setCurrentContent:e,wallet:t,onClose:n,switchFeedback:r})=>{let{t:i}=Y(),{network:a}=$(),{isolatedView:o}=gu();return J(Yh,{children:[J(Z,{children:[!o&&q(Fo,{onClick:()=>{e(`profile`)}}),J(L,{children:[i(`Wallet`),a?.type!==`main`&&q(nn,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${a?.type}`})]}),q(I,{})]}),q(F,{w:`full`,children:J(z,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:8,children:[q(ig,{showFeedback:r?.showFeedback}),q(Pu,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),q(Iu,{onAssetsClick:()=>{e(`assets`)}}),q(zu,{setCurrentContent:e})]})}),q(It,{pt:0})]})},hu=({onSelectToken:e,onBack:t,showAllTokens:n=!1,excludedTokenSymbols:r=p})=>{let{t:i}=Y(),{darkMode:a}=$(),{currentCurrency:o}=lc(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`),l=B(`colors`,`vechain-kit-text-tertiary`),{account:u}=Q(),{tokensWithBalance:d,sortedTokens:f}=uc({address:u?.address??``}),[m,h]=G(``),g=W(()=>{let e=e=>r.includes(e),t;if(n){let n=f.filter(t=>Number(t.balance)>0&&!e(t.symbol)),r=[...f.filter(t=>Number(t.balance)===0&&!e(t.symbol))].sort((e,t)=>e.symbol.localeCompare(t.symbol));t=[...n,...r]}else t=d.filter(t=>!e(t.symbol));return t},[n,f,d,r]).filter(({symbol:e})=>e.toLowerCase().includes(m.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:i(`Select Token`)}),q(Fo,{onClick:t}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:4,align:`stretch`,children:[J(Ot,{size:`lg`,children:[q(Dt,{placeholder:`Search token`,bg:a?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:m,onChange:e=>h(e.target.value),"data-testid":`search-token-input`}),q(kt,{h:`56px`,w:`56px`,pl:4,children:q(ri,{color:l})})]}),q(R,{fontSize:`lg`,fontWeight:`semibold`,color:s,mt:4,children:i(n?`All tokens`:`Your tokens`)}),g.length===0?J(z,{spacing:2,py:8,children:[q(P,{as:si,boxSize:12,color:l}),q(R,{fontSize:`lg`,color:s,children:i(`No tokens found`)}),q(R,{fontSize:`md`,color:c,children:i(`Try searching with a different term`)})]}):q(z,{spacing:2,align:`stretch`,children:g.map(t=>q(Kh,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:o,onClick:()=>e(t)},t.address))})]})})}),q(It,{pt:0})]})},gu=()=>{let{isolatedView:e,closeAccountModal:t}=bp();return{isolatedView:e,closeAccountModal:t}},_u=({setCurrentContent:t,preselectedToken:n,initialAmount:r=``,initialToAddressOrDomain:i=``,onBack:a=()=>t(`main`)})=>{let{t:o}=Y(),{darkMode:s,feeDelegation:c}=$(),{currentCurrency:l}=lc(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-text-tertiary`),m=B(`colors`,`vechain-kit-error`),h=B(`colors`,`vechain-kit-card`),{exchangeRates:g}=ic(),{account:_}=Q(),{isolatedView:v}=gu(),{tokensWithBalance:y}=uc({address:_?.address??``}),b=W(()=>y.filter(e=>!p.includes(e.symbol)),[y]),[S,C]=G(()=>n&&!p.includes(n.symbol)?n:b[0]??null),[w,ee]=G(!1);U(()=>{!S&&b.length>0&&C(b[0])},[b,S]);let{register:T,watch:E,setValue:D,setError:O,formState:{errors:k,isValid:te},handleSubmit:A}=Ta({defaultValues:{amount:r,toAddressOrDomain:i},mode:`onChange`}),{toAddressOrDomain:ne,amount:re}=E(),ie=xn(S);U(()=>{ie.current&&S&&ie.current.address!==S.address&&D(`amount`,``),ie.current=S},[S,D]);let ae=W(()=>S?sc(ac(Number(re)*S.priceUsd,l,g),{currency:l}):``,[re,S,l,g]),{data:oe,isLoading:se}=$o(ne),ce=()=>{S&&D(`amount`,S.balance)},le=()=>{a()},ue=async e=>{if(S){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){O(`toAddressOrDomain`,{type:`manual`,message:o(`Invalid address or domain`)});return}if(S){let t=Dn(e.amount),n=c?.b3trTransfers?.minAmountInEther;if(S.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(t<Dn(String(n))){O(`amount`,{type:`manual`,message:o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:S.symbol,min:n})});return}}catch{}if(t>Dn(S.balance)){O(`amount`,{type:`manual`,message:o(`Insufficient {{symbol}} balance`,{symbol:S.symbol})});return}}t({type:`send-token-summary`,props:{toAddressOrDomain:e.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:e.amount,selectedToken:S,formattedTotalAmount:ae,setCurrentContent:t}})}};return w?q(hu,{setCurrentContent:t,onSelectToken:e=>{C(e),ee(!1)},onBack:()=>{ee(!1)}}):J(K,{children:[J(Z,{children:[q(L,{children:o(`Send`)}),!v&&q(Fo,{onClick:le}),q(I,{})]}),q(F,{children:J(z,{spacing:2,align:`stretch`,position:`relative`,children:[J(N,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`Amount`)}),J(R,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:ce,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:d,children:[o(`Balance`),`:`,` `,Number(S?.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(j,{p:4,borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,children:J(bt,{isInvalid:!!k.amount,children:[J(N,{justify:`space-between`,children:[q(Dt,{...T(`amount`,{required:o(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:o(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return o(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return S?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:S.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,D(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),S?J(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>ee(!0),leftIcon:x[S.symbol]?V.cloneElement(x[S.symbol],{boxSize:`20px`,borderRadius:`full`}):q(Et,{src:e[S.symbol],alt:`${S.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:u,children:S.symbol.slice(0,3)})})}),children:[S.symbol,q(P,{as:Er,boxSize:5,color:d})]}):J(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>ee(!0),children:[o(`Select token`),q(P,{as:Er,boxSize:5,color:d})]})]}),S&&q(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:J(R,{color:d,children:[`≈ `,ae]})}),k.amount&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:k.amount.message})]})})}),q(N,{justify:`space-between`,mt:2,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`To`)})}),q(j,{borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,p:4,width:`100%`,children:J(bt,{isInvalid:!!k.toAddressOrDomain,children:[q(Dt,{...T(`toAddressOrDomain`,{required:o(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?Ea(t):t;e.target.value=n,D(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:o(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),k.toAddressOrDomain&&q(R,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:k.toAddressOrDomain.message})]})})})]})}),q(It,{children:q(M,{variant:`vechainKitPrimary`,isDisabled:!S||!te,isLoading:se,onClick:A(ue),"data-testid":`send-button`,children:o(S?`Send`:`Select Token`)})})]})},vu=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:i,selectedToken:a,formattedTotalAmount:o})=>{let{t:s}=Y(),{account:c,connection:u,connectedWallet:d}=Q(),{data:f}=Is(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Hh(),{isolatedView:g,closeAccountModal:_}=gu(),v=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b}=nh(c?.address??``,d?.address??``,3),{open:x}=Yp(),S=W(()=>f||l(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{a.symbol===`VET`?await A():await ee()}catch(e){console.error(s(`Transaction failed:`),e)}},w=V.useCallback(t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:s(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},[e,s,g,_]),{sendTransaction:ee,txReceipt:T,error:E,isWaitingForWalletConfirmation:D,isTransactionPending:O,clauses:k,isLoadingTokenInfo:te}=gh({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,tokenAddress:a.address,tokenName:a.symbol,onError:e=>{me(e??``)}}),{sendTransaction:A,txReceipt:ne,error:re,isWaitingForWalletConfirmation:ie,isTransactionPending:ae,clauses:oe}=vh({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,onError:e=>{me(e??``)}}),se=V.useCallback(()=>a.symbol===`VET`?ne:T,[a.symbol,ne,T]),ce=D||ie,le=ce||O||ae,ue=a.symbol!==`VET`&&te,[de,fe]=V.useState(!1);V.useEffect(()=>{let e=se();if(!e||e.reverted||de||le)return;let t=e.meta.txID;t&&(fe(!0),w(t))},[se,de,le,w]),V.useEffect(()=>{le&&fe(!1)},[le]);let pe=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:a,initialAmount:i,initialToAddressOrDomain:t}})},me=e=>{console.error(`Transaction failed:`,e)},[he,ge]=V.useState(null),[_e,ve]=V.useState(null),ye=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:be,isLoading:xe,error:Se,refetch:Ce}=Uh({clauses:a.symbol===`VET`?oe:k,tokens:he?[he]:h.availableGasTokens,sendingAmount:i,sendingTokenSymbol:a.symbol,enabled:ye&&!!m?.genericDelegatorUrl}),we=be?.usedToken,Te=(xe||!be)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,Ee=V.useCallback(e=>{ge(e),ve(e),setTimeout(()=>Ce(),100)},[Ce]),De=!!we&&!Se;return V.useEffect(()=>{Se&&he&&ge(null)},[Se,he]),J(K,{children:[J(Z,{children:[q(L,{children:`Send`}),q(Fo,{isDisabled:le,onClick:pe}),q(I,{isDisabled:le})]}),q(F,{children:q(z,{spacing:6,align:`stretch`,w:`full`,children:J(z,{spacing:4,w:`full`,children:[J(j,{w:`full`,children:[q(R,{fontSize:`sm`,mb:2,color:y,children:s(`From`)}),q(qh,{address:c?.address??``,domain:c?.domain,imageSrc:c?.image??``,imageAlt:`From account`,balance:Number(a.balance),tokenAddress:a.address})]}),J(j,{w:`full`,children:[q(R,{fontSize:`sm`,mb:2,color:y,children:s(`To`)}),q(qh,{address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:a.address})]}),u.isConnectedWithPrivy&&q(eg,{estimation:be,isLoading:xe,isLoadingTransaction:le,onTokenChange:Ee,clauses:a.symbol===`VET`?oe:k,userSelectedToken:_e}),J(z,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:s(`Amount`)}),J(N,{justifyContent:`flex-start`,w:`full`,children:[J(R,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(i).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,a.symbol]}),J(R,{color:y,children:[`≈ `,o]})]})]})]})})}),q(It,{children:q(Zh,{transactionError:a.symbol===`VET`?re:E,isSubmitting:le,isTxWaitingConfirmation:ce,onConfirm:C,transactionPendingText:s(`Sending...`),txReceipt:se(),buttonText:s(`Confirm`),isDisabled:le||ue||Te,gasEstimationError:Se,hasEnoughGasBalance:De,isLoadingGasEstimation:xe,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},yu=({setCurrentContent:e,onBack:t})=>{let{t:n}=Y(),{account:r}=Q(),{isolatedView:i}=gu(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=t??(()=>e(`main`));return J(K,{children:[J(Z,{children:[q(L,{children:n(`Receive`)}),!i&&q(Fo,{onClick:s}),q(I,{})]}),J(_t,{maxW:`container.lg`,children:[q(F,{children:J(z,{spacing:4,align:`center`,w:`full`,children:[q(Da,{value:r?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),q(Io,{wallet:r,style:{w:`85%`}}),q(R,{fontSize:`sm`,textAlign:`center`,color:a,children:n(`Copy your address or scan this QR code`)}),q(R,{fontSize:`xs`,textAlign:`center`,color:o,children:n(`This address only supports VeChain assets.`)})]})}),q(It,{pt:0})]})]})},bu=({quotes:t,selectedQuote:n,toTokenAddress:r,onSelectQuote:i,onBack:a})=>{let{t:o}=Y(),{darkMode:s}=$(),{currentCurrency:c}=lc(),{account:l}=Q(),{exchangeRates:u,prices:d}=ic(),{tokens:f}=uc({address:l?.address??``}),[p,m]=G(!1),h=W(()=>r&&f.find(e=>E(e.address,r))||null,[r,f]),g=t.filter(e=>!e.reverted),_=t.filter(e=>e.reverted),v=W(()=>g.length===0?null:g.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[g]),y=W(()=>{let e=r&&d[r]||0;return g.map(t=>{let n=Wi(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=ac(r,c,u),a=v&&t.aggregatorName===v.aggregatorName,o=0;if(v&&!a){let e=BigInt(v.outputAmount||`0`),n=BigInt(t.outputAmount||`0`);o=Number(n-e)/Number(e)*100}return{...t,outputAmountFormatted:n,valueUsd:r,valueInCurrency:i,isBest:a,percentageDiff:o}}).sort((e,t)=>{let n=BigInt(e.outputAmount||`0`),r=BigInt(t.outputAmount||`0`);return Number(r-n)})},[g,r,d,c,u,v]);return J(K,{children:[J(Z,{children:[q(L,{children:o(`Found following rates`)}),q(Fo,{onClick:a}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,children:[y.length>0&&q(z,{spacing:2,align:`stretch`,children:y.map(t=>{let r=n?.aggregatorName===t.aggregatorName;return J(j,{p:2.5,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,borderWidth:1,borderColor:r?`blue.500`:s?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>i(t),_hover:{borderColor:r?`blue.500`:s?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(t.isBest||!t.isBest&&t.percentageDiff<0)&&q(j,{position:`absolute`,top:-1,left:0,zIndex:1,children:t.isBest?q(st,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:o(`Best`)}):J(st,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[t.percentageDiff.toFixed(2),`%`]})}),J(z,{align:`stretch`,spacing:1.5,marginTop:4,children:[J(N,{justify:`space-between`,align:`center`,children:[J(N,{spacing:1.5,align:`center`,children:[t.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`bold`,children:t.aggregatorName})]}),q(N,{align:`center`,spacing:1.5,children:h&&J(K,{children:[x[h.symbol]?V.cloneElement(x[h.symbol],{boxSize:`24px`,borderRadius:`full`}):e[h.symbol]?q(Et,{src:e[h.symbol],alt:`${h.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,q(an,{label:Number(t.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:J(R,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(t.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,h.symbol]})})]})})]}),J(N,{justify:`space-between`,align:`center`,children:[q(R,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:t.gasCostVTHO&&t.gasCostVTHO>0?`Gas: ${t.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),t.valueUsd>0&&J(R,{fontSize:`xs`,color:s?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,sc(t.valueInCurrency,{currency:c})]})]})]})]},t.aggregatorName)})}),_.length>0&&J(j,{children:[J(N,{justify:`space-between`,cursor:`pointer`,onClick:()=>m(!p),py:2,children:[J(R,{fontSize:`sm`,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:[_.length,` `,o(`rate`),_.length===1?``:`s`,` `,o(`unavailable`)]}),q(P,{as:p?kr:Er,boxSize:4,color:s?`whiteAlpha.600`:`blackAlpha.600`})]}),q(gt,{in:p,animateOpacity:!0,children:q(z,{spacing:2,align:`stretch`,pt:2,children:_.map(e=>q(j,{p:2,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,opacity:.6,children:J(N,{justify:`space-between`,children:[J(N,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),q(R,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:o(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),y.length===0&&_.length===0&&q(z,{spacing:2,py:8,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:q(R,{fontSize:`lg`,children:o(`No quotes available`)})})]})})}),q(It,{})]})},xu=e=>e===`0x`||e===Qi||!e,Su=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=xu(n),c=xu(r),l=[],u=[];if(e.outputs&&Array.isArray(e.outputs))for(let t of e.outputs)t.events&&Array.isArray(t.events)&&l.push(...t.events),t.transfers&&Array.isArray(t.transfers)&&u.push(...t.transfers);let d=Ti.createInterface().getEvent(`Transfer`),f=d?.topicHash.toLowerCase(),p=l.filter(e=>e.topics&&e.topics.length>0&&e.topics[0]?.toString().toLowerCase()===f),m=null,h=null;if(s){for(let e of u)if(e.sender?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){m=t;break}}}if(c){for(let e of u)if(e.recipient?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){h=t;break}}}if(p.length>0)for(let e of p)try{let t=Vi({abi:[d],data:e.data.toString(),topics:e.topics.map(e=>e.toString())});if(!t.args||!(`from`in t.args)||!(`to`in t.args)||!(`value`in t.args))continue;let n=t.args.from?.toString().toLowerCase(),r=t.args.to?.toString().toLowerCase(),l=t.args.value,u=e.address.toLowerCase();!s&&n===i&&u&&u===a&&l>0n&&m===null&&(m=l),!c&&r===i&&u&&u===o&&l>0n&&h===null&&(h=l)}catch(e){console.warn(`Failed to decode transfer event:`,e);continue}return{fromAmount:m??0n,toAmount:h??0n}},Cu=({setCurrentContent:t,fromTokenAddress:n,toTokenAddress:r,onBack:i})=>{let{t:a}=Y(),{account:o,connection:s}=Q(),{currentCurrency:c}=lc(),{network:l,feeDelegation:u,darkMode:d,appConfig:f}=$(),{isolatedView:m,closeAccountModal:h}=gu(),g=B(`colors`,`vechain-kit-card`),_=B(`colors`,`vechain-kit-text-primary`),v=B(`colors`,`vechain-kit-text-secondary`),y=B(`colors`,`vechain-kit-text-tertiary`),b=B(`colors`,`vechain-kit-button-primary-bg`),S=B(`colors`,`vechain-kit-button-primary-color`),{preferences:C}=Hh(),{sortedTokens:w}=uc({address:o?.address??``}),[ee,T]=G(`main`),[D,O]=G(null),[k,te]=G(null),[A,ne]=G(``),[re,ie]=G(!1),[ae,oe]=G(1),[se,ce]=G(`1`),[le,ue]=G(null),[de,fe]=V.useState(null),[pe,me]=V.useState(null),[he,ge]=V.useState([]),{prices:_e,exchangeRates:ve}=ic(),ye=ae===1;V.useEffect(()=>{ce(ae===1?`1`:ae===.5?`0.5`:ae===3?`3`:ae.toString())},[ae]),V.useEffect(()=>{if(w.length!==0){if((n||r)&&(!D||!k)){if(n&&!D){let e=w.find(e=>E(e.address,n));e&&!p.includes(e.symbol)&&O(e)}if(r&&!k){let e=w.find(e=>E(e.address,r));e&&!p.includes(e.symbol)&&te(e)}return}if(!D&&!k){let e=w.find(e=>e.symbol===`VET`);e&&O(e);let t=w.find(e=>e.symbol===`B3TR`);if(!t)try{let e=f.b3trContractAddress;e&&(t=w.find(t=>E(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&te(t)}}},[w,D,k,n,r,l.type]),V.useEffect(()=>{ue(null)},[D?.address,k?.address,A]);let{bestQuote:be,quotes:xe,isLoading:Se,from:Ce,to:we}=Wl(D,k,A,o?.address??``,ae,!!D&&!!k&&Number(A)>0),Te=W(()=>{if(!A||Number(A)<=0||!Ce)return 0n;try{return Xi(A,Ce.decimals)}catch{return 0n}},[A,Ce?.decimals]),Ee=le||be,De=W(()=>{if(!Ee?.outputAmount||!we)return`0`;try{return Gi(Ee.outputAmount,we.decimals)}catch{return`0`}},[Ee,we?.decimals]),Oe=W(()=>{if(!D||!A)return 0;let e=_e[D.address]||0;return ac(Number(A)*e,c,ve)},[D?.address,A,_e,c,ve]),ke=W(()=>{if(!k||!De)return 0;let e=_e[k.address]||0;return ac(Number(De)*e,c,ve)},[k?.address,De,_e,c,ve]),Ae=W(()=>!D||!k||!o?.address||Te===0n?null:{fromTokenAddress:D.address,toTokenAddress:k.address,amountIn:Te.toString(),userAddress:o.address,slippageTolerance:ae},[D,k,o?.address,Te,ae]),je=Ee?.gasCostVTHO??0;V.useEffect(()=>{(async()=>{if(!Ee||!Ae||!Ee.aggregator){ge([]);return}try{ge(await Ee.aggregator.buildSwapTransaction(Ae,Ee))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),ge([])}})()},[Ee,Ae]);let Me=C.availableGasTokens.length>0&&(s.isConnectedWithPrivy||s.isConnectedWithVeChain)&&!u?.delegatorUrl,{data:Ne,isLoading:Pe,error:Fe,refetch:Ie}=Uh({clauses:he,tokens:de?[de]:C.availableGasTokens,sendingAmount:A,sendingTokenSymbol:D?.symbol??``,enabled:Me&&!!u?.genericDelegatorUrl&&he.length>0}),Le=Ne?.usedToken,Re=(Pe||!Ne)&&s.isConnectedWithPrivy&&!u?.delegatorUrl,ze=V.useCallback(e=>{fe(e),me(e),setTimeout(()=>Ie(),100)},[Ie]),Be=!!Le&&!Fe;V.useEffect(()=>{Fe&&de&&fe(null)},[Fe,de]);let{executeSwap:Ve,isTransactionPending:He,isWaitingForWalletConfirmation:Ue,txReceipt:We,status:Ge,error:Ke}=wl(Ae,Ee),qe=H(()=>{let e=We?.meta.txID??``,n=a(`Swap successful`,{defaultValue:`Swap successful`}),r;if(We&&D&&k&&o?.address){let e=Su(We,o.address,D.address,k.address);if(e&&Ce&&we)try{let t=Ce.decimals,n=we.decimals,i=Gi(e.fromAmount,t),o=Gi(e.toAmount,n),s=e=>{let t=Number(e);return t>=1e3?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString(void 0,{maximumFractionDigits:6,minimumFractionDigits:0})};r=a(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(i),fromSymbol:D.symbol,toAmount:s(o),toSymbol:k.symbol,defaultValue:`You successfully swapped ${s(i)} ${D.symbol} for ${s(o)} ${k.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!r&&D&&k&&(r=a(`You successfully swapped {fromToken} for {toToken}`,{fromToken:D.symbol,toToken:k.symbol,defaultValue:`You successfully swapped ${D.symbol} for ${k.symbol}`})),t({type:`successful-operation`,props:{setCurrentContent:t,txId:e,title:n,description:r,onDone:()=>{m?h():t(`main`)},showSocialButtons:!0}})},[D,k,A,Ee,We,o?.address,t,a,m,h]),Je=H(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[D,k,A]),[Ye,Xe]=V.useState(!1);V.useEffect(()=>{if(Ge===`ready`){Xe(!1);return}Ye||(Ge===`success`&&We&&!We.reverted?(Xe(!0),qe()):Ge===`error`&&Ke?Je(Ke?.reason||Ke?.message||String(Ke)):We?.reverted&&Je(`Transaction reverted`))},[Ge,We,Ke,qe,Je,Ye]);let Ze=H(e=>{if(O(e),e.symbol===`VET`&&!k){let e=w.find(e=>e.symbol===`B3TR`);if(!e)try{let t=f.b3trContractAddress;t&&(e=w.find(e=>E(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&te(e)}T(`main`)},[k,w,l.type]),Qe=H(e=>{te(e),T(`main`)},[]),$e=H(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&ne(e)},[]),et=H(()=>{D&&ne(D.balance)},[D]),tt=t=>{if(!t)return null;let n=x[t.symbol],r=e[t.symbol];return{symbol:t.symbol,logoComponent:n,logoUrl:r,balance:t.balance,value:t.valueInCurrency}},nt=tt(D),rt=tt(k);return ee===`select-from-token`?q(hu,{setCurrentContent:t,onSelectToken:Ze,onBack:()=>T(`main`),showAllTokens:!1}):ee===`select-quote`?q(bu,{quotes:xe,selectedQuote:Ee,toTokenAddress:k?.address??null,onSelectQuote:e=>{ue(e),T(`main`)},onBack:()=>T(`main`)}):ee===`select-to-token`?q(hu,{setCurrentContent:t,onSelectToken:Qe,onBack:()=>T(`main`),showAllTokens:!0}):J(K,{children:[J(Z,{children:[q(L,{children:a(`Swap`)}),!m&&q(Fo,{onClick:i??(()=>t(`main`)),isDisabled:He||Ue}),q(I,{isDisabled:He||Ue})]}),q(F,{children:J(z,{spacing:2,align:`stretch`,w:`full`,children:[J(N,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:_,children:a(`From`)}),nt&&J(R,{cursor:`pointer`,_hover:{color:v,textDecoration:`underline`},onClick:et,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:v,children:[a(`Balance`),`:`,` `,Number(nt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(j,{p:4,borderRadius:`2xl`,bg:g,children:J(z,{align:`stretch`,spacing:2,children:[J(N,{justify:`space-between`,children:[q(Dt,{placeholder:`0`,value:A,onChange:e=>$e(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:nt&&A&&Number(A)>Number(nt.balance)?`red.500`:_}),nt?J(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:nt.logoComponent?V.cloneElement(nt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):nt.logoUrl?q(Et,{src:nt.logoUrl,alt:`${nt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:nt.symbol.slice(0,3)})})}):void 0,children:[nt.symbol,q(P,{as:Er,boxSize:5,color:v})]}):J(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:y},children:[a(`Select token`),q(P,{as:Er,boxSize:5,color:v})]})]}),q(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:q(N,{spacing:2,alignItems:`center`,children:J(R,{color:v,children:[`≈`,` `,sc(Oe??0,{currency:c})]})})})]})}),q(N,{justify:`space-between`,mt:4,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:_,children:a(`To`)})}),q(j,{borderRadius:`2xl`,bg:g,p:4,children:J(z,{align:`stretch`,spacing:2,width:`100%`,children:[J(N,{justify:`space-between`,alignItems:`center`,children:[q(Dt,{value:Number(De).toLocaleString(void 0,{maximumFractionDigits:Number(De)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:_}),rt?J(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:rt.logoComponent?V.cloneElement(rt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):rt.logoUrl?q(Et,{src:rt.logoUrl,alt:`${rt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:rt.symbol.slice(0,3)})})}):void 0,children:[rt.symbol,q(P,{as:Er,boxSize:5,color:v})]}):J(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:y},children:[a(`Select token`),q(P,{as:Er,boxSize:5,color:v})]})]}),J(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:[q(N,{spacing:2,alignItems:`center`,children:J(R,{color:v,children:[`≈`,` `,sc(ke??0,{currency:c})]})}),rt&&J(R,{noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:v,children:[a(`Balance`),`:`,` `,Number(rt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})}),q(gt,{in:re&&!!Ee,animateOpacity:!0,children:J(z,{spacing:1,align:`stretch`,p:4,borderRadius:`2xl`,bg:g,children:[Ee&&J(N,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[a(`Source`),`:`]}),q(M,{variant:`outline`,size:`xs`,borderRadius:`full`,px:3,h:`auto`,py:1,cursor:`pointer`,onClick:()=>T(`select-quote`),color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:Ee.aggregator?.getIcon(`12px`),children:q(R,{fontSize:`xs`,color:_,children:Ee.aggregatorName})})]}),J(z,{align:`stretch`,spacing:2,children:[J(N,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[a(`Slippage tolerance`),`:`]}),J(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:[ae,`%`]})]}),q(z,{spacing:3,align:`stretch`,pt:2,children:J(N,{spacing:2,children:[q(M,{size:`sm`,variant:`outline`,onClick:()=>{oe(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ye?b:`transparent`,color:ye?S:v,borderColor:ye?b:v,_hover:{bg:ye?b:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ye?.8:1},children:`Auto`}),q(M,{size:`sm`,variant:`outline`,onClick:()=>{oe(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ae===.5?b:`transparent`,color:ae===.5?S:v,borderColor:ae===.5?b:v,_hover:{bg:ae===.5?b:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ae===.5?.8:1},children:`0.5%`}),q(M,{size:`sm`,variant:`outline`,onClick:()=>{oe(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ae===3?b:`transparent`,color:ae===3?S:v,borderColor:ae===3?b:v,_hover:{bg:ae===3?b:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ae===3?.8:1},children:`3%`}),J(Ot,{size:`sm`,flex:1,children:[q(Dt,{value:se,onChange:e=>{let t=e.target.value;if(/^\d*\.?\d*$/.test(t)||t===``)if(ce(t),t!==``){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&oe(e)}else oe(1)},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:_}),q(At,{width:`2rem`,pointerEvents:`none`,children:q(R,{fontSize:`2xs`,color:v,children:`%`})})]})]})})]}),J(N,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[a(`Fee`),`:`]}),q(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:je>0?`${je.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),Ee&&q(j,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(M,{variant:`ghost`,size:`xs`,onClick:()=>ie(!re),rightIcon:q(P,{color:y,_hover:{color:v},as:re?yr:hr}),fontSize:`xs`,fontWeight:`light`,color:y,_hover:{color:v},children:a(re?`Hide`:`Show Advanced Options`)})}),he.length>0&&s.isConnectedWithPrivy&&q(eg,{estimation:Ne,isLoading:Pe,isLoadingTransaction:He,onTokenChange:ze,clauses:he,userSelectedToken:pe})]})}),q(It,{children:q(Zh,{buttonText:a(Se?`Loading quote...`:`Swap`),onConfirm:Ve,isSubmitting:He,isTxWaitingConfirmation:Ue,transactionPendingText:a(`Swapping...`),txReceipt:We,transactionError:Ke,onError:e=>{Je(e)},isDisabled:!D||!k||!A||Number(A)<=0||Se||!Ee||Ee?.reverted===!0||!!(nt&&A&&Number(A)>Number(nt.balance))||Re,gasEstimationError:Fe,hasEnoughGasBalance:Be,isLoadingGasEstimation:Pe,showGasEstimationError:!u?.delegatorUrl&&s.isConnectedWithPrivy,context:`transaction`})})]})},wu=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=Y(),{isolatedView:i}=gu(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=()=>{t()};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose your account name`)}),!i&&q(Fo,{onClick:s}),q(I,{})]}),q(F,{children:J(z,{spacing:6,align:`center`,py:8,children:[q(P,{as:li,boxSize:16,color:o}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:a,children:r(`Finally say goodbye to 0x addresses`)}),q(R,{fontSize:`md`,color:o,textAlign:`center`,px:4,children:r(`Name your account to make it easier to exchange assets`)})]})]})}),q(It,{children:q(M,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},Tu=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:i}=Q(),{t:a}=Y(),o=rl(e.name,i.network),s=B(`colors`,`vechain-kit-card`),c=B(`colors`,`vechain-kit-card-hover`),u=B(`colors`,`vechain-kit-border`),d=B(`colors`,`vechain-kit-text-primary`),f=B(`colors`,`vechain-kit-text-secondary`),p=B(`colors`,`vechain-kit-card`);return q(Nt,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${u}`,_hover:{bg:t?c:s,borderColor:u},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:J(N,{spacing:3,align:`center`,children:[q(Xh,{props:{width:`40px`,height:`40px`,src:o.image??l(e.name),alt:e.name}}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:d,fontSize:`md`,fontWeight:`500`,children:r(e.name,24,0)}),t&&q(R,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&q(nn,{size:`sm`,bg:p,color:d,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},Eu=({onUnset:e})=>{let t=B(`colors`,`vechain-kit-card`),n=B(`colors`,`vechain-kit-card-hover`),r=B(`colors`,`vechain-kit-border`),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`),o=B(`colors`,`vechain-kit-error`),{t:s}=Y();return q(Nt,{p:4,bg:t,borderRadius:`xl`,cursor:`pointer`,opacity:1,border:`1px solid ${r}`,_hover:{bg:n,borderColor:r,color:`red.400`},onClick:e,transition:`all 0.2s`,role:`button`,"aria-label":s(`Unset current domain`),children:J(N,{spacing:3,align:`center`,children:[q(j,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:q(P,{as:ui,fontSize:`18px`,color:o})}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:i,fontSize:`md`,fontWeight:`500`,children:s(`Unset current domain`)}),q(R,{fontSize:`sm`,color:a,children:s(`Remove your current domain name`)})]})]})},`unset-domain-list-item`)},Du=({domains:e,onDomainSelect:t,onUnsetDomain:n,isLoading:r})=>{let{t:i}=Y(),{account:a}=Q(),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-hover`),c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return e.length===0||r?null:q($e,{allowToggle:!0,children:q(tt,{border:`none`,children:({isExpanded:u})=>J(K,{children:[J(et,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[q(j,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:c,children:r?i(`Loading your domains...`):`${i(`Your existing domains`)} (${e.length})`})}),q(P,{as:u?kr:Er,fontSize:`20px`,color:l})]}),q(nt,{pb:4,pt:2,children:J(Mt,{spacing:2,children:[e.map(e=>q(Tu,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&q(Eu,{onUnset:n})]})})]})})})},Ou=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=Y(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=gu(),[s,c]=G(Ea(e)),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(!1),_=B(`colors`,`vechain-kit-error`),v=B(`colors`,`vechain-kit-success`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b,isLoading:x}=ns(s),{data:S,isLoading:C}=$o(`${s}.veworld.vet`),{data:w,isLoading:ee}=gs(s),{data:T,isLoading:E}=xs(i?.address,``),D=x||C||ee;U(()=>{if(!h)return;let e=/[^a-zA-Z0-9-]|\s/.test(s);s.length<3?(u(r(`Name must be at least 3 characters long`)),m(!1),f(!1)):e?(u(r(`Only letters, numbers, and hyphens are allowed`)),m(!1),f(!1)):w?(u(r(`This domain is protected`)),m(!1),f(!1)):b?S?.address?.toLowerCase()===i?.address?.toLowerCase()?(u(null),m(!0),f(!0)):(u(r(`This domain is already taken`)),m(!1),f(!1)):x||(u(null),m(!0),f(!1))},[s,h,b,x,S,i?.address,w,p,D]);let O=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},k=e=>{let r=e.split(`.`);t({type:`choose-name-summary`,props:{fullDomain:e,domainType:r.length>2?`${r[1]}.${r[2]}`:`vet`,isOwnDomain:!0,setCurrentContent:t,initialContentSource:n}})},te=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},A=()=>{t(n)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&q(Fo,{onClick:A}),q(I,{})]}),q(F,{children:J(z,{spacing:4,align:`stretch`,children:[q(Du,{domains:T?.domains||[],onDomainSelect:k,onUnsetDomain:te,isLoading:E}),J(Ot,{size:`lg`,children:[q(Dt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(Ea(e.target.value)),h||g(!0)},paddingRight:`120px`,fontSize:`lg`,height:`60px`,bg:a?`#00000038`:`white`,border:`1px solid ${a?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${a?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${a?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},isInvalid:!!l,"data-testid":`domain-input`}),q(At,{width:`auto`,paddingRight:`12px`,h:`full`,children:q(j,{mr:4,fontSize:`sm`,color:y,children:`.veworld.vet`})})]}),l&&h&&q(R,{color:_,fontSize:`sm`,"data-testid":`domain-availability-status`,children:l}),!l&&h&&s.length>=3&&q(R,{fontSize:`sm`,color:p?v:_,fontWeight:`500`,"data-testid":`domain-availability-status`,children:r(d?`YOU OWN THIS`:p?`AVAILABLE`:`UNAVAILABLE`)})]})}),q(It,{children:q(M,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||D,isLoading:D,onClick:O,loadingText:r(`Checking...`),"data-testid":`continue-button`,children:r(`Continue`)})})]})},ku=({setCurrentContent:e,fullDomain:t,domainType:n=`veworld.vet`,isOwnDomain:r,isUnsetting:i=!1,initialContentSource:a=`settings`})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),{isolatedView:c,closeAccountModal:l}=gu(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=nh(u?.address??``,d?.address??``,3),{open:m}=Yp(),{preferences:h}=Hh(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=Gs({onSuccess:()=>D()}),y=n.endsWith(`veworld.vet`),b=cs({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>D()}),x=fs({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>D()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:ee,isTransactionPending:T,clauses:E}=i?v:y?b:x,D=()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:C?.meta.txID,title:o(i?`Domain unset`:`Domain set`),description:i?o(`Your domain has been unset successfully.`):o(`Your address has been successfully set to {{name}}`,{name:t}),onDone:()=>{c?l():e(a)}}})},O=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},k=()=>{O()},te=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[A,ne]=V.useState(null),[re,ie]=V.useState(null),ae=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:oe,isLoading:se,error:ce,refetch:le}=Uh({clauses:E(),tokens:A?[A]:h.availableGasTokens,enabled:ae&&!!g?.genericDelegatorUrl}),ue=oe?.usedToken,de=(se||!oe)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,fe=V.useCallback(e=>{ne(e),ie(e),setTimeout(()=>le(),100)},[le]),pe=!!ue&&!ce;return V.useEffect(()=>{ce&&A&&ne(null)},[ce,A]),J(K,{children:[J(Z,{children:[q(L,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),q(Fo,{onClick:te,isDisabled:T}),q(I,{isDisabled:T})]}),J(F,{children:[J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:li,color:s,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:s,children:i?o(`By confirming, your current domain will be unset`):o(`By confirming, your address will be set to {{domain}}`,{domain:t})})]}),!i&&q(z,{spacing:4,align:`stretch`,mt:6,children:q(R,{fontSize:`xl`,fontWeight:`bold`,color:s,textAlign:`center`,"data-testid":`preconfirm-domain-val`,children:t})}),f.isConnectedWithPrivy&&q(eg,{estimation:oe,isLoading:se,isLoadingTransaction:T,onTokenChange:fe,clauses:E(),userSelectedToken:re})]}),q(It,{gap:4,w:`full`,children:q(Zh,{transactionError:w,isSubmitting:T,isTxWaitingConfirmation:ee,onConfirm:O,onRetry:k,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:T||de,onError:_,gasEstimationError:ce,hasEnoughGasBalance:pe,isLoadingGasEstimation:se,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},Au=()=>{let{t:e}=Y(),[t,n]=G(``),r=B(`colors`,`vechain-kit-card`),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-text-tertiary`),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-elevated`),c=[{question:e(`What is VeChain?`),answer:e(`VeChain, headquartered in San Marino, Europe, is a pioneering blockchain ecosystem and creator of VeChainThor, a world-class smart contract platform driving real-world blockchain adoption. Founded in 2015 by Sunny Lu, VeChain has consistently worked to deliver a transparent, efficient, scalable, and adaptable blockchain solution.`)},{question:e(`What is a wallet?`),answer:e(`A wallet is your gateway to the VeChain blockchain. It stores your private keys and allows you to securely manage your digital assets, send and receive tokens, and interact with decentralized applications. Think of it as your digital bank account for blockchain transactions.`)},{question:e(`What is a Smart Account?`),answer:e(`A Smart Account is a smart contract wallet that provides enhanced security and functionality. It allows for features like social recovery, transaction batching, and more.`)},{question:e(`How is my wallet secured?`),answer:e(`Your wallet security depends on how you access it. With self-custody options like the VeWorld extension, mobile app, or hardware wallet, you have complete control over your private keys. This extension itself has no access to your private keys. When logging in with social accounts or VeChain, your wallet is created and secured by Privy and managed by VeChain, providing an easier onboarding experience while maintaining security.`)},{question:e(`How do I backup my wallet?`),answer:e(`Backing up your wallet is crucial as you are the only one with access to your private keys. If something goes wrong, having your private key is the only way to recover your assets. How to backup depends on how you access your wallet: If using VeWorld, the backup option is available within the app. For social login users, you can find backup options in the Wallet section. If you're connected through VeChain or another ecosystem app, you'll need to visit the original website, log in, and access the Wallet section from there.`)},{question:e(`What is a network?`),answer:e(`A network in blockchain refers to the environment where transactions take place. VeChain has two main networks: Mainnet (the live network where real transactions occur) and Testnet (a testing environment for developers). The network you're connected to is displayed at the top of this modal.`)},{question:e(`What is a domain name?`),answer:e(`A domain name is a sort of nickname for your wallet address. It allows you to easily identify your wallet and interact with dApps using a human-readable name. For example, if your wallet address is 0x1234567890, your nickname could be "alice.vechain".`)},{question:e(`What is Privy?`),answer:e(`Privy builds user onboarding and embedded wallet infrastructure to enable better products built on crypto rails. This means embedding asset control within applications themselves to enable users, businesses or machines to use digital assets through seamless product experiences.`)},{question:e(`What is VeBetterDAO?`),answer:e(`VeBetterDAO is a decentralized organization on VeChain blockchain focused on sustainability. Members participate in the governance of the DAO using B3TR tokens for rewards and VOT3 for voting in proposals and weekly token allocation rounds.`)},{question:e(`What is an x2earn application?`),answer:e(`An X2Earn application in VeBetterDAO is a sustainable app that rewards users with B3TR tokens for eco-friendly actions. These apps must distribute B3TR, link user wallets, and provide proof of sustainable actions. They join VeBetterDAO through endorsement and participate in weekly token allocation rounds.`)},{question:e(`What is B3TR?`),answer:e(`B3TR is the incentive token of VeBetterDAO, built on VechainThor blockchain. It has a capped supply of 1 billion tokens, emitted weekly over 12 years. B3TR is used for rewards, governance, and backing VOT3 tokens 1:1. It supports sustainability applications and DAO treasury management.`)},{question:e(`What is VET?`),answer:e(`VET is the primary cryptocurrency of the VeChain network. It represents value and ownership in the VeChain ecosystem, similar to how stocks represent ownership in a company. Holding VET automatically generates VTHO, which is needed to pay for transactions on the network.`)},{question:e(`What is VTHO?`),answer:e(`VTHO (VeThor) is the energy or 'gas' token of the VeChain network. It's used to pay for transaction fees when interacting with the blockchain. VTHO is automatically generated by holding VET tokens, creating a two-token system that helps maintain network stability and manage transaction costs.`)},{question:e(`How do I send tokens?`),answer:e(`You can send tokens by clicking the send icon in the Quick Actions section. Enter the recipient's address or VeChain domain name, select the token, and specify the amount you want to send.`)},{question:e(`What is fee delegation?`),answer:e(`Fee delegation is a unique feature of VeChain that allows someone else (a delegator) to pay for your transaction fees. While many dApps and service providers act as delegators to make it easier for new users to get started, some transactions may still require you to pay fees using your own VTHO. Fees are necessary to prevent network spam and compensate the nodes that process and validate transactions on the blockchain. When paying fees yourself, you'll be able to select VTHO from your assets to cover the transaction cost.`)}].filter(e=>e.question.toLowerCase().includes(t.toLowerCase())||typeof e.answer==`string`&&e.answer.toLowerCase().includes(t.toLowerCase()));return J(z,{spacing:4,align:`stretch`,children:[J(Ot,{size:`lg`,children:[q(Dt,{placeholder:e(`Search FAQ`),bg:r,borderRadius:`xl`,height:`56px`,pl:12,value:t,onChange:e=>n(e.target.value)}),q(kt,{h:`56px`,w:`56px`,pl:4,children:q(ri,{color:a})})]}),c.length===0?J(z,{spacing:2,py:8,color:i,children:[q(P,{as:si,boxSize:12,opacity:.5}),q(R,{fontSize:`lg`,children:e(`No questions found`)}),q(R,{fontSize:`md`,children:e(`Try searching with a different term`)})]}):q($e,{allowMultiple:!0,children:c.map((e,t)=>q(tt,{border:`none`,mb:2,children:({isExpanded:t})=>J(K,{children:[J(et,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[q(j,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:i,children:e.question})}),q(P,{as:t?kr:Er,fontSize:`20px`,opacity:.5})]}),q(nt,{pb:4,children:q(R,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},ju=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=Y(),{isolatedView:i}=gu(),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-border`),s=B(`colors`,`vechain-kit-border-hover`);return J(Yh,{children:[J(Z,{children:[q(L,{children:r(`Help`)}),!i&&q(Fo,{onClick:e}),q(I,{})]}),q(F,{w:`full`,children:J(z,{spacing:6,align:`stretch`,children:[t&&q(Gt,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:io.map(e=>q(`option`,{value:e,children:oo[e]},e))}),q(M,{as:jt,href:pe,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:q(P,{as:Lr}),children:r(`For developers`)}),q(Au,{})]})}),q(It,{pt:0})]})},Mu=({leftIcon:e,rightIcon:t,title:n,wallet:i,onClick:a,leftImage:o,isActive:s=!1})=>{let{t:c}=Y(),{darkMode:l}=$();return q(M,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:a,backgroundColor:`transparent`,border:`1px solid ${l?`#ffffff29`:`#ebebeb`}`,children:J(N,{w:`full`,justify:`space-between`,children:[q(j,{minW:`40px`,justifyContent:`center`,children:o?q(Et,{justifySelf:`center`,src:o,w:`28px`,alt:`left-image`}):q(P,{as:e,fontSize:`28px`})}),J(z,{textAlign:`left`,w:`full`,flex:1,children:[q(N,{w:`full`,spacing:2,justifyContent:`flex-start`,children:q(R,{fontSize:`sm`,fontWeight:`400`,children:n})}),q(R,{fontSize:`sm`,fontWeight:`500`,opacity:.5,overflowWrap:`break-word`,wordBreak:`break-word`,whiteSpace:`normal`,w:`full`,children:i?.domain?r(i?.domain??``,18,0):d(i?.address??``,6,4)})]}),q(z,{minW:`40px`,justifyContent:`flex-end`,children:J(N,{justifyContent:`flex-end`,minW:`40px`,children:[s&&q(nn,{size:`sm`,colorScheme:`green`,children:c(`Active`)}),q(P,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},Nu=({leftIcon:e,rightIcon:t,title:n,onClick:r,leftImage:i,hide:a=!1,showComingSoon:o=!1,backgroundColor:s,_hover:c,isDisabled:l=!1,stacked:u=!1,isLoading:d,loadingText:f,style:p,extraContent:m,dataTestId:h,variant:g=`actionButton`})=>{let{t:_}=Y();return q(M,{variant:g===`actionButton`?`vechainKitSecondary`:g,py:u?0:2,minHeight:`50px`,height:`fit-content`,p:0,onClick:r,display:a?`none`:`flex`,isDisabled:o||l,isLoading:d,loadingText:f,bgColor:s,_hover:c,"data-testid":h,...p,children:J(N,{w:`full`,justify:`space-between`,alignItems:`center`,children:[q(j,{minW:`40px`,h:`20px`,children:i?q(Et,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):q(P,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),q(z,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:J(N,{justify:`flex-start`,alignItems:`baseline`,children:[q(R,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&q(nn,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&q(z,{minW:`40px`,justifyContent:`flex-end`,children:q(P,{as:t,fontSize:`20px`,opacity:.5})})]})})},Pu=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:i,onClose:a,mt:o,style:s})=>{let{t:c}=Y(),{connection:l}=Q(),{switchWallet:u,isSwitching:f,isInAppBrowser:p}=al(),{isSwitchWalletEnabled:m}=rr(),[h,g]=G(!1),_=async()=>{await D(e?.domain??e?.address??``)&&(g(!0),setTimeout(()=>{g(!1)},2e3))},v=()=>{p?u():t?.({type:`select-wallet`,props:{setCurrentContent:t,onClose:a,returnTo:`main`,onLogoutSuccess:a}})};return J(N,{mt:o,w:`full`,...s,justifyContent:`flex-start`,alignItems:`center`,children:[q(M,{w:`full`,h:12,"aria-label":`Wallet`,onClick:i,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:J(N,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[J(N,{spacing:2,justifyContent:`flex-start`,children:[q(Xh,{wallet:e,props:{width:7,height:7}}),q(R,{fontSize:n,fontWeight:`500`,children:h?c(`Copied!`):r(e?.domain??``,22,0)||d(e?.address??``,6,4)})]}),q(P,{boxSize:5,as:Or,cursor:`pointer`,opacity:.5})]})}),l.isInAppBrowser&&m||!l.isInAppBrowser&&l.isConnectedWithDappKit?q(Tt,{"aria-label":`Switch wallet`,icon:q(P,{as:_r}),onClick:v,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3,isLoading:f,isDisabled:f,"data-testid":`switch-wallet-button`}):q(Tt,{"aria-label":`Copy address`,icon:q(P,{as:h?Tr:Pr}),onClick:_,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3})]})},Fu=({address:t,maxIcons:n=3,iconSize:r=20,ml:i=0,style:a,iconsGap:o=0,rightIcon:s,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=Y(),{tokensWithBalance:d}=uc({address:t}),{darkMode:f}=$(),p=B(`colors`,`vechain-kit-text-secondary`),m=o<1?`-${r/2}px`:`${o}px`,h=d.slice(0,n),g=d.length-n;return!t||d.length===0&&!c?null:J(N,{spacing:0,ml:i,...a,onClick:l,children:[J(N,{spacing:0,children:[h.map((t,n)=>q(ht,{ml:n>0?m:`0`,zIndex:n,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:x[t.symbol]?V.cloneElement(x[t.symbol],{width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):e[t.symbol]?q(Et,{src:e[t.symbol],alt:`${t.symbol} logo`,width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):q(R,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:t.symbol.slice(0,3)})},t.symbol)),g>0&&q(ht,{ml:m,zIndex:h.length,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:J(R,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,g]})}),d.length===0&&c&&q(R,{fontSize:`sm`,color:p,fontWeight:`700`,children:u(`No assets`)})]}),s]})},Iu=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=Y(),{account:i}=Q(),{formattedBalance:a,isLoading:o,priceChange24hPct:s}=wc({address:i?.address??``}),{refresh:c}=Zc(),[l,u]=G(!1),d=B(`colors`,`vechain-kit-text-secondary`),f=async()=>{u(!0),await c(),setTimeout(()=>{u(!1)},1500)},[p,m]=jh(Ah.SHOW_ASSETS,!0);return J(z,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[J(N,{w:`full`,justifyContent:`space-between`,alignItems:`center`,spacing:0,role:`group`,children:[q(wt,{size:`xs`,fontWeight:`800`,color:d,textTransform:`uppercase`,letterSpacing:1.2,ml:`5px`,children:r(`Assets`)}),J(N,{spacing:0,alignItems:`center`,children:[q(Tt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:f,icon:q(P,{as:ni,boxSize:4}),isLoading:o||l,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}}),q(Tt,{"aria-label":`Show/hide assets`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:()=>m(!p),icon:q(P,{as:p?Oa:ka,boxSize:4})})]})]}),q(M,{onClick:n,h:`fit-content`,variant:`vechainKitSecondary`,children:J(z,{spacing:2,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,mt:4,mb:4,children:[J(N,{spacing:3,align:`baseline`,children:[q(wt,{size:`2xl`,fontWeight:`700`,children:p?a:`$****`}),p&&q(Gh,{valuePct:s,showSuffix:!0,fontSize:`sm`})]}),q(N,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:q(Fu,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:q(P,{as:Or,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},Lu=[{id:`send`,icon:br,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{id:`swap`,icon:_r,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{id:`receive`,icon:gr,label:`Receive`,onClick:e=>{e(`receive-token`)}}],Ru=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=Y();return q(Tt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:J(z,{spacing:4,children:[q(P,{as:e,boxSize:5,opacity:.9}),J(N,{p:0,alignItems:`baseline`,spacing:1,children:[q(R,{fontSize:`sm`,fontWeight:`600`,"data-testid":`${t.toLowerCase()}-button-label`,children:a(t,t)}),i&&q(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},zu=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hiddenQuickActions:o=[]}=$(),{hasAnyBalance:s}=wc({address:n?.address??``}),{data:c}=nh(r?.address??``,i?.address??``,3),l=a.isConnectedWithPrivy&&c,u=Lu.filter(e=>!o.includes(e.id));return u.length?q(St,{templateColumns:`repeat(${u.length}, 1fr)`,gap:2,w:`full`,mt:e,children:u.map(e=>q(Ru,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(s),showRedDot:l&&e.label===`Settings`},e.id))}):null},Bu=({setCurrentContent:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-primary`),r=B(`colors`,`vechain-kit-text-secondary`);return q(ct,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`profile`),initialContentSource:`profile`}})},cursor:`pointer`,_hover:{opacity:.8},children:q(lt,{p:4,children:q(N,{justify:`space-between`,align:`flex-start`,spacing:3,children:J(z,{align:`flex-start`,spacing:1,children:[J(N,{spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`400`,color:n,children:t(`Claim your vet domain!`)}),q(nn,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),q(R,{fontSize:`xs`,color:r,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]})})})})},Vu=()=>{let{t:e}=Y();return q(rt,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(N,{spacing:2,align:`flex-start`,children:[q(at,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},Hu=()=>{let{t:e}=Y();return q(rt,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(N,{spacing:2,align:`flex-start`,children:[q(at,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`A .vet domain is required to customize your profile. Choose an account name to get started.`)})]})})})},Uu=()=>{let{t:e}=Y(),{getConnectionCache:t}=om(),n=t();return J(ct,{variant:`vechainKitBase`,w:`full`,children:[J(dt,{p:4,pl:6,borderBottomWidth:`1px`,children:[q(R,{fontWeight:`medium`,opacity:.8,children:e(`Security preferences`)}),q(R,{fontSize:`xs`,mt:1,opacity:.7,children:e(`For security reasons, you can manage your embedded wallet settings only on the {{appName}} platform.`,{appName:n?.ecosystemApp.name??`origin app`})})]}),q(lt,{borderRadius:`none`,children:J(z,{spacing:3,align:`stretch`,children:[J(N,{spacing:3,align:`center`,children:[q(ft,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(P,{as:fi})}),J(j,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Login methods`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Manage your login methods and passkeys`)})]})]}),J(N,{spacing:3,align:`center`,children:[q(ft,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(P,{as:oi})}),J(j,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Security settings`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Backup your wallet, configure MFA and set recovery options`)})]})]})]})}),q(ut,{children:J(M,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??Ze,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),q(P,{as:Lr,ml:2})]})})]})},Wu=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:r}=Y(),{network:i}=$(),{account:a}=Q(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-error`),c=B(`colors`,`vechain-kit-card`),l=xn(null),u=xn(null),[d,f]=G(!1),{onUpload:p}=xl({compressImage:!0}),[m,h]=G(null),[g,_]=G(null),v=!!a?.domain,[y,b]=G(null),[x,S]=G(``),[C,w]=G(``),{register:ee,watch:T,formState:{errors:E,isValid:D}}=Ta({defaultValues:{displayName:a?.metadata?.display||``,description:a?.metadata?.description||``},mode:`onChange`});U(()=>{if(a?.metadata){let e=a.metadata;S(e.display||``),w(e.description||``),b(a.image?a.image.replace(`ipfs://`,``):null),h(e=>e??a.image??null)}},[a,i.type]);let O=T(),k=async e=>{let t=e.target.files?.[0];if(t)try{f(!0),m&&URL.revokeObjectURL(m),h(URL.createObjectURL(t));let e=await p(t);if(!e)throw Error(`Failed to compress image`);_(await n(e.file,t.name,i.type))}catch(e){console.error(`Error uploading image:`,e),h(null)}finally{f(!1)}};U(()=>()=>{m&&URL.revokeObjectURL(m)},[m]);let te=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),O.displayName!==x&&(e.displayName=O.displayName),O.description!==C&&(e.description=O.description),e},A=W(()=>{let e=te();return Object.keys(e).length>0},[te]),ne=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:te(),onDoneRedirectContent:t}})},re=()=>{e(t)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Customization`)}),q(Fo,{onClick:re}),q(I,{})]}),J(F,{children:[J(j,{cursor:v?`pointer`:`default`,pt:2,display:`flex`,justifyContent:`center`,position:`relative`,onClick:()=>v&&l.current?.click(),children:[q(Xh,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&q(P,{as:wr,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&q(j,{display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`,position:`absolute`,transform:`translateX(0%)`,width:`100px`,height:`100px`,borderRadius:`full`,zIndex:10,children:q(R,{fontSize:`xs`,color:`white`,children:d?`Uploading...`:`Processing...`})})]}),J(z,{spacing:6,mt:4,children:[!v&&q(Hu,{}),q(Nu,{title:a?.domain??r(`Choose account name`),description:r(`Choose a unique .vet domain name for your account.`),onClick:()=>{a?.domain?e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}}}}):e({type:`choose-name`,props:{setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}},onBack:()=>e({type:`account-customization`,props:{setCurrentContent:e}})}})},leftIcon:li,rightIcon:Or,dataTestId:`set-domain-name-button`}),J(bt,{isDisabled:!v,isInvalid:!!E.displayName,children:[q(xt,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Display Name`)}),q(Dt,{...ee(`displayName`,{maxLength:{value:25,message:r(`Display name must be less than 25 characters`)}}),placeholder:r(v?`Enter your display name`:`Set a domain first`),fontWeight:`medium`,color:o,"data-testid":`display-name-input`}),E.displayName&&q(R,{color:s,fontSize:`sm`,mt:1,fontWeight:`medium`,children:E.displayName.message})]}),J(bt,{isDisabled:!v,isInvalid:!!E.description,children:[q(xt,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Description`)}),q(rn,{...ee(`description`,{maxLength:{value:100,message:r(`Description must be less than 100 characters`)}}),placeholder:r(`Eg: DevRel @ ENS Labs`),fontWeight:`medium`,color:o,"data-testid":`description-input`,minH:`50px`}),E.description&&q(R,{color:s,mt:1,fontSize:`sm`,fontWeight:`medium`,children:E.description.message})]})]}),q(`input`,{type:`file`,ref:l,hidden:!0,accept:`image/*`,onChange:async e=>await k(e)}),q(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),q(It,{w:`full`,children:q(M,{variant:`vechainKitPrimary`,onClick:ne,isDisabled:!v||!A||!D,isLoading:d,loadingText:r(`Preparing changes...`),"data-testid":`save-changes-button`,children:r(`Save Changes`)})})]})},Gu=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=Y(),{darkMode:i,network:a,feeDelegation:o}=$(),s=B(`colors`,`vechain-kit-text-primary`),{account:c,connectedWallet:l,connection:u}=Q(),{preferences:d}=Hh(),{data:f}=nh(c?.address??``,l?.address??``,3),{open:p}=Yp(),{handleSubmit:m}=Ta({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),h=c?.domain??``,{data:g}=Ms(h),_=dr(),{sendTransaction:v,txReceipt:y,error:b,isWaitingForWalletConfirmation:x,isTransactionPending:C,clauses:w}=As({resolverAddress:g,signerAccountAddress:c?.address??``,onSuccess:async()=>{try{await he()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),[ee,T]=V.useState(!1);V.useEffect(()=>{if(!y||y.reverted||ee||C)return;let t=y.meta.txID;t&&(T(!0),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}}))},[y,ee,C,e,r,n]),V.useEffect(()=>{C&&T(!1)},[C]);let E=W(()=>{let e=c?.domain??``,n={displayName:`display`,description:`description`,twitter:`com.x`,website:`url`,email:`email`,avatarIpfsHash:`avatar`};return Object.entries(t).filter(e=>e[1]!==void 0&&e[1]!==null).map(([t,r])=>({domain:e,key:n[t],value:t===`avatarIpfsHash`?`ipfs://${r}`:r}))},[t,c?.domain]),D=W(()=>{try{return!g||E.length===0||!w?[]:w(E)}catch(e){return console.error(`Error building clauses:`,e),[]}},[E,w,g]),[O,k]=V.useState(null),[te,A]=V.useState(null),ne=d.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:re,isLoading:ie,error:ae,refetch:oe}=Uh({clauses:D,tokens:O?[O]:d.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),se=re?.usedToken,ce=(ie||!re)&&u.isConnectedWithPrivy&&!o?.delegatorUrl,le=V.useCallback(e=>{k(e),A(e),setTimeout(()=>oe(),100)},[oe]),ue=!!se&&!ae;V.useEffect(()=>{ae&&O&&k(null)},[ae,O]);let de=async()=>{if(f){p();return}try{E.length>0&&await v(E)}catch(e){console.error(`Error saving changes:`,e)}},fe=(e,t)=>t?.trim()?J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:e}),q(R,{fontSize:`md`,children:t})]}):null,pe=()=>{m(de)()},me=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},he=async()=>{t.avatarIpfsHash&&(_.setQueryData(Ss(h,a.type),S(`ipfs://`+t.avatarIpfsHash,a.type)),_.setQueryData(Fs(c?.address??``),S(`ipfs://`+t.avatarIpfsHash,a.type))),await _.invalidateQueries({queryKey:Es(h,a.type)}),await _.refetchQueries({queryKey:Es(h,a.type)})};return J(K,{children:[J(Z,{children:[q(L,{children:r(`Confirm Changes`)}),q(Fo,{isDisabled:C,onClick:me}),q(I,{isDisabled:C})]}),J(F,{children:[J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:Rr,color:s,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:s,children:r(`By confirming, the following details attached to your name ({{domain}}) will be updated`,{domain:h})})]}),J(z,{spacing:4,align:`stretch`,mt:6,children:[t.avatarIpfsHash&&J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:r(`Profile Image`)}),q(R,{fontSize:`md`,children:r(`New image selected`)})]}),t.displayName&&fe(r(`Display Name`),t.displayName),t.description&&fe(r(`Description`),t.description),t.twitter&&fe(r(`Twitter`),t.twitter),t.website&&fe(r(`Website`),t.website),t.email&&fe(r(`Email`),t.email)]}),u.isConnectedWithPrivy&&q(eg,{estimation:re,isLoading:ie,isLoadingTransaction:C,onTokenChange:le,clauses:D,userSelectedToken:te})]}),q(It,{gap:4,w:`full`,children:q(Zh,{transactionError:b,isSubmitting:C,isTxWaitingConfirmation:x,onConfirm:m(de),onRetry:pe,transactionPendingText:r(`Saving changes...`),txReceipt:y,buttonText:r(`Confirm`),isDisabled:C||ce,gasEstimationError:ae,hasEnoughGasBalance:ue,isLoadingGasEstimation:ie,showGasEstimationError:!o?.delegatorUrl&&u.isConnectedWithPrivy,context:`customization`})})]})},Ku=({address:e,showHeader:t=!0,showLinks:n=!0,showDescription:r=!0,showDisplayName:i=!0,reserveNameDescriptionSpace:a=!1,setCurrentContent:o,onLogout:s})=>{let{network:c}=$(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-card`),p=rl(e,c.type),m=l(e),h=p?.records?.url||p?.records?.[`com.x`]||p?.records?.email,g=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}};return J(z,{spacing:0,w:`full`,children:[q(j,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,background:t?`no-repeat url('${m}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),J(j,{position:`relative`,display:`inline-block`,cursor:o?`pointer`:`default`,onClick:o?()=>{o({type:`account-customization`,props:{setCurrentContent:o,initialContentSource:`profile`}})}:void 0,children:[q(Xh,{wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},props:{width:`120px`,height:`120px`}}),o&&q(P,{as:Qr,position:`absolute`,bottom:`0`,right:`0`,bg:f,color:u,p:`1`,borderRadius:`full`,boxSize:`6`,border:`2px solid`,borderColor:f})]}),J(z,{w:`full`,spacing:2,children:[i&&(p?.records?.display?q(R,{fontSize:`xl`,color:u,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:p?.records?.display}):a&&q(j,{mt:2,minH:`28px`,"aria-hidden":!0})),r&&(p?.records?.description?q(R,{fontSize:`sm`,color:d,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:p?.records?.description}):a&&q(j,{minH:`20px`,"aria-hidden":!0})),n&&h&&J(N,{w:`full`,justify:`center`,spacing:5,mt:4,children:[p?.records?.email&&q(jt,{href:`mailto:${p?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:q(P,{as:Xr,color:u})}),p?.records?.url&&q(jt,{href:g(p.records.url)??void 0,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`website-link`,children:q(P,{as:Ur,color:u})}),p?.records?.[`com.x`]&&q(jt,{href:`https://x.com/${encodeURIComponent(String(p.records[`com.x`]))}`,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`twitter-link`,children:q(P,{as:ja,color:u})})]}),q(Io,{onLogout:s,wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},style:{mt:4},setCurrentContent:o})]})]})},qu=({onClick:e,...t})=>{let{smartAccount:n,connectedWallet:r,connection:i}=Q(),[a,o]=G(!1);U(()=>{o(!localStorage.getItem(`app-first-visit`))},[]);let{data:s}=nh(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return q(Tt,{"aria-label":`Settings`,size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,lineHeight:`0`,onClick:l,icon:J(j,{position:`relative`,children:[q(P,{as:ii,fontSize:`18px`}),c&&q(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},Ju=({setCurrentContent:e,onLogoutSuccess:t,switchFeedback:n})=>{let{t:r}=Y(),{account:i,disconnect:a,connection:o}=Q(),{switchWallet:s,isSwitching:c,isInAppBrowser:l}=al(),{isSwitchWalletEnabled:u}=rr(),{hasAnyBalance:d,formattedBalance:f}=wc({address:i?.address}),[p]=jh(Ah.SHOW_ASSETS,!0),m=()=>{l?s():e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:`profile`,onLogoutSuccess:t}})};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Profile`)}),q(qu,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),q(I,{})]}),q(F,{w:`full`,children:J(z,{w:`full`,spacing:6,children:[q(ig,{showFeedback:n?.showFeedback}),!i?.domain&&q(Bu,{setCurrentContent:e}),q(Ku,{reserveNameDescriptionSpace:!!i?.domain,onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,setCurrentContent:e,onLogout:()=>{a(),t?.()}})]})}),q(It,{w:`full`,children:J(N,{w:`full`,justify:`space-between`,spacing:4,mt:4,children:[q(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:d?void 0:q(P,{as:mi}),onClick:()=>e(`main`),"data-testid":`wallet-button`,children:d?J(N,{spacing:2,w:`full`,justify:`center`,children:[q(Fu,{address:i?.address??``,maxIcons:2}),q(R,{fontWeight:`600`,children:p?f:`$****`})]}):r(`Wallet`)}),o.isInAppBrowser&&u||!o.isInAppBrowser&&o.isConnectedWithDappKit?q(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(P,{as:_r}),colorScheme:`red`,onClick:async()=>{m()},isLoading:c,isDisabled:c,"data-testid":`switch-wallet-button`,children:r(`Switch`)}):q(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(P,{as:Yr}),colorScheme:`red`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}}),"data-testid":`logout-button`,children:r(`Logout`)})]})})]})},Yu=({setCurrentContent:e,handleClose:t,initialContent:n=`settings`})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=nh(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=sh({smartAccountAddress:i?.address??``,targetVersion:3,onSuccess:()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:d?.meta.txID,title:r(`Upgrade Successful!`),description:r(`Your account has been successfully upgraded to the latest version. You can now enjoy a better user experience, lower gas costs, and enhanced security.`),onDone:()=>{t?t():e(n)},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(Fo,{onClick:()=>{e(n)}}),q(I,{})]}),q(F,{children:J(z,{spacing:10,align:`stretch`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(o?`Your smart account needs to be upgraded to the latest version (v3).`:`Your smart account is already upgraded to this version.`)}),J(N,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(j,{position:`relative`,display:`inline-block`,children:[q(ht,{size:`60px`,bg:`gray.200`,children:q(Et,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(wt,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(P,{as:vr,color:`#3DBA67`}),J(j,{position:`relative`,display:`inline-block`,children:[q(ht,{size:`60px`,bg:`gray.200`,children:q(Et,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(wt,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(rt,{status:`info`,borderRadius:`md`,children:[q(at,{}),J(j,{children:[q(ot,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(it,{fontSize:`xs`,children:J(z,{align:`start`,spacing:0,mt:1,children:[J(R,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),J(R,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),q(It,{justifyContent:`center`,children:J(z,{spacing:3,w:`full`,children:[q(Zh,{buttonText:r(o?`Upgrade account`:`Account already upgraded`),onConfirm:async()=>{try{await s()}catch(e){console.error(`Failed to upgrade Smart Account:`,e)}},isTxWaitingConfirmation:l,isSubmitting:c,transactionPendingText:r(`Upgrading...`),txReceipt:d,transactionError:u,isDisabled:!o}),q(M,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},Xu=({icon:e,label:t,onClick:n,isDisabled:r})=>{let{t:i}=Y(),a=i(t,t);return q(Tt,{variant:`vechainKitSecondary`,h:`44px`,flex:1,borderRadius:`lg`,"aria-label":a,isDisabled:r,onClick:n,icon:J(N,{spacing:1.5,children:[q(P,{as:e,boxSize:3.5,opacity:.85}),q(R,{fontSize:`sm`,fontWeight:`600`,children:a})]})})},Zu=({onSend:e,onSwap:t,onHistory:n,hideHistory:r})=>{let{account:i}=Q(),{formattedBalance:a,hasAnyBalance:o,isLoading:s,priceChange24hPct:c}=wc({address:i?.address??``}),{points:l}=Rc(i?.address),{currentCurrency:u}=lc(),d=typeof c==`number`?c>0?`up`:c<0?`down`:`neutral`:`neutral`,[f]=jh(Ah.SHOW_ASSETS,!0);return J(z,{w:`full`,spacing:4,align:`stretch`,children:[J(N,{spacing:3,align:`baseline`,children:[q(wt,{size:`2xl`,fontWeight:`700`,children:s?`...`:f?a:`$****`}),f&&q(Gh,{valuePct:c,showSuffix:!0,fontSize:`sm`})]}),f&&l.length>1&&q(lg,{points:l,tone:d,chartHeight:72,interactive:!0,formatValue:e=>sc(e,{currency:u})}),J(N,{spacing:2,w:`full`,children:[q(Xu,{icon:_r,label:`Swap`,onClick:t,isDisabled:!o}),q(Xu,{icon:br,label:`Send`,onClick:e,isDisabled:!o}),!r&&q(Xu,{icon:Gr,label:`History`,onClick:n})]})]})},Qu=({tabIndex:e,onTabChange:t,tokenPanel:n,stakingPanel:r})=>{let{t:i}=Y();return J(tn,{index:e,onChange:e=>t(e??0),variant:`unstyled`,isLazy:!0,children:[J(Qt,{children:[q(Xt,{fontWeight:`600`,fontSize:`md`,children:i(`Token`)}),q(Xt,{fontWeight:`600`,fontSize:`md`,children:i(`Staking`)})]}),q(Zt,{mt:`-2px`,height:`2px`,bg:`vechain-kit-accent`}),J(en,{children:[q($t,{px:0,pt:4,children:n}),q($t,{px:0,pt:4,children:r})]})]})},$u=({onSelect:e,onManageTokens:t})=>{let{t:n}=Y(),{account:r}=Q(),{darkMode:i}=$(),{sortedTokens:a}=uc({address:r?.address}),{currentCurrency:o}=lc(),[s,c]=G(``),l=B(`colors`,`vechain-kit-text-tertiary`),u=a.filter(({symbol:e})=>e.toLowerCase().includes(s.toLowerCase()));return J(z,{spacing:3,align:`stretch`,w:`full`,children:[J(N,{spacing:2,children:[J(Ot,{size:`md`,flex:1,children:[q(Dt,{placeholder:n(`Search token`),bg:i?`#00000038`:`gray.50`,borderRadius:`lg`,height:`40px`,pl:10,value:s,onChange:e=>c(e.target.value),"data-testid":`search-token-input`}),q(kt,{h:`40px`,w:`40px`,pl:3,children:q(ri,{color:l})})]}),t&&q(an,{label:n(`Manage Custom Tokens`),children:q(Tt,{"aria-label":n(`Manage Custom Tokens`),icon:q(Qr,{}),variant:`vechainKitSecondary`,size:`md`,height:`40px`,width:`40px`,minW:`40px`,borderRadius:`lg`,onClick:t})})]}),q(z,{spacing:2,align:`stretch`,children:u.map(t=>q(Kh,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:o,onClick:()=>e(t),priceChange24hPct:t.priceChange24hPct},t.address))})]})},ed=({name:e,logoSrc:t,logoFallback:n,totalValueInCurrency:r,tag:i,platformUrl:a,children:o})=>{let{t:s}=Y(),{currentCurrency:c}=lc(),l=B(`colors`,`vechain-kit-text-primary`);return J(z,{w:`full`,align:`stretch`,spacing:3,p:4,borderRadius:`xl`,bg:B(`colors`,`vechain-kit-card`),children:[J(N,{w:`full`,justify:`space-between`,align:`center`,children:[J(N,{spacing:2,children:[t?q(Et,{src:t,alt:e,boxSize:`24px`,borderRadius:`full`,fallback:q(j,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):n??q(j,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.300`}),q(wt,{size:`sm`,color:l,children:e})]}),q(R,{fontWeight:`600`,color:l,children:sc(r,{currency:c})})]}),i&&q(j,{children:q(nn,{size:`sm`,colorScheme:`purple`,borderRadius:`md`,children:i})}),q(vt,{opacity:.2}),q(z,{w:`full`,align:`stretch`,spacing:2,children:o}),a&&q(M,{as:`a`,href:a,target:`_blank`,rel:`noopener noreferrer`,variant:`vechainKitSecondary`,size:`xs`,leftIcon:q(Lr,{size:11}),fontSize:`xs`,h:`40px`,px:3,mt:1,children:s(`Go to platform`)})]})},td=({label:e,amount:t,valueInCurrency:n,rightLabel:r,iconSrc:i,iconFallback:a})=>{let{currentCurrency:o}=lc(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`);return J(N,{w:`full`,justify:`space-between`,align:`center`,children:[J(N,{spacing:2,children:[i?q(Et,{src:i,alt:e,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):a,J(z,{spacing:0,align:`flex-start`,children:[q(R,{fontSize:`sm`,color:c,children:e}),q(R,{fontSize:`sm`,color:s,children:t})]})]}),J(z,{spacing:0,align:`flex-end`,children:[q(R,{fontSize:`sm`,color:s,children:sc(n,{currency:o})}),r]})]})},nd=()=>{let{t}=Y(),{account:n}=Q(),{positions:r,totalValueInCurrency:i,isLoading:a}=dc(n?.address);return a||!r.length?null:q(ed,{name:`StarGate`,logoSrc:`https://app.stargate.vechain.org/stargate-icon.png`,totalValueInCurrency:i,tag:r.some(e=>e.isDelegated)?t(`Delegating`):t(`Staked`),platformUrl:`https://app.stargate.vechain.org/`,children:r.map(n=>q(td,{label:t(`Supplied`),amount:`${n.vetAmountFormatted.toLocaleString(void 0,{maximumFractionDigits:2})} VET`,valueInCurrency:n.valueInCurrency,iconSrc:e.VET,rightLabel:n.isDelegated?q(nn,{size:`sm`,colorScheme:`green`,borderRadius:`md`,children:t(`Delegated`)}):q(R,{fontSize:`xs`,opacity:.6,children:t(`Not delegated`)})},n.tokenId))})},rd=()=>{let{t}=Y(),{account:n}=Q(),{isNavigator:r,isDelegated:i,stakedB3TR:a,delegatedAmount:o,navigatorAddress:s,totalValueInCurrency:c,isLoading:l}=mc(n?.address);return l||!r&&!i?null:J(ed,{name:`VeBetter`,logoSrc:e.B3TR,totalValueInCurrency:c,tag:t(r?`Navigator`:`Delegating`),platformUrl:`https://governance.vebetterdao.org`,children:[r&&q(td,{label:t(`Staked B3TR`),amount:`${a.toLocaleString(void 0,{maximumFractionDigits:2})} B3TR`,valueInCurrency:c*(a+o>0?a/(a+o):1),iconSrc:e.B3TR}),i&&q(td,{label:t(`Delegated to {{name}}`,{name:s?d(s,4,4):t(`navigator`)}),amount:`${o.toLocaleString(void 0,{maximumFractionDigits:2})} B3TR`,valueInCurrency:c*(a+o>0?o/(a+o):1),iconSrc:e.B3TR})]})},id=()=>{let{t:e}=Y(),{account:t}=Q(),{positions:n,totalValueInCurrency:r,isLoading:i}=_c(t?.address);return i||!n.length?null:q(ed,{name:`BetterSwap`,logoFallback:q(Ue,{boxSize:`24px`}),totalValueInCurrency:r,tag:e(`Liquidity`),platformUrl:`https://www.betterswap.io/`,children:n.map(e=>q(td,{label:`${e.token0.symbol||`?`} / ${e.token1.symbol||`?`}`,amount:`${e.lpBalance.toLocaleString(void 0,{maximumFractionDigits:4})} LP`,valueInCurrency:e.valueInCurrency},e.pairAddress))})},ad=e=>e==null||!Number.isFinite(e)?null:e>=1e3?`${Math.round(e)}`:e.toFixed(2),od=e=>{if(e!=null)return e<1.1?`red`:e<1.5?`orange`:`green`},sd=()=>{let{t}=Y(),{account:n}=Q(),{currentCurrency:r}=lc(),i=B(`colors`,`vechain-kit-text-secondary`),{supplied:a,borrowed:o,totalSuppliedInCurrency:s,totalBorrowedInCurrency:c,healthFactor:l,netValueInCurrency:u,hasPosition:d,isLoading:f}=Cc(n?.address);if(f||!d)return null;let p=o.length?t(`Borrowing`):t(`Lending`),m=ad(l),h=od(l);return J(ed,{name:`Juicy Finance`,logoSrc:`https://www.juicyfinance.io/logo192.png`,totalValueInCurrency:u,tag:p,platformUrl:`https://www.juicyfinance.io/`,children:[m&&J(N,{w:`full`,justify:`space-between`,align:`center`,px:1,children:[q(R,{fontSize:`xs`,color:i,children:t(`Health rate`)}),q(nn,{size:`sm`,colorScheme:h,borderRadius:`md`,children:m})]}),a.length>0&&J(j,{w:`full`,children:[J(N,{w:`full`,justify:`space-between`,align:`center`,px:1,mb:1,children:[q(R,{fontSize:`xs`,color:i,children:t(`Supplied`)}),q(R,{fontSize:`xs`,color:i,children:sc(s,{currency:r})})]}),a.map(t=>q(td,{label:t.symbol,amount:`${t.amount.toLocaleString(void 0,{maximumFractionDigits:4})} ${t.symbol}`,valueInCurrency:t.valueInCurrency,iconSrc:e[t.symbol]},`s-${t.asset}`))]}),o.length>0&&J(j,{w:`full`,children:[J(N,{w:`full`,justify:`space-between`,align:`center`,px:1,mb:1,mt:2,children:[q(R,{fontSize:`xs`,color:i,children:t(`Borrowed`)}),q(R,{fontSize:`xs`,color:i,children:sc(c,{currency:r})})]}),o.map(t=>q(td,{label:t.symbol,amount:`${t.amount.toLocaleString(void 0,{maximumFractionDigits:4})} ${t.symbol}`,valueInCurrency:t.valueInCurrency,iconSrc:e[t.symbol]},`b-${t.asset}`))]})]})},cd=()=>{let{t:e}=Y(),{account:t}=Q(),n=B(`colors`,`vechain-kit-text-secondary`),r=dc(t?.address),i=mc(t?.address),a=_c(t?.address),o=Cc(t?.address),s=r.positions.length>0,c=i.isNavigator||i.isDelegated,l=a.positions.length>0,u=o.hasPosition;return!(r.isLoading||i.isLoading||a.isLoading||o.isLoading)&&!(s||c||l||u)?q(j,{py:6,textAlign:`center`,children:q(R,{color:n,children:e(`No staking positions yet`)})}):J(z,{spacing:3,align:`stretch`,w:`full`,children:[s&&q(nd,{}),c&&q(rd,{}),u&&q(sd,{}),l&&q(id,{})]})},ld=({setCurrentContent:e})=>{let{t}=Y(),{allowCustomTokens:n}=$(),{isolatedView:r}=gu(),[i,a]=G(0);return J(K,{children:[J(Z,{children:[q(L,{children:t(`Assets`)}),!r&&q(Fo,{onClick:()=>e(`main`)}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,w:`full`,children:[q(Zu,{onSend:()=>{e({type:`send-token`,props:{setCurrentContent:e,onBack:()=>e(`assets`)}})},onSwap:()=>{e({type:`swap-token`,props:{setCurrentContent:e,onBack:()=>e(`assets`)}})},onHistory:()=>{e({type:`transaction-history`,props:{setCurrentContent:e}})}}),q(Qu,{tabIndex:i,onTabChange:a,tokenPanel:q($u,{onSelect:t=>{e({type:`token-detail`,props:{setCurrentContent:e,token:t}})},onManageTokens:n?()=>e(`add-custom-token`):void 0}),stakingPanel:q(cd,{})})]})})})]})},ud=({setCurrentContent:t})=>{let{t:n}=Y(),r=B(`colors`,`vechain-kit-text-primary`),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-overlay`),{addToken:s,removeToken:c,isTokenIncluded:l,isDefaultToken:u,customTokens:f}=kc(),{register:p,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=Ta({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(l(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:n(`Token already added`)});try{await s(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token:`,e),m(`newTokenAddress`,{type:`manual`,message:n(`Invalid token address`)})}}};return J(K,{children:[J(Z,{children:[q(L,{children:n(`Manage Custom Tokens`)}),q(Fo,{onClick:()=>t(`assets`)}),q(I,{})]}),q(F,{children:J(z,{spacing:4,align:`stretch`,children:[q(j,{p:4,borderRadius:`xl`,bg:a,children:J(z,{align:`stretch`,spacing:3,children:[q(R,{fontSize:`sm`,color:i,children:n(`Paste a token contract address to track its balance in your wallet.`)}),J(bt,{isInvalid:!!g.newTokenAddress,children:[J(N,{spacing:2,children:[q(Dt,{...p(`newTokenAddress`,{required:n(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:n(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||n(`Invalid contract address`)}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,h(`newTokenAddress`,t,{shouldValidate:!0})},placeholder:`0x...`,variant:`outline`,fontSize:`md`,fontWeight:`medium`,flex:1}),q(Tt,{"aria-label":n(`Add Token`),icon:q(ei,{}),variant:`vechainKitPrimary`,size:`md`,minW:`40px`,w:`40px`,h:`40px`,borderRadius:`lg`,isDisabled:!_,onClick:v(y)})]}),g.newTokenAddress&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,children:g.newTokenAddress.message})]})]})}),J(j,{children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:i,mb:2,px:1,children:n(`Existing Custom Tokens`)}),f.length>0?q(z,{align:`stretch`,spacing:2,children:f.map(t=>J(N,{justify:`space-between`,fontSize:`sm`,p:3,borderRadius:`xl`,bg:o,children:[J(N,{spacing:3,children:[q(Et,{src:e[t?.symbol],alt:`${t.symbol} logo`,boxSize:`28px`,borderRadius:`full`,fallback:q(j,{boxSize:`28px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`9px`,fontWeight:`bold`,color:r,children:t.symbol?.slice(0,3)})})}),J(z,{spacing:0,align:`start`,children:[q(R,{fontWeight:`medium`,color:r,fontSize:`sm`,children:t.symbol??`Unknown`}),q(R,{color:i,fontSize:`xs`,children:d(t.address??``,6,4)})]})]}),q(M,{size:`sm`,variant:`ghost`,color:i,borderRadius:`md`,p:2,onClick:()=>c(t.address),children:q(ui,{size:16})})]},t.address))}):q(j,{p:6,borderRadius:`xl`,bg:o,textAlign:`center`,children:q(R,{fontSize:`sm`,color:i,children:n(`No custom tokens added yet.`)})})]})]})})]})},dd=({setCurrentContent:e})=>{let{t}=Y(),{darkMode:n}=$(),{isolatedView:r}=gu();return J(K,{children:[J(Z,{children:[q(L,{children:t(`Bridge`)}),!r&&q(Fo,{onClick:()=>e(`main`)}),q(I,{})]}),q(_t,{maxW:`container.lg`,children:q(F,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[q(Ke,{isDark:n,borderRadius:`xl`}),q(R,{fontSize:`sm`,textAlign:`center`,children:t(`Exchange your digital assets between VeChain and other blockchain networks easily and securely. Swaps are executed through partners that leverage both decentralized and centralized exchanges to convert tokens.`)})]})})}),q(It,{children:J(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(Xe,`_blank`)},children:[t(`Launch vechain.energy`),q(P,{as:Lr,ml:2})]})})]})},fd=({setCurrentContent:e})=>{let{t:n}=Y(),{currentCurrency:r,changeCurrency:i,allCurrencies:a}=lc(),o=mn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`);U(()=>{ue(`settings-currency-visited`,`true`)},[]);let s=e=>{let n=r===e;return J(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:n?o:void 0,children:[J(N,{spacing:3,children:[q(R,{fontSize:`xl`,children:t[e]}),q(R,{children:e.toUpperCase()})]}),n&&q(P,{as:Tr,boxSize:5,color:`blue.500`})]},e)};return J(Yh,{children:[J(Z,{children:[q(L,{children:n(`Select currency`)}),q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:a.map(e=>s(e))})}),q(It,{pt:0})]})},pd=({setCurrentContent:e})=>{let{t,i18n:n}=Y(),r=mn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`),i=e=>{n.changeLanguage(e)},a=e=>{let t=n.language===e;return J(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:t?r:void 0,children:[q(R,{children:oo[e]}),t&&q(P,{as:Tr,boxSize:5,color:`blue.500`})]},e)};return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Select language`)}),q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:io.map(e=>a(e))})}),q(It,{pt:0})]})},md=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:s,onTouchStart:c,onTouchMove:l,onTouchEnd:u,isDragging:d,isDraggedOver:f})=>{let p=o[e],{darkMode:m}=$(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-card`);return q(j,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:d?m?`blue.500`:`blue.300`:f?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:d||n?.5:1,cursor:`move`,transition:`background-color 0.2s ease, border-color 0.2s ease`,draggable:!0,onDragStart:()=>i(t),onDragOver:e=>{e.preventDefault(),a(t)},onDrop:()=>s(t),onTouchStart:e=>c(t,e),onTouchMove:l,onTouchEnd:u,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:J(N,{justify:`space-between`,children:[J(N,{opacity:n?.5:1,children:[q(j,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:q(P,{as:Wr,color:g})}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:p.name}),q(R,{fontSize:`sm`,color:g,children:p.description})]})]}),q(Yt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},hd=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=G(null),[o,s]=G(null),c=xn([]),l=xn(0),u=e=>{a(e)},d=e=>{s(e)},f=t=>{if(i===null||i===t){a(null),s(null);return}let r=[...e],o=r[i];r.splice(i,1),r.splice(t,0,o),n(r),a(null),s(null)},p=(e,t)=>{l.current=t.touches[0].clientY,a(e)},m=e=>{if(i===null)return;let t=e.touches[0].clientY;for(let e=0;e<c.current.length;e++){let n=c.current[e];if(!n)continue;let r=n.getBoundingClientRect();if(t>=r.top&&t<=r.bottom){s(e);break}}},h=()=>{if(i!==null&&o!==null&&i!==o){let t=[...e],r=t[i];t.splice(i,1),t.splice(o,0,r),n(t)}a(null),s(null),l.current=0};return q(j,{w:`full`,children:e.map((e,n)=>q(j,{ref:e=>{c.current[n]=e},children:q(md,{token:e,index:n,isExcluded:t.includes(e),onToggleExclusion:r,onDragStart:u,onDragOver:d,onDrop:f,onTouchStart:p,onTouchMove:m,onTouchEnd:h,isDragging:i===n,isDraggedOver:o===n})},e))})},gd=({setCurrentContent:e})=>{let{t}=Y(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Hh(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=H(e=>{r(e)},[r]);return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Gas Token Preferences`)}),q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{w:`full`,children:J(z,{justify:`center`,spacing:6,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:o,textAlign:`center`,children:t(`Choose which tokens to use for transaction fees when the app is not covering them.`)})}),n.availableGasTokens.length===0&&J(rt,{status:`warning`,borderRadius:`md`,children:[q(at,{}),q(it,{fontSize:`sm`,color:o,children:t(`You must enable at least one token to perform transactions. Without any enabled tokens, you will not be able to pay for gas fees.`)})]}),J(z,{w:`full`,align:`start`,spacing:3,children:[q(R,{fontSize:`md`,fontWeight:`semibold`,color:a,children:t(`Token Priority Order`)}),q(R,{fontSize:`sm`,color:o,children:t(`Drag to reorder. The system will automatically use the highest priority token with sufficient balance.`)}),q(hd,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},_d=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=gu(),{exportWallet:i,linkPasskey:a}=Yn(),{showMfaEnrollmentModal:o}=Jn(),{feeDelegation:s}=$(),{connection:c,disconnect:l,smartAccount:u,connectedWallet:d}=Q(),{data:f}=nh(u?.address??``,d?.address??``,3),p=()=>{e({type:`upgrade-smart-account`,props:{setCurrentContent:e,initialContent:`settings`}})},m=()=>{e(`connection-details`)},h=()=>{l(),t()},g=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:n(`Settings`)}),!r&&q(Fo,{onClick:()=>e(`profile`)}),q(I,{})]}),J(F,{w:`full`,children:[J(z,{w:`full`,spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`General`)}),q(Nu,{title:n(`Currency`),onClick:()=>{e(`change-currency`)},leftIcon:Fr,rightIcon:Or}),q(Nu,{title:n(`Language`),onClick:()=>{e(`change-language`)},leftIcon:qr,rightIcon:Or}),c.isConnectedWithPrivy&&!s?.delegatorUrl&&q(Nu,{title:n(`Gas Token Preferences`),onClick:()=>{e(`gas-token-settings`)},leftIcon:Br,rightIcon:Or}),q(Nu,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:ai,rightIcon:Or}),q(Nu,{title:n(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:h,onBack:()=>e(`settings`)}}),leftIcon:Yr})]}),f&&q(z,{w:`full`,spacing:2,mt:4,children:q(Nu,{title:n(`Upgrade Smart Account to V3`),description:n(`A new version is available for your account`),onClick:p,leftIcon:ii,extraContent:q(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,ml:2})})}),c.isConnectedWithSocialLogin&&J(z,{w:`full`,spacing:2,mt:4,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Access and security`)}),q(Nu,{title:n(`Passkey`),onClick:()=>a(),leftIcon:zr}),q(Nu,{title:n(`Backup`),onClick:()=>{i()},leftIcon:Kr}),q(Nu,{title:n(`Manage MFA`),onClick:()=>{o()},leftIcon:oi}),q(Nu,{title:n(`Login methods`),onClick:()=>{e(`privy-linked-accounts`)},leftIcon:fi,rightIcon:Or})]}),J(z,{w:`full`,spacing:2,mt:4,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Help`)}),q(Nu,{title:n(`Connection details`),onClick:m,leftIcon:di,rightIcon:Or}),q(Nu,{title:n(`Explore ecosystem`),onClick:()=>e(`ecosystem`),leftIcon:Jr,rightIcon:Or}),q(Nu,{title:n(`Frequently asked questions`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:Mr,rightIcon:Or})]})]}),q(It,{p:0})]})},vd=({title:e,description:t,icon:n})=>{let r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return J(z,{spacing:6,align:`center`,py:8,children:[q(P,{as:n,boxSize:16,color:r}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:i,children:e}),q(R,{fontSize:`md`,color:r,textAlign:`center`,px:4,children:t})]})]})},yd=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),bd=({document:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===oe.VECHAIN_KIT&&e.documentType===le.TERMS;return J(N,{children:[J(nn,{size:`sm`,borderRadius:`full`,color:n,children:[`v`,e.version]}),q(R,{fontSize:`xs`,cursor:`pointer`,color:n,onClick:()=>{window.open(e.url,`_blank`)},_hover:{textDecoration:`underline`},children:r?t(`'{{policyName}}' on connect`,{policyName:e.displayName??t(`Vechain Kit Policy`)}):t(`'{{policyName}}' on {{date}}`,{policyName:e.displayName??t(`Policy`),date:yd(e.timestamp)})})]})},xd=({title:e,description:t,documents:n,bg:r,hoverBg:i,currentPolicy:a})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`),l=n?.length>0,u=n?.find(e=>e.id===a?.id);return l?q(tt,{border:`none`,mb:3,children:({isExpanded:l})=>J(K,{children:[J(et,{bg:r,borderRadius:`xl`,_hover:{bg:i},children:[J(z,{w:`full`,align:`flex-start`,textAlign:`left`,children:[q(R,{fontWeight:`700`,color:s,children:e}),q(R,{fontSize:`xs`,color:c,children:t})]}),q(P,{as:l?kr:Er,fontSize:`20px`,color:c})]}),q(nt,{pb:4,pt:3,children:J(z,{align:`stretch`,spacing:4,children:[u?.id?J(N,{w:`full`,children:[q(P,{as:Tr,color:s}),q(R,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:yd(u.timestamp)})})]}):null,q(N,{w:`full`,textAlign:`left`,children:q(R,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),q(N,{w:`full`,gap:2,children:q(z,{align:`stretch`,spacing:2,children:n.map(e=>q(bd,{document:e},e.id))})}),a&&q(M,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Sd=()=>{let{account:e}=Q(),{t}=Y(),{darkMode:n}=$(),{agreements:r,documents:i}=bg(),a=W(()=>{let t=r?.filter(t=>E(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...ee,documentType:le.TERMS,documentSource:oe.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),o=W(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),s=W(()=>Object.values(a).some(e=>e.length>0),[a]),c=n?`whiteAlpha.50`:`blackAlpha.50`,l=n?`whiteAlpha.100`:`blackAlpha.100`,u=W(()=>{let e=[];return a[le.TERMS]?.length>0&&e.push(0),a[le.PRIVACY]?.length>0&&e.push(1),a[le.COOKIES]?.length>0&&e.push(2),e},[a]);return s?q(z,{spacing:4,align:`stretch`,children:J($e,{allowMultiple:!0,defaultIndex:u,children:[q(xd,{title:t(`Terms and Conditions`),description:t(`Legal agreement between you, Vechain Kit and the current app, outlining the rules for using wallet services.`),documents:a[le.TERMS],bg:c,hoverBg:l,currentPolicy:o[le.TERMS]}),q(xd,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[le.PRIVACY],bg:c,hoverBg:l,currentPolicy:o[le.PRIVACY]}),q(xd,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[le.COOKIES],bg:c,hoverBg:l,currentPolicy:o[le.COOKIES]})]})}):q(vd,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:Vr})},Cd=({onGoBack:e})=>{let{t}=Y();return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Terms and Policies`)}),q(Fo,{onClick:e}),q(I,{})]}),q(F,{w:`full`,children:q(z,{spacing:6,align:`stretch`,children:q(Sd,{})})}),q(It,{pt:0})]})},wd=({onDisconnect:e,onBack:t,onClose:n,showCloseButton:r=!0,text:i})=>{let{t:a}=Y(),o=B(`colors`,`vechain-kit-text-primary`),s=i??a(`Are you sure you want to disconnect your wallet?`);return J(K,{children:[J(Z,{children:[q(L,{children:a(`Logout`)}),q(Fo,{onClick:t}),r?q(I,{onClick:n}):null]}),q(F,{children:J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:Yr,color:`#ef4444`,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:o,children:s})]})}),q(It,{w:`full`,mt:4,children:J(z,{spacing:3,w:`full`,children:[q(M,{onClick:e,"data-testid":`disconnect-button`,variant:`vechainKitLogout`,children:a(`Confirm`)}),q(M,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},Td=({wallet:e,isActive:t,onSelect:n,onRemove:i,showRemove:a=!0})=>{let{t:o}=Y(),{network:s}=$(),{formattedBalance:c,isLoading:l}=wc({address:e.address}),{domain:u,image:f,isLoading:p}=rl(e.address,s.type),m=B(`colors`,`vechain-kit-text-primary`),h=B(`colors`,`vechain-kit-text-secondary`),g=B(`colors`,`vechain-kit-border`),_=l||p;return q(ct,{variant:`vechainKitWalletCard`,onClick:n,borderWidth:t?`2px`:`1px`,borderColor:t?`vechain-kit-primary`:g,_hover:{borderColor:t?`vechain-kit-primary`:`vechain-kit-text-secondary`},children:q(lt,{p:4,children:J(N,{spacing:3,w:`full`,justifyContent:`space-between`,children:[J(N,{spacing:3,flex:1,minW:0,children:[q(Xh,{wallet:{address:e.address,domain:u??void 0,image:f??void 0,isLoadingMetadata:p},props:{width:10,height:10}}),J(z,{spacing:0,alignItems:`flex-start`,flex:1,minW:0,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:m,noOfLines:1,children:u?r(u,22,0):d(e.address,6,4)}),q(R,{fontSize:`xs`,color:h,noOfLines:1,children:_?o(`Loading...`):c})]})]}),t&&q(j,{children:q(P,{as:Tr,boxSize:5,color:`vechain-kit-primary`})}),a&&!t&&q(Tt,{"aria-label":o(`Remove wallet`),icon:q(P,{as:ui}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,onClick:e=>{e.stopPropagation(),i()}})]})})})},Ed=e=>te(e.map(e=>e.address.toLowerCase()).sort().join(`|`)),Dd=({setCurrentContent:e,returnTo:t=`main`,onLogoutSuccess:n})=>{let{t:r}=Y(),{isolatedView:i}=gu(),{account:a,disconnect:o}=Q(),{disconnect:s}=rr(),{open:c}=ar(),{getStoredWallets:l,setActiveWallet:u,removeWallet:d}=al(),{saveWallet:f}=il(),{refresh:p}=Zc(),m=B(`colors`,`vechain-kit-text-secondary`),[h,g]=G(l()),_=xn(Ed(l())),v=H(()=>{let e=l();g(e),_.current=Ed(e)},[l]);U(()=>{v()},[v,a?.address]),U(()=>{let e=()=>{setTimeout(()=>{v()},100)};if(typeof window<`u`)return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[v]),U(()=>{let e=setInterval(()=>{Ed(l())!==_.current&&v()},200);return()=>clearInterval(e)},[l,v]);let y=W(()=>{let e=h.find(e=>e.isActive);return e?e.address:a?.address??null},[h,a?.address]),b=W(()=>h.find(e=>e.address.toLowerCase()===y?.toLowerCase()),[h,y]),x=W(()=>h.filter(e=>e.address.toLowerCase()!==y?.toLowerCase()),[h,y]),S=H(n=>{n.toLowerCase()!==y?.toLowerCase()&&(b&&f(b.address),u(n),setTimeout(()=>{v()},50),p(),e({type:t,props:{switchFeedback:{showFeedback:!0}}}))},[y,b,a,u,p,e,v,f]),C=H(r=>{let i=r.address.toLowerCase()===y?.toLowerCase(),a=h.filter(e=>e.address.toLowerCase()!==r.address.toLowerCase());e({type:`remove-wallet-confirm`,props:{walletAddress:r.address,walletDomain:null,onConfirm:async()=>{if(i&&a.length>0){let e=a[0];u(e.address)}else if(i&&a.length===0)try{await s()}catch(e){console.error(`Error disconnecting:`,e)}if(d(r.address),setTimeout(()=>{v()},50),a.length===0){n&&n();return}e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})},onBack:()=>{e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}})},[d,v,e,t,n,y,h,u,s]),w=H(()=>{c()},[c]),ee=()=>{o(),n?.()};return J(K,{children:[J(Z,{children:[!i&&q(Fo,{onClick:()=>{e(t)}}),q(L,{children:r(`Select Wallet`)}),q(I,{})]}),q(F,{w:`full`,children:J(z,{w:`full`,spacing:4,children:[b&&J(z,{w:`full`,spacing:2,alignItems:`flex-start`,children:[q(wt,{size:`sm`,color:m,children:r(`Active Wallet`)}),q(Td,{wallet:b,isActive:!0,onSelect:()=>{},onRemove:()=>C(b),showRemove:h.length>1})]}),x.length>0&&J(z,{w:`full`,spacing:2,alignItems:`flex-start`,children:[q(wt,{size:`sm`,color:m,children:r(`Other Wallets`)}),x.map(e=>q(Td,{wallet:e,isActive:!1,onSelect:()=>S(e.address),onRemove:()=>C(e),showRemove:!0},e.address))]})]})}),q(It,{w:`full`,children:J(z,{w:`full`,spacing:2,children:[q(M,{w:`full`,leftIcon:q(ei,{}),variant:`vechainKitSecondary`,onClick:w,children:r(`Add New Wallet`)}),q(M,{w:`full`,leftIcon:q(Yr,{}),variant:`vechainKitLogout`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:ee,onBack:()=>e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}),children:r(`Logout`)})]})})]})},Od=({walletAddress:e,walletDomain:t,onConfirm:n,onBack:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),{domain:c}=rl(e,s.type),l=B(`colors`,`vechain-kit-text-primary`),u=c?r(c,20,0):d(e,6,4);return J(K,{children:[J(Z,{children:[q(L,{children:o(`Remove`)}),q(Fo,{onClick:i}),a&&q(I,{onClick:a})]}),q(F,{children:J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:ui,color:`#ef4444`,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:l,children:o(`Are you sure you want to remove this wallet?`)}),q(R,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,fontWeight:`600`,children:u}),q(R,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,children:d(e,8,7)})]})}),q(It,{w:`full`,mt:4,children:J(z,{spacing:3,w:`full`,children:[q(M,{onClick:n,"data-testid":`remove-wallet-button`,variant:`vechainKitLogout`,children:o(`Remove`)}),q(M,{variant:`vechainKitSecondary`,onClick:i,"data-testid":`cancel-remove-button`,children:o(`Cancel`)})]})})]})},kd=e=>e.toLowerCase()===`0x0000000000000000000000000000000000000000`,Ad=({item:t,onClick:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`),o=B(`colors`,`vechain-kit-success`),s=B(`colors`,`vechain-kit-error`),c=t.direction===`sent`,l=c?`-`:`+`,u=c?s:o,d=c?t.to:t.from,f=t.amount.toLocaleString(void 0,{maximumFractionDigits:4}),p=!c&&kd(t.from),m=e[t.tokenSymbol];return J(M,{variant:`ghost`,h:`64px`,w:`full`,justifyContent:`space-between`,px:2,onClick:n,isDisabled:!n,_disabled:{cursor:`default`,opacity:1},children:[J(N,{spacing:3,flex:1,minW:0,children:[p?q(j,{boxSize:`32px`,borderRadius:`full`,bg:`whiteAlpha.300`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,children:q(P,{as:ci,boxSize:4,color:a})}):m?q(Et,{src:m,alt:t.tokenSymbol,boxSize:`32px`,borderRadius:`full`,flexShrink:0,fallback:q(j,{boxSize:`32px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):q(j,{boxSize:`32px`,borderRadius:`full`,bg:`whiteAlpha.300`,flexShrink:0}),J(z,{spacing:0,align:`flex-start`,minW:0,children:[q(R,{fontWeight:`600`,color:i,children:r(c?`Sent`:`Received`)}),J(N,{spacing:1,align:`baseline`,maxW:`full`,children:[q(R,{fontSize:`xs`,color:a,children:r(c?`To`:`From`)}),q(ag,{address:d,fontSize:`xs`,color:a})]})]})]}),J(z,{spacing:0,align:`flex-end`,maxW:`45%`,flexShrink:0,children:[J(R,{fontWeight:`600`,color:u,lineHeight:`short`,children:[l,f]}),q(R,{fontSize:`xs`,color:a,lineHeight:`short`,maxW:`full`,isTruncated:!0,children:t.tokenSymbol})]})]})},jd=({tokenAddress:e,onItemClick:t,onSeeAll:n})=>{let{t:r}=Y(),{account:i}=Q(),a=B(`colors`,`vechain-kit-text-secondary`),{transfers:o,isLoading:s,isUnsupportedNetwork:c}=Xl(i?.address,e),l=o.slice(0,5);return J(z,{w:`full`,align:`stretch`,spacing:3,children:[J(N,{w:`full`,justify:`space-between`,align:`center`,children:[q(wt,{size:`sm`,children:r(`Token History`)}),o.length>5&&q(M,{variant:`link`,size:`sm`,fontWeight:`500`,onClick:n,children:r(`See all`)})]}),c?q(j,{py:4,textAlign:`center`,children:q(R,{fontSize:`sm`,color:a,children:r(`History is only available on mainnet.`)})}):s?J(R,{fontSize:`sm`,color:a,textAlign:`center`,children:[r(`Loading`),`…`]}):l.length===0?q(R,{fontSize:`sm`,color:a,textAlign:`center`,children:r(`No transfers yet.`)}):l.map(e=>q(Ad,{item:e,onClick:()=>t(e)},e.id))]})},Md=({icon:e,label:t,onClick:n,isDisabled:r})=>{let{t:i}=Y(),a=i(t,t);return q(Tt,{variant:`vechainKitSecondary`,h:`44px`,flex:1,borderRadius:`lg`,"aria-label":a,isDisabled:r,onClick:n,icon:J(N,{spacing:1.5,children:[q(P,{as:e,boxSize:3.5,opacity:.85}),q(R,{fontSize:`sm`,fontWeight:`600`,children:a})]})})},Nd=({setCurrentContent:e,token:t})=>{let{isolatedView:n}=gu(),{currentCurrency:r}=lc(),i=B(`colors`,`vechain-kit-text-secondary`),a=p.includes(t.symbol),o=Number(t.balance),s=o.toLocaleString(void 0,{maximumFractionDigits:4}),{points:c}=rc((()=>{switch(t.symbol){case`VET`:case`VVET`:return`VET`;case`VTHO`:return`VTHO`;case`B3TR`:case`VOT3`:case`veDelegate`:return`B3TR`;default:return}})()),l=typeof t.priceChange24hPct==`number`?t.priceChange24hPct>0?`up`:t.priceChange24hPct<0?`down`:`neutral`:`neutral`,u=()=>e({type:`token-detail`,props:{setCurrentContent:e,token:t}});return J(K,{children:[J(Z,{children:[q(L,{children:t.symbol}),!n&&q(Fo,{onClick:()=>e(`assets`)}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,w:`full`,children:[J(z,{spacing:1,align:`flex-start`,children:[q(wt,{size:`2xl`,fontWeight:`700`,children:s}),J(N,{spacing:2,align:`center`,children:[J(R,{color:i,children:[`=`,` `,sc(t.valueInCurrency,{currency:r})]}),q(Gh,{valuePct:t.priceChange24hPct})]})]}),c.length>1&&q(lg,{points:c,tone:l,chartHeight:72,interactive:!0}),J(N,{spacing:2,w:`full`,children:[q(Md,{icon:_r,label:`Swap`,onClick:()=>{e({type:`swap-token`,props:{setCurrentContent:e,fromTokenAddress:t.address&&t.address!==`0x`?t.address:void 0,onBack:u}})},isDisabled:a}),q(Md,{icon:br,label:`Send`,onClick:()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:t,onBack:u}})},isDisabled:a||o<=0}),q(Md,{icon:gr,label:`Receive`,onClick:()=>{e({type:`receive-token`,props:{setCurrentContent:e,onBack:u}})}})]}),q(jd,{tokenAddress:t.address||`0x`,onItemClick:t=>{e({type:`transaction-detail`,props:{setCurrentContent:e,item:t,onBack:u}})},onSeeAll:()=>{e({type:`transaction-history`,props:{setCurrentContent:e,tokenFilter:{address:t.address||`0x`,symbol:t.symbol},onBack:u}})}})]})})})]})},Pd=(e,t)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`,year:`numeric`}).format(new Date(e*1e3)),Fd=(e,t)=>{let n=new Set,r=new Map;for(let i of e){if(n.has(i.id))continue;n.add(i.id);let e=Pd(i.timestamp,t),a=r.get(e);a?a.push(i):r.set(e,[i])}return Array.from(r,([e,t])=>({label:e,items:t}))},Id=({setCurrentContent:e,tokenFilter:t,onBack:n})=>{let{t:r,i18n:i}=Y(),{account:a}=Q(),{isolatedView:o}=gu(),s=B(`colors`,`vechain-kit-text-secondary`),{transfers:c,isLoading:l,hasNextPage:u,fetchNextPage:d,isFetchingNextPage:f,isUnsupportedNetwork:p}=Yl(a?.address,{tokenAddress:t?.address}),m=W(()=>Fd(c,i.language||`en-US`),[c,i.language]),h=()=>e({type:`transaction-history`,props:{setCurrentContent:e,tokenFilter:t,onBack:n}}),g=t=>{e({type:`transaction-detail`,props:{setCurrentContent:e,item:t,onBack:h}})};return J(K,{children:[J(Z,{children:[q(L,{children:t?r(`{{symbol}} history`,{symbol:t.symbol}):r(`History`)}),!o&&q(Fo,{onClick:n??(()=>e(`assets`))}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:p?q(j,{py:6,textAlign:`center`,children:q(R,{color:s,children:r(`History is only available on mainnet.`)})}):l?J(R,{textAlign:`center`,color:s,children:[r(`Loading`),`…`]}):m.length===0?q(j,{py:6,textAlign:`center`,children:q(R,{color:s,children:r(`No transfers yet.`)})}):J(z,{spacing:4,align:`stretch`,w:`full`,children:[m.map(e=>J(z,{spacing:1,align:`stretch`,children:[q(wt,{size:`xs`,color:s,textTransform:`uppercase`,children:e.label}),e.items.map(e=>q(Ad,{item:e,onClick:()=>g(e)},e.id))]},e.label)),u&&q(M,{variant:`vechainKitSecondary`,size:`sm`,isLoading:f,onClick:()=>d(),children:r(`Load more`)})]})})})]})},Ld=(e,t)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}).format(new Date(e*1e3)),Rd=({label:e,value:t,copyValue:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-text-primary`);return J(N,{w:`full`,justify:`space-between`,align:`center`,children:[q(R,{fontSize:`sm`,color:i,children:e}),J(N,{spacing:1,align:`center`,children:[typeof t==`string`?q(R,{fontSize:`sm`,color:a,fontWeight:`500`,children:t}):t,n&&q(og,{value:n,ariaLabel:`${r(`Copy`)} ${e}`})]})]})},zd=({setCurrentContent:t,item:n,onBack:r})=>{let{t:i,i18n:a}=Y(),{isolatedView:o}=gu(),s=Eg(),{currentCurrency:c}=lc(),{prices:l,exchangeRates:u}=ic(),f=B(`colors`,`vechain-kit-success`),p=B(`colors`,`vechain-kit-error`),m=n.direction===`sent`,h=m?`-`:`+`,g=m?p:f,_=!m&&n.from.toLowerCase()===`0x0000000000000000000000000000000000000000`,v=B(`colors`,`vechain-kit-text-secondary`),y=l[(n.tokenAddress??`0x`).toLowerCase()]??0,b=n.amount*y,x=(()=>c===`eur`?b*(u?.eurUsdPrice??1):c===`gbp`?b*(u?.gbpUsdPrice??1):b)(),S=`${s.explorerUrl}/${n.txId}`,C=r??(()=>t({type:`transaction-history`,props:{setCurrentContent:t}}));return J(K,{children:[J(Z,{children:[q(L,{children:i(m?`Sent`:`Received`)}),!o&&q(Fo,{onClick:C}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,w:`full`,children:[J(N,{spacing:3,children:[_?q(j,{boxSize:`40px`,borderRadius:`full`,bg:`whiteAlpha.300`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(P,{as:ci,boxSize:5,color:v})}):e[n.tokenSymbol]?q(Et,{src:e[n.tokenSymbol],alt:n.tokenSymbol,boxSize:`40px`,borderRadius:`full`,fallback:q(j,{boxSize:`40px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):q(j,{boxSize:`40px`,borderRadius:`full`,bg:`whiteAlpha.300`}),J(z,{spacing:0,align:`flex-start`,children:[J(wt,{size:`md`,color:g,fontWeight:`700`,children:[h,n.amount.toLocaleString(void 0,{maximumFractionDigits:4}),` `,n.tokenSymbol]}),J(R,{fontSize:`sm`,opacity:.7,children:[`=`,` `,sc(x,{currency:c})]})]})]}),J(z,{w:`full`,align:`stretch`,spacing:3,p:4,borderRadius:`xl`,bg:`vechain-kit-card`,children:[q(Rd,{label:i(`Date`),value:Ld(n.timestamp,a.language||`en-US`)}),q(Rd,{label:i(`Status`),value:q(R,{color:f,fontWeight:`600`,children:i(`Succeeded`)})}),q(Rd,{label:i(`From`),value:q(ag,{address:n.from,headLen:6,tailLen:6,fontSize:`sm`,fontWeight:`500`}),copyValue:n.from}),q(Rd,{label:i(`To`),value:q(ag,{address:n.to,headLen:6,tailLen:6,fontSize:`sm`,fontWeight:`500`}),copyValue:n.to}),q(Rd,{label:i(`Hash`),value:d(n.txId,6,6),copyValue:n.txId})]}),q(M,{as:`a`,href:S,target:`_blank`,rel:`noopener noreferrer`,variant:`vechainKitSecondary`,leftIcon:q(Lr,{}),children:i(`View on explorer`)})]})})})]})},Bd=Ro[`@vechain/dapp-kit-react`]||zo[`@vechain/dapp-kit-react`]||`unknown`,Vd=Ro[`@privy-io/react-auth`]||`unknown`,Hd=({connectionCache:e})=>{let{t}=Y(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{source:a}=ir(),{privy:o,network:s}=$(),c=o?.appId,{data:l,isLoading:u}=Yo(c||[]),{onCopy:f,hasCopied:p}=pn(``),{data:m,isLoading:h}=Zo(),{data:g,isLoading:_}=Vm(r.address??``,i?.address??``),y=B(`colors`,`vechain-kit-card`),b=B(`colors`,`vechain-kit-text-secondary`),x=B(`colors`,`vechain-kit-text-primary`),S=(()=>n.isConnectedWithCrossApp&&e?.ecosystemApp?e.ecosystemApp.name:n.isConnectedWithSocialLogin&&l?Object.values(l)[0]?.name??null:n.isConnectedWithDappKit&&a?a:null)(),C=n.isConnectedWithSocialLogin&&u,w=({label:e,value:t,isLoading:n=!1,href:r})=>J(N,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:x,children:[e,`:`]}),q(R,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:b,children:n?`Loading...`:t})]});return C?q(z,{w:`full`,h:`full`,justify:`center`,align:`center`,minH:`200px`,borderRadius:`xl`,bg:y,children:q(qt,{})}):S?J(z,{p:4,bg:y,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[q(w,{label:t(`Logged in with`),value:S}),n.isConnectedWithCrossApp&&e?.timestamp&&q(w,{label:t(`At`),value:new Date(e.timestamp).toLocaleString()}),q(w,{label:t(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),q(vt,{}),q(w,{label:t(`Network`),value:s.type}),q(w,{label:t(`Node URL`),value:s.nodeUrl||v(s.type).nodeUrl}),n.isConnectedWithPrivy&&q(vt,{}),n.isConnectedWithPrivy&&J(N,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:x,children:[t(`Embedded wallet`),`:`]}),J(N,{children:[q(R,{fontSize:`sm`,color:b,children:i?.address?d(i.address,8,7):`-`}),q(P,{color:b,onClick:()=>{i?.address&&f(i.address)},opacity:i?.address?1:.4,pointerEvents:i?.address?`auto`:`none`,cursor:`pointer`,as:p?Tr:Pr})]})]}),n.isConnectedWithPrivy?J(K,{children:[q(w,{label:t(`Smart Account`),value:`v${g?.version??``} ${g?.isDeployed?``:`(not deployed)`}`,isLoading:_}),q(w,{label:t(`Privy Status`),value:m||``,isLoading:h})]}):r.isDeployed&&q(w,{label:t(`Smart Account`),value:`v${g?.version??``}`,isLoading:_}),q(vt,{}),q(w,{label:t(`VeChain Kit`),value:Lo,href:`https://github.com/vechain/vechain-kit/releases/tag/${Lo}`}),q(w,{label:`DAppKit`,value:Bd}),q(w,{label:`Privy`,value:Vd})]}):null},Ud=()=>{let{connection:e}=Q(),{t}=Y(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=om(),a=i(),o=B(`colors`,`vechain-kit-card`);return e.isConnectedWithPrivy?J(z,{w:`full`,align:`stretch`,textAlign:`center`,mt:5,p:3,borderRadius:`lg`,bg:o,shadow:`sm`,children:[q(R,{fontSize:`xs`,fontWeight:`800`,children:t(`Wallet secured by`)}),J(N,{justify:`center`,children:[q(Be,{isDark:r,w:`50px`}),q(P,{as:Zr,ml:3}),e.isConnectedWithVeChain?q(ye,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&q(Et,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&q(Et,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]}):null},Wd=({onGoBack:e})=>{let{t}=Y(),{getConnectionCache:n}=om(),r=n()??void 0;return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Connection Details`)}),q(Fo,{onClick:()=>{e()}}),q(I,{})]}),J(F,{w:`full`,children:[q(Hd,{connectionCache:r}),q(Ud,{})]}),q(It,{pt:0})]})},Gd=({accountType:e,accountDescription:t,isLoading:n,onConfirm:r,onCancel:i})=>{let{t:a}=Y();return J(z,{spacing:6,align:`stretch`,children:[q(R,{fontSize:`md`,textAlign:`center`,color:B(`colors`,`vechain-kit-text-primary`),children:a(`Are you sure you want to unlink {{accountType}} as a login method linked to {{accountDescription}}?`,{accountType:e,accountDescription:t})}),J(z,{spacing:3,w:`full`,children:[q(M,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),q(M,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Kd=({onBack:e})=>{let{t}=Y(),{privy:n,dappKit:r}=$(),[i,a]=G(null),[o,s]=G(!1),[c,l]=G(!1),[u,f]=G(!1),p=B(`colors`,`vechain-kit-text-primary`),m=B(`colors`,`vechain-kit-text-secondary`),{user:h,linkEmail:g,linkGoogle:_,linkTwitter:v,linkPhone:y,linkSpotify:b,linkApple:x,linkInstagram:S,linkTiktok:C,linkGithub:w,linkLinkedIn:ee,linkTelegram:T,linkFarcaster:E,linkPasskey:D,linkDiscord:O,unlinkEmail:k,unlinkGoogle:te,unlinkApple:A,unlinkSpotify:ne,unlinkInstagram:re,unlinkTiktok:ie,unlinkGithub:ae,unlinkLinkedIn:oe,unlinkTelegram:se,unlinkFarcaster:ce,unlinkPhone:le,unlinkPasskey:ue,unlinkDiscord:de,linkWallet:fe}=Xn(),pe=W(()=>{let e=n?.loginMethods?.filter(e=>[`rabby_wallet`,`coinbase_wallet`,`rainbow`,`phantom`,`metamask`].includes(e))??[],t=r?.allowedWallets??[];return e.length>0||t.length>0},[n?.loginMethods,r?.allowedWallets]),me=e=>{switch(e){case`google_oauth`:return ha;case`email`:return Xr;case`passkey`:return zr;case`wallet`:return pi;case`twitter_oauth`:return ja;case`phone`:return $r;case`spotify_oauth`:return ba;case`apple_oauth`:return ga;case`instagram_oauth`:return va;case`tiktok_oauth`:return Ca;case`github_oauth`:return Hr;case`linkedin_oauth`:return ya;case`telegram`:return xa;case`farcaster`:return Ma;case`discord_oauth`:return _a;default:return}},he=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},ge=async e=>{if(he()){f(!0);try{switch(e.type){case`google_oauth`:await te(e.subject);break;case`email`:await k(e.address);break;case`passkey`:await ue(e.subject);break;case`phone`:await le(e.number);break;case`spotify_oauth`:await ne(e.subject);break;case`apple_oauth`:await A(e.subject);break;case`instagram_oauth`:await re(e.subject);break;case`tiktok_oauth`:await ie(e.subject);break;case`github_oauth`:await ae(e.subject);break;case`linkedin_oauth`:await oe(e.subject);break;case`telegram`:await se(e.subject);break;case`farcaster`:await ce(e.subject);break;case`discord_oauth`:await de(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},_e=e=>{switch(e.type){case`google_oauth`:return e.email;case`email`:return e.address;case`passkey`:return`${e.authenticatorName} - ${e.createdWithBrowser}`;case`phone`:return e.number;case`wallet`:return`${d(e.address)} - ${e.walletClientType}`;default:return``}},ve=h?.linkedAccounts?.map(e=>e.type)||[],ye=n?.loginMethods||[],be=!ve.includes(`google_oauth`)&&ye.includes(`google`),xe=!ve.includes(`email`)&&ye.includes(`email`),Se=!ve.includes(`twitter_oauth`)&&ye.includes(`twitter`),Ce=!ve.includes(`phone`)&&ye.includes(`sms`),we=!ve.includes(`spotify_oauth`)&&ye.includes(`spotify`),Te=!ve.includes(`apple_oauth`)&&ye.includes(`apple`),Ee=!ve.includes(`instagram_oauth`)&&ye.includes(`instagram`),De=!ve.includes(`tiktok_oauth`)&&ye.includes(`tiktok`),Oe=!ve.includes(`github_oauth`)&&ye.includes(`github`),ke=!ve.includes(`linkedin_oauth`)&&ye.includes(`linkedin`),Ae=!ve.includes(`telegram`)&&ye.includes(`telegram`),je=!ve.includes(`farcaster`)&&ye.includes(`farcaster`),Me=!ve.includes(`discord_oauth`)&&ye.includes(`discord`);return o?J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Select Additional Login Method`)}),q(Fo,{onClick:()=>s(!1)}),q(I,{})]}),q(F,{w:`full`,children:J(z,{spacing:3,align:`stretch`,w:`full`,children:[q(Nu,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>D(),leftIcon:zr}),be&&q(Nu,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:ha}),xe&&q(Nu,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Xr,stacked:!0}),Se&&q(Nu,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:ja}),Ce&&q(Nu,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:$r}),we&&q(Nu,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:ba}),Te&&q(Nu,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:ga}),Ee&&q(Nu,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:va}),De&&q(Nu,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:Ca}),Oe&&q(Nu,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:Hr}),ke&&q(Nu,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>ee(),leftIcon:ya}),Ae&&q(Nu,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>T(),leftIcon:xa}),je&&q(Nu,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>E(),leftIcon:Ma}),Me&&q(Nu,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>O(),leftIcon:_a}),pe&&q(Nu,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>fe(),leftIcon:pi}),!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),q(It,{pt:0})]}):i?J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Remove Login Method`)}),q(Fo,{onClick:()=>a(null)}),q(I,{})]}),q(F,{children:q(Gd,{accountType:i.type,accountDescription:_e(i),isLoading:u,onConfirm:()=>ge(i),onCancel:()=>a(null)})}),q(It,{pt:0})]}):J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Login methods`)}),q(Fo,{onClick:e}),q(I,{})]}),q(F,{w:`full`,children:J(z,{spacing:3,align:`center`,w:`full`,justify:`center`,children:[J(z,{spacing:1,justify:`flex-start`,alignItems:`flex-start`,mb:5,textAlign:`left`,w:`full`,children:[q(R,{fontSize:`sm`,color:m,children:t(`These accounts are linked to your embedded wallet and can be used to login to your wallet and access your private key.`)}),c&&q(R,{fontSize:`sm`,color:m,children:t(`Adding more linked accounts increases security against loss of access, but also introduces additional potential attack vectors. For enhanced security, we recommend enabling MFA.`)}),q(M,{variant:`link`,mt:0,size:`sm`,onClick:()=>l(!c),color:p,children:t(c?`Show Less`:`Read More`)})]}),h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`).map(e=>J(yt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[J(yt,{align:`center`,gap:3,children:[q(P,{as:me(e.type),color:p}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`500`,color:p,children:e.type===`google_oauth`?t(`Google`):e.type===`email`?t(`Email`):e.type===`passkey`?t(`Passkey`):e.type===`twitter_oauth`?t(`Twitter`):e.type===`phone`?t(`Phone Number`):e.type===`spotify_oauth`?t(`Spotify`):e.type===`apple_oauth`?t(`Apple`):e.type===`instagram_oauth`?t(`Instagram`):e.type===`tiktok_oauth`?t(`Tiktok`):e.type===`github_oauth`?t(`Github`):e.type===`linkedin_oauth`?t(`LinkedIn`):e.type===`telegram`?t(`Telegram`):e.type===`farcaster`?t(`Farcaster`):e.type===`discord_oauth`?t(`Discord`):t(`Wallet`)}),q(R,{fontSize:`sm`,color:m,children:_e(e)})]})]}),q(M,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!he(),onClick:()=>{e.type===`passkey`?D():a(e)},children:t(`Remove`)})]},e.type))]})}),q(It,{w:`full`,children:q(M,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:q(P,{as:ei}),isDisabled:!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me,children:t(`Add Login Method`)})})]})},qd=[{id:`welcome`,title:`Welcome to the VeChain`,description:`Welcome! Here you can manage your wallet, send tokens, and interact with the VeChain blockchain and its applications.`,timestamp:Date.now(),status:`success`,isRead:!1}],Jd=()=>{let{t:e}=Y(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=Yd(),{data:o}=ah(r?.address??``,3);U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),s=`smart_account_upgrade_${t.address.toLowerCase()}`;!r.some(e=>e.id===s)&&o&&i({id:s,title:e(`Account Upgrade Required`),description:e(`A new upgrade is available for your smart account. Please head over to the 'Access and Security' section to upgrade it.`),status:`warning`})},[n.isConnectedWithPrivy,t?.address,o]),U(()=>{!n.isConnectedWithPrivy||!t?.address||a().some(e=>e.id===`smart_account_${t.address.toLowerCase()}`)||i({id:`smart_account_${t.address.toLowerCase()}`,title:e(`Smart Account detected`),description:e(`You have an active smart account associated to this wallet. It has been set as your main identity.`),status:`info`})},[n.isConnectedWithPrivy,t?.address]),U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),o=r.some(e=>e.id===`multiclause_warning_${t.address.toLowerCase()}`),s=r.some(e=>e.id===`multiclause_support_${t.address.toLowerCase()}`);o&&!s&&i({id:`multiclause_support_${t.address.toLowerCase()}`,title:e(`Multiclause Transactions Are Now Supported`),description:e(`Good news! Multiclause transactions are now fully supported for smart accounts. You can now enjoy a better user experience, lower gas costs, and enchanced security.`),status:`info`})},[n.isConnectedWithPrivy,t?.address])},Yd=()=>{let{account:e}=Q(),t=H(e=>{let t=e?.toLowerCase();return{notifications:`vechain_kit_notifications_${t}`,archived:`vechain_kit_archived_notifications_${t}`,initialized:`vechain_kit_notifications_initialized_${t}`}},[]),n=H(()=>{if(!e?.address||!O())return;let n=t(e.address);b(n.initialized)||(ue(n.notifications,JSON.stringify(qd)),ue(n.initialized,`true`))},[e?.address,t]);U(()=>{n()},[n]);let r=H(()=>{if(!e?.address||!O())return[];let n=b(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=H(()=>{if(!e?.address||!O())return[];let n=b(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=H(n=>{if(!e?.address||!O())return;let i=t(e.address),a=r(),o=b(i.archived),s=o?JSON.parse(o):[];if([...a,...s].some(e=>e.title===n.title))return;let c={...n,id:n.id||Math.random().toString(36).substring(7),timestamp:Date.now(),isRead:!1};ue(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=H(n=>{if(!e?.address||!O())return;let i=t(e.address),a=r().filter(e=>e.id!==n);ue(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:H(()=>{if(!e?.address||!O())return;let n=t(e.address),a=r();ue(n.archived,JSON.stringify([...i(),...a])),ue(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:H(n=>{if(!e?.address||!O())return;let a=t(e.address),o=r(),s=i(),c=o.find(e=>e.id===n),l=o.filter(e=>e.id!==n);if(c){let e=[{...c,isRead:!0},...s];ue(a.notifications,JSON.stringify(l)),ue(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},Xd=({showArchived:e})=>{let{t}=Y();return q(vd,{title:t(e?`No archived notifications`:`No notifications`),description:t(e?`Cleared notifications will appear here`:`When you have notifications, they will appear here`),icon:e?mr:xr})},Zd=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=Y(),i=()=>{n(e.id)};return e.isRead&&!t?null:J(rt,{status:e.status,variant:`subtle`,borderRadius:`lg`,pr:8,position:`relative`,opacity:e.isRead?.7:1,cursor:`pointer`,_hover:{opacity:.8},"data-testid":`notification-item`,children:[q(at,{boxSize:`16px`}),J(j,{children:[q(ot,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),q(it,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&q(Tt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:q(Nr,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},Qd=({setCurrentContent:e})=>{let{t}=Y(),{isolatedView:n}=gu(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=Yd(),[s,c]=G(!1),[l,u]=G(r()),[d,f]=G(i()),p=()=>{a(),f([...d,...l]),u([])},m=e=>{o(e);let t=l.find(t=>t.id===e);u(l.filter(t=>t.id!==e)),t&&f([{...t,isRead:!0},...d])},h=()=>{c(!s)},g=s?d:l,_=[...g].sort((e,t)=>e.id===`welcome`?-1:t.id===`welcome`?1:e.id===`smart-account`?-1:t.id===`smart-account`?1:e.id===`multiclause`?-1:t.id===`multiclause`?1:t.timestamp-e.timestamp);return J(Yh,{children:[J(Z,{children:[!n&&q(Fo,{onClick:()=>e(`main`)}),q(L,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),q(I,{})]}),J(_t,{h:[`540px`,`auto`],p:0,children:[q(F,{children:J(z,{spacing:4,align:`stretch`,w:`full`,children:[J(N,{justify:`space-between`,children:[q(M,{variant:`ghost`,leftIcon:q(P,{as:s?xr:mr}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&q(M,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?q(Xd,{showArchived:s}):q(z,{spacing:3,children:_.map(e=>q(Zd,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),q(It,{pt:0})]})]})},$d=e=>{switch(e){case`defi`:return`blue`;case`games`:return`green`;case`collectibles`:return`purple`;case`marketplaces`:return`orange`;case`utilities`:return`cyan`;default:return`gray`}},ef=({category:e,...t})=>{let{t:n}=Y(),r=e.toLowerCase();return q(nn,{size:`sm`,colorScheme:$d(r),borderRadius:`full`,px:2,...t,children:n(r)})},tf=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>J(ct,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&q(j,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:q(ef,{category:r})}),q(lt,{p:a===`sm`?2:4,alignItems:`center`,children:J(z,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&q(Et,{src:t,fallbackSrc:y,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&q(R,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),nf=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=cl(e.id),{data:a,isLoading:o}=hl(r?.logo);return q(Kt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:q(tf,{name:r?.name??``,imageUrl:a?.image??``,linkUrl:r?.external_url??``,category:`vebetter`,onClick:()=>{r?.name&&t({type:`app-overview`,props:{name:r.name,image:a?.image??``,url:r?.external_url??``,description:r?.description??``,category:`vebetter`,selectedCategory:n,setCurrentContent:t}})}})})},rf=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>q(tf,{name:e,imageUrl:t,linkUrl:n,category:i,onClick:()=>{s({type:`app-overview`,props:{name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s}})},...a&&{logoComponent:a}}),af=({})=>{let{t:e}=Y(),{shortcuts:t}=Ph();return t.length===0?null:J(z,{w:`full`,align:`flex-start`,spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`500`,children:e(`Shortcuts`)}),q(St,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>q(Ct,{children:q(ct,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:q(lt,{p:2,alignItems:`center`,children:q(Et,{src:e.image,fallbackSrc:y,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},of=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=Y();return J(j,{width:`full`,mb:4,children:[q(R,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),J(on,{spacing:2,children:[q(sn,{children:q(nn,{size:`md`,borderRadius:`full`,variant:e===null?`solid`:`outline`,colorScheme:r?`gray`:`blackAlpha`,cursor:`pointer`,onClick:()=>t(null),children:i(`All`)})}),n.map(n=>q(sn,{children:q(ef,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},sf=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:Ze,logo:new URL(`/static/img/coins/64x64/33509.png`,Le).toString(),banner:new URL(`/static/img/icons/vbd.png`,Le).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/static/img/icons/vbd.png`,Le).toString()},categories:[]},{name:`vet.domains`,description:`.vet.domains provides a unique and unchangeable identity for Vechain users by linking information to their wallet addresses. It becomes easier for people to use the blockchain by replacing complicated wallet addresses with easy-to-remember names.`,external_url:He,logo:new URL(`/assets/walletconnect.png`,He).toString(),banner:new URL(`/assets/walletconnect.png`,He).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/assets/walletconnect.png`,He).toString()},categories:[]}],cf=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=Y(),{darkMode:r,network:i}=$(),{isolatedView:a}=gu(),o=B(`colors`,`vechain-kit-text-tertiary`),[s,c]=G(``),[l,u]=G(t||null);U(()=>{t!==void 0&&u(t)},[t]);let{data:d}=Oc(),{data:f}=Xc(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=hm(),g=W(()=>{let e=new Set;return i.type===`main`&&f&&f.length>0&&e.add(`vebetter`),p&&p.forEach(t=>{t.category&&e.add(t.category)}),Array.from(e).sort()},[p,f,i.type]),_=i.type===`main`?f.filter(e=>e.app.name.toLowerCase().includes(s.toLowerCase())):[],v=sf.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),y=p?.filter(e=>(e.name.toLowerCase().includes(s.toLowerCase())||e.description.toLowerCase().includes(s.toLowerCase())||e.tags.some(e=>e.toLowerCase().includes(s.toLowerCase())))&&(l===null||e.category===l))||[],b=l===null,x=l===null||l===`vebetter`,{shortcuts:S}=Ph();return J(K,{children:[J(Z,{children:[q(L,{children:n(`Ecosystem`)}),!a&&q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{overflowY:`auto`,minH:`300px`,children:J(z,{spacing:6,w:`full`,children:[q(af,{setCurrentContent:e}),S.length>0&&q(R,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),J(Ot,{size:`lg`,children:[q(Dt,{placeholder:n(`Search Apps`),value:s,onChange:e=>{c(e.target.value)},bg:r?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12}),q(kt,{h:`56px`,w:`56px`,pl:4,children:q(ri,{color:o})})]}),g.length>0&&q(of,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),J(St,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&q(K,{children:v.map(t=>q(Ct,{children:q(rf,{name:t.name,image:t.logo,url:t.external_url,setCurrentContent:e,description:t.description,selectedCategory:l})},t.name))}),x&&_.length>0&&q(K,{children:_.map(t=>q(Ct,{children:q(nf,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?q(Ct,{colSpan:2,children:q(ft,{py:4,children:q(qt,{})})}):h?q(Ct,{colSpan:2,children:q(R,{color:`red.500`,textAlign:`center`,children:n(`Failed to load App Hub apps`)})}):y.length>0?y.map(t=>q(Ct,{children:q(rf,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&q(Ct,{colSpan:2,children:q(ft,{py:4,children:q(R,{children:n(`No apps found in this category`)})})})]})]})}),q(It,{pt:0})]})},lf=({name:e,image:t,url:n,description:r})=>{let{t:i}=Y(),{isShortcut:a,addShortcut:o,removeShortcut:s}=Ph(),c=a(n);return q(M,{px:4,width:`full`,height:`45px`,variant:`vechainKitSecondary`,borderRadius:`xl`,onClick:()=>{c?s(n):o({name:e,image:t,url:n,description:r})},leftIcon:q(P,{as:c?Cr:Sr}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},uf=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=Y();return J(K,{children:[J(Z,{children:[q(L,{children:t}),q(Fo,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),q(I,{})]}),q(F,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[J(yt,{direction:`column`,align:`center`,children:[s||q(Et,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&q(N,{mt:2,children:q(ef,{category:a})})]}),q(R,{fontSize:`sm`,textAlign:`center`,children:i}),q(R,{fontSize:`sm`,textAlign:`center`,children:c(`Click below to access {{ name }} and explore its features.`,{name:t})})]})}),q(It,{children:J(z,{w:`full`,spacing:4,children:[J(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),q(P,{as:Lr,ml:2})]}),q(lf,{name:t,image:n,url:r,description:i})]})})]})},df=({children:e})=>q(pr.div,{whileHover:{scale:1.1},transition:{duration:.5,ease:`easeInOut`,repeat:1/0,repeatDelay:crypto.getRandomValues(new Uint32Array(1))[0]/2**32*5},animate:{y:[0,-2,0],rotate:[0,10,-10,0]},children:e}),ff=({description:e})=>{let{darkMode:t}=$(),n=new URL(`intent/tweet`,Je);n.searchParams.set(`text`,e);let r=new URL(`share/url`,Pe);r.searchParams.set(`url`,e);let i=new URL(``,de);return i.searchParams.set(`text`,e),J(N,{gap:2,children:[q(df,{children:q(jt,{href:n.toString(),isExternal:!0,children:q(j,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:q(ja,{size:22})})})}),q(df,{children:q(jt,{href:r.toString(),isExternal:!0,children:q(j,{bg:`#30abec`,p:2,borderRadius:`full`,children:q(Sa,{color:`white`,size:22})})})}),q(df,{children:q(jt,{href:i.toString(),isExternal:!0,children:q(j,{bg:`#01cb37`,p:2,borderRadius:`full`,children:q(wa,{size:22,color:`white`})})})})]})},pf=({status:e,uiConfig:t,onTryAgain:n,txReceipt:r,txError:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=B(`colors`,`vechain-kit-error`),l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=W(()=>i?i.reason||o(`Something went wrong. Please try again.`):null,[i,o]),p=(()=>{let n=e===`waitingConfirmation`;switch(n&&(e=`pending`),e){case`pending`:return{title:t?.title??o(n?`Sending Transaction...`:`Waiting for confirmation`),icon:t?.loadingIcon??q(qt,{size:`xl`,"data-testid":`pending-spinner-modal`}),description:n?o(`Transaction is being processed, it can take up to 15 seconds.`):t?.description??o(`Please confirm the transaction in your wallet.`)};case`error`:return{title:o(`Something went wrong`),icon:t?.errorIcon??q(P,{as:Ar,color:c,fontSize:`100px`,"data-testid":`error-icon-modal`}),description:f??o(`An unexpected error occurred.`)};case`success`:return{title:o(`Transaction successful!`),icon:t?.successIcon??q(P,{as:jr,color:l,fontSize:`100px`,"data-testid":`success-icon-modal`}),description:``};case`ready`:return{title:t?.title??o(`Confirm transaction`),icon:null,description:t?.description??o(`Confirm the transaction in your wallet to complete it.`)};default:return{title:``,icon:null,description:``}}})(),m=`${v(s.type).explorerUrl}/${r?.meta.txID}`;return J(K,{children:[J(Z,{children:[q(L,{children:p.title}),q(I,{isDisabled:e===`pending`&&!t?.isClosable})]}),q(F,{children:J(z,{align:`center`,p:6,spacing:3,children:[p.icon,e===`success`&&t?.showShareOnSocials&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:o(`Share on`)}),q(ff,{description:m})]}),p.description&&q(R,{fontSize:e===`ready`?`md`:`sm`,textAlign:`center`,color:e===`error`?c:u,mt:5,style:{lineBreak:`anywhere`},children:p.description})]})}),q(It,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[e===`error`&&!!n&&J(M,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[q(P,{mr:2,as:ni}),o(`Try again`)]}),e===`ready`&&q(M,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&q(M,{onClick:a,variant:`ghost`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&q(jt,{href:`${v(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:o(`View transaction on the explorer`)}),q(P,{size:`sm`,as:Lr,color:d})]})})]})})]})},mf=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>{let{darkMode:s,theme:c}=$();return e?q(vp,{darkMode:s,theme:c,children:q(Ko,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:q(pf,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})})}):null},hf=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=v(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:t}),q(I,{})]}),q(F,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(P,{as:jr,fontSize:`100px`,color:l,"data-testid":`success-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,color:u,children:n}),i&&e&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:a(`Share on`)}),q(ff,{description:c})]})]})}),q(It,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(jt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:a(`View transaction on the explorer`)}),q(P,{size:16,as:Lr})]})})]})})]})},gf=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=Y(),{network:a,darkMode:o}=$(),s=v(a.type).explorerUrl;return J(K,{children:[J(Z,{children:[q(L,{children:t}),q(I,{})]}),q(F,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(P,{as:Ar,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n})]})}),q(It,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&q(jt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:i(`View transaction on the explorer`)}),q(P,{size:16,as:Lr})]})})]})})]})},_f=({isOpen:e,onClose:t,initialContent:n=`profile`})=>{let{account:r}=Q(),{themeConfig:i}=_p(),{accountModalContent:a,setAccountModalContent:o}=bp();return U(()=>{e&&o(n)},[e,n,o]),q(Ko,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,mobileMaxHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,desktopMinHeight:`485px`,desktopMaxHeight:`485px`,children:(()=>{if(typeof a==`object`)switch(a.type){case`send-token`:return q(_u,{...a.props});case`send-token-summary`:return q(vu,{...a.props});case`token-detail`:return q(Nd,{...a.props});case`transaction-history`:return q(Id,{...a.props});case`transaction-detail`:return q(zd,{...a.props});case`swap-token`:return q(Cu,{...a.props});case`receive-token`:return q(yu,{...a.props});case`choose-name`:return q(wu,{...a.props});case`choose-name-search`:return q(Ou,{...a.props});case`choose-name-summary`:return q(ku,{...a.props});case`app-overview`:return q(uf,{...a.props,setCurrentContent:o});case`disconnect-confirm`:return q(wd,{...a.props});case`remove-wallet-confirm`:return q(Od,{...a.props});case`account-customization`:return q(Wu,{...a.props});case`account-customization-summary`:return q(Gu,{...a.props});case`successful-operation`:return q(hf,{...a.props});case`failed-operation`:return q(gf,{...a.props});case`upgrade-smart-account`:return q(Yu,{...a.props});case`faq`:return q(ju,{...a.props});case`terms-and-privacy`:return q(Cd,{...a.props});case`ecosystem-with-category`:return q(cf,{setCurrentContent:o,selectedCategory:a.props.selectedCategory});case`select-wallet`:return q(Dd,{setCurrentContent:o,onClose:t,returnTo:a.props.returnTo,onLogoutSuccess:a.props.onLogoutSuccess});case`main`:return q(mu,{setCurrentContent:o,onClose:t,wallet:r,switchFeedback:a.props?.switchFeedback});case`profile`:return q(Ju,{setCurrentContent:o,onLogoutSuccess:()=>{t()},switchFeedback:a.props?.switchFeedback})}switch(a){case`main`:return q(mu,{setCurrentContent:o,onClose:t,wallet:r});case`settings`:return q(_d,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`profile`:return q(Ju,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`assets`:return q(ld,{setCurrentContent:o});case`notifications`:return q(Qd,{setCurrentContent:o});case`receive-token`:return q(yu,{setCurrentContent:o});case`swap-token`:return q(Cu,{setCurrentContent:o});case`connection-details`:return q(Wd,{onGoBack:()=>o(`settings`)});case`privy-linked-accounts`:return q(Kd,{onBack:()=>o(`settings`)});case`ecosystem`:return q(cf,{setCurrentContent:o});case`add-custom-token`:return q(ud,{setCurrentContent:o});case`change-currency`:return q(fd,{setCurrentContent:o});case`change-language`:return q(pd,{setCurrentContent:o});case`gas-token-settings`:return q(gd,{setCurrentContent:o});case`account-customization`:return q(Wu,{setCurrentContent:o});default:return null}})()})},vf=ma`
127
+ }`,a=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({operationName:`Registrations`,query:i,extensions:{}})});if(!a.ok)throw Error(`Failed to fetch domains`);let o=await a.json();return o.data&&o.data.domains&&(o.data.domains=o.data.domains.filter(e=>!e.name.endsWith(`addr.reverse`))),vs.parse(o.data)},bs=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],xs=(e,t)=>{let{network:n}=$();return X({queryKey:bs(e,t),queryFn:()=>ys(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Ss=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],Cs=e=>{let{network:t}=$();return X({queryKey:Ss(e??``,t.type),queryFn:async()=>e?vi(e,{networkUrl:t.nodeUrl}):null,enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ws=new Cn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),Ts=async(e,t,n)=>{if(!n)return{};let r=En(n);try{let n=new URL(`accounts/*`,e),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:v(t).vetDomainsContractAddress,data:ws.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return{};let{resolverAddress:o}=ws.decodeFunctionResult(`resolver`,i);return(await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:s.map(e=>({to:o,data:ws.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=ws.decodeFunctionResult(`text`,t)[0];n&&(e[s[r]]=n)}catch(e){console.error(`Failed to decode text record for ${s[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},Es=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],Ds=e=>{let{network:t}=$(),n=t.nodeUrl??v(t.type).nodeUrl;return X({queryKey:Es(e,t.type),queryFn:()=>Ts(n,t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Os=new Cn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),ks=(e,t)=>{let n=[];for(let{domain:r,key:i,value:a}of t){if(!r)throw Error(`Domain is required`);if(!e)throw Error(`Resolver address is required`);let t=En(r);n.push({to:e,data:Os.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},As=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=H(e=>{if(!r)throw Error(`Resolver address is required`);return ks(r,e)},[r]),a=Cl({signerAccountAddress:n,onTxConfirmed:async()=>{await e?.()},onTxFailedOrCancelled:async()=>{await t?.()},privyUIOptions:{title:`Update Profile Information`,description:`Update the profile information associated with your domain`,buttonText:`Sign to continue`}});return{...a,clauses:i,sendTransaction:async e=>a.sendTransaction(i(e))}},js=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Ms=e=>{let{network:t}=$();return ym({address:v(t.type).vetDomainsContractAddress,abi:Pi.abi,method:`resolver`,args:[e?Ji(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},Ns={Mugshot:new URL(`mugshot.png`,Ye).toString(),Greencart:new URL(`greencart.png`,Ye).toString(),Cleanify:new URL(`cleanify.png`,Ye).toString(),EVearn:new URL(`evearn.png`,Ye).toString()},Ps=()=>{let e=b(`vechain_kit_cross_app_connection`);if(!e)return null;try{let t=JSON.parse(e)?.ecosystemApp?.name;return t?Ns[t]??null:null}catch{return null}},Fs=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],Is=e=>{let{network:t}=$();return X({queryKey:Fs(e),queryFn:async()=>{if(!e||!t.nodeUrl)return Ps()??l(e??``);if(t.type!==`main`&&t.type!==`test`)return Ps()??l(e);let n=await _i(e,{networkUrl:t.nodeUrl});return n&&await vi(n,{networkUrl:t.nodeUrl})||(Ps()??l(e??``))},enabled:!!e&&!!t.nodeUrl,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Ls=new Cn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),Rs=new Cn([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),zs=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=En(n);try{let n=new URL(`accounts/*`,t),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:v(e).vetDomainsContractAddress,data:Ls.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return null;let{resolverAddress:o}=Ls.decodeFunctionResult(`resolver`,i),[{data:s,reverted:c}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:o,data:Ls.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(c||s===`0x`)return null;try{let{avatar:n}=Ls.decodeFunctionResult(`text`,s),r=n===``?null:n;return r?Vs(r,e,t):null}catch(e){return console.error(`Failed to decode avatar data:`,e),null}}catch(e){throw console.error(`Error fetching avatar using legacy API:`,e),e}},Bs=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function Vs(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return S(e,t)||null;let r=e.match(/eip155:(\d+)\/(?:erc721|erc1155):([^/]+)\/(\d+)/);if(r){let[,i,a,o]=r,s=e.includes(`erc1155`);if(!i||!a||o===void 0)return null;let c=[{to:a,data:Rs.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],l=new URL(`accounts/*`,n),[{data:u,reverted:d}]=await fetch(l,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(d)return console.error(`Failed to fetch tokenURI`),null;let f=``;try{f=Rs.decodeFunctionResult(s?`uri`:`tokenURI`,u)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),f=kn(u)}f=S(f,t)||f,s&&(f=f.replace(`{id}`,An(On(BigInt(o||0)),32).slice(2)));let p=await fetch(f);if(!p.ok)return console.error(`Failed to fetch metadata`),null;let m=await p.json(),h=m.image||m.image_url||m.image_data;return h?S(h,t)||h:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const Hs=e=>{let{network:t}=$(),n=t.nodeUrl??v(t.type).nodeUrl;return X({queryKey:Bs(e??``,t.type),queryFn:async()=>e?zs(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},Us=Fi.createInterface(),Ws=(e,t)=>{let n=[];return n.push({to:v(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:Us.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(e?.address??``,4,4)}`,abi:Us.getFunction(`setName`)}),n},Gs=({onSuccess:e,onError:t})=>{let n=dr(),{account:r}=Q(),{network:i}=$(),a=H(()=>Ws(r,i),[r,i]),o=H(async()=>{await is(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=Cl({signerAccountAddress:r?.address??``,privyUIOptions:{title:`Sign to unset your VeChain nickname`,description:`Unset your current VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:o,onTxFailedOrCancelled:t});return{...s,clauses:a,sendTransaction:async()=>s.sendTransaction(a())}},Ks=e=>{let{network:t,allowCommunityTokens:n}=$(),r=Eg(),{data:i,isLoading:a}=km(e),{data:o,isLoading:s}=jc(e),{data:c,isLoading:l}=Bc(e),{data:u,isLoading:d}=Fc(r.veDelegateTokenContractAddress,e),{data:f,isLoading:p}=Fc(r.vvetContractAddress,e,{enabled:!!r.vvetContractAddress}),{data:m,isLoading:h}=Fc(r.sassContractAddress,e,{enabled:n}),g=Nc(e),_=g.map(e=>e.data).filter(Boolean),v=g.some(e=>e.isLoading);return{balances:W(()=>{if(!e)return[];let t={vet:`0x`,vtho:r.vthoContractAddress,b3tr:r.b3trContractAddress,vot3:r.vot3ContractAddress,veDelegate:r.veDelegate,vvet:r.vvetContractAddress},a=[{address:t.vet,symbol:`VET`,balance:i?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:i?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:o?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:c?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:u?.scaled??`0`}];t.vvet&&a.push({address:t.vvet,symbol:`VVET`,balance:f?.scaled??`0`});let s=_.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`})),l=n?[{address:r.sassContractAddress,symbol:`SASS`,balance:m?.scaled??`0`}]:[];return[...a,...s,...l]},[e,i,o,c,u,f,_,n,m,r.sassContractAddress,r.vvetContractAddress,t.type]),isLoading:a||s||l||d||!!r.vvetContractAddress&&p||n&&h||v}},qs={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},Js=async(e,t,n)=>{let r=await e.contracts.load(v(n).oracleContractAddress,Ei.abi).read.getLatestValue(qs[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new Sn(r[0].toString()).div(0xe8d4a51000).toNumber()},Ys=e=>Ba.price.token(e),Xs=e=>{let t=nr(),{network:n}=$();return X({queryKey:Ys(e),queryFn:async()=>Js(t,e,n.type),enabled:!!t&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Zs=1e3,Qs=async({thor:e,order:t=`asc`,offset:n=0,limit:r=Zs,from:i=0,to:a=e.blocks.getHeadBlock()?.number,filterCriteria:o})=>{let s=await e.logs.filterEventLogs({range:{from:i,to:a,unit:`block`},options:{offset:n,limit:r},order:t,criteriaSet:o});if(!s)throw Error(`Failed to fetch events`);return s},$s=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await Qs({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:Zs,order:n,offset:s});if(o.push(...c),c.length<Zs)return o;s+=Zs}},ec=e=>new Sn(e.toString()).shiftedBy(-12).toNumber(),tc=()=>{let e=nr(),{network:t}=$(),n=v(t.type).oracleContractAddress;return X({queryKey:[`VECHAIN_KIT`,`ORACLE_HISTORY_24H`,t.type,n],enabled:!!e&&!!n,staleTime:300*1e3,gcTime:1800*1e3,retry:1,queryFn:async()=>{let r=await e.blocks.getBestBlockExpanded();if(!r)return{history:{},latest:{}};let i=e.contracts.load(n,Ei.abi),a=Object.entries(qs),o=await Promise.all(a.map(async([e,t])=>{try{let n=(await i.read.getLatestValue(t))[0];return[e,ec(n)]}catch{return[e,null]}})),s={};for(let[e,t]of o)t!=null&&(s[e]=t);let c=Math.max(0,r.number-8640),l=i.getEventAbi(`ValueUpdate`),u=await Qs({thor:e,nodeUrl:t.nodeUrl,from:c,to:r.number,order:`asc`,limit:256,filterCriteria:[{criteria:{address:n},eventAbi:l}]}),d=new Map;for(let e of u)try{let t=Vi({abi:Ei.abi,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});if(t.eventName!==`ValueUpdate`)continue;let n=t.args,r=n.id.toLowerCase(),i=d.get(r)??[];i.push({timestamp:Number(e.meta.blockTimestamp),value:ec(n.value)}),d.set(r,i)}catch{}let f={},p=Math.floor(Date.now()/1e3);for(let[e,t]of a){let n=d.get(t.toLowerCase())??[],r=s[e],i=r==null?null:{timestamp:p,value:r},a=i?[...n,i]:n;a.length&&(f[e]=a)}return{history:f,latest:s}}})},nc=()=>{let{data:e}=tc(),t={};if(e?.history)for(let[n,r]of Object.entries(e.history)){if(!r||r.length<2)continue;let e=r[0].value,i=r[r.length-1].value;if(!e)continue;let a=(i-e)/e*100;Number.isFinite(a)&&(t[n]=a)}return{data:t}},rc=e=>{let{data:t,isLoading:n}=tc();return{points:e?t?.history?.[e]??[]:[],isLoading:n}},ic=()=>{let e=Eg(),{data:t,isLoading:n}=Xs(`VET`),{data:r,isLoading:i}=Xs(`VTHO`),{data:a,isLoading:o}=Xs(`B3TR`),{data:s,isLoading:c}=Xs(`EUR`),{data:l,isLoading:u}=Xs(`GBP`),{data:d}=nc();return{prices:W(()=>{let n={vet:`0x`,vtho:e.vthoContractAddress,b3tr:e.b3trContractAddress,vot3:e.vot3ContractAddress,veDelegate:e.veDelegate,SASS:e.sassContractAddress,vvet:e.vvetContractAddress},i={[n.vet]:t||0,[n.vtho]:r||0,[n.b3tr]:a||0,[n.vot3]:a||0,[n.veDelegate]:a||0,[n.SASS]:0};n.vvet&&(i[n.vvet]=t||0);for(let e of Object.keys(i)){let t=e.toLowerCase();t!==e&&i[t]===void 0&&(i[t]=i[e])}return i},[t,r,a,e.vthoContractAddress,e.b3trContractAddress,e.vot3ContractAddress,e.veDelegate,e.sassContractAddress,e.vvetContractAddress]),priceChanges:W(()=>{let t={};if(!d)return t;let n=d.VET,r=d.VTHO,i=d.B3TR;n!==void 0&&(t[`0x`]=n),r!==void 0&&(t[e.vthoContractAddress]=r),i!==void 0&&(t[e.b3trContractAddress]=i,t[e.vot3ContractAddress]=i,t[e.veDelegate]=i),n!==void 0&&e.vvetContractAddress&&(t[e.vvetContractAddress]=n);for(let e of Object.keys(t)){let n=e.toLowerCase();n!==e&&t[n]===void 0&&(t[n]=t[e])}return t},[d,e.vthoContractAddress,e.b3trContractAddress,e.vot3ContractAddress,e.veDelegate,e.vvetContractAddress]),exchangeRates:W(()=>({eurUsdPrice:s||1,gbpUsdPrice:l||1}),[s,l]),isLoading:n||i||o||c||u}},ac=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},oc=(e,t=`en`,n)=>{let r={style:`currency`,currencyDisplay:`narrowSymbol`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(so[t],r).format(e)},sc=(e,t)=>oc(e,lo.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),cc=[`usd`,`eur`,`gbp`],lc=()=>{let{currentCurrency:e,setCurrency:t}=$();return U(()=>{ue(`vechain_kit_currency`,e)},[e]),{currentCurrency:e,allCurrencies:cc,changeCurrency:e=>{if(!cc.includes(e)){console.error(`Invalid currency: ${e}`);return}t(e)}}},uc=({address:e=``})=>{let{balances:t,isLoading:n}=Ks(e),{prices:r,priceChanges:i,exchangeRates:a,isLoading:o}=ic(),{currentCurrency:s}=lc(),c=W(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,o=ac(n,s,a),c=i?.[e.address];return{...e,priceUsd:t,valueUsd:n,valueInCurrency:o,priceChange24hPct:c}}),[t,r,i,s,a]),l=W(()=>[...c].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[c]);return{tokens:c,sortedTokens:l,tokensWithBalance:W(()=>l.filter(e=>Number(e.balance)>0),[l]),isLoading:n||o}},dc=e=>{let t=nr(),{network:n}=$(),r=Eg(),i=r.stargateContractAddress,a=r.stargateNftContractAddress,{prices:o,exchangeRates:s}=ic(),{currentCurrency:c}=lc(),l=o[`0x`]||0,u=!!e&&!!i&&!!a&&!!t,d=X({queryKey:[`VECHAIN_KIT`,`STARGATE_POSITIONS`,n.type,e?.toLowerCase()],enabled:u,staleTime:6e4,queryFn:async()=>{if(!e)return[];let n=ki.abi,r=Ai.abi,o=await t.contracts.load(a,n).read.balanceOf(e),u=Number(o[0]??o);if(!u)return[];let d=(await A({thor:t,calls:Array.from({length:u},(e,t)=>BigInt(t)).map(t=>({abi:n,functionName:`tokenOfOwnerByIndex`,address:a,args:[e,t]}))})).map(e=>e);if(!d.length)return[];let f=await A({thor:t,calls:d.flatMap(e=>[{abi:n,functionName:`getToken`,address:a,args:[e]},{abi:r,functionName:`getDelegationStatus`,address:i,args:[e]}])}),p=[];for(let e=0;e<d.length;e++){let t=f[e*2],n=Number(f[e*2+1]),r=t.vetAmountStaked.toString(),i=Number(Tn(t.vetAmountStaked,18)),a=i*l,o=ac(a,c,s);p.push({tokenId:t.tokenId.toString(),levelId:Number(t.levelId),vetAmountStaked:r,vetAmountFormatted:i,valueUsd:a,valueInCurrency:o,isDelegated:n!==0})}return p}}),f=d.data??[];return{positions:f,totalVet:f.reduce((e,t)=>e+t.vetAmountFormatted,0),totalValueUsd:f.reduce((e,t)=>e+t.valueUsd,0),totalValueInCurrency:f.reduce((e,t)=>e+t.valueInCurrency,0),isLoading:d.isLoading,error:d.error}},fc=[{inputs:[],name:`getReservesList`,outputs:[{name:``,type:`address[]`}],stateMutability:`view`,type:`function`},{inputs:[{name:`user`,type:`address`}],name:`getUserAccountData`,outputs:[{name:`totalCollateralBase`,type:`uint256`},{name:`totalDebtBase`,type:`uint256`},{name:`availableBorrowsBase`,type:`uint256`},{name:`currentLiquidationThreshold`,type:`uint256`},{name:`ltv`,type:`uint256`},{name:`healthFactor`,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{name:`asset`,type:`address`}],name:`getReserveData`,outputs:[{components:[{components:[{name:`data`,type:`uint256`}],name:`configuration`,type:`tuple`},{name:`liquidityIndex`,type:`uint128`},{name:`currentLiquidityRate`,type:`uint128`},{name:`variableBorrowIndex`,type:`uint128`},{name:`currentVariableBorrowRate`,type:`uint128`},{name:`currentStableBorrowRate`,type:`uint128`},{name:`lastUpdateTimestamp`,type:`uint40`},{name:`id`,type:`uint16`},{name:`aTokenAddress`,type:`address`},{name:`stableDebtTokenAddress`,type:`address`},{name:`variableDebtTokenAddress`,type:`address`},{name:`interestRateStrategyAddress`,type:`address`},{name:`accruedToTreasury`,type:`uint128`},{name:`unbacked`,type:`uint128`},{name:`isolationModeTotalDebt`,type:`uint128`}],name:``,type:`tuple`}],stateMutability:`view`,type:`function`}],pc=[{inputs:[{name:`account`,type:`address`}],name:`isNavigator`,outputs:[{name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[{name:`navigator`,type:`address`}],name:`getStake`,outputs:[{name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{name:`citizen`,type:`address`}],name:`isDelegated`,outputs:[{name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[{name:`citizen`,type:`address`}],name:`getDelegatedAmount`,outputs:[{name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{name:`citizen`,type:`address`}],name:`getNavigator`,outputs:[{name:``,type:`address`}],stateMutability:`view`,type:`function`}],mc=e=>{let t=nr(),{network:n}=$(),r=Eg(),i=r.navigatorRegistryContractAddress,a=r.b3trContractAddress,{prices:o,exchangeRates:s}=ic(),{currentCurrency:c}=lc(),l=o[a]||0,u=!!e&&!!i&&!!t,d=X({queryKey:[`VECHAIN_KIT`,`NAVIGATOR_POSITION`,n.type,e?.toLowerCase()],enabled:u,staleTime:6e4,queryFn:async()=>{if(!e)return{isNavigator:!1,isDelegated:!1,stakedB3TR:`0`,delegatedAmount:`0`,navigatorAddress:void 0};let[n,r,a,o,s]=await A({thor:t,calls:[{abi:pc,functionName:`isNavigator`,address:i,args:[e]},{abi:pc,functionName:`getStake`,address:i,args:[e]},{abi:pc,functionName:`isDelegated`,address:i,args:[e]},{abi:pc,functionName:`getDelegatedAmount`,address:i,args:[e]},{abi:pc,functionName:`getNavigator`,address:i,args:[e]}]});return{isNavigator:!!n,isDelegated:!!a,stakedB3TR:r.toString(),delegatedAmount:o.toString(),navigatorAddress:s}}}),f=d.data,p=f?Number(Tn(f.stakedB3TR,18)):0,m=f?Number(Tn(f.delegatedAmount,18)):0,h=p+m,g=h*l,_=ac(g,c,s),v=f?.navigatorAddress,y=v&&v!==`0x0000000000000000000000000000000000000000`?v:void 0;return{isNavigator:!!f?.isNavigator,isDelegated:!!f?.isDelegated,stakedB3TR:p,stakedB3TRRaw:f?.stakedB3TR??`0`,delegatedAmount:m,delegatedAmountRaw:f?.delegatedAmount??`0`,navigatorAddress:y,totalB3TR:h,totalValueUsd:g,totalValueInCurrency:_,isLoading:d.isLoading,error:d.error}},hc=[{inputs:[],name:`symbol`,outputs:[{name:``,type:`string`}],stateMutability:`view`,type:`function`}],gc=e=>{let t=nr(),{network:n}=$();return X({queryKey:[`VECHAIN_KIT`,`BETTERSWAP_PAIRS`,n.type,e],enabled:!!e&&!!t,staleTime:1440*60*1e3,queryFn:async()=>{if(!e)return[];let n=ji.abi,r=await t.contracts.load(e,n).read.allPairsLength(),i=Number(r[0]??r);return i?(await A({thor:t,calls:Array.from({length:i},(e,t)=>BigInt(t)).map(t=>({abi:n,functionName:`allPairs`,address:e,args:[t]}))})).map(e=>e):[]}})},_c=e=>{let t=nr(),{network:n}=$(),r=Eg().betterSwapFactoryAddress,{prices:i,exchangeRates:a}=ic(),{currentCurrency:o}=lc(),{data:s=[],isLoading:c}=gc(r),l=!!e&&Ki(e)&&!!r&&Ki(r)&&!!t&&s.length>0,u=s.length?`${s[0]}-${s[s.length-1]}-${s.length}`:`empty`,d=X({queryKey:[`VECHAIN_KIT`,`BETTERSWAP_LP_POSITIONS`,n.type,e?.toLowerCase(),u],enabled:l,staleTime:6e4,queryFn:async()=>{if(!e||!s.length)return[];let n=Mi.abi,r=s.filter(e=>Ki(e));if(!r.length)return[];let c=await A({thor:t,calls:r.map(t=>({abi:n,functionName:`balanceOf`,address:t,args:[e]}))}),l=[];if(c.forEach((e,t)=>{let n=e;n&&n>0n&&l.push(t)}),!l.length)return[];let u=await A({thor:t,calls:l.flatMap(e=>{let t=r[e];return[{abi:n,functionName:`totalSupply`,address:t,args:[]},{abi:n,functionName:`getReserves`,address:t,args:[]},{abi:n,functionName:`token0`,address:t,args:[]},{abi:n,functionName:`token1`,address:t,args:[]}]})}),d=new Set;for(let e=0;e<l.length;e++){let t=u[e*4+2],n=u[e*4+3];d.add(t.toLowerCase()),d.add(n.toLowerCase())}let f=Array.from(d),p=new Map;f.length&&(await A({thor:t,calls:f.map(e=>({abi:hc,functionName:`symbol`,address:e,args:[]}))})).forEach((e,t)=>{let n=e;p.set(f[t],n??``)});let m=[];for(let e=0;e<l.length;e++){let t=l[e],n=r[t],s=c[t],d=u[e*4],f=u[e*4+1],h=f[0],g=f[1],_=u[e*4+2],v=u[e*4+3],y=Number(Tn(s,18)),b=d>0n?Number(s*1000000n/d)/1e6:0,x=Number(Tn(h,18))*b,S=Number(Tn(g,18))*b,C=i[_.toLowerCase()]||0,w=i[v.toLowerCase()]||0,ee=x*C+S*w,T=ac(ee,o,a);m.push({pairAddress:n,lpBalance:y,sharePct:b*100,token0:{address:_,symbol:p.get(_.toLowerCase())??``,amount:x},token1:{address:v,symbol:p.get(v.toLowerCase())??``,amount:S},valueUsd:ee,valueInCurrency:T})}return m}}),f=d.data??[];return{positions:f,totalValueUsd:f.reduce((e,t)=>e+t.valueUsd,0),totalValueInCurrency:f.reduce((e,t)=>e+t.valueInCurrency,0),isLoading:c||d.isLoading,error:d.error}},vc=async(e,t)=>Si(e,{networkUrl:t}),yc=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],bc=e=>{let{network:t}=$();return X({queryKey:yc(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return vc(e,t.nodeUrl)},enabled:!!t.type&&!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`token address is required`||e===`network node url is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},xc=[{inputs:[{name:`account`,type:`address`}],name:`balanceOf`,outputs:[{name:``,type:`uint256`}],stateMutability:`view`,type:`function`}],Sc=(1n<<256n)-1n,Cc=e=>{let t=nr(),{network:n}=$(),r=Eg().juicyPoolAddress,{prices:i,exchangeRates:a}=ic(),{currentCurrency:o}=lc(),s=!!e&&!!r&&!!t,c=X({queryKey:[`VECHAIN_KIT`,`JUICY_POSITION`,n.type,e?.toLowerCase(),r],enabled:s,staleTime:6e4,queryFn:async()=>{if(!e||!r)return{supplied:[],borrowed:[],healthFactor:null};let s=t.contracts.load(r,fc),c=await s.read.getReservesList(),l=c[0]??c,u=Array.from(l);if(!u.length)return{supplied:[],borrowed:[],healthFactor:null};let d=await A({thor:t,calls:u.map(e=>({abi:fc,functionName:`getReserveData`,address:r,args:[e]}))}),f=u.map((e,t)=>{let n=d[t];return{asset:e,aTokenAddress:n.aTokenAddress,stableDebtTokenAddress:n.stableDebtTokenAddress,variableDebtTokenAddress:n.variableDebtTokenAddress}}),p=await A({thor:t,calls:f.flatMap(t=>[{abi:xc,functionName:`balanceOf`,address:t.aTokenAddress,args:[e]},{abi:xc,functionName:`balanceOf`,address:t.variableDebtTokenAddress,args:[e]},{abi:xc,functionName:`balanceOf`,address:t.stableDebtTokenAddress,args:[e]}])}),m=await s.read.getUserAccountData(e),h=m[5],g=m[1],_=[],v=Array(f.length).fill(0n),y=Array(f.length).fill(0n),b=Array(f.length).fill(0n);for(let e=0;e<f.length;e++){let t=p[e*3],n=p[e*3+1],r=p[e*3+2];v[e]=t,y[e]=n,b[e]=r,(t>0n||n>0n||r>0n)&&_.push(f[e].asset.toLowerCase())}let x=new Map;await Promise.all(_.map(async e=>{try{let t=await vc(e,n.nodeUrl),r=Number(t.decimals);x.set(e,{symbol:t.symbol??e.slice(0,6),decimals:Number.isFinite(r)?r:18})}catch{x.set(e,{symbol:e.slice(0,6),decimals:18})}}));let S=[],C=[];for(let e=0;e<f.length;e++){let t=f[e].asset,n=t.toLowerCase(),r=x.get(n)??{symbol:t.slice(0,6),decimals:18},s=i[n]??i[t]??0,c=v[e];if(c>0n){let e=Number(Tn(c,r.decimals)),n=e*s;S.push({asset:t,symbol:r.symbol,decimals:r.decimals,amount:e,valueUsd:n,valueInCurrency:ac(n,o,a)})}let l=y[e]+b[e];if(l>0n){let e=Number(Tn(l,r.decimals)),n=e*s;C.push({asset:t,symbol:r.symbol,decimals:r.decimals,amount:e,valueUsd:n,valueInCurrency:ac(n,o,a)})}}let w=null;return g>0n&&h<Sc&&(w=Number(Tn(h,18))),{supplied:S,borrowed:C,healthFactor:w}}}),l=c.data,u=l?.supplied??[],d=l?.borrowed??[],f=u.reduce((e,t)=>e+t.valueUsd,0),p=u.reduce((e,t)=>e+t.valueInCurrency,0),m=d.reduce((e,t)=>e+t.valueUsd,0),h=d.reduce((e,t)=>e+t.valueInCurrency,0);return{supplied:u,borrowed:d,totalSuppliedUsd:f,totalSuppliedInCurrency:p,totalBorrowedUsd:m,totalBorrowedInCurrency:h,healthFactor:l?.healthFactor??null,netValueUsd:f-m,netValueInCurrency:p-h,hasPosition:u.length>0||d.length>0,isLoading:c.isLoading,error:c.error}},wc=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=uc({address:e}),{currentCurrency:r}=lc(),i=dc(e),a=mc(e),o=_c(e),s=Cc(e),c=W(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]),l=W(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),u=W(()=>{let e=0,n=0;for(let r of t)typeof r.priceChange24hPct==`number`&&(e+=r.valueUsd*r.priceChange24hPct,n+=r.valueUsd);if(n!==0)return e/n},[t]),d=i.totalValueInCurrency+a.totalValueInCurrency+o.totalValueInCurrency+s.netValueInCurrency,f=i.totalValueUsd+a.totalValueUsd+o.totalValueUsd+s.netValueUsd,p=c+d;return{totalBalanceInCurrency:p,totalBalanceUsd:l+f,liquidBalanceInCurrency:c,liquidBalanceUsd:l,stakingInCurrency:d,stakingUsd:f,priceChange24hPct:u,formattedBalance:W(()=>sc(p,{currency:r}),[p,r]),isLoading:n||i.isLoading||a.isLoading||o.isLoading||s.isLoading,hasAnyBalance:t.length>0||f>0}},Tc=zi.abi,Ec=`currentRoundId`,Dc=e=>gm({abi:Tc,address:e,method:Ec}),Oc=()=>{let{network:e}=$(),t=v(e.type).xAllocationVotingContractAddress;return ym({abi:Tc,address:t,method:Ec,args:[],queryOptions:{select:e=>e[0].toString()}})},kc=()=>{let[e,t]=jh(Ah.CUSTOM_TOKENS,[]),{network:n}=$(),r=Eg(),i=async r=>{if(!o(r)&&!s(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await vc(r,n.nodeUrl),address:r};t([...e,i])}},a=n=>{t(e.filter(e=>e.address!==n))},o=t=>e.some(e=>E(e.address,t)),s=e=>{let t={vet:`0x`,vtho:r.vthoContractAddress,b3tr:r.b3trContractAddress,vot3:r.vot3ContractAddress,veDelegate:r.veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:i,removeToken:a,isTokenIncluded:o,isDefaultToken:s}},Ac=e=>Ba.balance.b3tr(e),jc=e=>{let{network:t}=$(),{b3trContractAddress:n}=Eg();return X({queryKey:Ac(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let r=await bi(n,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get b3tr balance`);let a=r[0];return i(a)},enabled:!!e&&!!t.type})},Mc=(e,t,n)=>Ba.balance.customToken(e,t,Number.isFinite(n)?n:18),Nc=e=>{let{network:t}=$(),{customTokens:n}=kc();return ur({queries:n.map(n=>({queryKey:Mc(n.address,e,Number(n.decimals)),queryFn:async()=>{if(!n.address)throw Error(`Token address is required`);if(!e)throw Error(`Address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);let r=await bi(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let a=i(r[0],Number(n.decimals));return{...n,...a}},enabled:!!e&&T(e)&&!!n.address&&T(n.address)&&!!t.nodeUrl}))})},Pc=(e,t)=>Ba.balance.erc20(e,t),Fc=(e,t,n)=>{let{network:r}=$(),a=!!t&&!!r.type;return X({queryKey:Pc(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let n=await bi(e,t,{networkUrl:r.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let a=n[0];return i(a)},enabled:a&&(n?.enabled??!0)})},Ic=e=>Number(e??`0`)||0,Lc=(e,t)=>{let n=t.vet??[],r=t.vtho??[],i=t.b3tr??[];if(!n.length&&!r.length&&!i.length)return[];let a=Array.from(new Set([...n.map(e=>e.timestamp),...r.map(e=>e.timestamp),...i.map(e=>e.timestamp)])).sort((e,t)=>e-t),o=0,s=0,c=0,l=n[0]?.value??0,u=r[0]?.value??0,d=i[0]?.value??0,f=[];for(let t of a){for(;o<n.length&&n[o].timestamp<=t;)l=n[o].value,o++;for(;s<r.length&&r[s].timestamp<=t;)u=r[s].value,s++;for(;c<i.length&&i[c].timestamp<=t;)d=i[c].value,c++;let a=e.vet*l+e.vtho*u+e.b3tr*d+e.flatUsdOffset;f.push({timestamp:t,value:a})}return f},Rc=e=>{let t=Eg(),{data:n,isLoading:r}=tc(),{balances:i,isLoading:a}=Ks(e),o=dc(e),s=mc(e),c=Cc(e),l=_c(e),u=W(()=>{let e=e=>i.find(t=>t.address.toLowerCase()===e.toLowerCase())?.balance,n=Ic(e(`0x`)),r=Ic(e(t.vthoContractAddress)),a=Ic(e(t.vvetContractAddress)),u=Ic(e(t.b3trContractAddress)),d=Ic(e(t.vot3ContractAddress)),f=Ic(e(t.veDelegate)),p=o.positions.reduce((e,t)=>e+t.vetAmountFormatted,0),m=(s.isNavigator?s.stakedB3TR:0)+(s.isDelegated?s.delegatedAmount:0),h=t.vvetContractAddress.toLowerCase(),g=t.vthoContractAddress.toLowerCase(),_=t.b3trContractAddress.toLowerCase(),v={vet:0,vtho:0,b3tr:0};for(let e of c.supplied){let t=e.asset.toLowerCase();t===h?v.vet+=e.amount:t===g?v.vtho+=e.amount:t===_&&(v.b3tr+=e.amount)}for(let e of c.borrowed){let t=e.asset.toLowerCase();t===h?v.vet-=e.amount:t===g?v.vtho-=e.amount:t===_&&(v.b3tr-=e.amount)}let y=l.totalValueUsd;return{vet:n+a+p+v.vet,vtho:r+v.vtho,b3tr:u+d+f+m+v.b3tr,flatUsdOffset:y}},[i,t.vthoContractAddress,t.vvetContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,o.positions,s.isNavigator,s.isDelegated,s.stakedB3TR,s.delegatedAmount,c.supplied,c.borrowed,l.totalValueUsd]);return{points:W(()=>Lc(u,{vet:n?.history?.VET,vtho:n?.history?.VTHO,b3tr:n?.history?.B3TR}),[u,n?.history]),isLoading:r||a||o.isLoading||s.isLoading||c.isLoading||l.isLoading}},zc=e=>Ba.balance.vot3(e),Bc=e=>{let{network:t}=$(),{vot3ContractAddress:n}=Eg();return X({queryKey:zc(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let r=await bi(n,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get vot3 balance`);let a=r[0];return i(a)},enabled:!!e&&!!t.type})},Vc=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],Hc=e=>{let{network:t}=$();return X({queryKey:Vc(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return xi(e,{networkUrl:t.nodeUrl})},enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`user address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Uc=zi.abi,Wc=`getAppsOfRound`,Gc=(e,t)=>vm({abi:Uc,address:v(t).xAllocationVotingContractAddress,method:Wc,args:[BigInt(e??0)]}),Kc=e=>{let{network:t}=$(),n=v(t.type).xAllocationVotingContractAddress;return ym({abi:Uc,address:n,method:Wc,args:[BigInt(e??0)],queryOptions:{enabled:!!e,select:e=>e[0].map(e=>({id:e.id.toString(),teamWalletAddress:e.teamWalletAddress,name:e.name,metadataURI:e.metadataURI,createdAtTimestamp:e.createdAtTimestamp.toString()}))}})},qc=Ri.abi,Jc=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Yc=(e,t)=>{let n=nr(),{network:r}=$(),i=v(r.type).xAllocationPoolContractAddress;return X({queryKey:Jc(t),queryFn:async()=>(await A({thor:n,calls:e.map(e=>({abi:qc,functionName:`getAppShares`,address:i,args:[t,e]}))})).map((t,n)=>({app:e[n],share:Number(t[0]||0)/100,unallocatedShare:Number(t[1]||0)/100})),enabled:!!t&&!!e.length})},Xc=e=>{let{data:t}=Kc(e),n=Yc(t?.map(e=>e.id)??[],e);return{data:W(()=>n.data?.map(e=>({percentage:e.share+e.unallocatedShare,id:t?.find(t=>t.id===e.app)?.id??``,app:t?.find(t=>t.id===e.app)??{}})).sort((e,t)=>Number(t.percentage)-Number(e.percentage))??[],[n.data,t]),isLoading:n.isLoading}},Zc=()=>{let e=dr();return{refresh:async()=>{await Promise.all([e.invalidateQueries({queryKey:Ba.balance.all}),e.invalidateQueries({queryKey:Ba.price.all})])}}},Qc=({error:e,mobileBrowserPopupMessage:t=`Mobile browser blocked the window. Please try again.`,rejectedMessage:n=`Request was cancelled.`,defaultMessage:r=`Operation failed`})=>{let i=e?.message;return la&&i&&!h(i)?Error(t):i&&h(i)?Error(n):e instanceof Error?e:Error(r)},$c=Hi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[me]}},blockExplorers:{default:{name:`Vechain Explorer`,url:De},vechainStats:{name:`Vechain Stats`,url:Ie}}}),el=()=>ca({id:g,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),tl=({privyEcosystemAppIDS:e,children:t})=>q(ea,{config:xn(ta({chains:[$c],ssr:!0,connectors:[el(),...e.map(e=>ca({id:e,name:``,iconUrl:``}))],transports:{[$c.id]:na()},multiInjectedProviderDiscovery:!1})).current,children:t}),nl=()=>{let{connectAsync:e,connectors:t}=ia(),{signTypedDataAsync:n}=sa(),{signMessageAsync:r}=oa(),{disconnectAsync:i}=aa(),{isConnected:a}=ra(),[o,s]=G(!1),[c,l]=G(null),u=H(async()=>{try{a&&(await i(),O()&&window.dispatchEvent(new Event(`wallet_disconnected`)))}catch(e){throw console.error(`Error during logout:`,e),e}},[i,a]);return{login:H(async n=>{try{s(!0),l(null);let r=t.find(e=>e.id===(n||g));if(!r)throw Error(`Connector not found`);return await e({connector:r})}catch(e){throw l(e),e}finally{s(!1)}},[e,t]),logout:u,signMessage:H(async e=>{try{return await r({message:e})}catch(e){throw Qc({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing a message. Please try again or contact support.`})}},[r]),signTypedData:H(async e=>{try{return await n(e)}catch(e){throw Qc({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing typed data. Please try again or contact support.`})}},[n]),isConnecting:o,connectionError:c}},rl=(e,t)=>{let{data:n,isLoading:r}=$o(e??``),{data:i,isLoading:a}=Is(e??``),{data:o,isLoading:s}=Ds(n?.domain??``),c=o?.header?S(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},il=()=>{let{network:e}=$(),t=H(e=>({wallets:`vechain_kit_wallets_${e}`,activeWallet:`vechain_kit_active_wallet_${e}`}),[]),n=H(()=>{if(!O())return[];let n=b(t(e.type).wallets);return n?JSON.parse(n):[]},[e.type,t]),r=H(()=>O()?b(t(e.type).activeWallet):null,[e.type,t]),i=H(r=>{if(!O())return;let i=t(e.type),a=n(),o=a.findIndex(e=>e.address.toLowerCase()===r.toLowerCase()),s={address:r,connectedAt:o>=0?a[o].connectedAt:Date.now(),isActive:!1};o>=0?a[o]=s:a.push(s),ue(i.wallets,JSON.stringify(a))},[e.type,t,n]),a=H(r=>{if(!O())return;let i=t(e.type),a=n().map(e=>({...e,isActive:e.address.toLowerCase()===r.toLowerCase()}));ue(i.wallets,JSON.stringify(a)),ue(i.activeWallet,r)},[e.type,t,n]);return{getStoredWallets:n,getActiveWallet:r,saveWallet:i,setActiveWallet:a,removeWallet:H(i=>{if(!O())return;let a=t(e.type),o=n().filter(e=>e.address.toLowerCase()!==i.toLowerCase());ue(a.wallets,JSON.stringify(o));let s=r();s&&s.toLowerCase()===i.toLowerCase()&&C(a.activeWallet),O()&&window.dispatchEvent(new CustomEvent(`wallet_removed`,{detail:{address:i}}))},[e.type,t,n,r]),initializeCurrentWallet:H(e=>{O()&&n().length===0&&(i(e),a(e))},[n,i,a])}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=ra(),{logout:i}=nl(),{loading:a}=Kn({}),{feeDelegation:o,network:s,privy:c}=$(),{user:l,authenticated:u,logout:d,ready:f}=Xn(),{data:p}=ph(),{account:m,disconnect:h}=rr(),{getConnectionCache:_,clearConnectionCache:v}=om(),y=_(),{initializeCurrentWallet:b,getActiveWallet:x,saveWallet:S,getStoredWallets:C}=il(),w=wm(),ee=W(()=>O()?!!window.vechain?.isInAppBrowser:!1,[]),T=!!m,D=u&&!!l,k=D||t,te=D&&c?.appId===g||t&&y?.ecosystemApp?.appId===g,A=n||r||a||!f,[ne,re]=G(!1),ie=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:T?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};U(()=>{let e=T||D||t;ne!==e&&(re(e),e||(v(),O()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[T,D,t,v,ne]);let ae=l?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,oe=T?m:t?e:ae,[se,ce]=G(()=>T&&!ee?x():null);U(()=>{ce(T&&!ee?x():null)},[T,ee,x]);let[le,ue]=G(!1);U(()=>{if(!O()||!T||ee)return;let e=e=>{ue(!0),ce(e.detail.address),setTimeout(()=>{ue(!1)},1e3)};return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[T,ee]);let de=C().some(e=>e.address.toLowerCase()===oe?.toLowerCase()),fe=T&&!ee?x():null,pe=le&&fe||fe&&de?fe:oe,{data:me}=$m(pe??``),he=T?pe:me?.address,ge=rl(he??``,s.type),_e=rl(pe??``,s.type),ve=rl(me?.address??``,s.type),{setActiveWallet:ye}=il(),be=xn(new Set);U(()=>{if(!O()||!T||ee)return;let e=e=>{be.current.add(e.detail.address.toLowerCase()),setTimeout(()=>{be.current.delete(e.detail.address.toLowerCase())},5e3)};return window.addEventListener(`wallet_removed`,e),()=>{window.removeEventListener(`wallet_removed`,e)}},[T,ee]),U(()=>{if(T&&!ee&&oe&&ge&&!ge.isLoading){if(be.current.has(oe.toLowerCase()))return;let e=!C().some(e=>e.address.toLowerCase()===oe.toLowerCase());b(oe),S(oe);let t=!se,n=se&&se.toLowerCase()===oe.toLowerCase();(e||t||n)&&!le&&ye(oe)}},[T,ee,oe,ge?.domain,ge?.image,ge?.isLoading,b,S,ye,se,C]),U(()=>{T&&!ee&&se&&se.toLowerCase()===pe?.toLowerCase()&&S(se)},[T,ee,se,pe,S]);let xe=he?{address:he,domain:ge.domain,image:ge.image,isLoadingMetadata:ge.isLoading,metadata:ge.records}:null,Se=oe?{address:oe,domain:_e.domain,image:_e.image,isLoadingMetadata:_e.isLoading,metadata:_e.records}:null,{data:Ce}=Vm(me?.address??``,Se?.address??``),we=!!me?.address&&!!xe?.address&&E(me?.address,xe?.address),Te=H(async()=>{try{re(!1),T?h():D?await d():t&&await i(),v(),O()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[T,h,D,d,t,i,v]);return{account:xe,smartAccount:{address:me?.address??``,domain:ve.domain,image:ve.image,isDeployed:me?.isDeployed??!1,isActive:we,version:Ce?.version??null,isLoadingMetadata:ve.isLoading,metadata:ve.records},connectedWallet:Se,privyUser:l,connection:{isLoading:A,isConnected:ne,isConnectedWithSocialLogin:D,isConnectedWithDappKit:T,isConnectedWithCrossApp:t,isConnectedWithPrivy:k,isConnectedWithVeChain:te,source:ie,isInAppBrowser:ee,nodeUrl:w,delegatorUrl:o?.delegatorUrl,chainId:p,network:s.type},disconnect:Te}},al=()=>{let{switchWallet:e}=rr(),{connection:t}=Q(),[n,r]=G(!1),{getStoredWallets:i,setActiveWallet:a,removeWallet:o}=il(),s=t.isInAppBrowser;return{switchWallet:H(async()=>{if(s){if(!e)return;r(!0);try{await e()}catch{}finally{r(!1)}}else return Promise.resolve()},[e,s]),isSwitching:n,getStoredWallets:i,setActiveWallet:H(e=>{a(e),O()&&window.dispatchEvent(new CustomEvent(`wallet_switched`,{detail:{address:e}}))},[a]),removeWallet:o,isInAppBrowser:s}},ol=async(e,t)=>{let n=S(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},sl=Li.abi,cl=e=>{let t=nr(),{network:n}=$();return X({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=v(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,sl),a=(await i.read.app(e))[0][3]?.toString()||``,[o]=await i.read.baseURI();return await ol(`${o}${a}`,n.type)},enabled:!!e})},ll=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=S(t,e);if(!r)throw Error(`Invalid URI`);let i=await(await fetch(r,{headers:{"X-Project-Id":`vechain-kit`}})).text();return n?JSON.parse(i):i},ul=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],dl=(e,t=!1)=>{let{network:n}=$();return X({queryKey:ul(n.type,e),queryFn:()=>ll(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0})},fl=1024*1024*10,pl=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(S(t,e)??``,{headers:{"X-Project-Id":`vechain-kit`}});if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.blob();if(![`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/bmp`,`image/tiff`,`image/webp`,`image/svg+xml`].includes(r.type))throw Error(`Unsupported MIME type: ${r.type}`);if(r.size>fl)throw Error(`Image size exceeds maximum allowed size`);return new Promise((e,t)=>{let n=new FileReader;n.readAsDataURL(r),n.onloadend=()=>{e({image:n.result,mime:r.type,mediaType:m(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},ml=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],hl=e=>{let{network:t}=$();return X({queryKey:ml(t.type,e),queryFn:()=>pl(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0})},gl=e=>{let{network:t}=$();return ur({queries:e.map(e=>({queryKey:ml(t.type,e),queryFn:()=>pl(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0}))})},_l=(e,t=!1)=>{let{network:n}=$();return ur({queries:e.map(e=>({queryKey:ul(n.type,e),queryFn:async()=>ll(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0}))})},vl={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},yl=async e=>{let t=[];try{for(let n of e){let e=await ua(n.file,vl);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},bl=({compressImages:e,defaultImages:t})=>{let[n,r]=G(t??[]);U(()=>{t&&r(t)},[t]);let[i,a]=G([]),o=H(e=>r(t=>t.filter((t,n)=>n!==e)),[]);return{uploadedImages:n,setUploadedImages:r,onUpload:H(async(t,n=!0)=>{a([]);let i=[];for(let n of t){let t=n;e&&(t=await ua(n,vl));let r={file:t,image:URL.createObjectURL(n)};i.push(r)}r(e=>[...i,...n?e.filter(e=>!i.some(t=>t.file.name===e.file.name)):[]])},[e]),onRemove:o,invalidDateError:i}},xl=({compressImage:e,defaultImage:t})=>{let[n,r]=G(t);U(()=>{t&&r(t)},[t]);let i=H(()=>r(void 0),[]);return{uploadedImage:n,setUploadedImage:r,onUpload:H(async t=>{let n=t;e&&(n=await ua(n,vl));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},Sl=async(e,t,n,r)=>{let i=await e.transactions.estimateGas(t,n,r);if(i.reverted)throw Error(`Failed to estimate gas`);let a=i?.totalGas??0;return(!a||Number.isNaN(a))&&(a=0),Math.ceil(a)},Cl=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o,delegationUrl:s})=>{let c=nr(),{signer:l,requestTransaction:u}=ir(),{connection:d}=Q(),{feeDelegation:f}=$(),p=wm(),m=wg(),h=H(async(t,n,r)=>{let a=typeof t==`function`?await t():t??[];if(d.isConnectedWithPrivy)return await m.sendTransaction({txClauses:a,...r,delegationUrl:n});if(!e)throw Error(`signerAccountAddress is required`);let s=0;try{s=await Sl(c,[...a],e,{revision:In.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}return(await u(a,{signer:d.isConnectedWithDappKit&&!d.isInAppBrowser&&e?e:l.address,gas:i??s,...f?.delegateAllTransactions||n?{delegator:{url:n??f?.delegatorUrl??``,signer:e}}:{}})).txid},[e,i,p,m,a,f,c,l,o,s,u,d.isConnectedWithDappKit,d.isInAppBrowser]),[g,_]=G(null),[v,y]=G(!1),[b,x]=G(null),S=H(async(e,n)=>{if(!e&&!t)throw Error(`clauses are required`);try{_(null),y(!0),x(null),D(void 0),_(await h(e??[],n,{...a}))}catch(e){x(e&&typeof e==`object`&&`message`in e?e.message:String(e)),r?.(e instanceof Error?e:Error(String(e)))}finally{y(!1)}},[h,t,a,s]),{data:C,isLoading:w,error:ee}=Sh(g??``),T=H(async e=>{if(!(!e.reverted||!e.meta.txID))return await c.transactions.getRevertReason(e.meta.txID)},[c]),[E,D]=G(),O=W(()=>{if(v)return`pending`;if(b)return`error`;if(g){if(w)return`waitingConfirmation`;if(ee)return`error`;if(C)return C.reverted?`error`:`success`}return`ready`},[w,b,v,g,C,ee]);U(()=>{if(O===`success`||O===`error`){if(b&&!E){D({type:`UserRejectedError`,reason:b});return}if(C?.reverted&&!E?.type){(async()=>{let e=await T(C);D({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}C&&!C.reverted&&n?.()}},[O,C,n,T,b]);let k=H(()=>{_(null),y(!1),x(null),D(void 0)},[]);return{sendTransaction:S,isTransactionPending:W(()=>v||w||O===`pending`||O===`waitingConfirmation`,[v,w,O]),isWaitingForWalletConfirmation:W(()=>O===`pending`,[v,O]),txReceipt:C??null,status:O,resetStatus:k,error:E}},wl=(e,t)=>{let{account:n}=Q(),{t:r}=Y(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=Cl({signerAccountAddress:n?.address??``,privyUIOptions:{title:r(`ConfirmSwapTitle`,{defaultValue:`Confirm Swap`}),description:r(`ConfirmSwapDescription`,{defaultValue:`Please confirm the swap transaction in your wallet`}),buttonText:r(`Confirm`,{defaultValue:`Confirm`})}});return{executeSwap:H(async()=>{if(!e||!t)throw Error(`Missing swap parameters or quote`);if(!t.aggregator)throw Error(`Aggregator not found for quote from ${t.aggregatorName}`);let n=await t.aggregator.buildSwapTransaction(e,t);if(n.length===0)throw Error(`Failed to build swap transaction`);await i(n)},[e,t,i]),isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}},Tl=e=>e===`0x`||e===Qi,El=(e,t,n,r)=>{let i={},a=r.toLowerCase();for(let t of e)try{let e=Vi({abi:Pn,eventName:`Transfer`,topics:t.topics,data:t.data}),n=e.args.from.toLowerCase(),r=e.args.to.toLowerCase(),o=e.args.value,s=typeof o==`bigint`?o:BigInt(o);if(n!==a&&r!==a)continue;let c=t.address.toLowerCase(),l=i[c]??{inflow:0n,outflow:0n};n===a&&(l.outflow+=s),r===a&&(l.inflow+=s),i[c]=l}catch{continue}if(n!==void 0){let e=BigInt(n);if(e>0n){let t=i[Qi]??{inflow:0n,outflow:0n};t.outflow+=e,i[Qi]=t}}for(let e of t){if(e.recipient.toLowerCase()!==a)continue;let t=BigInt(e.amount);if(t<=0n)continue;let n=i[Qi]??{inflow:0n,outflow:0n};n.inflow+=t,i[Qi]=n}return i},Dl=async(e,t,n,r)=>{try{if(n.length===0)return{gasCostVTHO:0,success:!1,error:`No clauses found for simulation`};let i=await r.transactions.simulateTransaction(n,{caller:e.userAddress}),a=!1,o,s=2e5,c={};for(let t=0;t<i.length;t++){let r=i[t];r.reverted&&(a=!0,o=r.vmError||`Transaction reverted`),s+=r.gasUsed;let l=n[t],u=El(r.events,r.transfers,l?.value,e.userAddress);for(let[e,t]of Object.entries(u)){let n=c[e]??{inflow:0n,outflow:0n};c[e]={inflow:n.inflow+t.inflow,outflow:n.outflow+t.outflow}}}if(a)return{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`};let l=s/1e5,u=Tl(e.fromTokenAddress),d=Tl(e.toTokenAddress),f=BigInt(e.amountIn);if(u){let e=c[Qi]??{inflow:0n,outflow:0n};if(e.outflow>f)return{gasCostVTHO:l,success:!1,error:`VET outflow mismatch: expected ${f.toString()}, got ${e.outflow.toString()}`};for(let[e,t]of Object.entries(c))if(e!==Qi&&t.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: token ${e} has outflow ${t.outflow.toString()}, expected 0`}}else{let t=e.fromTokenAddress.toLowerCase(),n=c[t]??{inflow:0n,outflow:0n};if(n.outflow>f)return{gasCostVTHO:l,success:!1,error:`Token outflow mismatch: expected ${f.toString()}, got ${n.outflow.toString()}`};for(let[e,n]of Object.entries(c))if(e!==t&&n.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: ${e===Qi?`VET`:e} has outflow ${n.outflow.toString()}, expected 0`}}if(t.minimumOutputAmount&&t.minimumOutputAmount>0n)if(d){let e=c[Qi]??{inflow:0n,outflow:0n};if(e.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`VET inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${e.inflow.toString()}`}}else{let n=c[e.toTokenAddress.toLowerCase()]??{inflow:0n,outflow:0n};if(n.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`Token inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${n.inflow.toString()}`}}return{gasCostVTHO:l,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},Ol=e=>e.startsWith(`0x`)?BigInt(e).toString():e,kl=(e,t)=>({name:e,type:`function`,inputs:t.map(e=>({name:e.name,type:e.type,internalType:e.internalType,components:e.components})),outputs:[],stateMutability:`nonpayable`}),Al=(e,t)=>{if(Array.isArray(e)&&e.length>0){let n=e[0];if(typeof n==`object`&&`name`in n&&`type`in n&&n.type===`function`)return e;if(typeof n==`object`&&`name`in n&&`type`in n&&!(`stateMutability`in n||`outputs`in n))return[kl(t,e)]}return e},jl=e=>{try{let t=e.functionName||e.name;if(!t)throw Error(`Function name is required (either functionName or name must be provided)`);return Ui({abi:Al(e.abi,t),functionName:t,args:e.args})}catch(t){console.error(`Failed to encode function call:`,t);let n=e.functionName||e.name||`unknown`;throw Error(`Failed to encode function call ${n}: ${t instanceof Error?t.message:`Unknown error`}`)}},Ml=e=>{let t=jl(e.functionCall);return{to:e.to,value:Ol(e.value),data:t,comment:e.comment||`Swap on aggregator`}},Nl=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){try{let r=new URLSearchParams({fromAddress:n.fromTokenAddress,toAddress:n.toTokenAddress,amountIn:n.amountIn,recipient:n.userAddress,slippageBps:String((n.slippageTolerance||1)*100),network:e.network}),i=new URL(e.apiBaseUrl);i.search=r.toString();let a=await fetch(i);if(!a.ok)throw Error(`API request failed: ${a.status} ${a.statusText}`);let o=await a.json(),s=o.clauses.map(Ml),c=BigInt(o.amountOut),l=BigInt(o.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:c,minimumOutputAmount:l,priceImpact:0,data:{clauses:s,path:o.path}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{clauses:[],path:[]}}}},async simulateSwap(e,t,n){try{return Dl(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Failed to build swap transaction for simulation`}}},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`clauses`in n.data))throw Error(`Invalid quote data: clauses not found`);let r=n.data.clauses;if(r.length===0)throw Error(`No clauses found in quote`);if(e.supportedAddresses&&e.supportedAddresses.length>0){let t=e.supportedAddresses.map(e=>e.toLowerCase());if(r=r.filter(e=>e.to?t.includes(e.to.toLowerCase()):!1),r.length===0)throw Error(`No clauses found matching supported addresses`)}if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);return r}};return t},Pl={main:{supportedAddresses:[`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,`0x7C755EC0165fCD926cC6faB10E7BB16a72E9f34A`]},test:{supportedAddresses:[]},solo:{supportedAddresses:[]}},Fl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,Il=e=>new URL(`api/quote/vck`,we).toString(),Ll=e=>{let t=Pl[e]??Pl.main,n=Nl({name:`VeTrade.vet`,apiBaseUrl:Il(e),network:e,getIcon:(e=`20px`)=>V.createElement(qe,{boxSize:e}),supportedAddresses:t.supportedAddresses});return{...n,async simulateSwap(e,t,n){try{return Dl(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(e,r){let i=[],a=await n.buildSwapTransaction(e,r);if(!a||a.length===0)throw Error(`Failed to build swap transaction`);if(Fl(e.fromTokenAddress))a[0].value=e.amountIn;else{if(t.supportedAddresses.length===0)throw Error(`No supported addresses configured for VeTrade on this network`);let n=jn.ofAbi(Ti.abi),o=Mn.of(e.fromTokenAddress),s=BigInt(e.amountIn);i.push(Nn.callFunction(o,n.getFunction(`approve`),[a[0].to,s.toString()],zn.of(0n,Rn.wei),{comment:`Approve ${r.aggregatorName} to access ${e.fromTokenAddress}`}))}return i.push(...a),i}}},Rl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,zl=()=>BigInt(Math.floor(Date.now()/1e3)+1200),Bl=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[Rl(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,Rl(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,Ni.abi).read.getAmountsOut(a,i),s=Array.isArray(o)?o:[o],c=s[s.length-1];if(!c||c===0n)throw Error(`Output amount is zero or invalid`);if(typeof c!=`bigint`)throw Error(`Output amount is not a valid bigint`);let l=n.slippageTolerance||1,u=c*BigInt(1e4-l*100)/BigInt(1e4);return{aggregatorName:e.name,aggregator:t,outputAmount:c,priceImpact:0,minimumOutputAmount:u,data:{path:i,routerAddress:e.routerAddress}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{path:i,routerAddress:e.routerAddress}}}},async simulateSwap(e,t,n){return Dl(e,t,await this.buildSwapTransaction(e,t),n)},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`path`in n.data))throw Error(`Invalid quote data`);let r=zl();if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);let i=n.minimumOutputAmount,a=BigInt(t.amountIn);if(i===0n)throw Error(`Invalid quote: minimumOutputAmount is zero`);let o=Rl(t.fromTokenAddress),s=Rl(t.toTokenAddress),c=jn.ofAbi(Ni.abi),l=[];if(o)l.push(Nn.callFunction(Mn.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],zn.of(a,Rn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=jn.ofAbi(Ti.abi),u=Mn.of(t.fromTokenAddress),d=Mn.of(e.routerAddress);l.push(Nn.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],zn.of(0n,Rn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(Nn.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],zn.of(0n,Rn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(Nn.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],zn.of(0n,Rn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},Vl={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Qi,wrappedVET:Qi},solo:{routerAddress:Qi,wrappedVET:Qi}},Hl=e=>{let t=Vl[e]??Vl.main;return Bl({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Ue,{boxSize:e})})},Ul=e=>[Ll(e),Hl(e)],Wl=(e,t,n,r,i=1,a=!0)=>{let o=nr(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=bc(c===`0x`||c===Qi||!c?``:c),{data:d}=bc(l===`0x`||l===Qi||!l?``:l),f=W(()=>!c||c===`0x`||c===Qi||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=W(()=>!l||l===`0x`||l===Qi||!d?18:Number(d?.decimals??18),[l,d?.decimals]),m=W(()=>{if(!c||!l||!n||!r)return null;let e;try{e=Xi(n,f)}catch(e){return console.error(`Failed to parse amount:`,n,e),null}return e<=0n?null:{fromTokenAddress:c,toTokenAddress:l,amountIn:e.toString(),userAddress:r,slippageTolerance:i}},[c,l,n,r,i,f]),{data:h,isLoading:g,error:_}=X({queryKey:[`unified-swap-quotes`,m,s.network],queryFn:async()=>{if(!m||!o||!s.network)return{quotes:[],best:null};let e=Ul(s.network).map(async e=>{try{let t=await e.getQuote(m,o);try{let n=await e.simulateSwap(m,t,o);return{...t,aggregator:e,reverted:!n.success,revertReason:n.error,gasCostVTHO:n.gasCostVTHO}}catch(n){return console.error(`Failed to simulate swap for ${e.name}:`,n),{...t,aggregator:e,reverted:!0,revertReason:n instanceof Error?n.message:`Simulation failed`,gasCostVTHO:0}}}catch(t){return console.error(`Failed to get quote from ${e.name}:`,t),null}}),t=(await Promise.all(e)).filter(e=>e!==null&&e.outputAmount!==0n),n=null;if(t.length>0){let e=t.filter(e=>!(e.reverted??!1));n=(e.length>0?e:t).reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e})}return{quotes:t,best:n}},enabled:a&&m!==null&&o!=null,refetchInterval:1e4});return{bestQuote:h?.best??null,quotes:h?.quotes??[],isLoading:g,error:_,from:e?{...e,address:c??``,decimals:f}:null,to:t?{...t,address:l??``,decimals:p}:null}},Gl=`0x`,Kl=`0x0000000000000000000000000000456e65726779`,ql=(e,t)=>(e??``).toLowerCase()===(t??``).toLowerCase(),Jl=(e,t,n)=>[`VECHAIN_KIT`,`TRANSFER_HISTORY`,t,e?.toLowerCase(),n?n.toLowerCase():`all`],Yl=(e,{tokenAddress:t,enabled:n=!0}={})=>{let{network:r}=$(),i=Eg(),{balances:a}=Ks(e),o=new Map,s=new Set([`0x`,Kl,i.b3trContractAddress,i.vot3ContractAddress,i.veDelegateTokenContractAddress,i.vvetContractAddress].filter(Boolean).map(e=>e.toLowerCase()));o.set(`0x`,{symbol:`VET`,decimals:18}),o.set(`0x0000000000000000000000000000456e65726779`,{symbol:`VTHO`,decimals:18});for(let e of a)!e.address||!e.symbol||s.has(e.address.toLowerCase())&&o.set(e.address.toLowerCase(),{symbol:e.symbol,decimals:18});let c=i.indexerUrl,l=t===`0x`,u=!!c&&r.type!==`solo`,d=lr({queryKey:Jl(e,r.type,t??null),initialPageParam:0,getNextPageParam:(e,t)=>e.hasNext?t.length:void 0,queryFn:async({pageParam:n=0})=>{if(!e)return{items:[],hasNext:!1};let i=new URLSearchParams({address:e.toLowerCase(),page:String(n)});l?i.set(`eventType`,`VET`):t&&i.set(`tokenAddress`,t.toLowerCase());let a=await fetch(`${c}/transfers?${i.toString()}`);if(!a.ok)throw Error(`Indexer request failed: ${a.status}`);let s=await a.json(),u=(s.data??[]).filter(e=>e.eventType!==`NFT`).filter(e=>t?l?e.eventType===`VET`:ql(e.tokenAddress,t):!0),d=new Set;for(let e of u){if(e.eventType!==`FUNGIBLE_TOKEN`||!e.tokenAddress)continue;let t=e.tokenAddress.toLowerCase();o.has(t)||d.add(t)}if(d.size&&r.nodeUrl){let e=Array.from(d);(await Promise.allSettled(e.map(e=>vc(e,r.nodeUrl)))).forEach((t,n)=>{if(t.status!==`fulfilled`||!t.value)return;let r=t.value;if(!r.symbol)return;let i=Number(r.decimals);o.set(e[n],{symbol:r.symbol,decimals:Number.isFinite(i)?i:18})})}return{items:u.map(t=>{let n=t.eventType===`VET`,r=n?`0x`:(t.tokenAddress??``).toLowerCase(),i=o.get(r),a=i?.decimals??18,s=i?.symbol??(n?`VET`:t.tokenAddress?.slice(0,6)??``),c=ql(t.from,e)?`sent`:`received`,l=0;try{l=Number(Tn(BigInt(t.value),a))}catch{l=0}return{id:t.id,txId:t.txId,blockNumber:t.blockNumber,timestamp:t.blockTimestamp,direction:c,from:t.from,to:t.to,tokenAddress:n?null:t.tokenAddress??null,tokenSymbol:s,tokenDecimals:a,rawValue:t.value,amount:l,eventType:t.eventType}}),hasNext:!!s.pagination?.hasNext}},enabled:n&&!!e&&u,staleTime:3e4});return{transfers:d.data?.pages.flatMap(e=>e.items)??[],isLoading:d.isLoading,isFetching:d.isFetching,isFetchingNextPage:d.isFetchingNextPage,hasNextPage:!!d.hasNextPage,fetchNextPage:d.fetchNextPage,isUnsupportedNetwork:!u,error:d.error}},Xl=(e,t,n={})=>Yl(e,{tokenAddress:t??void 0,enabled:n.enabled}),Zl=({email:e,onResend:t,isLoading:n,isOpen:r,onClose:i})=>{let{t:a}=Y(),{darkMode:o}=$(),s=B(`colors`,`vechain-kit-text-secondary`),[c,l]=G(``),[u,d]=G(null),{createWallet:f}=Wn(),{loginWithCode:p}=Gn({onComplete:async({isNewUser:e})=>{e&&await f()}});return U(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),J(Ko,{isOpen:r,onClose:i,trapFocus:!1,children:[J(Z,{children:[q(L,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),q(I,{})]}),J(_t,{maxW:`container.lg`,children:[q(F,{children:J(z,{spacing:2,children:[q(P,{as:Xr,w:`48px`,h:`48px`,color:s}),q(R,{fontSize:`xs`,color:s,textAlign:`center`,children:a(`Please check {{email}} for an email from privy.io and enter your code below.`,{email:e})}),q(N,{spacing:2,justify:`center`,mt:4,children:J(Rt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(zt,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`})]})}),u&&q(R,{color:`#ef4444`,fontSize:`xs`,children:u})]})}),q(It,{children:J(R,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,q(M,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},Ql=()=>{let{t:e}=Y(),{darkMode:t}=$(),[n,r]=G(``),{sendCode:i,state:a}=Gn({}),o=hn(),s=async()=>{await i({email:n}),o.onOpen()};return J(K,{children:[q(Ct,{colSpan:4,w:`full`,children:q(z,{spacing:3,w:`full`,children:J(Ot,{size:`lg`,w:`full`,children:[q(kt,{pointerEvents:`none`,height:`100%`,pl:4,children:q(P,{as:Xr,color:t?`whiteAlpha.600`:`blackAlpha.700`,w:`20px`,h:`20px`})}),q(Dt,{placeholder:e(`your@email.com`),value:n,onChange:e=>r(e.target.value),fontSize:`16px`,fontWeight:`400`,backgroundColor:t?`transparent`:`#ffffff`,border:`1px solid ${t?`#ffffff0a`:`#ebebeb`}`,p:6,borderRadius:16,w:`full`,pl:12}),q(M,{"aria-label":`Send code`,position:`absolute`,right:2,top:`50%`,transform:`translateY(-50%)`,zIndex:2,variant:`ghost`,size:`sm`,px:6,borderRadius:`full`,isLoading:a.status===`sending-code`,onClick:s,children:e(`Submit`)})]})})}),q(Zl,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},$l=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=am(),[i,a,o]=B(`colors`,[`vechain-kit-border-button`,`vechain-kit-border-hover`,`vechain-kit-button-secondary-bg`]);return q(Ct,{colSpan:t??4,w:`full`,children:q(jf,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:ha,iconWidth:`24px`,text:n(`Continue with Google`),style:{bg:`transparent`,border:`1px solid ${i}`,_hover:{bg:o,borderColor:a,opacity:1}}})})},eu=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=am(),[i,a,o,s]=B(`colors`,[`vechain-kit-border-button`,`vechain-kit-border-hover`,`vechain-kit-button-secondary-bg`,`vechain-kit-text-primary`]);return q(Ct,{colSpan:t??4,w:`full`,children:q(jf,{isDark:e,onClick:async()=>{await r({provider:`apple`})},customIcon:q(P,{as:ga,w:`24px`,h:`24px`,color:s}),text:n(`Continue with Apple`),style:{bg:`transparent`,border:`1px solid ${i}`,_hover:{bg:o,borderColor:a,opacity:1}}})})},tu=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=am();return q(Ct,{colSpan:t??4,w:`full`,children:q(jf,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:Hr,text:n(`Continue with Github`)})})},nu=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=Yn();return q(Ct,{colSpan:t||4,w:`full`,children:q(jf,{isDark:e,onClick:r,icon:e?be:Ge,text:n(`Login with social`),variant:`loginWithVechain`,rightIcon:q(Lf,{})})})},ru=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=Y(),{login:i}=sm(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting to VeChain`),loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:a}});try{await i()}catch(e){console.error(r(`Login failed:`),e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with VeChain`),onTryAgain:a}})}};return q(Ct,{colSpan:t||4,w:`full`,children:q(jf,{isDark:e,onClick:a,icon:e?be:Ge,text:r(`Login with social`),variant:`loginWithVechain`,rightIcon:q(Lf,{})})})},iu=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=Y(),{loginWithPasskey:i}=rm(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting with Passkey`),loadingText:r(`Please complete the passkey authentication...`),onTryAgain:a}});try{await i()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&console.error(e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with Passkey`),onTryAgain:a}})}};return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:a,icon:zr,text:t&&t>=2?r(`Passkey`):void 0})})},au=({isDark:e,gridColumn:t=2})=>{let{t:n}=Y(),{open:r,onConnectionStatusChange:i}=ar(),{dappKit:a}=$(),{source:o}=ir(),s=a?.allowedWallets?.includes(`sync2`)?n(`Connect wallet`):n(`Connect with VeWorld wallet`);return U(()=>{i((e,t)=>{if(!e)return t?.message&&console.error(t?.message),{...o&&{source:o}}})},[i,o]),q(Ct,{colSpan:t||2,w:`full`,children:q(jf,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?pi:e?Se:Ve,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&q(P,{as:vr})||void 0})})},ou=`#16a34a`,su=()=>q(j,{w:`6px`,h:`6px`,borderRadius:`full`,bg:ou,boxShadow:`0 0 0 3px ${ou}2e`,mr:`3px`,flexShrink:0,"aria-hidden":!0}),cu=({isDark:e,gridColumn:t=4,setCurrentContent:n})=>{let{t:r}=Y(),{connect:i}=um(`veworld`,n),a=e?`#ffffff`:`#0E0D18`,o=e?`#0E0D18`:`#ffffff`;return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:i,customIcon:q(e?Ve:Se,{w:`24px`,h:`24px`}),text:t>=2?r(`Continue with VeWorld`):void 0,rightIcon:q(su,{}),style:{bg:a,color:o,border:`none`,_hover:{bg:a,opacity:.92}}})})},lu=({isDark:e,gridColumn:t=4,setCurrentContent:n})=>{let{t:r}=Y(),{connect:i}=um(`sync2`,n);return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:i,icon:pi,text:t>=2?r(`Continue with Sync2`):void 0})})},uu=({isDark:e,gridColumn:t=4,setCurrentContent:n})=>{let{t:r}=Y(),{connect:i}=um(`wallet-connect`,n);return q(Ct,{colSpan:t,w:`full`,children:q(jf,{isDark:e,onClick:i,icon:ti,text:t>=2?r(`Continue with WalletConnect`):void 0})})},du=({setCurrentContent:e})=>{let{t}=Y(),{loginMethods:n,darkMode:r}=$(),{showGoogleLogin:i,showAppleLogin:a,showEmailLogin:o,showPasskey:s,showVeChainLogin:c,showDappKit:l,showVeWorld:u,showSync2:d,showWalletConnect:f,showMoreLogin:p,showGithubLogin:m,isOfficialVeChainApp:h}=Jp(),g=(n,g)=>{switch(n){case`email`:return o&&q(Ql,{},`email`);case`google`:return i&&q($l,{isDark:r,gridColumn:g},`google`);case`apple`:return a&&q(eu,{isDark:r,gridColumn:g},`apple`);case`github`:return m&&q(tu,{isDark:r,gridColumn:g},`github`);case`vechain`:return c&&(h?q(nu,{isDark:r,gridColumn:g},`vechain`):q(ru,{isDark:r,gridColumn:g,setCurrentContent:e},`vechain`));case`passkey`:return s&&q(iu,{isDark:r,gridColumn:g,setCurrentContent:e},`passkey`);case`dappkit`:return l&&q(au,{isDark:r,gridColumn:g},`dappkit`);case`veworld`:return u&&q(cu,{isDark:r,gridColumn:g??4,setCurrentContent:e},`veworld`);case`sync2`:return d&&q(lu,{isDark:r,gridColumn:g??4,setCurrentContent:e},`sync2`);case`wallet-connect`:return f&&q(uu,{isDark:r,gridColumn:g??4,setCurrentContent:e},`wallet-connect`);case`more`:return p&&q(Ct,{colSpan:g??4,w:`full`,display:`flex`,justifyContent:`center`,pt:3,children:q(M,{variant:`link`,size:`sm`,fontWeight:500,rightIcon:q(P,{as:Er,ml:`-1`}),onClick:()=>e({type:`more`,props:{}}),children:t(`More options`)})},`more`);default:return null}};return q(Jt,{spacing:4,w:`full`,align:`center`,children:q(St,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:n?.map(({method:e,gridColumn:t})=>g(e,t))})})},fu=({appsInfo:e,isLoading:t,setCurrentContent:n})=>{let{t:r}=Y();return q(M,{fontSize:`sm`,variant:`link`,onClick:()=>n({type:`ecosystem`,props:{appsInfo:e,isLoading:t}}),children:r(`Already have an x2earn app wallet?`)})},pu=({setCurrentContent:e})=>{let{t}=Y(),{loginModalUI:n,darkMode:r}=$(),{loginMethods:i,privyEcosystemAppIDS:a}=$(),{data:o,isLoading:s}=Yo(a),c=B(`colors`,`vechain-kit-text-secondary`),l=()=>{e(`faq`)},u=i?.some(({method:e})=>e===`ecosystem`);return J(K,{children:[J(Z,{children:[q(Jh,{onClick:l}),q(L,{children:t(`Log in or sign up`)}),q(I,{})]}),n?.logo&&q(N,{justify:`center`,children:q(Et,{src:n.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),J(F,{children:[n?.description&&q(N,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:q(R,{color:c,fontSize:`sm`,textAlign:`center`,children:n?.description})}),q(du,{setCurrentContent:e})]}),u?q(It,{children:q(N,{justify:`center`,w:`full`,children:q(fu,{isDark:r,appsInfo:Object.values(o||{}),isLoading:s,setCurrentContent:e})})}):q(It,{pt:0,pb:`5px`})]})},mu=({setCurrentContent:e,wallet:t,onClose:n,switchFeedback:r})=>{let{t:i}=Y(),{network:a}=$(),{isolatedView:o}=gu();return J(Yh,{children:[J(Z,{children:[!o&&q(Fo,{onClick:()=>{e(`profile`)}}),J(L,{children:[i(`Wallet`),a?.type!==`main`&&q(nn,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${a?.type}`})]}),q(I,{})]}),q(F,{w:`full`,children:J(z,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:8,children:[q(ig,{showFeedback:r?.showFeedback}),q(Pu,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),q(Iu,{onAssetsClick:()=>{e(`assets`)}}),q(zu,{setCurrentContent:e})]})}),q(It,{pt:0})]})},hu=({onSelectToken:e,onBack:t,showAllTokens:n=!1,excludedTokenSymbols:r=p})=>{let{t:i}=Y(),{darkMode:a}=$(),{currentCurrency:o}=lc(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`),l=B(`colors`,`vechain-kit-text-tertiary`),{account:u}=Q(),{tokensWithBalance:d,sortedTokens:f}=uc({address:u?.address??``}),[m,h]=G(``),g=W(()=>{let e=e=>r.includes(e),t;if(n){let n=f.filter(t=>Number(t.balance)>0&&!e(t.symbol)),r=[...f.filter(t=>Number(t.balance)===0&&!e(t.symbol))].sort((e,t)=>e.symbol.localeCompare(t.symbol));t=[...n,...r]}else t=d.filter(t=>!e(t.symbol));return t},[n,f,d,r]).filter(({symbol:e})=>e.toLowerCase().includes(m.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:i(`Select Token`)}),q(Fo,{onClick:t}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:4,align:`stretch`,children:[J(Ot,{size:`lg`,children:[q(Dt,{placeholder:`Search token`,bg:a?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:m,onChange:e=>h(e.target.value),"data-testid":`search-token-input`}),q(kt,{h:`56px`,w:`56px`,pl:4,children:q(ri,{color:l})})]}),q(R,{fontSize:`lg`,fontWeight:`semibold`,color:s,mt:4,children:i(n?`All tokens`:`Your tokens`)}),g.length===0?J(z,{spacing:2,py:8,children:[q(P,{as:si,boxSize:12,color:l}),q(R,{fontSize:`lg`,color:s,children:i(`No tokens found`)}),q(R,{fontSize:`md`,color:c,children:i(`Try searching with a different term`)})]}):q(z,{spacing:2,align:`stretch`,children:g.map(t=>q(Kh,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:o,onClick:()=>e(t)},t.address))})]})})}),q(It,{pt:0})]})},gu=()=>{let{isolatedView:e,closeAccountModal:t}=bp();return{isolatedView:e,closeAccountModal:t}},_u=({setCurrentContent:t,preselectedToken:n,initialAmount:r=``,initialToAddressOrDomain:i=``,onBack:a=()=>t(`main`)})=>{let{t:o}=Y(),{darkMode:s,feeDelegation:c}=$(),{currentCurrency:l}=lc(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-text-tertiary`),m=B(`colors`,`vechain-kit-error`),h=B(`colors`,`vechain-kit-card`),{exchangeRates:g}=ic(),{account:_}=Q(),{isolatedView:v}=gu(),{tokensWithBalance:y}=uc({address:_?.address??``}),b=W(()=>y.filter(e=>!p.includes(e.symbol)),[y]),[S,C]=G(()=>n&&!p.includes(n.symbol)?n:b[0]??null),[w,ee]=G(!1);U(()=>{!S&&b.length>0&&C(b[0])},[b,S]);let{register:T,watch:E,setValue:D,setError:O,formState:{errors:k,isValid:te},handleSubmit:A}=Ta({defaultValues:{amount:r,toAddressOrDomain:i},mode:`onChange`}),{toAddressOrDomain:ne,amount:re}=E(),ie=xn(S);U(()=>{ie.current&&S&&ie.current.address!==S.address&&D(`amount`,``),ie.current=S},[S,D]);let ae=W(()=>S?sc(ac(Number(re)*S.priceUsd,l,g),{currency:l}):``,[re,S,l,g]),{data:oe,isLoading:se}=$o(ne),ce=()=>{S&&D(`amount`,S.balance)},le=()=>{a()},ue=async e=>{if(S){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){O(`toAddressOrDomain`,{type:`manual`,message:o(`Invalid address or domain`)});return}if(S){let t=Dn(e.amount),n=c?.b3trTransfers?.minAmountInEther;if(S.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(t<Dn(String(n))){O(`amount`,{type:`manual`,message:o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:S.symbol,min:n})});return}}catch{}if(t>Dn(S.balance)){O(`amount`,{type:`manual`,message:o(`Insufficient {{symbol}} balance`,{symbol:S.symbol})});return}}t({type:`send-token-summary`,props:{toAddressOrDomain:e.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:e.amount,selectedToken:S,formattedTotalAmount:ae,setCurrentContent:t}})}};return w?q(hu,{setCurrentContent:t,onSelectToken:e=>{C(e),ee(!1)},onBack:()=>{ee(!1)}}):J(K,{children:[J(Z,{children:[q(L,{children:o(`Send`)}),!v&&q(Fo,{onClick:le}),q(I,{})]}),q(F,{children:J(z,{spacing:2,align:`stretch`,position:`relative`,children:[J(N,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`Amount`)}),J(R,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:ce,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:d,children:[o(`Balance`),`:`,` `,Number(S?.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(j,{p:4,borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,children:J(bt,{isInvalid:!!k.amount,children:[J(N,{justify:`space-between`,children:[q(Dt,{...T(`amount`,{required:o(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:o(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return o(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return S?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:S.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,D(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),S?J(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>ee(!0),leftIcon:x[S.symbol]?V.cloneElement(x[S.symbol],{boxSize:`20px`,borderRadius:`full`}):q(Et,{src:e[S.symbol],alt:`${S.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:u,children:S.symbol.slice(0,3)})})}),children:[S.symbol,q(P,{as:Er,boxSize:5,color:d})]}):J(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>ee(!0),children:[o(`Select token`),q(P,{as:Er,boxSize:5,color:d})]})]}),S&&q(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:J(R,{color:d,children:[`≈ `,ae]})}),k.amount&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:k.amount.message})]})})}),q(N,{justify:`space-between`,mt:2,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`To`)})}),q(j,{borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,p:4,width:`100%`,children:J(bt,{isInvalid:!!k.toAddressOrDomain,children:[q(Dt,{...T(`toAddressOrDomain`,{required:o(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?Ea(t):t;e.target.value=n,D(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:o(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),k.toAddressOrDomain&&q(R,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:k.toAddressOrDomain.message})]})})})]})}),q(It,{children:q(M,{variant:`vechainKitPrimary`,isDisabled:!S||!te,isLoading:se,onClick:A(ue),"data-testid":`send-button`,children:o(S?`Send`:`Select Token`)})})]})},vu=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:i,selectedToken:a,formattedTotalAmount:o})=>{let{t:s}=Y(),{account:c,connection:u,connectedWallet:d}=Q(),{data:f}=Is(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Hh(),{isolatedView:g,closeAccountModal:_}=gu(),v=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b}=nh(c?.address??``,d?.address??``,3),{open:x}=Yp(),S=W(()=>f||l(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{a.symbol===`VET`?await A():await ee()}catch(e){console.error(s(`Transaction failed:`),e)}},w=V.useCallback(t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:s(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},[e,s,g,_]),{sendTransaction:ee,txReceipt:T,error:E,isWaitingForWalletConfirmation:D,isTransactionPending:O,clauses:k,isLoadingTokenInfo:te}=gh({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,tokenAddress:a.address,tokenName:a.symbol,onError:e=>{me(e??``)}}),{sendTransaction:A,txReceipt:ne,error:re,isWaitingForWalletConfirmation:ie,isTransactionPending:ae,clauses:oe}=vh({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,onError:e=>{me(e??``)}}),se=V.useCallback(()=>a.symbol===`VET`?ne:T,[a.symbol,ne,T]),ce=D||ie,le=ce||O||ae,ue=a.symbol!==`VET`&&te,[de,fe]=V.useState(!1);V.useEffect(()=>{let e=se();if(!e||e.reverted||de||le)return;let t=e.meta.txID;t&&(fe(!0),w(t))},[se,de,le,w]),V.useEffect(()=>{le&&fe(!1)},[le]);let pe=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:a,initialAmount:i,initialToAddressOrDomain:t}})},me=e=>{console.error(`Transaction failed:`,e)},[he,ge]=V.useState(null),[_e,ve]=V.useState(null),ye=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:be,isLoading:xe,error:Se,refetch:Ce}=Uh({clauses:a.symbol===`VET`?oe:k,tokens:he?[he]:h.availableGasTokens,sendingAmount:i,sendingTokenSymbol:a.symbol,enabled:ye&&!!m?.genericDelegatorUrl}),we=be?.usedToken,Te=(xe||!be)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,Ee=V.useCallback(e=>{ge(e),ve(e),setTimeout(()=>Ce(),100)},[Ce]),De=!!we&&!Se;return V.useEffect(()=>{Se&&he&&ge(null)},[Se,he]),J(K,{children:[J(Z,{children:[q(L,{children:`Send`}),q(Fo,{isDisabled:le,onClick:pe}),q(I,{isDisabled:le})]}),q(F,{children:q(z,{spacing:6,align:`stretch`,w:`full`,children:J(z,{spacing:4,w:`full`,children:[J(j,{w:`full`,children:[q(R,{fontSize:`sm`,mb:2,color:y,children:s(`From`)}),q(qh,{address:c?.address??``,domain:c?.domain,imageSrc:c?.image??``,imageAlt:`From account`,balance:Number(a.balance),tokenAddress:a.address})]}),J(j,{w:`full`,children:[q(R,{fontSize:`sm`,mb:2,color:y,children:s(`To`)}),q(qh,{address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:a.address})]}),u.isConnectedWithPrivy&&q(eg,{estimation:be,isLoading:xe,isLoadingTransaction:le,onTokenChange:Ee,clauses:a.symbol===`VET`?oe:k,userSelectedToken:_e}),J(z,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:s(`Amount`)}),J(N,{justifyContent:`flex-start`,w:`full`,children:[J(R,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(i).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,a.symbol]}),J(R,{color:y,children:[`≈ `,o]})]})]})]})})}),q(It,{children:q(Zh,{transactionError:a.symbol===`VET`?re:E,isSubmitting:le,isTxWaitingConfirmation:ce,onConfirm:C,transactionPendingText:s(`Sending...`),txReceipt:se(),buttonText:s(`Confirm`),isDisabled:le||ue||Te,gasEstimationError:Se,hasEnoughGasBalance:De,isLoadingGasEstimation:xe,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},yu=({setCurrentContent:e,onBack:t})=>{let{t:n}=Y(),{account:r}=Q(),{isolatedView:i}=gu(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=t??(()=>e(`main`));return J(K,{children:[J(Z,{children:[q(L,{children:n(`Receive`)}),!i&&q(Fo,{onClick:s}),q(I,{})]}),J(_t,{maxW:`container.lg`,children:[q(F,{children:J(z,{spacing:4,align:`center`,w:`full`,children:[q(Da,{value:r?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),q(Io,{wallet:r,style:{w:`85%`}}),q(R,{fontSize:`sm`,textAlign:`center`,color:a,children:n(`Copy your address or scan this QR code`)}),q(R,{fontSize:`xs`,textAlign:`center`,color:o,children:n(`This address only supports VeChain assets.`)})]})}),q(It,{pt:0})]})]})},bu=({quotes:t,selectedQuote:n,toTokenAddress:r,onSelectQuote:i,onBack:a})=>{let{t:o}=Y(),{darkMode:s}=$(),{currentCurrency:c}=lc(),{account:l}=Q(),{exchangeRates:u,prices:d}=ic(),{tokens:f}=uc({address:l?.address??``}),[p,m]=G(!1),h=W(()=>r&&f.find(e=>E(e.address,r))||null,[r,f]),g=t.filter(e=>!e.reverted),_=t.filter(e=>e.reverted),v=W(()=>g.length===0?null:g.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[g]),y=W(()=>{let e=r&&d[r]||0;return g.map(t=>{let n=Wi(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=ac(r,c,u),a=v&&t.aggregatorName===v.aggregatorName,o=0;if(v&&!a){let e=BigInt(v.outputAmount||`0`),n=BigInt(t.outputAmount||`0`);o=Number(n-e)/Number(e)*100}return{...t,outputAmountFormatted:n,valueUsd:r,valueInCurrency:i,isBest:a,percentageDiff:o}}).sort((e,t)=>{let n=BigInt(e.outputAmount||`0`),r=BigInt(t.outputAmount||`0`);return Number(r-n)})},[g,r,d,c,u,v]);return J(K,{children:[J(Z,{children:[q(L,{children:o(`Found following rates`)}),q(Fo,{onClick:a}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,children:[y.length>0&&q(z,{spacing:2,align:`stretch`,children:y.map(t=>{let r=n?.aggregatorName===t.aggregatorName;return J(j,{p:2.5,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,borderWidth:1,borderColor:r?`blue.500`:s?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>i(t),_hover:{borderColor:r?`blue.500`:s?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(t.isBest||!t.isBest&&t.percentageDiff<0)&&q(j,{position:`absolute`,top:-1,left:0,zIndex:1,children:t.isBest?q(st,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:o(`Best`)}):J(st,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[t.percentageDiff.toFixed(2),`%`]})}),J(z,{align:`stretch`,spacing:1.5,marginTop:4,children:[J(N,{justify:`space-between`,align:`center`,children:[J(N,{spacing:1.5,align:`center`,children:[t.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`bold`,children:t.aggregatorName})]}),q(N,{align:`center`,spacing:1.5,children:h&&J(K,{children:[x[h.symbol]?V.cloneElement(x[h.symbol],{boxSize:`24px`,borderRadius:`full`}):e[h.symbol]?q(Et,{src:e[h.symbol],alt:`${h.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,q(an,{label:Number(t.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:J(R,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(t.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,h.symbol]})})]})})]}),J(N,{justify:`space-between`,align:`center`,children:[q(R,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:t.gasCostVTHO&&t.gasCostVTHO>0?`Gas: ${t.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),t.valueUsd>0&&J(R,{fontSize:`xs`,color:s?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,sc(t.valueInCurrency,{currency:c})]})]})]})]},t.aggregatorName)})}),_.length>0&&J(j,{children:[J(N,{justify:`space-between`,cursor:`pointer`,onClick:()=>m(!p),py:2,children:[J(R,{fontSize:`sm`,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:[_.length,` `,o(`rate`),_.length===1?``:`s`,` `,o(`unavailable`)]}),q(P,{as:p?kr:Er,boxSize:4,color:s?`whiteAlpha.600`:`blackAlpha.600`})]}),q(gt,{in:p,animateOpacity:!0,children:q(z,{spacing:2,align:`stretch`,pt:2,children:_.map(e=>q(j,{p:2,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,opacity:.6,children:J(N,{justify:`space-between`,children:[J(N,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),q(R,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:o(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),y.length===0&&_.length===0&&q(z,{spacing:2,py:8,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:q(R,{fontSize:`lg`,children:o(`No quotes available`)})})]})})}),q(It,{})]})},xu=e=>e===`0x`||e===Qi||!e,Su=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=xu(n),c=xu(r),l=[],u=[];if(e.outputs&&Array.isArray(e.outputs))for(let t of e.outputs)t.events&&Array.isArray(t.events)&&l.push(...t.events),t.transfers&&Array.isArray(t.transfers)&&u.push(...t.transfers);let d=Ti.createInterface().getEvent(`Transfer`),f=d?.topicHash.toLowerCase(),p=l.filter(e=>e.topics&&e.topics.length>0&&e.topics[0]?.toString().toLowerCase()===f),m=null,h=null;if(s){for(let e of u)if(e.sender?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){m=t;break}}}if(c){for(let e of u)if(e.recipient?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){h=t;break}}}if(p.length>0)for(let e of p)try{let t=Vi({abi:[d],data:e.data.toString(),topics:e.topics.map(e=>e.toString())});if(!t.args||!(`from`in t.args)||!(`to`in t.args)||!(`value`in t.args))continue;let n=t.args.from?.toString().toLowerCase(),r=t.args.to?.toString().toLowerCase(),l=t.args.value,u=e.address.toLowerCase();!s&&n===i&&u&&u===a&&l>0n&&m===null&&(m=l),!c&&r===i&&u&&u===o&&l>0n&&h===null&&(h=l)}catch(e){console.warn(`Failed to decode transfer event:`,e);continue}return{fromAmount:m??0n,toAmount:h??0n}},Cu=({setCurrentContent:t,fromTokenAddress:n,toTokenAddress:r,onBack:i})=>{let{t:a}=Y(),{account:o,connection:s}=Q(),{currentCurrency:c}=lc(),{network:l,feeDelegation:u,darkMode:d,appConfig:f}=$(),{isolatedView:m,closeAccountModal:h}=gu(),g=B(`colors`,`vechain-kit-card`),_=B(`colors`,`vechain-kit-text-primary`),v=B(`colors`,`vechain-kit-text-secondary`),y=B(`colors`,`vechain-kit-text-tertiary`),b=B(`colors`,`vechain-kit-button-primary-bg`),S=B(`colors`,`vechain-kit-button-primary-color`),{preferences:C}=Hh(),{sortedTokens:w}=uc({address:o?.address??``}),[ee,T]=G(`main`),[D,O]=G(null),[k,te]=G(null),[A,ne]=G(``),[re,ie]=G(!1),[ae,oe]=G(1),[se,ce]=G(`1`),[le,ue]=G(null),[de,fe]=V.useState(null),[pe,me]=V.useState(null),[he,ge]=V.useState([]),{prices:_e,exchangeRates:ve}=ic(),ye=ae===1;V.useEffect(()=>{ce(ae===1?`1`:ae===.5?`0.5`:ae===3?`3`:ae.toString())},[ae]),V.useEffect(()=>{if(w.length!==0){if((n||r)&&(!D||!k)){if(n&&!D){let e=w.find(e=>E(e.address,n));e&&!p.includes(e.symbol)&&O(e)}if(r&&!k){let e=w.find(e=>E(e.address,r));e&&!p.includes(e.symbol)&&te(e)}return}if(!D&&!k){let e=w.find(e=>e.symbol===`VET`);e&&O(e);let t=w.find(e=>e.symbol===`B3TR`);if(!t)try{let e=f.b3trContractAddress;e&&(t=w.find(t=>E(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&te(t)}}},[w,D,k,n,r,l.type]),V.useEffect(()=>{ue(null)},[D?.address,k?.address,A]);let{bestQuote:be,quotes:xe,isLoading:Se,from:Ce,to:we}=Wl(D,k,A,o?.address??``,ae,!!D&&!!k&&Number(A)>0),Te=W(()=>{if(!A||Number(A)<=0||!Ce)return 0n;try{return Xi(A,Ce.decimals)}catch{return 0n}},[A,Ce?.decimals]),Ee=le||be,De=W(()=>{if(!Ee?.outputAmount||!we)return`0`;try{return Gi(Ee.outputAmount,we.decimals)}catch{return`0`}},[Ee,we?.decimals]),Oe=W(()=>{if(!D||!A)return 0;let e=_e[D.address]||0;return ac(Number(A)*e,c,ve)},[D?.address,A,_e,c,ve]),ke=W(()=>{if(!k||!De)return 0;let e=_e[k.address]||0;return ac(Number(De)*e,c,ve)},[k?.address,De,_e,c,ve]),Ae=W(()=>!D||!k||!o?.address||Te===0n?null:{fromTokenAddress:D.address,toTokenAddress:k.address,amountIn:Te.toString(),userAddress:o.address,slippageTolerance:ae},[D,k,o?.address,Te,ae]),je=Ee?.gasCostVTHO??0;V.useEffect(()=>{(async()=>{if(!Ee||!Ae||!Ee.aggregator){ge([]);return}try{ge(await Ee.aggregator.buildSwapTransaction(Ae,Ee))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),ge([])}})()},[Ee,Ae]);let Me=C.availableGasTokens.length>0&&(s.isConnectedWithPrivy||s.isConnectedWithVeChain)&&!u?.delegatorUrl,{data:Ne,isLoading:Pe,error:Fe,refetch:Ie}=Uh({clauses:he,tokens:de?[de]:C.availableGasTokens,sendingAmount:A,sendingTokenSymbol:D?.symbol??``,enabled:Me&&!!u?.genericDelegatorUrl&&he.length>0}),Le=Ne?.usedToken,Re=(Pe||!Ne)&&s.isConnectedWithPrivy&&!u?.delegatorUrl,ze=V.useCallback(e=>{fe(e),me(e),setTimeout(()=>Ie(),100)},[Ie]),Be=!!Le&&!Fe;V.useEffect(()=>{Fe&&de&&fe(null)},[Fe,de]);let{executeSwap:Ve,isTransactionPending:He,isWaitingForWalletConfirmation:Ue,txReceipt:We,status:Ge,error:Ke}=wl(Ae,Ee),qe=H(()=>{let e=We?.meta.txID??``,n=a(`Swap successful`,{defaultValue:`Swap successful`}),r;if(We&&D&&k&&o?.address){let e=Su(We,o.address,D.address,k.address);if(e&&Ce&&we)try{let t=Ce.decimals,n=we.decimals,i=Gi(e.fromAmount,t),o=Gi(e.toAmount,n),s=e=>{let t=Number(e);return t>=1e3?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString(void 0,{maximumFractionDigits:6,minimumFractionDigits:0})};r=a(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(i),fromSymbol:D.symbol,toAmount:s(o),toSymbol:k.symbol,defaultValue:`You successfully swapped ${s(i)} ${D.symbol} for ${s(o)} ${k.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!r&&D&&k&&(r=a(`You successfully swapped {fromToken} for {toToken}`,{fromToken:D.symbol,toToken:k.symbol,defaultValue:`You successfully swapped ${D.symbol} for ${k.symbol}`})),t({type:`successful-operation`,props:{setCurrentContent:t,txId:e,title:n,description:r,onDone:()=>{m?h():t(`main`)},showSocialButtons:!0}})},[D,k,A,Ee,We,o?.address,t,a,m,h]),Je=H(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[D,k,A]),[Ye,Xe]=V.useState(!1);V.useEffect(()=>{if(Ge===`ready`){Xe(!1);return}Ye||(Ge===`success`&&We&&!We.reverted?(Xe(!0),qe()):Ge===`error`&&Ke?Je(Ke?.reason||Ke?.message||String(Ke)):We?.reverted&&Je(`Transaction reverted`))},[Ge,We,Ke,qe,Je,Ye]);let Ze=H(e=>{if(O(e),e.symbol===`VET`&&!k){let e=w.find(e=>e.symbol===`B3TR`);if(!e)try{let t=f.b3trContractAddress;t&&(e=w.find(e=>E(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&te(e)}T(`main`)},[k,w,l.type]),Qe=H(e=>{te(e),T(`main`)},[]),$e=H(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&ne(e)},[]),et=H(()=>{D&&ne(D.balance)},[D]),tt=t=>{if(!t)return null;let n=x[t.symbol],r=e[t.symbol];return{symbol:t.symbol,logoComponent:n,logoUrl:r,balance:t.balance,value:t.valueInCurrency}},nt=tt(D),rt=tt(k);return ee===`select-from-token`?q(hu,{setCurrentContent:t,onSelectToken:Ze,onBack:()=>T(`main`),showAllTokens:!1}):ee===`select-quote`?q(bu,{quotes:xe,selectedQuote:Ee,toTokenAddress:k?.address??null,onSelectQuote:e=>{ue(e),T(`main`)},onBack:()=>T(`main`)}):ee===`select-to-token`?q(hu,{setCurrentContent:t,onSelectToken:Qe,onBack:()=>T(`main`),showAllTokens:!0}):J(K,{children:[J(Z,{children:[q(L,{children:a(`Swap`)}),!m&&q(Fo,{onClick:i??(()=>t(`main`)),isDisabled:He||Ue}),q(I,{isDisabled:He||Ue})]}),q(F,{children:J(z,{spacing:2,align:`stretch`,w:`full`,children:[J(N,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:_,children:a(`From`)}),nt&&J(R,{cursor:`pointer`,_hover:{color:v,textDecoration:`underline`},onClick:et,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:v,children:[a(`Balance`),`:`,` `,Number(nt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(j,{p:4,borderRadius:`2xl`,bg:g,children:J(z,{align:`stretch`,spacing:2,children:[J(N,{justify:`space-between`,children:[q(Dt,{placeholder:`0`,value:A,onChange:e=>$e(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:nt&&A&&Number(A)>Number(nt.balance)?`red.500`:_}),nt?J(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:nt.logoComponent?V.cloneElement(nt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):nt.logoUrl?q(Et,{src:nt.logoUrl,alt:`${nt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:nt.symbol.slice(0,3)})})}):void 0,children:[nt.symbol,q(P,{as:Er,boxSize:5,color:v})]}):J(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:y},children:[a(`Select token`),q(P,{as:Er,boxSize:5,color:v})]})]}),q(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:q(N,{spacing:2,alignItems:`center`,children:J(R,{color:v,children:[`≈`,` `,sc(Oe??0,{currency:c})]})})})]})}),q(N,{justify:`space-between`,mt:4,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:_,children:a(`To`)})}),q(j,{borderRadius:`2xl`,bg:g,p:4,children:J(z,{align:`stretch`,spacing:2,width:`100%`,children:[J(N,{justify:`space-between`,alignItems:`center`,children:[q(Dt,{value:Number(De).toLocaleString(void 0,{maximumFractionDigits:Number(De)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:_}),rt?J(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:rt.logoComponent?V.cloneElement(rt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):rt.logoUrl?q(Et,{src:rt.logoUrl,alt:`${rt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:rt.symbol.slice(0,3)})})}):void 0,children:[rt.symbol,q(P,{as:Er,boxSize:5,color:v})]}):J(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:y},children:[a(`Select token`),q(P,{as:Er,boxSize:5,color:v})]})]}),J(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:[q(N,{spacing:2,alignItems:`center`,children:J(R,{color:v,children:[`≈`,` `,sc(ke??0,{currency:c})]})}),rt&&J(R,{noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:v,children:[a(`Balance`),`:`,` `,Number(rt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})}),q(gt,{in:re&&!!Ee,animateOpacity:!0,children:J(z,{spacing:1,align:`stretch`,p:4,borderRadius:`2xl`,bg:g,children:[Ee&&J(N,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[a(`Source`),`:`]}),q(M,{variant:`outline`,size:`xs`,borderRadius:`full`,px:3,h:`auto`,py:1,cursor:`pointer`,onClick:()=>T(`select-quote`),color:v,borderColor:v,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:Ee.aggregator?.getIcon(`12px`),children:q(R,{fontSize:`xs`,color:_,children:Ee.aggregatorName})})]}),J(z,{align:`stretch`,spacing:2,children:[J(N,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[a(`Slippage tolerance`),`:`]}),J(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:[ae,`%`]})]}),q(z,{spacing:3,align:`stretch`,pt:2,children:J(N,{spacing:2,children:[q(M,{size:`sm`,variant:`outline`,onClick:()=>{oe(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ye?b:`transparent`,color:ye?S:v,borderColor:ye?b:v,_hover:{bg:ye?b:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ye?.8:1},children:`Auto`}),q(M,{size:`sm`,variant:`outline`,onClick:()=>{oe(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ae===.5?b:`transparent`,color:ae===.5?S:v,borderColor:ae===.5?b:v,_hover:{bg:ae===.5?b:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ae===.5?.8:1},children:`0.5%`}),q(M,{size:`sm`,variant:`outline`,onClick:()=>{oe(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ae===3?b:`transparent`,color:ae===3?S:v,borderColor:ae===3?b:v,_hover:{bg:ae===3?b:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ae===3?.8:1},children:`3%`}),J(Ot,{size:`sm`,flex:1,children:[q(Dt,{value:se,onChange:e=>{let t=e.target.value;if(/^\d*\.?\d*$/.test(t)||t===``)if(ce(t),t!==``){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&oe(e)}else oe(1)},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:_}),q(At,{width:`2rem`,pointerEvents:`none`,children:q(R,{fontSize:`2xs`,color:v,children:`%`})})]})]})})]}),J(N,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[a(`Fee`),`:`]}),q(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:je>0?`${je.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),Ee&&q(j,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(M,{variant:`ghost`,size:`xs`,onClick:()=>ie(!re),rightIcon:q(P,{color:y,_hover:{color:v},as:re?yr:hr}),fontSize:`xs`,fontWeight:`light`,color:y,_hover:{color:v},children:a(re?`Hide`:`Show Advanced Options`)})}),he.length>0&&s.isConnectedWithPrivy&&q(eg,{estimation:Ne,isLoading:Pe,isLoadingTransaction:He,onTokenChange:ze,clauses:he,userSelectedToken:pe})]})}),q(It,{children:q(Zh,{buttonText:a(Se?`Loading quote...`:`Swap`),onConfirm:Ve,isSubmitting:He,isTxWaitingConfirmation:Ue,transactionPendingText:a(`Swapping...`),txReceipt:We,transactionError:Ke,onError:e=>{Je(e)},isDisabled:!D||!k||!A||Number(A)<=0||Se||!Ee||Ee?.reverted===!0||!!(nt&&A&&Number(A)>Number(nt.balance))||Re,gasEstimationError:Fe,hasEnoughGasBalance:Be,isLoadingGasEstimation:Pe,showGasEstimationError:!u?.delegatorUrl&&s.isConnectedWithPrivy,context:`transaction`})})]})},wu=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=Y(),{isolatedView:i}=gu(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=()=>{t()};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose your account name`)}),!i&&q(Fo,{onClick:s}),q(I,{})]}),q(F,{children:J(z,{spacing:6,align:`center`,py:8,children:[q(P,{as:li,boxSize:16,color:o}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:a,children:r(`Finally say goodbye to 0x addresses`)}),q(R,{fontSize:`md`,color:o,textAlign:`center`,px:4,children:r(`Name your account to make it easier to exchange assets`)})]})]})}),q(It,{children:q(M,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},Tu=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:i}=Q(),{t:a}=Y(),o=rl(e.name,i.network),s=B(`colors`,`vechain-kit-card`),c=B(`colors`,`vechain-kit-card-hover`),u=B(`colors`,`vechain-kit-border`),d=B(`colors`,`vechain-kit-text-primary`),f=B(`colors`,`vechain-kit-text-secondary`),p=B(`colors`,`vechain-kit-card`);return q(Nt,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${u}`,_hover:{bg:t?c:s,borderColor:u},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:J(N,{spacing:3,align:`center`,children:[q(Xh,{props:{width:`40px`,height:`40px`,src:o.image??l(e.name),alt:e.name}}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:d,fontSize:`md`,fontWeight:`500`,children:r(e.name,24,0)}),t&&q(R,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&q(nn,{size:`sm`,bg:p,color:d,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},Eu=({onUnset:e})=>{let t=B(`colors`,`vechain-kit-card`),n=B(`colors`,`vechain-kit-card-hover`),r=B(`colors`,`vechain-kit-border`),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`),o=B(`colors`,`vechain-kit-error`),{t:s}=Y();return q(Nt,{p:4,bg:t,borderRadius:`xl`,cursor:`pointer`,opacity:1,border:`1px solid ${r}`,_hover:{bg:n,borderColor:r,color:`red.400`},onClick:e,transition:`all 0.2s`,role:`button`,"aria-label":s(`Unset current domain`),children:J(N,{spacing:3,align:`center`,children:[q(j,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:q(P,{as:ui,fontSize:`18px`,color:o})}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:i,fontSize:`md`,fontWeight:`500`,children:s(`Unset current domain`)}),q(R,{fontSize:`sm`,color:a,children:s(`Remove your current domain name`)})]})]})},`unset-domain-list-item`)},Du=({domains:e,onDomainSelect:t,onUnsetDomain:n,isLoading:r})=>{let{t:i}=Y(),{account:a}=Q(),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-hover`),c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return e.length===0||r?null:q($e,{allowToggle:!0,children:q(tt,{border:`none`,children:({isExpanded:u})=>J(K,{children:[J(et,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[q(j,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:c,children:r?i(`Loading your domains...`):`${i(`Your existing domains`)} (${e.length})`})}),q(P,{as:u?kr:Er,fontSize:`20px`,color:l})]}),q(nt,{pb:4,pt:2,children:J(Mt,{spacing:2,children:[e.map(e=>q(Tu,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&q(Eu,{onUnset:n})]})})]})})})},Ou=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=Y(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=gu(),[s,c]=G(Ea(e)),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(!1),_=B(`colors`,`vechain-kit-error`),v=B(`colors`,`vechain-kit-success`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b,isLoading:x}=ns(s),{data:S,isLoading:C}=$o(`${s}.veworld.vet`),{data:w,isLoading:ee}=gs(s),{data:T,isLoading:E}=xs(i?.address,``),D=x||C||ee;U(()=>{if(!h)return;let e=/[^a-zA-Z0-9-]|\s/.test(s);s.length<3?(u(r(`Name must be at least 3 characters long`)),m(!1),f(!1)):e?(u(r(`Only letters, numbers, and hyphens are allowed`)),m(!1),f(!1)):w?(u(r(`This domain is protected`)),m(!1),f(!1)):b?S?.address?.toLowerCase()===i?.address?.toLowerCase()?(u(null),m(!0),f(!0)):(u(r(`This domain is already taken`)),m(!1),f(!1)):x||(u(null),m(!0),f(!1))},[s,h,b,x,S,i?.address,w,p,D]);let O=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},k=e=>{let r=e.split(`.`);t({type:`choose-name-summary`,props:{fullDomain:e,domainType:r.length>2?`${r[1]}.${r[2]}`:`vet`,isOwnDomain:!0,setCurrentContent:t,initialContentSource:n}})},te=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},A=()=>{t(n)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&q(Fo,{onClick:A}),q(I,{})]}),q(F,{children:J(z,{spacing:4,align:`stretch`,children:[q(Du,{domains:T?.domains||[],onDomainSelect:k,onUnsetDomain:te,isLoading:E}),J(Ot,{size:`lg`,children:[q(Dt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(Ea(e.target.value)),h||g(!0)},paddingRight:`120px`,fontSize:`lg`,height:`60px`,bg:a?`#00000038`:`white`,border:`1px solid ${a?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${a?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${a?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},isInvalid:!!l,"data-testid":`domain-input`}),q(At,{width:`auto`,paddingRight:`12px`,h:`full`,children:q(j,{mr:4,fontSize:`sm`,color:y,children:`.veworld.vet`})})]}),l&&h&&q(R,{color:_,fontSize:`sm`,"data-testid":`domain-availability-status`,children:l}),!l&&h&&s.length>=3&&q(R,{fontSize:`sm`,color:p?v:_,fontWeight:`500`,"data-testid":`domain-availability-status`,children:r(d?`YOU OWN THIS`:p?`AVAILABLE`:`UNAVAILABLE`)})]})}),q(It,{children:q(M,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||D,isLoading:D,onClick:O,loadingText:r(`Checking...`),"data-testid":`continue-button`,children:r(`Continue`)})})]})},ku=({setCurrentContent:e,fullDomain:t,domainType:n=`veworld.vet`,isOwnDomain:r,isUnsetting:i=!1,initialContentSource:a=`settings`})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),{isolatedView:c,closeAccountModal:l}=gu(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=nh(u?.address??``,d?.address??``,3),{open:m}=Yp(),{preferences:h}=Hh(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=Gs({onSuccess:()=>D()}),y=n.endsWith(`veworld.vet`),b=cs({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>D()}),x=fs({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>D()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:ee,isTransactionPending:T,clauses:E}=i?v:y?b:x,D=()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:C?.meta.txID,title:o(i?`Domain unset`:`Domain set`),description:i?o(`Your domain has been unset successfully.`):o(`Your address has been successfully set to {{name}}`,{name:t}),onDone:()=>{c?l():e(a)}}})},O=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},k=()=>{O()},te=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[A,ne]=V.useState(null),[re,ie]=V.useState(null),ae=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:oe,isLoading:se,error:ce,refetch:le}=Uh({clauses:E(),tokens:A?[A]:h.availableGasTokens,enabled:ae&&!!g?.genericDelegatorUrl}),ue=oe?.usedToken,de=(se||!oe)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,fe=V.useCallback(e=>{ne(e),ie(e),setTimeout(()=>le(),100)},[le]),pe=!!ue&&!ce;return V.useEffect(()=>{ce&&A&&ne(null)},[ce,A]),J(K,{children:[J(Z,{children:[q(L,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),q(Fo,{onClick:te,isDisabled:T}),q(I,{isDisabled:T})]}),J(F,{children:[J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:li,color:s,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:s,children:i?o(`By confirming, your current domain will be unset`):o(`By confirming, your address will be set to {{domain}}`,{domain:t})})]}),!i&&q(z,{spacing:4,align:`stretch`,mt:6,children:q(R,{fontSize:`xl`,fontWeight:`bold`,color:s,textAlign:`center`,"data-testid":`preconfirm-domain-val`,children:t})}),f.isConnectedWithPrivy&&q(eg,{estimation:oe,isLoading:se,isLoadingTransaction:T,onTokenChange:fe,clauses:E(),userSelectedToken:re})]}),q(It,{gap:4,w:`full`,children:q(Zh,{transactionError:w,isSubmitting:T,isTxWaitingConfirmation:ee,onConfirm:O,onRetry:k,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:T||de,onError:_,gasEstimationError:ce,hasEnoughGasBalance:pe,isLoadingGasEstimation:se,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},Au=()=>{let{t:e}=Y(),[t,n]=G(``),r=B(`colors`,`vechain-kit-card`),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-text-tertiary`),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-elevated`),c=[{question:e(`What is VeChain?`),answer:e(`VeChain, headquartered in San Marino, Europe, is a pioneering blockchain ecosystem and creator of VeChainThor, a world-class smart contract platform driving real-world blockchain adoption. Founded in 2015 by Sunny Lu, VeChain has consistently worked to deliver a transparent, efficient, scalable, and adaptable blockchain solution.`)},{question:e(`What is a wallet?`),answer:e(`A wallet is your gateway to the VeChain blockchain. It stores your private keys and allows you to securely manage your digital assets, send and receive tokens, and interact with decentralized applications. Think of it as your digital bank account for blockchain transactions.`)},{question:e(`What is a Smart Account?`),answer:e(`A Smart Account is a smart contract wallet that provides enhanced security and functionality. It allows for features like social recovery, transaction batching, and more.`)},{question:e(`How is my wallet secured?`),answer:e(`Your wallet security depends on how you access it. With self-custody options like the VeWorld extension, mobile app, or hardware wallet, you have complete control over your private keys. This extension itself has no access to your private keys. When logging in with social accounts or VeChain, your wallet is created and secured by Privy and managed by VeChain, providing an easier onboarding experience while maintaining security.`)},{question:e(`How do I backup my wallet?`),answer:e(`Backing up your wallet is crucial as you are the only one with access to your private keys. If something goes wrong, having your private key is the only way to recover your assets. How to backup depends on how you access your wallet: If using VeWorld, the backup option is available within the app. For social login users, you can find backup options in the Wallet section. If you're connected through VeChain or another ecosystem app, you'll need to visit the original website, log in, and access the Wallet section from there.`)},{question:e(`What is a network?`),answer:e(`A network in blockchain refers to the environment where transactions take place. VeChain has two main networks: Mainnet (the live network where real transactions occur) and Testnet (a testing environment for developers). The network you're connected to is displayed at the top of this modal.`)},{question:e(`What is a domain name?`),answer:e(`A domain name is a sort of nickname for your wallet address. It allows you to easily identify your wallet and interact with dApps using a human-readable name. For example, if your wallet address is 0x1234567890, your nickname could be "alice.vechain".`)},{question:e(`What is Privy?`),answer:e(`Privy builds user onboarding and embedded wallet infrastructure to enable better products built on crypto rails. This means embedding asset control within applications themselves to enable users, businesses or machines to use digital assets through seamless product experiences.`)},{question:e(`What is VeBetterDAO?`),answer:e(`VeBetterDAO is a decentralized organization on VeChain blockchain focused on sustainability. Members participate in the governance of the DAO using B3TR tokens for rewards and VOT3 for voting in proposals and weekly token allocation rounds.`)},{question:e(`What is an x2earn application?`),answer:e(`An X2Earn application in VeBetterDAO is a sustainable app that rewards users with B3TR tokens for eco-friendly actions. These apps must distribute B3TR, link user wallets, and provide proof of sustainable actions. They join VeBetterDAO through endorsement and participate in weekly token allocation rounds.`)},{question:e(`What is B3TR?`),answer:e(`B3TR is the incentive token of VeBetterDAO, built on VechainThor blockchain. It has a capped supply of 1 billion tokens, emitted weekly over 12 years. B3TR is used for rewards, governance, and backing VOT3 tokens 1:1. It supports sustainability applications and DAO treasury management.`)},{question:e(`What is VET?`),answer:e(`VET is the primary cryptocurrency of the VeChain network. It represents value and ownership in the VeChain ecosystem, similar to how stocks represent ownership in a company. Holding VET automatically generates VTHO, which is needed to pay for transactions on the network.`)},{question:e(`What is VTHO?`),answer:e(`VTHO (VeThor) is the energy or 'gas' token of the VeChain network. It's used to pay for transaction fees when interacting with the blockchain. VTHO is automatically generated by holding VET tokens, creating a two-token system that helps maintain network stability and manage transaction costs.`)},{question:e(`How do I send tokens?`),answer:e(`You can send tokens by clicking the send icon in the Quick Actions section. Enter the recipient's address or VeChain domain name, select the token, and specify the amount you want to send.`)},{question:e(`What is fee delegation?`),answer:e(`Fee delegation is a unique feature of VeChain that allows someone else (a delegator) to pay for your transaction fees. While many dApps and service providers act as delegators to make it easier for new users to get started, some transactions may still require you to pay fees using your own VTHO. Fees are necessary to prevent network spam and compensate the nodes that process and validate transactions on the blockchain. When paying fees yourself, you'll be able to select VTHO from your assets to cover the transaction cost.`)}].filter(e=>e.question.toLowerCase().includes(t.toLowerCase())||typeof e.answer==`string`&&e.answer.toLowerCase().includes(t.toLowerCase()));return J(z,{spacing:4,align:`stretch`,children:[J(Ot,{size:`lg`,children:[q(Dt,{placeholder:e(`Search FAQ`),bg:r,borderRadius:`xl`,height:`56px`,pl:12,value:t,onChange:e=>n(e.target.value)}),q(kt,{h:`56px`,w:`56px`,pl:4,children:q(ri,{color:a})})]}),c.length===0?J(z,{spacing:2,py:8,color:i,children:[q(P,{as:si,boxSize:12,opacity:.5}),q(R,{fontSize:`lg`,children:e(`No questions found`)}),q(R,{fontSize:`md`,children:e(`Try searching with a different term`)})]}):q($e,{allowMultiple:!0,children:c.map((e,t)=>q(tt,{border:`none`,mb:2,children:({isExpanded:t})=>J(K,{children:[J(et,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[q(j,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:i,children:e.question})}),q(P,{as:t?kr:Er,fontSize:`20px`,opacity:.5})]}),q(nt,{pb:4,children:q(R,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},ju=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=Y(),{isolatedView:i}=gu(),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-border`),s=B(`colors`,`vechain-kit-border-hover`);return J(Yh,{children:[J(Z,{children:[q(L,{children:r(`Help`)}),!i&&q(Fo,{onClick:e}),q(I,{})]}),q(F,{w:`full`,children:J(z,{spacing:6,align:`stretch`,children:[t&&q(Gt,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:io.map(e=>q(`option`,{value:e,children:oo[e]},e))}),q(M,{as:jt,href:pe,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:q(P,{as:Lr}),children:r(`For developers`)}),q(Au,{})]})}),q(It,{pt:0})]})},Mu=({leftIcon:e,rightIcon:t,title:n,wallet:i,onClick:a,leftImage:o,isActive:s=!1})=>{let{t:c}=Y(),{darkMode:l}=$();return q(M,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:a,backgroundColor:`transparent`,border:`1px solid ${l?`#ffffff29`:`#ebebeb`}`,children:J(N,{w:`full`,justify:`space-between`,children:[q(j,{minW:`40px`,justifyContent:`center`,children:o?q(Et,{justifySelf:`center`,src:o,w:`28px`,alt:`left-image`}):q(P,{as:e,fontSize:`28px`})}),J(z,{textAlign:`left`,w:`full`,flex:1,children:[q(N,{w:`full`,spacing:2,justifyContent:`flex-start`,children:q(R,{fontSize:`sm`,fontWeight:`400`,children:n})}),q(R,{fontSize:`sm`,fontWeight:`500`,opacity:.5,overflowWrap:`break-word`,wordBreak:`break-word`,whiteSpace:`normal`,w:`full`,children:i?.domain?r(i?.domain??``,18,0):d(i?.address??``,6,4)})]}),q(z,{minW:`40px`,justifyContent:`flex-end`,children:J(N,{justifyContent:`flex-end`,minW:`40px`,children:[s&&q(nn,{size:`sm`,colorScheme:`green`,children:c(`Active`)}),q(P,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},Nu=({leftIcon:e,rightIcon:t,title:n,onClick:r,leftImage:i,hide:a=!1,showComingSoon:o=!1,backgroundColor:s,_hover:c,isDisabled:l=!1,stacked:u=!1,isLoading:d,loadingText:f,style:p,extraContent:m,dataTestId:h,variant:g=`actionButton`})=>{let{t:_}=Y();return q(M,{variant:g===`actionButton`?`vechainKitSecondary`:g,py:u?0:2,minHeight:`50px`,height:`fit-content`,p:0,onClick:r,display:a?`none`:`flex`,isDisabled:o||l,isLoading:d,loadingText:f,bgColor:s,_hover:c,"data-testid":h,...p,children:J(N,{w:`full`,justify:`space-between`,alignItems:`center`,children:[q(j,{minW:`40px`,h:`20px`,children:i?q(Et,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):q(P,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),q(z,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:J(N,{justify:`flex-start`,alignItems:`baseline`,children:[q(R,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&q(nn,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&q(z,{minW:`40px`,justifyContent:`flex-end`,children:q(P,{as:t,fontSize:`20px`,opacity:.5})})]})})},Pu=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:i,onClose:a,mt:o,style:s})=>{let{t:c}=Y(),{connection:l}=Q(),{switchWallet:u,isSwitching:f,isInAppBrowser:p}=al(),{isSwitchWalletEnabled:m}=rr(),[h,g]=G(!1),_=async()=>{await D(e?.domain??e?.address??``)&&(g(!0),setTimeout(()=>{g(!1)},2e3))},v=()=>{p?u():t?.({type:`select-wallet`,props:{setCurrentContent:t,onClose:a,returnTo:`main`,onLogoutSuccess:a}})};return J(N,{mt:o,w:`full`,...s,justifyContent:`flex-start`,alignItems:`center`,children:[q(M,{w:`full`,h:12,"aria-label":`Wallet`,onClick:i,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:J(N,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[J(N,{spacing:2,justifyContent:`flex-start`,children:[q(Xh,{wallet:e,props:{width:7,height:7}}),q(R,{fontSize:n,fontWeight:`500`,children:h?c(`Copied!`):r(e?.domain??``,22,0)||d(e?.address??``,6,4)})]}),q(P,{boxSize:5,as:Or,cursor:`pointer`,opacity:.5})]})}),l.isInAppBrowser&&m||!l.isInAppBrowser&&l.isConnectedWithDappKit?q(Tt,{"aria-label":`Switch wallet`,icon:q(P,{as:_r}),onClick:v,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3,isLoading:f,isDisabled:f,"data-testid":`switch-wallet-button`}):q(Tt,{"aria-label":`Copy address`,icon:q(P,{as:h?Tr:Pr}),onClick:_,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3})]})},Fu=({address:t,maxIcons:n=3,iconSize:r=20,ml:i=0,style:a,iconsGap:o=0,rightIcon:s,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=Y(),{tokensWithBalance:d}=uc({address:t}),{darkMode:f}=$(),p=B(`colors`,`vechain-kit-text-secondary`),m=o<1?`-${r/2}px`:`${o}px`,h=d.slice(0,n),g=d.length-n;return!t||d.length===0&&!c?null:J(N,{spacing:0,ml:i,...a,onClick:l,children:[J(N,{spacing:0,children:[h.map((t,n)=>q(ht,{ml:n>0?m:`0`,zIndex:n,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:x[t.symbol]?V.cloneElement(x[t.symbol],{width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):e[t.symbol]?q(Et,{src:e[t.symbol],alt:`${t.symbol} logo`,width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):q(R,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:t.symbol.slice(0,3)})},t.symbol)),g>0&&q(ht,{ml:m,zIndex:h.length,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:J(R,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,g]})}),d.length===0&&c&&q(R,{fontSize:`sm`,color:p,fontWeight:`700`,children:u(`No assets`)})]}),s]})},Iu=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=Y(),{account:i}=Q(),{formattedBalance:a,isLoading:o,priceChange24hPct:s}=wc({address:i?.address??``}),{refresh:c}=Zc(),[l,u]=G(!1),d=B(`colors`,`vechain-kit-text-secondary`),f=async()=>{u(!0),await c(),setTimeout(()=>{u(!1)},1500)},[p,m]=jh(Ah.SHOW_ASSETS,!0);return J(z,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[J(N,{w:`full`,justifyContent:`space-between`,alignItems:`center`,spacing:0,role:`group`,children:[q(wt,{size:`xs`,fontWeight:`800`,color:d,textTransform:`uppercase`,letterSpacing:1.2,ml:`5px`,children:r(`Assets`)}),J(N,{spacing:0,alignItems:`center`,children:[q(Tt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:f,icon:q(P,{as:ni,boxSize:4}),isLoading:o||l,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}}),q(Tt,{"aria-label":`Show/hide assets`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:()=>m(!p),icon:q(P,{as:p?Oa:ka,boxSize:4})})]})]}),q(M,{onClick:n,h:`fit-content`,variant:`vechainKitSecondary`,children:J(z,{spacing:2,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,mt:4,mb:4,children:[J(N,{spacing:3,align:`baseline`,children:[q(wt,{size:`2xl`,fontWeight:`700`,children:p?a:`$****`}),p&&q(Gh,{valuePct:s,showSuffix:!0,fontSize:`sm`})]}),q(N,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:q(Fu,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:q(P,{as:Or,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},Lu=[{id:`send`,icon:br,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{id:`swap`,icon:_r,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{id:`receive`,icon:gr,label:`Receive`,onClick:e=>{e(`receive-token`)}}],Ru=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=Y();return q(Tt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:J(z,{spacing:4,children:[q(P,{as:e,boxSize:5,opacity:.9}),J(N,{p:0,alignItems:`baseline`,spacing:1,children:[q(R,{fontSize:`sm`,fontWeight:`600`,"data-testid":`${t.toLowerCase()}-button-label`,children:a(t,t)}),i&&q(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},zu=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hiddenQuickActions:o=[]}=$(),{hasAnyBalance:s}=wc({address:n?.address??``}),{data:c}=nh(r?.address??``,i?.address??``,3),l=a.isConnectedWithPrivy&&c,u=Lu.filter(e=>!o.includes(e.id));return u.length?q(St,{templateColumns:`repeat(${u.length}, 1fr)`,gap:2,w:`full`,mt:e,children:u.map(e=>q(Ru,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(s),showRedDot:l&&e.label===`Settings`},e.id))}):null},Bu=({setCurrentContent:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-primary`),r=B(`colors`,`vechain-kit-text-secondary`);return q(ct,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`profile`),initialContentSource:`profile`}})},cursor:`pointer`,_hover:{opacity:.8},children:q(lt,{p:4,children:q(N,{justify:`space-between`,align:`flex-start`,spacing:3,children:J(z,{align:`flex-start`,spacing:1,children:[J(N,{spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`400`,color:n,children:t(`Claim your vet domain!`)}),q(nn,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),q(R,{fontSize:`xs`,color:r,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]})})})})},Vu=()=>{let{t:e}=Y();return q(rt,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(N,{spacing:2,align:`flex-start`,children:[q(at,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},Hu=()=>{let{t:e}=Y();return q(rt,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(N,{spacing:2,align:`flex-start`,children:[q(at,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`A .vet domain is required to customize your profile. Choose an account name to get started.`)})]})})})},Uu=()=>{let{t:e}=Y(),{getConnectionCache:t}=om(),n=t();return J(ct,{variant:`vechainKitBase`,w:`full`,children:[J(dt,{p:4,pl:6,borderBottomWidth:`1px`,children:[q(R,{fontWeight:`medium`,opacity:.8,children:e(`Security preferences`)}),q(R,{fontSize:`xs`,mt:1,opacity:.7,children:e(`For security reasons, you can manage your embedded wallet settings only on the {{appName}} platform.`,{appName:n?.ecosystemApp.name??`origin app`})})]}),q(lt,{borderRadius:`none`,children:J(z,{spacing:3,align:`stretch`,children:[J(N,{spacing:3,align:`center`,children:[q(ft,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(P,{as:fi})}),J(j,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Login methods`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Manage your login methods and passkeys`)})]})]}),J(N,{spacing:3,align:`center`,children:[q(ft,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(P,{as:oi})}),J(j,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Security settings`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Backup your wallet, configure MFA and set recovery options`)})]})]})]})}),q(ut,{children:J(M,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??Ze,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),q(P,{as:Lr,ml:2})]})})]})},Wu=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:r}=Y(),{network:i}=$(),{account:a}=Q(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-error`),c=B(`colors`,`vechain-kit-card`),l=xn(null),u=xn(null),[d,f]=G(!1),{onUpload:p}=xl({compressImage:!0}),[m,h]=G(null),[g,_]=G(null),v=!!a?.domain,[y,b]=G(null),[x,S]=G(``),[C,w]=G(``),{register:ee,watch:T,formState:{errors:E,isValid:D}}=Ta({defaultValues:{displayName:a?.metadata?.display||``,description:a?.metadata?.description||``},mode:`onChange`});U(()=>{if(a?.metadata){let e=a.metadata;S(e.display||``),w(e.description||``),b(a.image?a.image.replace(`ipfs://`,``):null),h(e=>e??a.image??null)}},[a,i.type]);let O=T(),k=async e=>{let t=e.target.files?.[0];if(t)try{f(!0),m&&URL.revokeObjectURL(m),h(URL.createObjectURL(t));let e=await p(t);if(!e)throw Error(`Failed to compress image`);_(await n(e.file,t.name,i.type))}catch(e){console.error(`Error uploading image:`,e),h(null)}finally{f(!1)}};U(()=>()=>{m&&URL.revokeObjectURL(m)},[m]);let te=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),O.displayName!==x&&(e.displayName=O.displayName),O.description!==C&&(e.description=O.description),e},A=W(()=>{let e=te();return Object.keys(e).length>0},[te]),ne=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:te(),onDoneRedirectContent:t}})},re=()=>{e(t)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Customization`)}),q(Fo,{onClick:re}),q(I,{})]}),J(F,{children:[J(j,{cursor:v?`pointer`:`default`,pt:2,display:`flex`,justifyContent:`center`,position:`relative`,onClick:()=>v&&l.current?.click(),children:[q(Xh,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&q(P,{as:wr,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&q(j,{display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`,position:`absolute`,transform:`translateX(0%)`,width:`100px`,height:`100px`,borderRadius:`full`,zIndex:10,children:q(R,{fontSize:`xs`,color:`white`,children:d?`Uploading...`:`Processing...`})})]}),J(z,{spacing:6,mt:4,children:[!v&&q(Hu,{}),q(Nu,{title:a?.domain??r(`Choose account name`),description:r(`Choose a unique .vet domain name for your account.`),onClick:()=>{a?.domain?e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}}}}):e({type:`choose-name`,props:{setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}},onBack:()=>e({type:`account-customization`,props:{setCurrentContent:e}})}})},leftIcon:li,rightIcon:Or,dataTestId:`set-domain-name-button`}),J(bt,{isDisabled:!v,isInvalid:!!E.displayName,children:[q(xt,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Display Name`)}),q(Dt,{...ee(`displayName`,{maxLength:{value:25,message:r(`Display name must be less than 25 characters`)}}),placeholder:r(v?`Enter your display name`:`Set a domain first`),fontWeight:`medium`,color:o,"data-testid":`display-name-input`}),E.displayName&&q(R,{color:s,fontSize:`sm`,mt:1,fontWeight:`medium`,children:E.displayName.message})]}),J(bt,{isDisabled:!v,isInvalid:!!E.description,children:[q(xt,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Description`)}),q(rn,{...ee(`description`,{maxLength:{value:100,message:r(`Description must be less than 100 characters`)}}),placeholder:r(`Eg: DevRel @ ENS Labs`),fontWeight:`medium`,color:o,"data-testid":`description-input`,minH:`50px`}),E.description&&q(R,{color:s,mt:1,fontSize:`sm`,fontWeight:`medium`,children:E.description.message})]})]}),q(`input`,{type:`file`,ref:l,hidden:!0,accept:`image/*`,onChange:async e=>await k(e)}),q(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),q(It,{w:`full`,children:q(M,{variant:`vechainKitPrimary`,onClick:ne,isDisabled:!v||!A||!D,isLoading:d,loadingText:r(`Preparing changes...`),"data-testid":`save-changes-button`,children:r(`Save Changes`)})})]})},Gu=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=Y(),{darkMode:i,network:a,feeDelegation:o}=$(),s=B(`colors`,`vechain-kit-text-primary`),{account:c,connectedWallet:l,connection:u}=Q(),{preferences:d}=Hh(),{data:f}=nh(c?.address??``,l?.address??``,3),{open:p}=Yp(),{handleSubmit:m}=Ta({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),h=c?.domain??``,{data:g}=Ms(h),_=dr(),{sendTransaction:v,txReceipt:y,error:b,isWaitingForWalletConfirmation:x,isTransactionPending:C,clauses:w}=As({resolverAddress:g,signerAccountAddress:c?.address??``,onSuccess:async()=>{try{await he()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),[ee,T]=V.useState(!1);V.useEffect(()=>{if(!y||y.reverted||ee||C)return;let t=y.meta.txID;t&&(T(!0),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}}))},[y,ee,C,e,r,n]),V.useEffect(()=>{C&&T(!1)},[C]);let E=W(()=>{let e=c?.domain??``,n={displayName:`display`,description:`description`,twitter:`com.x`,website:`url`,email:`email`,avatarIpfsHash:`avatar`};return Object.entries(t).filter(e=>e[1]!==void 0&&e[1]!==null).map(([t,r])=>({domain:e,key:n[t],value:t===`avatarIpfsHash`?`ipfs://${r}`:r}))},[t,c?.domain]),D=W(()=>{try{return!g||E.length===0||!w?[]:w(E)}catch(e){return console.error(`Error building clauses:`,e),[]}},[E,w,g]),[O,k]=V.useState(null),[te,A]=V.useState(null),ne=d.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:re,isLoading:ie,error:ae,refetch:oe}=Uh({clauses:D,tokens:O?[O]:d.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),se=re?.usedToken,ce=(ie||!re)&&u.isConnectedWithPrivy&&!o?.delegatorUrl,le=V.useCallback(e=>{k(e),A(e),setTimeout(()=>oe(),100)},[oe]),ue=!!se&&!ae;V.useEffect(()=>{ae&&O&&k(null)},[ae,O]);let de=async()=>{if(f){p();return}try{E.length>0&&await v(E)}catch(e){console.error(`Error saving changes:`,e)}},fe=(e,t)=>t?.trim()?J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:e}),q(R,{fontSize:`md`,children:t})]}):null,pe=()=>{m(de)()},me=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},he=async()=>{t.avatarIpfsHash&&(_.setQueryData(Ss(h,a.type),S(`ipfs://`+t.avatarIpfsHash,a.type)),_.setQueryData(Fs(c?.address??``),S(`ipfs://`+t.avatarIpfsHash,a.type))),await _.invalidateQueries({queryKey:Es(h,a.type)}),await _.refetchQueries({queryKey:Es(h,a.type)})};return J(K,{children:[J(Z,{children:[q(L,{children:r(`Confirm Changes`)}),q(Fo,{isDisabled:C,onClick:me}),q(I,{isDisabled:C})]}),J(F,{children:[J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:Rr,color:s,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:s,children:r(`By confirming, the following details attached to your name ({{domain}}) will be updated`,{domain:h})})]}),J(z,{spacing:4,align:`stretch`,mt:6,children:[t.avatarIpfsHash&&J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:r(`Profile Image`)}),q(R,{fontSize:`md`,children:r(`New image selected`)})]}),t.displayName&&fe(r(`Display Name`),t.displayName),t.description&&fe(r(`Description`),t.description),t.twitter&&fe(r(`Twitter`),t.twitter),t.website&&fe(r(`Website`),t.website),t.email&&fe(r(`Email`),t.email)]}),u.isConnectedWithPrivy&&q(eg,{estimation:re,isLoading:ie,isLoadingTransaction:C,onTokenChange:le,clauses:D,userSelectedToken:te})]}),q(It,{gap:4,w:`full`,children:q(Zh,{transactionError:b,isSubmitting:C,isTxWaitingConfirmation:x,onConfirm:m(de),onRetry:pe,transactionPendingText:r(`Saving changes...`),txReceipt:y,buttonText:r(`Confirm`),isDisabled:C||ce,gasEstimationError:ae,hasEnoughGasBalance:ue,isLoadingGasEstimation:ie,showGasEstimationError:!o?.delegatorUrl&&u.isConnectedWithPrivy,context:`customization`})})]})},Ku=({address:e,showHeader:t=!0,showLinks:n=!0,showDescription:r=!0,showDisplayName:i=!0,reserveNameDescriptionSpace:a=!1,setCurrentContent:o,onLogout:s})=>{let{network:c}=$(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-card`),p=rl(e,c.type),m=l(e),h=p?.records?.url||p?.records?.[`com.x`]||p?.records?.email,g=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}};return J(z,{spacing:0,w:`full`,children:[q(j,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,background:t?`no-repeat url('${m}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),J(j,{position:`relative`,display:`inline-block`,cursor:o?`pointer`:`default`,onClick:o?()=>{o({type:`account-customization`,props:{setCurrentContent:o,initialContentSource:`profile`}})}:void 0,children:[q(Xh,{wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},props:{width:`120px`,height:`120px`}}),o&&q(P,{as:Qr,position:`absolute`,bottom:`0`,right:`0`,bg:f,color:u,p:`1`,borderRadius:`full`,boxSize:`6`,border:`2px solid`,borderColor:f})]}),J(z,{w:`full`,spacing:2,children:[i&&(p?.records?.display?q(R,{fontSize:`xl`,color:u,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:p?.records?.display}):a&&q(j,{mt:2,minH:`28px`,"aria-hidden":!0})),r&&(p?.records?.description?q(R,{fontSize:`sm`,color:d,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:p?.records?.description}):a&&q(j,{minH:`20px`,"aria-hidden":!0})),n&&h&&J(N,{w:`full`,justify:`center`,spacing:5,mt:4,children:[p?.records?.email&&q(jt,{href:`mailto:${p?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:q(P,{as:Xr,color:u})}),p?.records?.url&&q(jt,{href:g(p.records.url)??void 0,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`website-link`,children:q(P,{as:Ur,color:u})}),p?.records?.[`com.x`]&&q(jt,{href:`https://x.com/${encodeURIComponent(String(p.records[`com.x`]))}`,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`twitter-link`,children:q(P,{as:ja,color:u})})]}),q(Io,{onLogout:s,wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},style:{mt:4},setCurrentContent:o})]})]})},qu=({onClick:e,...t})=>{let{smartAccount:n,connectedWallet:r,connection:i}=Q(),[a,o]=G(!1);U(()=>{o(!localStorage.getItem(`app-first-visit`))},[]);let{data:s}=nh(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return q(Tt,{"aria-label":`Settings`,size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,lineHeight:`0`,onClick:l,icon:J(j,{position:`relative`,children:[q(P,{as:ii,fontSize:`18px`}),c&&q(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},Ju=({setCurrentContent:e,onLogoutSuccess:t,switchFeedback:n})=>{let{t:r}=Y(),{account:i,disconnect:a,connection:o}=Q(),{switchWallet:s,isSwitching:c,isInAppBrowser:l}=al(),{isSwitchWalletEnabled:u}=rr(),{hasAnyBalance:d,formattedBalance:f}=wc({address:i?.address}),[p]=jh(Ah.SHOW_ASSETS,!0),m=()=>{l?s():e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:`profile`,onLogoutSuccess:t}})};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Profile`)}),q(qu,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),q(I,{})]}),q(F,{w:`full`,children:J(z,{w:`full`,spacing:6,children:[q(ig,{showFeedback:n?.showFeedback}),!i?.domain&&q(Bu,{setCurrentContent:e}),q(Ku,{reserveNameDescriptionSpace:!!i?.domain,onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,setCurrentContent:e,onLogout:()=>{a(),t?.()}})]})}),q(It,{w:`full`,children:J(N,{w:`full`,justify:`space-between`,spacing:4,mt:4,children:[q(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:d?void 0:q(P,{as:mi}),onClick:()=>e(`main`),"data-testid":`wallet-button`,children:d?J(N,{spacing:2,w:`full`,justify:`center`,children:[q(Fu,{address:i?.address??``,maxIcons:2}),q(R,{fontWeight:`600`,children:p?f:`$****`})]}):r(`Wallet`)}),o.isInAppBrowser&&u||!o.isInAppBrowser&&o.isConnectedWithDappKit?q(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(P,{as:_r}),colorScheme:`red`,onClick:async()=>{m()},isLoading:c,isDisabled:c,"data-testid":`switch-wallet-button`,children:r(`Switch`)}):q(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(P,{as:Yr}),colorScheme:`red`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}}),"data-testid":`logout-button`,children:r(`Logout`)})]})})]})},Yu=({setCurrentContent:e,handleClose:t,initialContent:n=`settings`})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=nh(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=sh({smartAccountAddress:i?.address??``,targetVersion:3,onSuccess:()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:d?.meta.txID,title:r(`Upgrade Successful!`),description:r(`Your account has been successfully upgraded to the latest version. You can now enjoy a better user experience, lower gas costs, and enhanced security.`),onDone:()=>{t?t():e(n)},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(Fo,{onClick:()=>{e(n)}}),q(I,{})]}),q(F,{children:J(z,{spacing:10,align:`stretch`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(o?`Your smart account needs to be upgraded to the latest version (v3).`:`Your smart account is already upgraded to this version.`)}),J(N,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(j,{position:`relative`,display:`inline-block`,children:[q(ht,{size:`60px`,bg:`gray.200`,children:q(Et,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(wt,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(P,{as:vr,color:`#3DBA67`}),J(j,{position:`relative`,display:`inline-block`,children:[q(ht,{size:`60px`,bg:`gray.200`,children:q(Et,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(wt,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(rt,{status:`info`,borderRadius:`md`,children:[q(at,{}),J(j,{children:[q(ot,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(it,{fontSize:`xs`,children:J(z,{align:`start`,spacing:0,mt:1,children:[J(R,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),J(R,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),q(It,{justifyContent:`center`,children:J(z,{spacing:3,w:`full`,children:[q(Zh,{buttonText:r(o?`Upgrade account`:`Account already upgraded`),onConfirm:async()=>{try{await s()}catch(e){console.error(`Failed to upgrade Smart Account:`,e)}},isTxWaitingConfirmation:l,isSubmitting:c,transactionPendingText:r(`Upgrading...`),txReceipt:d,transactionError:u,isDisabled:!o}),q(M,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},Xu=({icon:e,label:t,onClick:n,isDisabled:r})=>{let{t:i}=Y(),a=i(t,t);return q(Tt,{variant:`vechainKitSecondary`,h:`44px`,flex:1,borderRadius:`lg`,"aria-label":a,isDisabled:r,onClick:n,icon:J(N,{spacing:1.5,children:[q(P,{as:e,boxSize:3.5,opacity:.85}),q(R,{fontSize:`sm`,fontWeight:`600`,children:a})]})})},Zu=({onSend:e,onSwap:t,onHistory:n,hideHistory:r})=>{let{account:i}=Q(),{formattedBalance:a,hasAnyBalance:o,isLoading:s,priceChange24hPct:c}=wc({address:i?.address??``}),{points:l}=Rc(i?.address),{currentCurrency:u}=lc(),d=typeof c==`number`?c>0?`up`:c<0?`down`:`neutral`:`neutral`,[f]=jh(Ah.SHOW_ASSETS,!0);return J(z,{w:`full`,spacing:4,align:`stretch`,children:[J(N,{spacing:3,align:`baseline`,children:[q(wt,{size:`2xl`,fontWeight:`700`,children:s?`...`:f?a:`$****`}),f&&q(Gh,{valuePct:c,showSuffix:!0,fontSize:`sm`})]}),f&&l.length>1&&q(lg,{points:l,tone:d,chartHeight:72,interactive:!0,formatValue:e=>sc(e,{currency:u})}),J(N,{spacing:2,w:`full`,children:[q(Xu,{icon:_r,label:`Swap`,onClick:t,isDisabled:!o}),q(Xu,{icon:br,label:`Send`,onClick:e,isDisabled:!o}),!r&&q(Xu,{icon:Gr,label:`History`,onClick:n})]})]})},Qu=({tabIndex:e,onTabChange:t,tokenPanel:n,stakingPanel:r})=>{let{t:i}=Y();return J(tn,{index:e,onChange:e=>t(e??0),variant:`unstyled`,isLazy:!0,children:[J(Qt,{children:[q(Xt,{fontWeight:`600`,fontSize:`md`,children:i(`Token`)}),q(Xt,{fontWeight:`600`,fontSize:`md`,children:i(`Staking`)})]}),q(Zt,{mt:`-2px`,height:`2px`,bg:`vechain-kit-accent`}),J(en,{children:[q($t,{px:0,pt:4,children:n}),q($t,{px:0,pt:4,children:r})]})]})},$u=({onSelect:e,onManageTokens:t})=>{let{t:n}=Y(),{account:r}=Q(),{darkMode:i}=$(),{sortedTokens:a}=uc({address:r?.address}),{currentCurrency:o}=lc(),[s,c]=G(``),l=B(`colors`,`vechain-kit-text-tertiary`),u=a.filter(({symbol:e})=>e.toLowerCase().includes(s.toLowerCase()));return J(z,{spacing:3,align:`stretch`,w:`full`,children:[J(N,{spacing:2,children:[J(Ot,{size:`md`,flex:1,children:[q(Dt,{placeholder:n(`Search token`),bg:i?`#00000038`:`gray.50`,borderRadius:`lg`,height:`40px`,pl:10,value:s,onChange:e=>c(e.target.value),"data-testid":`search-token-input`}),q(kt,{h:`40px`,w:`40px`,pl:3,children:q(ri,{color:l})})]}),t&&q(an,{label:n(`Manage Custom Tokens`),children:q(Tt,{"aria-label":n(`Manage Custom Tokens`),icon:q(Qr,{}),variant:`vechainKitSecondary`,size:`md`,height:`40px`,width:`40px`,minW:`40px`,borderRadius:`lg`,onClick:t})})]}),q(z,{spacing:2,align:`stretch`,children:u.map(t=>q(Kh,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:o,onClick:()=>e(t),priceChange24hPct:t.priceChange24hPct},t.address))})]})},ed=({name:e,logoSrc:t,logoFallback:n,totalValueInCurrency:r,tag:i,platformUrl:a,children:o})=>{let{t:s}=Y(),{currentCurrency:c}=lc(),l=B(`colors`,`vechain-kit-text-primary`);return J(z,{w:`full`,align:`stretch`,spacing:3,p:4,borderRadius:`xl`,bg:B(`colors`,`vechain-kit-card`),children:[J(N,{w:`full`,justify:`space-between`,align:`center`,children:[J(N,{spacing:2,children:[t?q(Et,{src:t,alt:e,boxSize:`24px`,borderRadius:`full`,fallback:q(j,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):n??q(j,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.300`}),q(wt,{size:`sm`,color:l,children:e})]}),q(R,{fontWeight:`600`,color:l,children:sc(r,{currency:c})})]}),i&&q(j,{children:q(nn,{size:`sm`,colorScheme:`purple`,borderRadius:`md`,children:i})}),q(vt,{opacity:.2}),q(z,{w:`full`,align:`stretch`,spacing:2,children:o}),a&&q(M,{as:`a`,href:a,target:`_blank`,rel:`noopener noreferrer`,variant:`vechainKitSecondary`,size:`xs`,leftIcon:q(Lr,{size:11}),fontSize:`xs`,h:`40px`,px:3,mt:1,children:s(`Go to platform`)})]})},td=({label:e,amount:t,valueInCurrency:n,rightLabel:r,iconSrc:i,iconFallback:a})=>{let{currentCurrency:o}=lc(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`);return J(N,{w:`full`,justify:`space-between`,align:`center`,children:[J(N,{spacing:2,children:[i?q(Et,{src:i,alt:e,boxSize:`20px`,borderRadius:`full`,fallback:q(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):a,J(z,{spacing:0,align:`flex-start`,children:[q(R,{fontSize:`sm`,color:c,children:e}),q(R,{fontSize:`sm`,color:s,children:t})]})]}),J(z,{spacing:0,align:`flex-end`,children:[q(R,{fontSize:`sm`,color:s,children:sc(n,{currency:o})}),r]})]})},nd=()=>{let{t}=Y(),{account:n}=Q(),{positions:r,totalValueInCurrency:i,isLoading:a}=dc(n?.address);return a||!r.length?null:q(ed,{name:`StarGate`,logoSrc:`https://app.stargate.vechain.org/stargate-icon.png`,totalValueInCurrency:i,tag:r.some(e=>e.isDelegated)?t(`Delegating`):t(`Staked`),platformUrl:`https://app.stargate.vechain.org/`,children:r.map(n=>q(td,{label:t(`Supplied`),amount:`${n.vetAmountFormatted.toLocaleString(void 0,{maximumFractionDigits:2})} VET`,valueInCurrency:n.valueInCurrency,iconSrc:e.VET,rightLabel:n.isDelegated?q(nn,{size:`sm`,colorScheme:`green`,borderRadius:`md`,children:t(`Delegated`)}):q(R,{fontSize:`xs`,opacity:.6,children:t(`Not delegated`)})},n.tokenId))})},rd=()=>{let{t}=Y(),{account:n}=Q(),{isNavigator:r,isDelegated:i,stakedB3TR:a,delegatedAmount:o,navigatorAddress:s,totalValueInCurrency:c,isLoading:l}=mc(n?.address);return l||!r&&!i?null:J(ed,{name:`VeBetter`,logoSrc:e.B3TR,totalValueInCurrency:c,tag:t(r?`Navigator`:`Delegating`),platformUrl:`https://governance.vebetterdao.org`,children:[r&&q(td,{label:t(`Staked B3TR`),amount:`${a.toLocaleString(void 0,{maximumFractionDigits:2})} B3TR`,valueInCurrency:c*(a+o>0?a/(a+o):1),iconSrc:e.B3TR}),i&&q(td,{label:t(`Delegated to {{name}}`,{name:s?d(s,4,4):t(`navigator`)}),amount:`${o.toLocaleString(void 0,{maximumFractionDigits:2})} B3TR`,valueInCurrency:c*(a+o>0?o/(a+o):1),iconSrc:e.B3TR})]})},id=()=>{let{t:e}=Y(),{account:t}=Q(),{positions:n,totalValueInCurrency:r,isLoading:i}=_c(t?.address);return i||!n.length?null:q(ed,{name:`BetterSwap`,logoFallback:q(Ue,{boxSize:`24px`}),totalValueInCurrency:r,tag:e(`Liquidity`),platformUrl:`https://www.betterswap.io/`,children:n.map(e=>q(td,{label:`${e.token0.symbol||`?`} / ${e.token1.symbol||`?`}`,amount:`${e.lpBalance.toLocaleString(void 0,{maximumFractionDigits:4})} LP`,valueInCurrency:e.valueInCurrency},e.pairAddress))})},ad=e=>e==null||!Number.isFinite(e)?null:e>=1e3?`${Math.round(e)}`:e.toFixed(2),od=e=>{if(e!=null)return e<1.1?`red`:e<1.5?`orange`:`green`},sd=()=>{let{t}=Y(),{account:n}=Q(),{currentCurrency:r}=lc(),i=B(`colors`,`vechain-kit-text-secondary`),{supplied:a,borrowed:o,totalSuppliedInCurrency:s,totalBorrowedInCurrency:c,healthFactor:l,netValueInCurrency:u,hasPosition:d,isLoading:f}=Cc(n?.address);if(f||!d)return null;let p=o.length?t(`Borrowing`):t(`Lending`),m=ad(l),h=od(l);return J(ed,{name:`Juicy Finance`,logoSrc:`https://www.juicyfinance.io/logo192.png`,totalValueInCurrency:u,tag:p,platformUrl:`https://www.juicyfinance.io/`,children:[m&&J(N,{w:`full`,justify:`space-between`,align:`center`,px:1,children:[q(R,{fontSize:`xs`,color:i,children:t(`Health rate`)}),q(nn,{size:`sm`,colorScheme:h,borderRadius:`md`,children:m})]}),a.length>0&&J(j,{w:`full`,children:[J(N,{w:`full`,justify:`space-between`,align:`center`,px:1,mb:1,children:[q(R,{fontSize:`xs`,color:i,children:t(`Supplied`)}),q(R,{fontSize:`xs`,color:i,children:sc(s,{currency:r})})]}),a.map(t=>q(td,{label:t.symbol,amount:`${t.amount.toLocaleString(void 0,{maximumFractionDigits:4})} ${t.symbol}`,valueInCurrency:t.valueInCurrency,iconSrc:e[t.symbol]},`s-${t.asset}`))]}),o.length>0&&J(j,{w:`full`,children:[J(N,{w:`full`,justify:`space-between`,align:`center`,px:1,mb:1,mt:2,children:[q(R,{fontSize:`xs`,color:i,children:t(`Borrowed`)}),q(R,{fontSize:`xs`,color:i,children:sc(c,{currency:r})})]}),o.map(t=>q(td,{label:t.symbol,amount:`${t.amount.toLocaleString(void 0,{maximumFractionDigits:4})} ${t.symbol}`,valueInCurrency:t.valueInCurrency,iconSrc:e[t.symbol]},`b-${t.asset}`))]})]})},cd=()=>{let{t:e}=Y(),{account:t}=Q(),n=B(`colors`,`vechain-kit-text-secondary`),r=dc(t?.address),i=mc(t?.address),a=_c(t?.address),o=Cc(t?.address),s=r.positions.length>0,c=i.isNavigator||i.isDelegated,l=a.positions.length>0,u=o.hasPosition;return!(r.isLoading||i.isLoading||a.isLoading||o.isLoading)&&!(s||c||l||u)?q(j,{py:6,textAlign:`center`,children:q(R,{color:n,children:e(`No staking positions yet`)})}):J(z,{spacing:3,align:`stretch`,w:`full`,children:[s&&q(nd,{}),c&&q(rd,{}),u&&q(sd,{}),l&&q(id,{})]})},ld=({setCurrentContent:e})=>{let{t}=Y(),{allowCustomTokens:n}=$(),{isolatedView:r}=gu(),[i,a]=G(0);return J(K,{children:[J(Z,{children:[q(L,{children:t(`Assets`)}),!r&&q(Fo,{onClick:()=>e(`main`)}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,w:`full`,children:[q(Zu,{onSend:()=>{e({type:`send-token`,props:{setCurrentContent:e,onBack:()=>e(`assets`)}})},onSwap:()=>{e({type:`swap-token`,props:{setCurrentContent:e,onBack:()=>e(`assets`)}})},onHistory:()=>{e({type:`transaction-history`,props:{setCurrentContent:e}})}}),q(Qu,{tabIndex:i,onTabChange:a,tokenPanel:q($u,{onSelect:t=>{e({type:`token-detail`,props:{setCurrentContent:e,token:t}})},onManageTokens:n?()=>e(`add-custom-token`):void 0}),stakingPanel:q(cd,{})})]})})})]})},ud=({setCurrentContent:t})=>{let{t:n}=Y(),r=B(`colors`,`vechain-kit-text-primary`),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-overlay`),{addToken:s,removeToken:c,isTokenIncluded:l,isDefaultToken:u,customTokens:f}=kc(),{register:p,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=Ta({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(l(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:n(`Token already added`)});try{await s(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token:`,e),m(`newTokenAddress`,{type:`manual`,message:n(`Invalid token address`)})}}};return J(K,{children:[J(Z,{children:[q(L,{children:n(`Manage Custom Tokens`)}),q(Fo,{onClick:()=>t(`assets`)}),q(I,{})]}),q(F,{children:J(z,{spacing:4,align:`stretch`,children:[q(j,{p:4,borderRadius:`xl`,bg:a,children:J(z,{align:`stretch`,spacing:3,children:[q(R,{fontSize:`sm`,color:i,children:n(`Paste a token contract address to track its balance in your wallet.`)}),J(bt,{isInvalid:!!g.newTokenAddress,children:[J(N,{spacing:2,children:[q(Dt,{...p(`newTokenAddress`,{required:n(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:n(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||n(`Invalid contract address`)}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,h(`newTokenAddress`,t,{shouldValidate:!0})},placeholder:`0x...`,variant:`outline`,fontSize:`md`,fontWeight:`medium`,flex:1}),q(Tt,{"aria-label":n(`Add Token`),icon:q(ei,{}),variant:`vechainKitPrimary`,size:`md`,minW:`40px`,w:`40px`,h:`40px`,borderRadius:`lg`,isDisabled:!_,onClick:v(y)})]}),g.newTokenAddress&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,children:g.newTokenAddress.message})]})]})}),J(j,{children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:i,mb:2,px:1,children:n(`Existing Custom Tokens`)}),f.length>0?q(z,{align:`stretch`,spacing:2,children:f.map(t=>J(N,{justify:`space-between`,fontSize:`sm`,p:3,borderRadius:`xl`,bg:o,children:[J(N,{spacing:3,children:[q(Et,{src:e[t?.symbol],alt:`${t.symbol} logo`,boxSize:`28px`,borderRadius:`full`,fallback:q(j,{boxSize:`28px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`9px`,fontWeight:`bold`,color:r,children:t.symbol?.slice(0,3)})})}),J(z,{spacing:0,align:`start`,children:[q(R,{fontWeight:`medium`,color:r,fontSize:`sm`,children:t.symbol??`Unknown`}),q(R,{color:i,fontSize:`xs`,children:d(t.address??``,6,4)})]})]}),q(M,{size:`sm`,variant:`ghost`,color:i,borderRadius:`md`,p:2,onClick:()=>c(t.address),children:q(ui,{size:16})})]},t.address))}):q(j,{p:6,borderRadius:`xl`,bg:o,textAlign:`center`,children:q(R,{fontSize:`sm`,color:i,children:n(`No custom tokens added yet.`)})})]})]})})]})},dd=({setCurrentContent:e})=>{let{t}=Y(),{darkMode:n}=$(),{isolatedView:r}=gu();return J(K,{children:[J(Z,{children:[q(L,{children:t(`Bridge`)}),!r&&q(Fo,{onClick:()=>e(`main`)}),q(I,{})]}),q(_t,{maxW:`container.lg`,children:q(F,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[q(Ke,{isDark:n,borderRadius:`xl`}),q(R,{fontSize:`sm`,textAlign:`center`,children:t(`Exchange your digital assets between VeChain and other blockchain networks easily and securely. Swaps are executed through partners that leverage both decentralized and centralized exchanges to convert tokens.`)})]})})}),q(It,{children:J(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(Xe,`_blank`)},children:[t(`Launch vechain.energy`),q(P,{as:Lr,ml:2})]})})]})},fd=({setCurrentContent:e})=>{let{t:n}=Y(),{currentCurrency:r,changeCurrency:i,allCurrencies:a}=lc(),o=mn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`);U(()=>{ue(`settings-currency-visited`,`true`)},[]);let s=e=>{let n=r===e;return J(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:n?o:void 0,children:[J(N,{spacing:3,children:[q(R,{fontSize:`xl`,children:t[e]}),q(R,{children:e.toUpperCase()})]}),n&&q(P,{as:Tr,boxSize:5,color:`blue.500`})]},e)};return J(Yh,{children:[J(Z,{children:[q(L,{children:n(`Select currency`)}),q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:a.map(e=>s(e))})}),q(It,{pt:0})]})},pd=({setCurrentContent:e})=>{let{t,i18n:n}=Y(),r=mn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`),i=e=>{n.changeLanguage(e)},a=e=>{let t=n.language===e;return J(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:t?r:void 0,children:[q(R,{children:oo[e]}),t&&q(P,{as:Tr,boxSize:5,color:`blue.500`})]},e)};return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Select language`)}),q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:io.map(e=>a(e))})}),q(It,{pt:0})]})},md=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:s,onTouchStart:c,onTouchMove:l,onTouchEnd:u,isDragging:d,isDraggedOver:f})=>{let p=o[e],{darkMode:m}=$(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-card`);return q(j,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:d?m?`blue.500`:`blue.300`:f?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:d||n?.5:1,cursor:`move`,transition:`background-color 0.2s ease, border-color 0.2s ease`,draggable:!0,onDragStart:()=>i(t),onDragOver:e=>{e.preventDefault(),a(t)},onDrop:()=>s(t),onTouchStart:e=>c(t,e),onTouchMove:l,onTouchEnd:u,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:J(N,{justify:`space-between`,children:[J(N,{opacity:n?.5:1,children:[q(j,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:q(P,{as:Wr,color:g})}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:p.name}),q(R,{fontSize:`sm`,color:g,children:p.description})]})]}),q(Yt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},hd=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=G(null),[o,s]=G(null),c=xn([]),l=xn(0),u=e=>{a(e)},d=e=>{s(e)},f=t=>{if(i===null||i===t){a(null),s(null);return}let r=[...e],o=r[i];r.splice(i,1),r.splice(t,0,o),n(r),a(null),s(null)},p=(e,t)=>{l.current=t.touches[0].clientY,a(e)},m=e=>{if(i===null)return;let t=e.touches[0].clientY;for(let e=0;e<c.current.length;e++){let n=c.current[e];if(!n)continue;let r=n.getBoundingClientRect();if(t>=r.top&&t<=r.bottom){s(e);break}}},h=()=>{if(i!==null&&o!==null&&i!==o){let t=[...e],r=t[i];t.splice(i,1),t.splice(o,0,r),n(t)}a(null),s(null),l.current=0};return q(j,{w:`full`,children:e.map((e,n)=>q(j,{ref:e=>{c.current[n]=e},children:q(md,{token:e,index:n,isExcluded:t.includes(e),onToggleExclusion:r,onDragStart:u,onDragOver:d,onDrop:f,onTouchStart:p,onTouchMove:m,onTouchEnd:h,isDragging:i===n,isDraggedOver:o===n})},e))})},gd=({setCurrentContent:e})=>{let{t}=Y(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Hh(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=H(e=>{r(e)},[r]);return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Gas Token Preferences`)}),q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{w:`full`,children:J(z,{justify:`center`,spacing:6,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:o,textAlign:`center`,children:t(`Choose which tokens to use for transaction fees when the app is not covering them.`)})}),n.availableGasTokens.length===0&&J(rt,{status:`warning`,borderRadius:`md`,children:[q(at,{}),q(it,{fontSize:`sm`,color:o,children:t(`You must enable at least one token to perform transactions. Without any enabled tokens, you will not be able to pay for gas fees.`)})]}),J(z,{w:`full`,align:`start`,spacing:3,children:[q(R,{fontSize:`md`,fontWeight:`semibold`,color:a,children:t(`Token Priority Order`)}),q(R,{fontSize:`sm`,color:o,children:t(`Drag to reorder. The system will automatically use the highest priority token with sufficient balance.`)}),q(hd,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},_d=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=gu(),{exportWallet:i,linkPasskey:a}=Yn(),{showMfaEnrollmentModal:o}=Jn(),{feeDelegation:s}=$(),{connection:c,disconnect:l,smartAccount:u,connectedWallet:d}=Q(),{data:f}=nh(u?.address??``,d?.address??``,3),p=()=>{e({type:`upgrade-smart-account`,props:{setCurrentContent:e,initialContent:`settings`}})},m=()=>{e(`connection-details`)},h=()=>{l(),t()},g=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:n(`Settings`)}),!r&&q(Fo,{onClick:()=>e(`profile`)}),q(I,{})]}),J(F,{w:`full`,children:[J(z,{w:`full`,spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`General`)}),q(Nu,{title:n(`Currency`),onClick:()=>{e(`change-currency`)},leftIcon:Fr,rightIcon:Or}),q(Nu,{title:n(`Language`),onClick:()=>{e(`change-language`)},leftIcon:qr,rightIcon:Or}),c.isConnectedWithPrivy&&!s?.delegatorUrl&&q(Nu,{title:n(`Gas Token Preferences`),onClick:()=>{e(`gas-token-settings`)},leftIcon:Br,rightIcon:Or}),q(Nu,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:ai,rightIcon:Or}),q(Nu,{title:n(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:h,onBack:()=>e(`settings`)}}),leftIcon:Yr})]}),f&&q(z,{w:`full`,spacing:2,mt:4,children:q(Nu,{title:n(`Upgrade Smart Account to V3`),description:n(`A new version is available for your account`),onClick:p,leftIcon:ii,extraContent:q(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,ml:2})})}),c.isConnectedWithSocialLogin&&J(z,{w:`full`,spacing:2,mt:4,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Access and security`)}),q(Nu,{title:n(`Passkey`),onClick:()=>a(),leftIcon:zr}),q(Nu,{title:n(`Backup`),onClick:()=>{i()},leftIcon:Kr}),q(Nu,{title:n(`Manage MFA`),onClick:()=>{o()},leftIcon:oi}),q(Nu,{title:n(`Login methods`),onClick:()=>{e(`privy-linked-accounts`)},leftIcon:fi,rightIcon:Or})]}),J(z,{w:`full`,spacing:2,mt:4,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Help`)}),q(Nu,{title:n(`Connection details`),onClick:m,leftIcon:di,rightIcon:Or}),q(Nu,{title:n(`Explore ecosystem`),onClick:()=>e(`ecosystem`),leftIcon:Jr,rightIcon:Or}),q(Nu,{title:n(`Frequently asked questions`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:Mr,rightIcon:Or})]})]}),q(It,{p:0})]})},vd=({title:e,description:t,icon:n})=>{let r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return J(z,{spacing:6,align:`center`,py:8,children:[q(P,{as:n,boxSize:16,color:r}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:i,children:e}),q(R,{fontSize:`md`,color:r,textAlign:`center`,px:4,children:t})]})]})},yd=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),bd=({document:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===oe.VECHAIN_KIT&&e.documentType===le.TERMS;return J(N,{children:[J(nn,{size:`sm`,borderRadius:`full`,color:n,children:[`v`,e.version]}),q(R,{fontSize:`xs`,cursor:`pointer`,color:n,onClick:()=>{window.open(e.url,`_blank`)},_hover:{textDecoration:`underline`},children:r?t(`'{{policyName}}' on connect`,{policyName:e.displayName??t(`Vechain Kit Policy`)}):t(`'{{policyName}}' on {{date}}`,{policyName:e.displayName??t(`Policy`),date:yd(e.timestamp)})})]})},xd=({title:e,description:t,documents:n,bg:r,hoverBg:i,currentPolicy:a})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`),l=n?.length>0,u=n?.find(e=>e.id===a?.id);return l?q(tt,{border:`none`,mb:3,children:({isExpanded:l})=>J(K,{children:[J(et,{bg:r,borderRadius:`xl`,_hover:{bg:i},children:[J(z,{w:`full`,align:`flex-start`,textAlign:`left`,children:[q(R,{fontWeight:`700`,color:s,children:e}),q(R,{fontSize:`xs`,color:c,children:t})]}),q(P,{as:l?kr:Er,fontSize:`20px`,color:c})]}),q(nt,{pb:4,pt:3,children:J(z,{align:`stretch`,spacing:4,children:[u?.id?J(N,{w:`full`,children:[q(P,{as:Tr,color:s}),q(R,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:yd(u.timestamp)})})]}):null,q(N,{w:`full`,textAlign:`left`,children:q(R,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),q(N,{w:`full`,gap:2,children:q(z,{align:`stretch`,spacing:2,children:n.map(e=>q(bd,{document:e},e.id))})}),a&&q(M,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Sd=()=>{let{account:e}=Q(),{t}=Y(),{darkMode:n}=$(),{agreements:r,documents:i}=bg(),a=W(()=>{let t=r?.filter(t=>E(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...ee,documentType:le.TERMS,documentSource:oe.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),o=W(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),s=W(()=>Object.values(a).some(e=>e.length>0),[a]),c=n?`whiteAlpha.50`:`blackAlpha.50`,l=n?`whiteAlpha.100`:`blackAlpha.100`,u=W(()=>{let e=[];return a[le.TERMS]?.length>0&&e.push(0),a[le.PRIVACY]?.length>0&&e.push(1),a[le.COOKIES]?.length>0&&e.push(2),e},[a]);return s?q(z,{spacing:4,align:`stretch`,children:J($e,{allowMultiple:!0,defaultIndex:u,children:[q(xd,{title:t(`Terms and Conditions`),description:t(`Legal agreement between you, Vechain Kit and the current app, outlining the rules for using wallet services.`),documents:a[le.TERMS],bg:c,hoverBg:l,currentPolicy:o[le.TERMS]}),q(xd,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[le.PRIVACY],bg:c,hoverBg:l,currentPolicy:o[le.PRIVACY]}),q(xd,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[le.COOKIES],bg:c,hoverBg:l,currentPolicy:o[le.COOKIES]})]})}):q(vd,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:Vr})},Cd=({onGoBack:e})=>{let{t}=Y();return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Terms and Policies`)}),q(Fo,{onClick:e}),q(I,{})]}),q(F,{w:`full`,children:q(z,{spacing:6,align:`stretch`,children:q(Sd,{})})}),q(It,{pt:0})]})},wd=({onDisconnect:e,onBack:t,onClose:n,showCloseButton:r=!0,text:i})=>{let{t:a}=Y(),o=B(`colors`,`vechain-kit-text-primary`),s=i??a(`Are you sure you want to disconnect your wallet?`);return J(K,{children:[J(Z,{children:[q(L,{children:a(`Logout`)}),q(Fo,{onClick:t}),r?q(I,{onClick:n}):null]}),q(F,{children:J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:Yr,color:`#ef4444`,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:o,children:s})]})}),q(It,{w:`full`,mt:4,children:J(z,{spacing:3,w:`full`,children:[q(M,{onClick:e,"data-testid":`disconnect-button`,variant:`vechainKitLogout`,children:a(`Confirm`)}),q(M,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},Td=({wallet:e,isActive:t,onSelect:n,onRemove:i,showRemove:a=!0})=>{let{t:o}=Y(),{network:s}=$(),{formattedBalance:c,isLoading:l}=wc({address:e.address}),{domain:u,image:f,isLoading:p}=rl(e.address,s.type),m=B(`colors`,`vechain-kit-text-primary`),h=B(`colors`,`vechain-kit-text-secondary`),g=B(`colors`,`vechain-kit-border`),_=l||p;return q(ct,{variant:`vechainKitWalletCard`,onClick:n,borderWidth:t?`2px`:`1px`,borderColor:t?`vechain-kit-primary`:g,_hover:{borderColor:t?`vechain-kit-primary`:`vechain-kit-text-secondary`},children:q(lt,{p:4,children:J(N,{spacing:3,w:`full`,justifyContent:`space-between`,children:[J(N,{spacing:3,flex:1,minW:0,children:[q(Xh,{wallet:{address:e.address,domain:u??void 0,image:f??void 0,isLoadingMetadata:p},props:{width:10,height:10}}),J(z,{spacing:0,alignItems:`flex-start`,flex:1,minW:0,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:m,noOfLines:1,children:u?r(u,22,0):d(e.address,6,4)}),q(R,{fontSize:`xs`,color:h,noOfLines:1,children:_?o(`Loading...`):c})]})]}),t&&q(j,{children:q(P,{as:Tr,boxSize:5,color:`vechain-kit-primary`})}),a&&!t&&q(Tt,{"aria-label":o(`Remove wallet`),icon:q(P,{as:ui}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,onClick:e=>{e.stopPropagation(),i()}})]})})})},Ed=e=>te(e.map(e=>e.address.toLowerCase()).sort().join(`|`)),Dd=({setCurrentContent:e,returnTo:t=`main`,onLogoutSuccess:n})=>{let{t:r}=Y(),{isolatedView:i}=gu(),{account:a,disconnect:o}=Q(),{disconnect:s}=rr(),{open:c}=ar(),{getStoredWallets:l,setActiveWallet:u,removeWallet:d}=al(),{saveWallet:f}=il(),{refresh:p}=Zc(),m=B(`colors`,`vechain-kit-text-secondary`),[h,g]=G(l()),_=xn(Ed(l())),v=H(()=>{let e=l();g(e),_.current=Ed(e)},[l]);U(()=>{v()},[v,a?.address]),U(()=>{let e=()=>{setTimeout(()=>{v()},100)};if(typeof window<`u`)return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[v]),U(()=>{let e=setInterval(()=>{Ed(l())!==_.current&&v()},200);return()=>clearInterval(e)},[l,v]);let y=W(()=>{let e=h.find(e=>e.isActive);return e?e.address:a?.address??null},[h,a?.address]),b=W(()=>h.find(e=>e.address.toLowerCase()===y?.toLowerCase()),[h,y]),x=W(()=>h.filter(e=>e.address.toLowerCase()!==y?.toLowerCase()),[h,y]),S=H(n=>{n.toLowerCase()!==y?.toLowerCase()&&(b&&f(b.address),u(n),setTimeout(()=>{v()},50),p(),e({type:t,props:{switchFeedback:{showFeedback:!0}}}))},[y,b,a,u,p,e,v,f]),C=H(r=>{let i=r.address.toLowerCase()===y?.toLowerCase(),a=h.filter(e=>e.address.toLowerCase()!==r.address.toLowerCase());e({type:`remove-wallet-confirm`,props:{walletAddress:r.address,walletDomain:null,onConfirm:async()=>{if(i&&a.length>0){let e=a[0];u(e.address)}else if(i&&a.length===0)try{await s()}catch(e){console.error(`Error disconnecting:`,e)}if(d(r.address),setTimeout(()=>{v()},50),a.length===0){n&&n();return}e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})},onBack:()=>{e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}})},[d,v,e,t,n,y,h,u,s]),w=H(()=>{c()},[c]),ee=()=>{o(),n?.()};return J(K,{children:[J(Z,{children:[!i&&q(Fo,{onClick:()=>{e(t)}}),q(L,{children:r(`Select Wallet`)}),q(I,{})]}),q(F,{w:`full`,children:J(z,{w:`full`,spacing:4,children:[b&&J(z,{w:`full`,spacing:2,alignItems:`flex-start`,children:[q(wt,{size:`sm`,color:m,children:r(`Active Wallet`)}),q(Td,{wallet:b,isActive:!0,onSelect:()=>{},onRemove:()=>C(b),showRemove:h.length>1})]}),x.length>0&&J(z,{w:`full`,spacing:2,alignItems:`flex-start`,children:[q(wt,{size:`sm`,color:m,children:r(`Other Wallets`)}),x.map(e=>q(Td,{wallet:e,isActive:!1,onSelect:()=>S(e.address),onRemove:()=>C(e),showRemove:!0},e.address))]})]})}),q(It,{w:`full`,children:J(z,{w:`full`,spacing:2,children:[q(M,{w:`full`,leftIcon:q(ei,{}),variant:`vechainKitSecondary`,onClick:w,children:r(`Add New Wallet`)}),q(M,{w:`full`,leftIcon:q(Yr,{}),variant:`vechainKitLogout`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:ee,onBack:()=>e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}),children:r(`Logout`)})]})})]})},Od=({walletAddress:e,walletDomain:t,onConfirm:n,onBack:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),{domain:c}=rl(e,s.type),l=B(`colors`,`vechain-kit-text-primary`),u=c?r(c,20,0):d(e,6,4);return J(K,{children:[J(Z,{children:[q(L,{children:o(`Remove`)}),q(Fo,{onClick:i}),a&&q(I,{onClick:a})]}),q(F,{children:J(z,{spacing:6,align:`center`,mt:10,children:[q(P,{as:ui,color:`#ef4444`,fontSize:`60px`,opacity:.5}),q(R,{fontSize:`md`,textAlign:`center`,color:l,children:o(`Are you sure you want to remove this wallet?`)}),q(R,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,fontWeight:`600`,children:u}),q(R,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,children:d(e,8,7)})]})}),q(It,{w:`full`,mt:4,children:J(z,{spacing:3,w:`full`,children:[q(M,{onClick:n,"data-testid":`remove-wallet-button`,variant:`vechainKitLogout`,children:o(`Remove`)}),q(M,{variant:`vechainKitSecondary`,onClick:i,"data-testid":`cancel-remove-button`,children:o(`Cancel`)})]})})]})},kd=e=>e.toLowerCase()===`0x0000000000000000000000000000000000000000`,Ad=({item:t,onClick:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`),o=B(`colors`,`vechain-kit-success`),s=B(`colors`,`vechain-kit-error`),c=t.direction===`sent`,l=c?`-`:`+`,u=c?s:o,d=c?t.to:t.from,f=t.amount.toLocaleString(void 0,{maximumFractionDigits:4}),p=!c&&kd(t.from),m=e[t.tokenSymbol];return J(M,{variant:`ghost`,h:`64px`,w:`full`,justifyContent:`space-between`,px:2,onClick:n,isDisabled:!n,_disabled:{cursor:`default`,opacity:1},children:[J(N,{spacing:3,flex:1,minW:0,children:[p?q(j,{boxSize:`32px`,borderRadius:`full`,bg:`whiteAlpha.300`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,children:q(P,{as:ci,boxSize:4,color:a})}):m?q(Et,{src:m,alt:t.tokenSymbol,boxSize:`32px`,borderRadius:`full`,flexShrink:0,fallback:q(j,{boxSize:`32px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):q(j,{boxSize:`32px`,borderRadius:`full`,bg:`whiteAlpha.300`,flexShrink:0}),J(z,{spacing:0,align:`flex-start`,minW:0,children:[q(R,{fontWeight:`600`,color:i,children:r(c?`Sent`:`Received`)}),J(N,{spacing:1,align:`baseline`,maxW:`full`,children:[q(R,{fontSize:`xs`,color:a,children:r(c?`To`:`From`)}),q(ag,{address:d,fontSize:`xs`,color:a})]})]})]}),J(z,{spacing:0,align:`flex-end`,maxW:`45%`,flexShrink:0,children:[J(R,{fontWeight:`600`,color:u,lineHeight:`short`,children:[l,f]}),q(R,{fontSize:`xs`,color:a,lineHeight:`short`,maxW:`full`,isTruncated:!0,children:t.tokenSymbol})]})]})},jd=({tokenAddress:e,onItemClick:t,onSeeAll:n})=>{let{t:r}=Y(),{account:i}=Q(),a=B(`colors`,`vechain-kit-text-secondary`),{transfers:o,isLoading:s,isUnsupportedNetwork:c}=Xl(i?.address,e),l=o.slice(0,5);return J(z,{w:`full`,align:`stretch`,spacing:3,children:[J(N,{w:`full`,justify:`space-between`,align:`center`,children:[q(wt,{size:`sm`,children:r(`Token History`)}),o.length>5&&q(M,{variant:`link`,size:`sm`,fontWeight:`500`,onClick:n,children:r(`See all`)})]}),c?q(j,{py:4,textAlign:`center`,children:q(R,{fontSize:`sm`,color:a,children:r(`History is only available on mainnet.`)})}):s?J(R,{fontSize:`sm`,color:a,textAlign:`center`,children:[r(`Loading`),`…`]}):l.length===0?q(R,{fontSize:`sm`,color:a,textAlign:`center`,children:r(`No transfers yet.`)}):l.map(e=>q(Ad,{item:e,onClick:()=>t(e)},e.id))]})},Md=({icon:e,label:t,onClick:n,isDisabled:r})=>{let{t:i}=Y(),a=i(t,t);return q(Tt,{variant:`vechainKitSecondary`,h:`44px`,flex:1,borderRadius:`lg`,"aria-label":a,isDisabled:r,onClick:n,icon:J(N,{spacing:1.5,children:[q(P,{as:e,boxSize:3.5,opacity:.85}),q(R,{fontSize:`sm`,fontWeight:`600`,children:a})]})})},Nd=({setCurrentContent:e,token:t})=>{let{isolatedView:n}=gu(),{currentCurrency:r}=lc(),i=B(`colors`,`vechain-kit-text-secondary`),a=p.includes(t.symbol),o=Number(t.balance),s=o.toLocaleString(void 0,{maximumFractionDigits:4}),{points:c}=rc((()=>{switch(t.symbol){case`VET`:case`VVET`:return`VET`;case`VTHO`:return`VTHO`;case`B3TR`:case`VOT3`:case`veDelegate`:return`B3TR`;default:return}})()),l=typeof t.priceChange24hPct==`number`?t.priceChange24hPct>0?`up`:t.priceChange24hPct<0?`down`:`neutral`:`neutral`,u=()=>e({type:`token-detail`,props:{setCurrentContent:e,token:t}});return J(K,{children:[J(Z,{children:[q(L,{children:t.symbol}),!n&&q(Fo,{onClick:()=>e(`assets`)}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,w:`full`,children:[J(z,{spacing:1,align:`flex-start`,children:[q(wt,{size:`2xl`,fontWeight:`700`,children:s}),J(N,{spacing:2,align:`center`,children:[J(R,{color:i,children:[`=`,` `,sc(t.valueInCurrency,{currency:r})]}),q(Gh,{valuePct:t.priceChange24hPct})]})]}),c.length>1&&q(lg,{points:c,tone:l,chartHeight:72,interactive:!0}),J(N,{spacing:2,w:`full`,children:[q(Md,{icon:_r,label:`Swap`,onClick:()=>{e({type:`swap-token`,props:{setCurrentContent:e,fromTokenAddress:t.address&&t.address!==`0x`?t.address:void 0,onBack:u}})},isDisabled:a}),q(Md,{icon:br,label:`Send`,onClick:()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:t,onBack:u}})},isDisabled:a||o<=0}),q(Md,{icon:gr,label:`Receive`,onClick:()=>{e({type:`receive-token`,props:{setCurrentContent:e,onBack:u}})}})]}),q(jd,{tokenAddress:t.address||`0x`,onItemClick:t=>{e({type:`transaction-detail`,props:{setCurrentContent:e,item:t,onBack:u}})},onSeeAll:()=>{e({type:`transaction-history`,props:{setCurrentContent:e,tokenFilter:{address:t.address||`0x`,symbol:t.symbol},onBack:u}})}})]})})})]})},Pd=(e,t)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`,year:`numeric`}).format(new Date(e*1e3)),Fd=(e,t)=>{let n=new Set,r=new Map;for(let i of e){if(n.has(i.id))continue;n.add(i.id);let e=Pd(i.timestamp,t),a=r.get(e);a?a.push(i):r.set(e,[i])}return Array.from(r,([e,t])=>({label:e,items:t}))},Id=({setCurrentContent:e,tokenFilter:t,onBack:n})=>{let{t:r,i18n:i}=Y(),{account:a}=Q(),{isolatedView:o}=gu(),s=B(`colors`,`vechain-kit-text-secondary`),{transfers:c,isLoading:l,hasNextPage:u,fetchNextPage:d,isFetchingNextPage:f,isUnsupportedNetwork:p}=Yl(a?.address,{tokenAddress:t?.address}),m=W(()=>Fd(c,i.language||`en-US`),[c,i.language]),h=()=>e({type:`transaction-history`,props:{setCurrentContent:e,tokenFilter:t,onBack:n}}),g=t=>{e({type:`transaction-detail`,props:{setCurrentContent:e,item:t,onBack:h}})};return J(K,{children:[J(Z,{children:[q(L,{children:t?r(`{{symbol}} history`,{symbol:t.symbol}):r(`History`)}),!o&&q(Fo,{onClick:n??(()=>e(`assets`))}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:p?q(j,{py:6,textAlign:`center`,children:q(R,{color:s,children:r(`History is only available on mainnet.`)})}):l?J(R,{textAlign:`center`,color:s,children:[r(`Loading`),`…`]}):m.length===0?q(j,{py:6,textAlign:`center`,children:q(R,{color:s,children:r(`No transfers yet.`)})}):J(z,{spacing:4,align:`stretch`,w:`full`,children:[m.map(e=>J(z,{spacing:1,align:`stretch`,children:[q(wt,{size:`xs`,color:s,textTransform:`uppercase`,children:e.label}),e.items.map(e=>q(Ad,{item:e,onClick:()=>g(e)},e.id))]},e.label)),u&&q(M,{variant:`vechainKitSecondary`,size:`sm`,isLoading:f,onClick:()=>d(),children:r(`Load more`)})]})})})]})},Ld=(e,t)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}).format(new Date(e*1e3)),Rd=({label:e,value:t,copyValue:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-text-primary`);return J(N,{w:`full`,justify:`space-between`,align:`center`,children:[q(R,{fontSize:`sm`,color:i,children:e}),J(N,{spacing:1,align:`center`,children:[typeof t==`string`?q(R,{fontSize:`sm`,color:a,fontWeight:`500`,children:t}):t,n&&q(og,{value:n,ariaLabel:`${r(`Copy`)} ${e}`})]})]})},zd=({setCurrentContent:t,item:n,onBack:r})=>{let{t:i,i18n:a}=Y(),{isolatedView:o}=gu(),s=Eg(),{currentCurrency:c}=lc(),{prices:l,exchangeRates:u}=ic(),f=B(`colors`,`vechain-kit-success`),p=B(`colors`,`vechain-kit-error`),m=n.direction===`sent`,h=m?`-`:`+`,g=m?p:f,_=!m&&n.from.toLowerCase()===`0x0000000000000000000000000000000000000000`,v=B(`colors`,`vechain-kit-text-secondary`),y=l[(n.tokenAddress??`0x`).toLowerCase()]??0,b=n.amount*y,x=(()=>c===`eur`?b*(u?.eurUsdPrice??1):c===`gbp`?b*(u?.gbpUsdPrice??1):b)(),S=`${s.explorerUrl}/${n.txId}`,C=r??(()=>t({type:`transaction-history`,props:{setCurrentContent:t}}));return J(K,{children:[J(Z,{children:[q(L,{children:i(m?`Sent`:`Received`)}),!o&&q(Fo,{onClick:C}),q(I,{})]}),q(_t,{h:[`540px`,`auto`],p:0,children:q(F,{children:J(z,{spacing:6,align:`stretch`,w:`full`,children:[J(N,{spacing:3,children:[_?q(j,{boxSize:`40px`,borderRadius:`full`,bg:`whiteAlpha.300`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(P,{as:ci,boxSize:5,color:v})}):e[n.tokenSymbol]?q(Et,{src:e[n.tokenSymbol],alt:n.tokenSymbol,boxSize:`40px`,borderRadius:`full`,fallback:q(j,{boxSize:`40px`,borderRadius:`full`,bg:`whiteAlpha.300`})}):q(j,{boxSize:`40px`,borderRadius:`full`,bg:`whiteAlpha.300`}),J(z,{spacing:0,align:`flex-start`,children:[J(wt,{size:`md`,color:g,fontWeight:`700`,children:[h,n.amount.toLocaleString(void 0,{maximumFractionDigits:4}),` `,n.tokenSymbol]}),J(R,{fontSize:`sm`,opacity:.7,children:[`=`,` `,sc(x,{currency:c})]})]})]}),J(z,{w:`full`,align:`stretch`,spacing:3,p:4,borderRadius:`xl`,bg:`vechain-kit-card`,children:[q(Rd,{label:i(`Date`),value:Ld(n.timestamp,a.language||`en-US`)}),q(Rd,{label:i(`Status`),value:q(R,{color:f,fontWeight:`600`,children:i(`Succeeded`)})}),q(Rd,{label:i(`From`),value:q(ag,{address:n.from,headLen:6,tailLen:6,fontSize:`sm`,fontWeight:`500`}),copyValue:n.from}),q(Rd,{label:i(`To`),value:q(ag,{address:n.to,headLen:6,tailLen:6,fontSize:`sm`,fontWeight:`500`}),copyValue:n.to}),q(Rd,{label:i(`Hash`),value:d(n.txId,6,6),copyValue:n.txId})]}),q(M,{as:`a`,href:S,target:`_blank`,rel:`noopener noreferrer`,variant:`vechainKitSecondary`,leftIcon:q(Lr,{}),children:i(`View on explorer`)})]})})})]})},Bd=Ro[`@vechain/dapp-kit-react`]||zo[`@vechain/dapp-kit-react`]||`unknown`,Vd=Ro[`@privy-io/react-auth`]||`unknown`,Hd=({connectionCache:e})=>{let{t}=Y(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{source:a}=ir(),{privy:o,network:s}=$(),c=o?.appId,{data:l,isLoading:u}=Yo(c||[]),{onCopy:f,hasCopied:p}=pn(``),{data:m,isLoading:h}=Zo(),{data:g,isLoading:_}=Vm(r.address??``,i?.address??``),y=B(`colors`,`vechain-kit-card`),b=B(`colors`,`vechain-kit-text-secondary`),x=B(`colors`,`vechain-kit-text-primary`),S=(()=>n.isConnectedWithCrossApp&&e?.ecosystemApp?e.ecosystemApp.name:n.isConnectedWithSocialLogin&&l?Object.values(l)[0]?.name??null:n.isConnectedWithDappKit&&a?a:null)(),C=n.isConnectedWithSocialLogin&&u,w=({label:e,value:t,isLoading:n=!1,href:r})=>J(N,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:x,children:[e,`:`]}),q(R,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:b,children:n?`Loading...`:t})]});return C?q(z,{w:`full`,h:`full`,justify:`center`,align:`center`,minH:`200px`,borderRadius:`xl`,bg:y,children:q(qt,{})}):S?J(z,{p:4,bg:y,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[q(w,{label:t(`Logged in with`),value:S}),n.isConnectedWithCrossApp&&e?.timestamp&&q(w,{label:t(`At`),value:new Date(e.timestamp).toLocaleString()}),q(w,{label:t(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),q(vt,{}),q(w,{label:t(`Network`),value:s.type}),q(w,{label:t(`Node URL`),value:s.nodeUrl||v(s.type).nodeUrl}),n.isConnectedWithPrivy&&q(vt,{}),n.isConnectedWithPrivy&&J(N,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:x,children:[t(`Embedded wallet`),`:`]}),J(N,{children:[q(R,{fontSize:`sm`,color:b,children:i?.address?d(i.address,8,7):`-`}),q(P,{color:b,onClick:()=>{i?.address&&f(i.address)},opacity:i?.address?1:.4,pointerEvents:i?.address?`auto`:`none`,cursor:`pointer`,as:p?Tr:Pr})]})]}),n.isConnectedWithPrivy?J(K,{children:[q(w,{label:t(`Smart Account`),value:`v${g?.version??``} ${g?.isDeployed?``:`(not deployed)`}`,isLoading:_}),q(w,{label:t(`Privy Status`),value:m||``,isLoading:h})]}):r.isDeployed&&q(w,{label:t(`Smart Account`),value:`v${g?.version??``}`,isLoading:_}),q(vt,{}),q(w,{label:t(`VeChain Kit`),value:Lo,href:`https://github.com/vechain/vechain-kit/releases/tag/${Lo}`}),q(w,{label:`DAppKit`,value:Bd}),q(w,{label:`Privy`,value:Vd})]}):null},Ud=()=>{let{connection:e}=Q(),{t}=Y(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=om(),a=i(),o=B(`colors`,`vechain-kit-card`);return e.isConnectedWithPrivy?J(z,{w:`full`,align:`stretch`,textAlign:`center`,mt:5,p:3,borderRadius:`lg`,bg:o,shadow:`sm`,children:[q(R,{fontSize:`xs`,fontWeight:`800`,children:t(`Wallet secured by`)}),J(N,{justify:`center`,children:[q(Be,{isDark:r,w:`50px`}),q(P,{as:Zr,ml:3}),e.isConnectedWithVeChain?q(ye,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&q(Et,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&q(Et,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]}):null},Wd=({onGoBack:e})=>{let{t}=Y(),{getConnectionCache:n}=om(),r=n()??void 0;return J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Connection Details`)}),q(Fo,{onClick:()=>{e()}}),q(I,{})]}),J(F,{w:`full`,children:[q(Hd,{connectionCache:r}),q(Ud,{})]}),q(It,{pt:0})]})},Gd=({accountType:e,accountDescription:t,isLoading:n,onConfirm:r,onCancel:i})=>{let{t:a}=Y();return J(z,{spacing:6,align:`stretch`,children:[q(R,{fontSize:`md`,textAlign:`center`,color:B(`colors`,`vechain-kit-text-primary`),children:a(`Are you sure you want to unlink {{accountType}} as a login method linked to {{accountDescription}}?`,{accountType:e,accountDescription:t})}),J(z,{spacing:3,w:`full`,children:[q(M,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),q(M,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Kd=({onBack:e})=>{let{t}=Y(),{privy:n,dappKit:r}=$(),[i,a]=G(null),[o,s]=G(!1),[c,l]=G(!1),[u,f]=G(!1),p=B(`colors`,`vechain-kit-text-primary`),m=B(`colors`,`vechain-kit-text-secondary`),{user:h,linkEmail:g,linkGoogle:_,linkTwitter:v,linkPhone:y,linkSpotify:b,linkApple:x,linkInstagram:S,linkTiktok:C,linkGithub:w,linkLinkedIn:ee,linkTelegram:T,linkFarcaster:E,linkPasskey:D,linkDiscord:O,unlinkEmail:k,unlinkGoogle:te,unlinkApple:A,unlinkSpotify:ne,unlinkInstagram:re,unlinkTiktok:ie,unlinkGithub:ae,unlinkLinkedIn:oe,unlinkTelegram:se,unlinkFarcaster:ce,unlinkPhone:le,unlinkPasskey:ue,unlinkDiscord:de,linkWallet:fe}=Xn(),pe=W(()=>{let e=n?.loginMethods?.filter(e=>[`rabby_wallet`,`coinbase_wallet`,`rainbow`,`phantom`,`metamask`].includes(e))??[],t=r?.allowedWallets??[];return e.length>0||t.length>0},[n?.loginMethods,r?.allowedWallets]),me=e=>{switch(e){case`google_oauth`:return ha;case`email`:return Xr;case`passkey`:return zr;case`wallet`:return pi;case`twitter_oauth`:return ja;case`phone`:return $r;case`spotify_oauth`:return ba;case`apple_oauth`:return ga;case`instagram_oauth`:return va;case`tiktok_oauth`:return Ca;case`github_oauth`:return Hr;case`linkedin_oauth`:return ya;case`telegram`:return xa;case`farcaster`:return Ma;case`discord_oauth`:return _a;default:return}},he=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},ge=async e=>{if(he()){f(!0);try{switch(e.type){case`google_oauth`:await te(e.subject);break;case`email`:await k(e.address);break;case`passkey`:await ue(e.subject);break;case`phone`:await le(e.number);break;case`spotify_oauth`:await ne(e.subject);break;case`apple_oauth`:await A(e.subject);break;case`instagram_oauth`:await re(e.subject);break;case`tiktok_oauth`:await ie(e.subject);break;case`github_oauth`:await ae(e.subject);break;case`linkedin_oauth`:await oe(e.subject);break;case`telegram`:await se(e.subject);break;case`farcaster`:await ce(e.subject);break;case`discord_oauth`:await de(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},_e=e=>{switch(e.type){case`google_oauth`:return e.email;case`email`:return e.address;case`passkey`:return`${e.authenticatorName} - ${e.createdWithBrowser}`;case`phone`:return e.number;case`wallet`:return`${d(e.address)} - ${e.walletClientType}`;default:return``}},ve=h?.linkedAccounts?.map(e=>e.type)||[],ye=n?.loginMethods||[],be=!ve.includes(`google_oauth`)&&ye.includes(`google`),xe=!ve.includes(`email`)&&ye.includes(`email`),Se=!ve.includes(`twitter_oauth`)&&ye.includes(`twitter`),Ce=!ve.includes(`phone`)&&ye.includes(`sms`),we=!ve.includes(`spotify_oauth`)&&ye.includes(`spotify`),Te=!ve.includes(`apple_oauth`)&&ye.includes(`apple`),Ee=!ve.includes(`instagram_oauth`)&&ye.includes(`instagram`),De=!ve.includes(`tiktok_oauth`)&&ye.includes(`tiktok`),Oe=!ve.includes(`github_oauth`)&&ye.includes(`github`),ke=!ve.includes(`linkedin_oauth`)&&ye.includes(`linkedin`),Ae=!ve.includes(`telegram`)&&ye.includes(`telegram`),je=!ve.includes(`farcaster`)&&ye.includes(`farcaster`),Me=!ve.includes(`discord_oauth`)&&ye.includes(`discord`);return o?J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Select Additional Login Method`)}),q(Fo,{onClick:()=>s(!1)}),q(I,{})]}),q(F,{w:`full`,children:J(z,{spacing:3,align:`stretch`,w:`full`,children:[q(Nu,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>D(),leftIcon:zr}),be&&q(Nu,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:ha}),xe&&q(Nu,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Xr,stacked:!0}),Se&&q(Nu,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:ja}),Ce&&q(Nu,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:$r}),we&&q(Nu,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:ba}),Te&&q(Nu,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:ga}),Ee&&q(Nu,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:va}),De&&q(Nu,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:Ca}),Oe&&q(Nu,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:Hr}),ke&&q(Nu,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>ee(),leftIcon:ya}),Ae&&q(Nu,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>T(),leftIcon:xa}),je&&q(Nu,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>E(),leftIcon:Ma}),Me&&q(Nu,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>O(),leftIcon:_a}),pe&&q(Nu,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>fe(),leftIcon:pi}),!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),q(It,{pt:0})]}):i?J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Remove Login Method`)}),q(Fo,{onClick:()=>a(null)}),q(I,{})]}),q(F,{children:q(Gd,{accountType:i.type,accountDescription:_e(i),isLoading:u,onConfirm:()=>ge(i),onCancel:()=>a(null)})}),q(It,{pt:0})]}):J(Yh,{children:[J(Z,{children:[q(L,{children:t(`Login methods`)}),q(Fo,{onClick:e}),q(I,{})]}),q(F,{w:`full`,children:J(z,{spacing:3,align:`center`,w:`full`,justify:`center`,children:[J(z,{spacing:1,justify:`flex-start`,alignItems:`flex-start`,mb:5,textAlign:`left`,w:`full`,children:[q(R,{fontSize:`sm`,color:m,children:t(`These accounts are linked to your embedded wallet and can be used to login to your wallet and access your private key.`)}),c&&q(R,{fontSize:`sm`,color:m,children:t(`Adding more linked accounts increases security against loss of access, but also introduces additional potential attack vectors. For enhanced security, we recommend enabling MFA.`)}),q(M,{variant:`link`,mt:0,size:`sm`,onClick:()=>l(!c),color:p,children:t(c?`Show Less`:`Read More`)})]}),h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`).map(e=>J(yt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[J(yt,{align:`center`,gap:3,children:[q(P,{as:me(e.type),color:p}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`500`,color:p,children:e.type===`google_oauth`?t(`Google`):e.type===`email`?t(`Email`):e.type===`passkey`?t(`Passkey`):e.type===`twitter_oauth`?t(`Twitter`):e.type===`phone`?t(`Phone Number`):e.type===`spotify_oauth`?t(`Spotify`):e.type===`apple_oauth`?t(`Apple`):e.type===`instagram_oauth`?t(`Instagram`):e.type===`tiktok_oauth`?t(`Tiktok`):e.type===`github_oauth`?t(`Github`):e.type===`linkedin_oauth`?t(`LinkedIn`):e.type===`telegram`?t(`Telegram`):e.type===`farcaster`?t(`Farcaster`):e.type===`discord_oauth`?t(`Discord`):t(`Wallet`)}),q(R,{fontSize:`sm`,color:m,children:_e(e)})]})]}),q(M,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!he(),onClick:()=>{e.type===`passkey`?D():a(e)},children:t(`Remove`)})]},e.type))]})}),q(It,{w:`full`,children:q(M,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:q(P,{as:ei}),isDisabled:!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me,children:t(`Add Login Method`)})})]})},qd=[{id:`welcome`,title:`Welcome to the VeChain`,description:`Welcome! Here you can manage your wallet, send tokens, and interact with the VeChain blockchain and its applications.`,timestamp:Date.now(),status:`success`,isRead:!1}],Jd=()=>{let{t:e}=Y(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=Yd(),{data:o}=ah(r?.address??``,3);U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),s=`smart_account_upgrade_${t.address.toLowerCase()}`;!r.some(e=>e.id===s)&&o&&i({id:s,title:e(`Account Upgrade Required`),description:e(`A new upgrade is available for your smart account. Please head over to the 'Access and Security' section to upgrade it.`),status:`warning`})},[n.isConnectedWithPrivy,t?.address,o]),U(()=>{!n.isConnectedWithPrivy||!t?.address||a().some(e=>e.id===`smart_account_${t.address.toLowerCase()}`)||i({id:`smart_account_${t.address.toLowerCase()}`,title:e(`Smart Account detected`),description:e(`You have an active smart account associated to this wallet. It has been set as your main identity.`),status:`info`})},[n.isConnectedWithPrivy,t?.address]),U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),o=r.some(e=>e.id===`multiclause_warning_${t.address.toLowerCase()}`),s=r.some(e=>e.id===`multiclause_support_${t.address.toLowerCase()}`);o&&!s&&i({id:`multiclause_support_${t.address.toLowerCase()}`,title:e(`Multiclause Transactions Are Now Supported`),description:e(`Good news! Multiclause transactions are now fully supported for smart accounts. You can now enjoy a better user experience, lower gas costs, and enchanced security.`),status:`info`})},[n.isConnectedWithPrivy,t?.address])},Yd=()=>{let{account:e}=Q(),t=H(e=>{let t=e?.toLowerCase();return{notifications:`vechain_kit_notifications_${t}`,archived:`vechain_kit_archived_notifications_${t}`,initialized:`vechain_kit_notifications_initialized_${t}`}},[]),n=H(()=>{if(!e?.address||!O())return;let n=t(e.address);b(n.initialized)||(ue(n.notifications,JSON.stringify(qd)),ue(n.initialized,`true`))},[e?.address,t]);U(()=>{n()},[n]);let r=H(()=>{if(!e?.address||!O())return[];let n=b(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=H(()=>{if(!e?.address||!O())return[];let n=b(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=H(n=>{if(!e?.address||!O())return;let i=t(e.address),a=r(),o=b(i.archived),s=o?JSON.parse(o):[];if([...a,...s].some(e=>e.title===n.title))return;let c={...n,id:n.id||Math.random().toString(36).substring(7),timestamp:Date.now(),isRead:!1};ue(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=H(n=>{if(!e?.address||!O())return;let i=t(e.address),a=r().filter(e=>e.id!==n);ue(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:H(()=>{if(!e?.address||!O())return;let n=t(e.address),a=r();ue(n.archived,JSON.stringify([...i(),...a])),ue(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:H(n=>{if(!e?.address||!O())return;let a=t(e.address),o=r(),s=i(),c=o.find(e=>e.id===n),l=o.filter(e=>e.id!==n);if(c){let e=[{...c,isRead:!0},...s];ue(a.notifications,JSON.stringify(l)),ue(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},Xd=({showArchived:e})=>{let{t}=Y();return q(vd,{title:t(e?`No archived notifications`:`No notifications`),description:t(e?`Cleared notifications will appear here`:`When you have notifications, they will appear here`),icon:e?mr:xr})},Zd=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=Y(),i=()=>{n(e.id)};return e.isRead&&!t?null:J(rt,{status:e.status,variant:`subtle`,borderRadius:`lg`,pr:8,position:`relative`,opacity:e.isRead?.7:1,cursor:`pointer`,_hover:{opacity:.8},"data-testid":`notification-item`,children:[q(at,{boxSize:`16px`}),J(j,{children:[q(ot,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),q(it,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&q(Tt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:q(Nr,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},Qd=({setCurrentContent:e})=>{let{t}=Y(),{isolatedView:n}=gu(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=Yd(),[s,c]=G(!1),[l,u]=G(r()),[d,f]=G(i()),p=()=>{a(),f([...d,...l]),u([])},m=e=>{o(e);let t=l.find(t=>t.id===e);u(l.filter(t=>t.id!==e)),t&&f([{...t,isRead:!0},...d])},h=()=>{c(!s)},g=s?d:l,_=[...g].sort((e,t)=>e.id===`welcome`?-1:t.id===`welcome`?1:e.id===`smart-account`?-1:t.id===`smart-account`?1:e.id===`multiclause`?-1:t.id===`multiclause`?1:t.timestamp-e.timestamp);return J(Yh,{children:[J(Z,{children:[!n&&q(Fo,{onClick:()=>e(`main`)}),q(L,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),q(I,{})]}),J(_t,{h:[`540px`,`auto`],p:0,children:[q(F,{children:J(z,{spacing:4,align:`stretch`,w:`full`,children:[J(N,{justify:`space-between`,children:[q(M,{variant:`ghost`,leftIcon:q(P,{as:s?xr:mr}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&q(M,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?q(Xd,{showArchived:s}):q(z,{spacing:3,children:_.map(e=>q(Zd,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),q(It,{pt:0})]})]})},$d=e=>{switch(e){case`defi`:return`blue`;case`games`:return`green`;case`collectibles`:return`purple`;case`marketplaces`:return`orange`;case`utilities`:return`cyan`;default:return`gray`}},ef=({category:e,...t})=>{let{t:n}=Y(),r=e.toLowerCase();return q(nn,{size:`sm`,colorScheme:$d(r),borderRadius:`full`,px:2,...t,children:n(r)})},tf=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>J(ct,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&q(j,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:q(ef,{category:r})}),q(lt,{p:a===`sm`?2:4,alignItems:`center`,children:J(z,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&q(Et,{src:t,fallbackSrc:y,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&q(R,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),nf=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=cl(e.id),{data:a,isLoading:o}=hl(r?.logo);return q(Kt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:q(tf,{name:r?.name??``,imageUrl:a?.image??``,linkUrl:r?.external_url??``,category:`vebetter`,onClick:()=>{r?.name&&t({type:`app-overview`,props:{name:r.name,image:a?.image??``,url:r?.external_url??``,description:r?.description??``,category:`vebetter`,selectedCategory:n,setCurrentContent:t}})}})})},rf=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>q(tf,{name:e,imageUrl:t,linkUrl:n,category:i,onClick:()=>{s({type:`app-overview`,props:{name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s}})},...a&&{logoComponent:a}}),af=({})=>{let{t:e}=Y(),{shortcuts:t}=Ph();return t.length===0?null:J(z,{w:`full`,align:`flex-start`,spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`500`,children:e(`Shortcuts`)}),q(St,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>q(Ct,{children:q(ct,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:q(lt,{p:2,alignItems:`center`,children:q(Et,{src:e.image,fallbackSrc:y,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},of=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=Y();return J(j,{width:`full`,mb:4,children:[q(R,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),J(on,{spacing:2,children:[q(sn,{children:q(nn,{size:`md`,borderRadius:`full`,variant:e===null?`solid`:`outline`,colorScheme:r?`gray`:`blackAlpha`,cursor:`pointer`,onClick:()=>t(null),children:i(`All`)})}),n.map(n=>q(sn,{children:q(ef,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},sf=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:Ze,logo:new URL(`/static/img/coins/64x64/33509.png`,Le).toString(),banner:new URL(`/static/img/icons/vbd.png`,Le).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/static/img/icons/vbd.png`,Le).toString()},categories:[]},{name:`vet.domains`,description:`.vet.domains provides a unique and unchangeable identity for Vechain users by linking information to their wallet addresses. It becomes easier for people to use the blockchain by replacing complicated wallet addresses with easy-to-remember names.`,external_url:He,logo:new URL(`/assets/walletconnect.png`,He).toString(),banner:new URL(`/assets/walletconnect.png`,He).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/assets/walletconnect.png`,He).toString()},categories:[]}],cf=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=Y(),{darkMode:r,network:i}=$(),{isolatedView:a}=gu(),o=B(`colors`,`vechain-kit-text-tertiary`),[s,c]=G(``),[l,u]=G(t||null);U(()=>{t!==void 0&&u(t)},[t]);let{data:d}=Oc(),{data:f}=Xc(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=hm(),g=W(()=>{let e=new Set;return i.type===`main`&&f&&f.length>0&&e.add(`vebetter`),p&&p.forEach(t=>{t.category&&e.add(t.category)}),Array.from(e).sort()},[p,f,i.type]),_=i.type===`main`?f.filter(e=>e.app.name.toLowerCase().includes(s.toLowerCase())):[],v=sf.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),y=p?.filter(e=>(e.name.toLowerCase().includes(s.toLowerCase())||e.description.toLowerCase().includes(s.toLowerCase())||e.tags.some(e=>e.toLowerCase().includes(s.toLowerCase())))&&(l===null||e.category===l))||[],b=l===null,x=l===null||l===`vebetter`,{shortcuts:S}=Ph();return J(K,{children:[J(Z,{children:[q(L,{children:n(`Ecosystem`)}),!a&&q(Fo,{onClick:()=>e(`settings`)}),q(I,{})]}),q(F,{overflowY:`auto`,minH:`300px`,children:J(z,{spacing:6,w:`full`,children:[q(af,{setCurrentContent:e}),S.length>0&&q(R,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),J(Ot,{size:`lg`,children:[q(Dt,{placeholder:n(`Search Apps`),value:s,onChange:e=>{c(e.target.value)},bg:r?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12}),q(kt,{h:`56px`,w:`56px`,pl:4,children:q(ri,{color:o})})]}),g.length>0&&q(of,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),J(St,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&q(K,{children:v.map(t=>q(Ct,{children:q(rf,{name:t.name,image:t.logo,url:t.external_url,setCurrentContent:e,description:t.description,selectedCategory:l})},t.name))}),x&&_.length>0&&q(K,{children:_.map(t=>q(Ct,{children:q(nf,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?q(Ct,{colSpan:2,children:q(ft,{py:4,children:q(qt,{})})}):h?q(Ct,{colSpan:2,children:q(R,{color:`red.500`,textAlign:`center`,children:n(`Failed to load App Hub apps`)})}):y.length>0?y.map(t=>q(Ct,{children:q(rf,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&q(Ct,{colSpan:2,children:q(ft,{py:4,children:q(R,{children:n(`No apps found in this category`)})})})]})]})}),q(It,{pt:0})]})},lf=({name:e,image:t,url:n,description:r})=>{let{t:i}=Y(),{isShortcut:a,addShortcut:o,removeShortcut:s}=Ph(),c=a(n);return q(M,{px:4,width:`full`,height:`45px`,variant:`vechainKitSecondary`,borderRadius:`xl`,onClick:()=>{c?s(n):o({name:e,image:t,url:n,description:r})},leftIcon:q(P,{as:c?Cr:Sr}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},uf=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=Y();return J(K,{children:[J(Z,{children:[q(L,{children:t}),q(Fo,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),q(I,{})]}),q(F,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[J(yt,{direction:`column`,align:`center`,children:[s||q(Et,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&q(N,{mt:2,children:q(ef,{category:a})})]}),q(R,{fontSize:`sm`,textAlign:`center`,children:i}),q(R,{fontSize:`sm`,textAlign:`center`,children:c(`Click below to access {{ name }} and explore its features.`,{name:t})})]})}),q(It,{children:J(z,{w:`full`,spacing:4,children:[J(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),q(P,{as:Lr,ml:2})]}),q(lf,{name:t,image:n,url:r,description:i})]})})]})},df=({children:e})=>q(pr.div,{whileHover:{scale:1.1},transition:{duration:.5,ease:`easeInOut`,repeat:1/0,repeatDelay:crypto.getRandomValues(new Uint32Array(1))[0]/2**32*5},animate:{y:[0,-2,0],rotate:[0,10,-10,0]},children:e}),ff=({description:e})=>{let{darkMode:t}=$(),n=new URL(`intent/tweet`,Je);n.searchParams.set(`text`,e);let r=new URL(`share/url`,Pe);r.searchParams.set(`url`,e);let i=new URL(``,de);return i.searchParams.set(`text`,e),J(N,{gap:2,children:[q(df,{children:q(jt,{href:n.toString(),isExternal:!0,children:q(j,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:q(ja,{size:22})})})}),q(df,{children:q(jt,{href:r.toString(),isExternal:!0,children:q(j,{bg:`#30abec`,p:2,borderRadius:`full`,children:q(Sa,{color:`white`,size:22})})})}),q(df,{children:q(jt,{href:i.toString(),isExternal:!0,children:q(j,{bg:`#01cb37`,p:2,borderRadius:`full`,children:q(wa,{size:22,color:`white`})})})})]})},pf=({status:e,uiConfig:t,onTryAgain:n,txReceipt:r,txError:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=B(`colors`,`vechain-kit-error`),l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=W(()=>i?i.reason||o(`Something went wrong. Please try again.`):null,[i,o]),p=(()=>{let n=e===`waitingConfirmation`;switch(n&&(e=`pending`),e){case`pending`:return{title:t?.title??o(n?`Sending Transaction...`:`Waiting for confirmation`),icon:t?.loadingIcon??q(qt,{size:`xl`,"data-testid":`pending-spinner-modal`}),description:n?o(`Transaction is being processed, it can take up to 15 seconds.`):t?.description??o(`Please confirm the transaction in your wallet.`)};case`error`:return{title:o(`Something went wrong`),icon:t?.errorIcon??q(P,{as:Ar,color:c,fontSize:`100px`,"data-testid":`error-icon-modal`}),description:f??o(`An unexpected error occurred.`)};case`success`:return{title:o(`Transaction successful!`),icon:t?.successIcon??q(P,{as:jr,color:l,fontSize:`100px`,"data-testid":`success-icon-modal`}),description:``};case`ready`:return{title:t?.title??o(`Confirm transaction`),icon:null,description:t?.description??o(`Confirm the transaction in your wallet to complete it.`)};default:return{title:``,icon:null,description:``}}})(),m=`${v(s.type).explorerUrl}/${r?.meta.txID}`;return J(K,{children:[J(Z,{children:[q(L,{children:p.title}),q(I,{isDisabled:e===`pending`&&!t?.isClosable})]}),q(F,{children:J(z,{align:`center`,p:6,spacing:3,children:[p.icon,e===`success`&&t?.showShareOnSocials&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:o(`Share on`)}),q(ff,{description:m})]}),p.description&&q(R,{fontSize:e===`ready`?`md`:`sm`,textAlign:`center`,color:e===`error`?c:u,mt:5,style:{lineBreak:`anywhere`},children:p.description})]})}),q(It,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[e===`error`&&!!n&&J(M,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[q(P,{mr:2,as:ni}),o(`Try again`)]}),e===`ready`&&q(M,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&q(M,{onClick:a,variant:`ghost`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&q(jt,{href:`${v(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:o(`View transaction on the explorer`)}),q(P,{size:`sm`,as:Lr,color:d})]})})]})})]})},mf=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>{let{darkMode:s,theme:c}=$();return e?q(vp,{darkMode:s,theme:c,children:q(Ko,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:q(pf,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})})}):null},hf=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=v(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:t}),q(I,{})]}),q(F,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(P,{as:jr,fontSize:`100px`,color:l,"data-testid":`success-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,color:u,children:n}),i&&e&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:a(`Share on`)}),q(ff,{description:c})]})]})}),q(It,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(jt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:a(`View transaction on the explorer`)}),q(P,{size:16,as:Lr})]})})]})})]})},gf=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=Y(),{network:a,darkMode:o}=$(),s=v(a.type).explorerUrl;return J(K,{children:[J(Z,{children:[q(L,{children:t}),q(I,{})]}),q(F,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(P,{as:Ar,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n})]})}),q(It,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&q(jt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:i(`View transaction on the explorer`)}),q(P,{size:16,as:Lr})]})})]})})]})},_f=({isOpen:e,onClose:t,initialContent:n=`profile`})=>{let{account:r}=Q(),{themeConfig:i}=_p(),{accountModalContent:a,setAccountModalContent:o}=bp();return U(()=>{e&&o(n)},[e,n,o]),q(Ko,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,mobileMaxHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,desktopMinHeight:`485px`,desktopMaxHeight:`485px`,children:(()=>{if(typeof a==`object`)switch(a.type){case`send-token`:return q(_u,{...a.props});case`send-token-summary`:return q(vu,{...a.props});case`token-detail`:return q(Nd,{...a.props});case`transaction-history`:return q(Id,{...a.props});case`transaction-detail`:return q(zd,{...a.props});case`swap-token`:return q(Cu,{...a.props});case`receive-token`:return q(yu,{...a.props});case`choose-name`:return q(wu,{...a.props});case`choose-name-search`:return q(Ou,{...a.props});case`choose-name-summary`:return q(ku,{...a.props});case`app-overview`:return q(uf,{...a.props,setCurrentContent:o});case`disconnect-confirm`:return q(wd,{...a.props});case`remove-wallet-confirm`:return q(Od,{...a.props});case`account-customization`:return q(Wu,{...a.props});case`account-customization-summary`:return q(Gu,{...a.props});case`successful-operation`:return q(hf,{...a.props});case`failed-operation`:return q(gf,{...a.props});case`upgrade-smart-account`:return q(Yu,{...a.props});case`faq`:return q(ju,{...a.props});case`terms-and-privacy`:return q(Cd,{...a.props});case`ecosystem-with-category`:return q(cf,{setCurrentContent:o,selectedCategory:a.props.selectedCategory});case`select-wallet`:return q(Dd,{setCurrentContent:o,onClose:t,returnTo:a.props.returnTo,onLogoutSuccess:a.props.onLogoutSuccess});case`main`:return q(mu,{setCurrentContent:o,onClose:t,wallet:r,switchFeedback:a.props?.switchFeedback});case`profile`:return q(Ju,{setCurrentContent:o,onLogoutSuccess:()=>{t()},switchFeedback:a.props?.switchFeedback})}switch(a){case`main`:return q(mu,{setCurrentContent:o,onClose:t,wallet:r});case`settings`:return q(_d,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`profile`:return q(Ju,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`assets`:return q(ld,{setCurrentContent:o});case`notifications`:return q(Qd,{setCurrentContent:o});case`receive-token`:return q(yu,{setCurrentContent:o});case`swap-token`:return q(Cu,{setCurrentContent:o});case`connection-details`:return q(Wd,{onGoBack:()=>o(`settings`)});case`privy-linked-accounts`:return q(Kd,{onBack:()=>o(`settings`)});case`ecosystem`:return q(cf,{setCurrentContent:o});case`add-custom-token`:return q(ud,{setCurrentContent:o});case`change-currency`:return q(fd,{setCurrentContent:o});case`change-language`:return q(pd,{setCurrentContent:o});case`gas-token-settings`:return q(gd,{setCurrentContent:o});case`account-customization`:return q(Wu,{setCurrentContent:o});default:return null}})()})},vf=ma`
128
128
  from { transform: rotate(0deg); }
129
129
  to { transform: rotate(360deg); }
130
130
  `,yf=({loadingText:e,title:t,onClose:n,onGoBack:r,showBackButton:i=!0,providerIcon:a})=>{let{t:o}=Y(),[s,c]=V.useState(!1),[l,u]=B(`colors`,[`vechain-kit-accent`,`vechain-kit-border-button`]);return V.useEffect(()=>{let e=setTimeout(()=>c(!0),7e3);return()=>clearTimeout(e)},[]),J(K,{children:[q(Z,{children:J(L,{children:[i&&q(Fo,{onClick:r}),t??o(`Connecting...`),q(I,{onClick:n})]})}),q(F,{children:J(z,{align:`center`,spacing:4,py:6,role:`status`,"aria-live":`polite`,children:[J(j,{position:`relative`,w:`64px`,h:`64px`,children:[q(j,{position:`absolute`,inset:0,borderRadius:`full`,border:`3px solid`,borderColor:u}),q(j,{position:`absolute`,inset:0,borderRadius:`full`,border:`3px solid transparent`,borderTopColor:l,animation:`${vf} 0.8s linear infinite`}),a&&q(j,{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,children:a})]}),q(R,{fontSize:`14px`,fontWeight:500,color:l,textAlign:`center`,children:o(`Waiting for signature...`)}),e&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:e}),s&&q(R,{color:`orange.300`,fontSize:`sm`,textAlign:`center`,pt:1,children:o(`This is taking longer than expected.`)})]})}),q(It,{justifyContent:`center`,children:q(M,{variant:`ghost`,size:`sm`,fontSize:`12px`,fontWeight:500,textTransform:`uppercase`,letterSpacing:`0.08em`,color:`vechain-kit-text-secondary`,onClick:r,children:o(`Cancel`)})})]})},bf=({error:e,onClose:t,onTryAgain:n,onGoBack:r})=>{let{t:i}=Y(),[a,o]=B(`colors`,[`vechain-kit-error`,`vechain-kit-error-bg`]);return J(K,{children:[q(Z,{children:J(L,{children:[q(Fo,{onClick:r}),i(`Couldn't connect`),q(I,{onClick:t})]})}),q(F,{children:J(z,{align:`center`,spacing:4,py:4,children:[q(j,{w:`56px`,h:`56px`,borderRadius:`full`,bg:o,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(P,{as:Ar,color:a,w:`28px`,h:`28px`})}),q(R,{fontSize:`18px`,fontWeight:700,textAlign:`center`,children:i(`Couldn't connect`)}),q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,px:2,children:e})]})}),q(It,{children:J(N,{w:`full`,spacing:3,children:[q(M,{variant:`vechainKitSecondary`,flex:1,h:`52px`,borderRadius:`16px`,onClick:r,children:i(`Back`)}),q(M,{variant:`vechainKitPrimary`,flex:1,h:`52px`,borderRadius:`16px`,onClick:n,children:i(`Try again`)})]})})]})},xf=({onClose:e,appsInfo:t,isLoading:n,setCurrentContent:r,showBackButton:i=!0})=>{let{t:a}=Y(),o=B(`colors`,`vechain-kit-text-primary`),{setConnectionCache:s}=om(),{login:c}=nl(),l=async(n,i)=>{r({type:`loading`,props:{title:`${a(`Connecting with`)} ${i}`,loadingText:a(`Please approve the request in the connection request window...`),onTryAgain:()=>{l(n,i)}}});try{await c(n),s({name:i,logoUrl:t.find(e=>e.id===n)?.logo_url,appId:n,website:t.find(e=>e.id===n)?.website}),e()}catch(e){let a=e?.message;if(a&&h(a)){r({type:`ecosystem`,props:{appsInfo:t,isLoading:!1}});return}r({type:`error`,props:{error:(e instanceof Error?e:Error(`An unexpected issue occurred while logging in with this app. Please try again or contact support.`)).message,onTryAgain:()=>{l(n,i)}}})}};return q(j,{children:J(K,{children:[q(Z,{children:J(L,{children:[i&&q(Fo,{onClick:()=>r(`main`)}),a(`Already have an x2earn app wallet?`),q(I,{onClick:e})]})}),J(F,{children:[n&&q(z,{minH:`200px`,w:`full`,justifyContent:`center`,children:q(qt,{})}),!n&&t&&q(z,{spacing:4,w:`full`,pb:6,children:t.map(e=>J(M,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{l(e.id,e.name)},justifyContent:`flex-start`,children:[q(Et,{src:e.logo_url,alt:e.name,w:`30px`}),q(R,{ml:5,children:e.name})]},e.id))}),!n&&!t&&q(R,{textAlign:`center`,color:o,children:a(`No application from VeChain ecosystem is available to login.`)})]}),q(It,{pt:0})]})})},Sf=new Set([`google`,`apple`,`email`,`github`,`passkey`]),Cf=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,wf=({children:e})=>q(R,{fontSize:`11px`,fontWeight:700,color:B(`colors`,`vechain-kit-text-secondary`),textTransform:`uppercase`,letterSpacing:`0.12em`,px:1,mb:2,children:e}),Tf=({icon:e,customIcon:t,label:n,onClick:r,iconBg:i,iconColor:a})=>{let o=B(`colors`,`vechain-kit-button-secondary-bg`);return q(M,{variant:`ghost`,w:`full`,h:`auto`,py:`10px`,px:`12px`,borderRadius:`14px`,justifyContent:`flex-start`,onClick:r,_hover:{bg:o},_active:{bg:o,transform:`scale(0.99)`},children:J(N,{w:`full`,spacing:3,children:[q(N,{w:`36px`,h:`36px`,borderRadius:`10px`,bg:i??`transparent`,justify:`center`,align:`center`,flexShrink:0,children:t||(e?q(P,{as:e,w:`18px`,h:`18px`,color:a}):null)}),q(R,{flex:1,textAlign:`left`,fontSize:`15px`,fontWeight:600,letterSpacing:`-0.005em`,children:n}),q(P,{as:Or,opacity:.4})]})})},Ef=({source:e,label:t,icon:n,customIcon:r,iconBg:i,iconColor:a,setCurrentContent:o})=>{let{connect:s}=um(e,o);return q(Tf,{icon:n,customIcon:r,label:t,onClick:s,iconBg:i,iconColor:a})},Df=({onClose:e,setCurrentContent:t,showBackButton:n=!0})=>{let{t:r}=Y(),{privy:i,privyEcosystemAppIDS:a,dappKit:o,loginMethods:s,darkMode:c}=$(),l=c?`#ffffff`:`#0E0D18`,u=c?`#0E0D18`:`#ffffff`,{data:d,isLoading:f}=Yo(a),{login:p}=Yn(),{initOAuth:m}=am(),{loginWithPasskey:g}=rm(),{setConnectionCache:_}=om(),{login:v}=nl(),y=B(`colors`,`vechain-kit-text-secondary`),b=e=>s?.some(t=>t.method===e)??!1,x=o?.allowedWallets??[],S=i?.loginMethods??[],C=x.includes(`veworld`)&&!b(`veworld`),w=x.includes(`sync2`)&&!b(`sync2`),ee=x.includes(`wallet-connect`)&&!!o?.walletConnectOptions?.projectId&&!b(`wallet-connect`),T=C||w||ee,E=S.includes(`google`)&&!b(`google`),D=S.includes(`apple`)&&!b(`apple`),O=S.includes(`email`)&&!b(`email`),k=S.includes(`github`)&&!b(`github`),te=!!i&&S.includes(`passkey`)&&!b(`passkey`),A=S.some(e=>!Sf.has(e)),ne=!!i&&(E||D||O||k||te||A),re=Object.values(d||{}),ie=!!i&&(f||re.length>0),ae=async()=>{t({type:`loading`,props:{title:r(`Connecting with Passkey`),loadingText:r(`Please complete the passkey authentication...`),onTryAgain:ae}});try{await g()}catch(e){t({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with Passkey`),onTryAgain:ae}})}},oe=async(i,a)=>{t({type:`loading`,props:{title:`${r(`Connecting with`)} ${a}`,loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:()=>{oe(i,a)}}});try{await v(i);let t=re.find(e=>e.id===i);_({name:a,logoUrl:t?.logo_url,appId:i,website:t?.website}),e()}catch(e){let r=e?.message;if(r&&h(r)){t({type:`more`,props:{showBackButton:n}});return}t({type:`error`,props:{error:(e instanceof Error?e:Error(`An unexpected issue occurred while logging in with this app. Please try again or contact support.`)).message,onTryAgain:()=>{oe(i,a)}}})}},[se,ce]=G(``),{sendCode:le,state:ue}=Gn({}),de=hn(),fe=Cf.test(se),pe=async()=>{if(fe)try{await le({email:se}),de.onOpen()}catch(e){let n=e instanceof Error?e.message:r(`Failed to connect, please try again later.`);console.error(`sendCode failed`,e),t({type:`error`,props:{error:n,onTryAgain:()=>{pe()}}})}},[me,he,ge,_e]=B(`colors`,[`vechain-kit-border-button`,`vechain-kit-accent`,`vechain-kit-text-primary`,`vechain-kit-button-secondary-bg`]);return J(j,{children:[q(Z,{children:J(L,{children:[n&&q(Fo,{onClick:()=>t(`main`)}),r(`More options`),q(I,{onClick:e})]})}),q(F,{children:J(z,{spacing:6,w:`full`,align:`stretch`,children:[T&&J(j,{children:[q(wf,{children:r(`Other wallets`)}),J(z,{spacing:1,w:`full`,align:`stretch`,children:[C&&q(Ef,{source:`veworld`,label:r(`Continue with VeWorld`),customIcon:q(Se,{w:`20px`,h:`20px`,color:u}),iconBg:l,setCurrentContent:t}),w&&q(Ef,{source:`sync2`,label:r(`Continue with Sync2`),icon:pi,iconBg:_e,iconColor:ge,setCurrentContent:t}),ee&&q(Ef,{source:`wallet-connect`,label:r(`Continue with WalletConnect`),icon:ti,iconBg:`#3B99FC`,iconColor:`#ffffff`,setCurrentContent:t})]})]}),ne&&J(j,{children:[q(wf,{children:r(`Other sign-in`)}),J(z,{spacing:1,w:`full`,align:`stretch`,children:[E&&q(Tf,{icon:ha,label:r(`Continue with Google`),onClick:()=>m({provider:`google`}),iconBg:`#ffffff`}),D&&q(Tf,{icon:ga,label:r(`Continue with Apple`),onClick:()=>m({provider:`apple`}),iconBg:l,iconColor:u}),k&&q(Tf,{icon:Hr,label:r(`Continue with Github`),onClick:()=>m({provider:`github`}),iconBg:`#24292e`,iconColor:`#ffffff`}),te&&q(Tf,{icon:zr,label:r(`Passkey`),onClick:ae,iconBg:_e,iconColor:ge}),O&&q(j,{px:`2px`,pt:1,children:J(Ot,{size:`md`,children:[q(kt,{pointerEvents:`none`,h:`100%`,pl:3,children:q(P,{as:Xr,w:`14px`,h:`14px`,opacity:.6})}),q(Dt,{type:`email`,placeholder:r(`your@email.com`),value:se,onChange:e=>ce(e.target.value),onKeyDown:e=>{e.key===`Enter`&&fe&&pe()},fontSize:`14px`,pl:`34px`,pr:`72px`,h:`44px`,borderRadius:`9999px`,bg:`transparent`,borderColor:me,_hover:{borderColor:me},_focus:{borderColor:he,boxShadow:`none`}}),q(M,{position:`absolute`,right:1,top:`50%`,transform:`translateY(-50%)`,zIndex:2,variant:`ghost`,size:`sm`,borderRadius:`9999px`,fontSize:`13px`,fontWeight:600,color:fe?he:y,isDisabled:!fe,isLoading:ue.status===`sending-code`,onClick:pe,children:r(`Submit`)})]})}),A&&q(Tf,{icon:Ir,label:r(`More options`),onClick:p,iconBg:_e,iconColor:ge})]})]}),ie&&J(j,{children:[q(wf,{children:r(`Ecosystem apps`)}),f?q(N,{minH:`60px`,w:`full`,justifyContent:`center`,children:q(qt,{})}):q(St,{templateColumns:`repeat(3, 1fr)`,gap:3,w:`full`,children:re.map(e=>q(Ct,{children:q(M,{variant:`ghost`,w:`full`,h:`auto`,py:2,onClick:()=>oe(e.id,e.name),_hover:{bg:_e},borderRadius:`12px`,children:J(z,{spacing:1.5,align:`center`,w:`full`,children:[q(Et,{src:e.logo_url,alt:e.name,w:`38px`,h:`38px`,borderRadius:`10px`,objectFit:`cover`}),q(R,{fontSize:`11px`,fontWeight:600,noOfLines:1,maxW:`full`,children:e.name})]})})},e.id))})]}),!T&&!ne&&!ie&&q(R,{textAlign:`center`,color:y,py:8,children:r(`No additional login options available.`)})]})}),q(It,{pt:0,pb:`5px`}),q(Zl,{isOpen:de.isOpen,onClose:de.onClose,onResend:()=>le({email:se}),email:se,isLoading:ue.status===`sending-code`})]})},Of=e=>e?typeof e==`string`?e:e.type:`main`,kf=ma`
@@ -203,7 +203,7 @@ import{$ as e,C as t,D as n,G as r,H as i,J as a,Q as o,S as s,T as c,U as l,V a
203
203
  font-family: ${t} !important;
204
204
  }
205
205
  }
206
- `}),hp=({children:e,theme:t,bodyFont:n,headingFont:r,colorModeManager:i})=>J(da,{value:W(()=>pp(),[]),children:[q(mp,{bodyFont:n,headingFont:r}),q(pt,{theme:t,resetCSS:!1,portalZIndex:void 0,colorModeManager:i,children:e})]}),gp=yn({portalRootRef:void 0,tokens:void 0,themeConfig:void 0}),_p=()=>{let e=bn(gp);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},vp=({children:e,darkMode:t=!1,theme:n})=>{let r=xn(null),i=bn(Tg),a=i?i.theme:void 0,o=n??a,s=W(()=>To(wo(t),Eo(o,t)),[t,o]),c=W(()=>({...dp(t,o),config:{...dp(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]),l=W(()=>({type:`localStorage`,ssr:!1,get:()=>t?`dark`:`light`,set:()=>{}}),[t]);return J(gp.Provider,{value:{portalRootRef:r,tokens:s,themeConfig:o},children:[q(hp,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,colorModeManager:l,children:q(j,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})}),q(fp,{})]})},yp=yn(null),bp=()=>{let e=bn(yp);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},xp=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=G(!1),[a,o]=G(`main`),[s,c]=G(!1),{setSource:l,connectV2:u}=rr(),d=H((e,t)=>{O()&&window.vechain&&window.vechain.isInAppBrowser?(l(`veworld`),u(null)):(o(e??`main`),c(t??!1),i(!0))},[]),f=H(()=>{i(!1),o(`main`),c(!1)},[]),[p,m]=G(!1),[h,g]=G(!1),[_,v]=G(`main`),y=H((e,t)=>{v(e??`main`),g(t?.isolatedView??!1),m(!0)},[]),b=H(()=>{m(!1),v(`main`),setTimeout(()=>{g(!1)},300)},[]),[x,S]=G(!1),C=H(()=>S(!0),[]),w=H(()=>S(!1),[]),[ee,T]=G(!1),E=H(()=>T(!0),[]),D=H(()=>T(!1),[]),[k,te]=G(!1),[A,ne]=G(void 0),re=H(e=>{ne(e),te(!0)},[]),ie=H(()=>te(!1),[]);return J(yp.Provider,{value:{openConnectModal:d,closeConnectModal:f,isConnectModalOpen:r,connectModalContent:a,setConnectModalContent:o,connectModalPreventAutoClose:s,setConnectModalPreventAutoClose:c,openAccountModal:y,closeAccountModal:b,isAccountModalOpen:p,setAccountModalContent:v,accountModalContent:_,isolatedView:h,openTransactionModal:C,closeTransactionModal:w,isTransactionModalOpen:x,openTransactionToast:E,closeTransactionToast:D,isTransactionToastOpen:ee,openUpgradeSmartAccountModal:re,closeUpgradeSmartAccountModal:ie,isUpgradeSmartAccountModalOpen:k},children:[e,J(vp,{darkMode:t,theme:n,children:[q(Af,{isOpen:r,onClose:f,initialContent:a,preventAutoClose:s}),q(_f,{isOpen:p,onClose:b,initialContent:_}),q(Hf,{isOpen:k,onClose:ie,style:A})]})]})},Sp=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=bp(),{open:a,close:o}=ar();return{open:t?a:e=>n(e),close:t?o:r,isOpen:t?!1:i}},Cp=({children:e})=>q(K,{children:e}),wp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:()=>e(),close:t,isOpen:n}},Tp=({children:e})=>q(K,{children:e}),Ep=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=bp();return{open:e,close:t,isOpen:n}},Dp=({children:e})=>q(K,{children:e}),Op=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=bp();return{open:e,close:t,isOpen:n}},kp=({children:e})=>q(K,{children:e}),Ap=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=bp();return{open:n=>{e.isConnected?i(void 0,n):t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},jp=({children:e})=>q(K,{children:e}),Mp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},Np=({children:e})=>q(K,{children:e}),Pp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},Fp=({children:e})=>q(K,{children:e}),Ip=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Lp=({children:e})=>q(K,{children:e}),Rp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},zp=({children:e})=>q(K,{children:e}),Bp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Vp=({children:e})=>q(K,{children:e}),Hp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Up=({children:e})=>q(K,{children:e}),Wp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`account-customization`,t)},close:()=>{t()},isOpen:n}},Gp=({children:e})=>q(K,{children:e}),Kp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},qp=({children:e})=>q(K,{children:e}),Jp=()=>{let{privy:e,loginMethods:t,dappKit:n}=$(),r=e?.appId===g,i=n?.allowedWallets,a=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,o=W(()=>t?t.length===0||a(`ecosystem`):!0,[t]),s=W(()=>a(`vechain`),[t]),c=W(()=>a(`dappkit`),[t]),l=W(()=>a(`passkey`),[t]),u=W(()=>a(`email`),[t]),d=W(()=>a(`google`),[t]),f=W(()=>a(`apple`),[t]),p=W(()=>a(`more`),[t]),m=W(()=>a(`github`),[t]),h={showGoogleLogin:d,showAppleLogin:f,showEmailLogin:u,showPasskey:l,showVeChainLogin:s,showDappKit:c,showVeWorld:W(()=>a(`veworld`)?i?i.includes(`veworld`):!0:!1,[t,i]),showSync2:W(()=>a(`sync2`)?i?i.includes(`sync2`):!0:!1,[t,i]),showWalletConnect:W(()=>a(`wallet-connect`)?i?i.includes(`wallet-connect`):!0:!1,[t,i]),showEcosystem:o,showMoreLogin:p,showGithubLogin:m,isOfficialVeChainApp:!1};return e?r?{...h,isOfficialVeChainApp:!0}:{...h}:{...h,showGoogleLogin:!1,showAppleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1,showGithubLogin:!1}},Yp=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=bp();return{open:()=>t(e),close:n,isOpen:r}},Xp=({children:e})=>q(K,{children:e}),Zp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Qp=({children:e})=>q(K,{children:e}),$p=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`settings`,t)},close:()=>{t()},isOpen:n}},em=({children:e})=>q(K,{children:e}),tm=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{connection:o,account:s}=Q(),{requestCertificate:c}=ir(),l=wg();return{signMessage:H(async e=>{if(!s)throw Error(`Account not found`);t(!0),a(null),r(null);try{let t=null;return t=o.isConnectedWithDappKit?(await c({purpose:`agreement`,payload:{type:`text`,content:e}},{signer:s.address})).signature:await l.signMessage(e),r(t),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw a(t),t}finally{t(!1)}},[o,l,s?.address]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},nm=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{signer:o}=rr(),{connection:s}=Q(),c=wg();return{signTypedData:H(async(e,n)=>{t(!0),a(null),r(null);try{let t;if(s.isConnectedWithDappKit){let r={...e.domain,salt:e.domain?.salt?Buffer.from(e.domain.salt).toString(`hex`):void 0};t=await o.signTypedData(r,e.types,e.message,void 0,n)}else t=await c.signTypedData(e);return r(t),t}catch(e){if(e&&typeof e==`object`&&`statusCode`in e&&e.statusCode===4001){let e=Error(`User denied signature request`);throw a(e),e}let t=e instanceof Error?e:Error(typeof e==`object`?JSON.stringify(e):String(e));throw console.error(t),a(t),t}finally{t(!1)}},[s,c]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},rm=()=>{let{loginWithPasskey:e}=qn();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let im=!1;const am=()=>{let{createWallet:e}=Wn(),{initOAuth:t}=Kn({onComplete:H(async({isNewUser:t})=>{if(t&&!im){im=!0;try{await e()}catch(e){throw im=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},om=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:H(t=>{let n={timestamp:Date.now(),ecosystemApp:t};ue(e,JSON.stringify(n))},[]),getConnectionCache:H(()=>{let t=b(e);return t?JSON.parse(t):null},[]),clearConnectionCache:H(()=>{C(e)},[])}},sm=()=>{let{login:e}=nl(),{setConnectionCache:t}=om(),{data:n}=Yo([g]);return{login:async()=>{try{await e(g),t({name:`VeChain`,logoUrl:n?.[g]?.logo_url,appId:g,website:Ze})}catch(e){throw Qc({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the login window. Please click 'Try again' to open the login window or change your browser settings.`,rejectedMessage:`Login request was cancelled.`,defaultMessage:`There was an unexpected issue logging in with VeChain. Please try again or contact support.`})}}}},cm={veworld:`VeWorld`,sync2:`Sync2`,sync:`Sync`,"wallet-connect":`WalletConnect`},lm=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;if(e&&typeof e==`object`){let t=e;if(typeof t.message==`string`)return t.message;if(typeof t.reason==`string`)return t.reason;try{return JSON.stringify(e)}catch{return``}}return``},um=(e,t)=>{let{t:n}=Y(),{setSource:r,connect:i}=rr(),a=H(async()=>{let o=cm[e]??e,s=()=>{a()};t({type:`loading`,props:{title:`${n(`Connecting with`)} ${o}`,loadingText:n(e===`wallet-connect`?`Scan the QR code with your wallet to continue.`:`Open your wallet and confirm the connection request.`),onTryAgain:s}});try{r(e),await i()}catch(e){let r=lm(e);if(h(r)){t(`main`);return}t({type:`error`,props:{error:r||n(`Failed to connect, please try again later.`),onTryAgain:s}})}},[e,r,i,t,n]);return{connect:a}},dm=`vechain-kit-app-hub-apps`,fm=`vechain-kit-app-hub-apps-expiry`,pm=()=>[`VECHAIN_KIT`,`appHub`,`apps`],mm=async()=>{if(typeof window<`u`)try{let e=b(dm),t=b(fm);if(e&&t){let n=parseInt(t,10);if(Date.now()<n)return JSON.parse(e)}}catch{console.warn(`Invalid app-hub cache, fetching fresh data`)}let e=new URL(`contents/apps`,Fe),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch app directories`);let n=(await t.json()).map(async e=>{if(e.type!==`dir`)return null;let t=new URL(`master/apps/${e.name}/manifest.json`,We),n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json(),r=new URL(`master/apps/${e.name}/logo.png`,We);return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:r.toString(),category:t.category,tags:t.tags||[],isVeWorldSupported:t.isVeWorldSupported||!1,repo:t.repo,contracts:t.contracts,veBetterDaoId:t.veBetterDaoId}}catch(t){return console.warn(`Error parsing manifest for ${e.name}:`,t),null}}),r=(await Promise.all(n)).filter(e=>e!==null);if(typeof window<`u`)try{ue(dm,JSON.stringify(r)),ue(fm,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return r},hm=()=>X({queryKey:pm(),queryFn:async()=>{try{return await mm()}catch(e){let t=localStorage.getItem(dm);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),gm=({abi:e,address:t,method:n})=>[`callClause`,t,n],_m=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?_m(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),vm=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?_m(r):[]],ym=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=nr();return X({queryKey:vm({abi:t,address:e,method:n,args:r}),queryFn:async()=>k({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},bm=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>X({queryKey:n,queryFn:()=>A({thor:e,calls:t}),enabled:r}),xm=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},Sm=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},Cm=()=>{let[e,t]=G(!0),n=`vechain_kit_feature_announcement_closed`;return U(()=>{b(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{ue(n,`true`),t(!1)}}},wm=()=>{let{network:e}=$();return e.nodeUrl??v(e.type).nodeUrl},Tm=()=>{let[e,t]=G(!0);return U(()=>{if(!O()){t(!1);return}let e=()=>{t(window.matchMedia(`(display-mode: standalone)`).matches||window.standalone||document.referrer.includes(`android-app://`))};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]),e},Em=()=>{U(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},Dm=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(Mn.of(t));return{balance:Wi(BigInt(n.balance)).toString(),energy:Wi(BigInt(n.energy)).toString()}},Om=e=>Ba.balance.native(e),km=e=>{let t=nr();return X({queryKey:Om(e),queryFn:()=>Dm(t,e),enabled:!!e&&Mn.isValid(e),refetchInterval:1e4})},Am=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(v(n).accountFactoryAddress,Di.abi),i;switch(t){case 1:case 2:i=r.read.accountImplementationV1();break;case 3:i=r.read.accountImplementationV3();break;default:throw Error(`Invalid version, must be between 1 and 3`)}let a=await i;if(!a)throw Error(`Failed to get account implementation address`);return a[0].toString()},jm=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],Mm=e=>{let t=nr(),{network:n}=$();return X({queryKey:jm(e,n.type),queryFn:async()=>Am(t,e,n.type),enabled:!!t&&!!e&&!!n})},Nm=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(v(t).accountFactoryAddress,Di.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},Pm=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],Fm=()=>{let e=nr(),{network:t}=$();return X({queryKey:Pm(t.type),queryFn:async()=>Nm(e,t.type),enabled:!!e&&!!t})},Im=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let r=await e.contracts.load(v(n).accountFactoryAddress,Di.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},Lm=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],Rm=e=>{let t=nr(),{network:n}=$();return X({queryKey:Lm(e,n.type),queryFn:async()=>Im(t,e,n.type),enabled:!!t&&!!e&&!!n})},zm=Di.abi,Bm=(e,t,n)=>vm({abi:zm,address:v(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),Vm=(e,t)=>{let{network:n}=$();return ym({address:v(n.type).accountFactoryAddress,abi:zm,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]}),enabled:!!e&&!!t}})},Hm=Di.abi,Um=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await k({thor:e,abi:Hm,contractAddress:v(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},Wm=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Gm=e=>{let t=nr(),{network:n}=$();return X({queryKey:Wm(e,n.type),queryFn:async()=>Um(t,e,n.type),enabled:!!t&&!!e&&!!n})},Km=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(Mn.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},qm=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Jm=e=>{let t=wm(),n=Ia.at(t);return X({queryKey:qm(e),queryFn:async()=>Km(n,e),enabled:!!n&&!!e})},Ym=()=>{let e=dr(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:Lm(i,r.type)}),e.cancelQueries({queryKey:Bm(a,i,r.type)}),e.cancelQueries({queryKey:Wm(i,r.type)}),e.cancelQueries({queryKey:Pm(r.type)}),e.cancelQueries({queryKey:th(a,i,3,r.type)}),e.cancelQueries({queryKey:ih(a,3,r.type)}),e.cancelQueries({queryKey:jm(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:Lm(i,r.type)}),e.refetchQueries({queryKey:Bm(a,i,r.type)}),e.refetchQueries({queryKey:Wm(i,r.type)}),e.refetchQueries({queryKey:Pm(r.type)}),e.refetchQueries({queryKey:th(a,i,3,r.type)}),e.refetchQueries({queryKey:ih(a,3,r.type)}),e.refetchQueries({queryKey:jm(3,r.type)})])}}},Xm=()=>{let e=dr(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Qm(n)}),e.cancelQueries({queryKey:qm(n)})]),await Promise.all([e.refetchQueries({queryKey:Qm(n)}),e.refetchQueries({queryKey:qm(n)})])}}},Zm=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(v(t).accountFactoryAddress,Di.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=Mn.of(r[0].toString()),a=await e.accounts.getAccount(i);if(!a)throw Error(`Failed to get account detail of ${i}`);return{address:i.toString(),isDeployed:a.hasCode}},Qm=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],$m=e=>{let{network:t}=$(),n=nr();return X({queryKey:Qm(e),queryFn:()=>Zm(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},eh=async(e,t,n,r,i)=>{let a=await e.contracts.load(v(i).accountFactoryAddress,Di.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${v(i).accountFactoryAddress}`);return a[0]},th=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],nh=(e,t,n)=>{let r=nr(),{network:i}=$();return X({queryKey:th(e,t,n,i.type),queryFn:async()=>eh(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},rh=async(e,t,n,r)=>{let i=await e.contracts.load(v(r).accountFactoryAddress,Di.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},ih=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],ah=(e,t)=>{let n=nr(),{network:r}=$();return X({queryKey:ih(e,t,r.type),queryFn:async()=>rh(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},oh=Oi.createInterface(),sh=({smartAccountAddress:e,targetVersion:t,onSuccess:n,onError:r})=>{let{refresh:i}=Ym(),{refresh:a}=Xm(),{data:o}=Mm(t),s=H(async()=>{if(!e||!T(e))throw Error(`Invalid smart account address`);if(!o)throw Error(`Unable to fetch implementation address for version ${t}`);return[{to:e,value:`0x0`,data:oh.encodeFunctionData(`upgradeToAndCall`,[o,`0x`]),comment:`Upgrade account to version ${t}`,abi:oh.getFunction(`upgradeToAndCall`).format(`json`)}]},[e,o,t]),c=Cl({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${d(e)} to version ${t}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([i(),a()]),n?.()},onTxFailedOrCancelled:async()=>{r?.()}});return{...c,sendTransaction:async()=>c.sendTransaction(await s())}},ch=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],lh=10*re.SECOND,uh=()=>{let e=nr();return X({queryKey:ch(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:lh})},dh=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},fh=()=>[`VECHAIN_KIT_CHAIN_ID`],ph=()=>{let e=nr();return X({queryKey:fh(),queryFn:()=>dh(e),enabled:!!e})},mh=Ti.createInterface(),hh=(e,t,n,r,i)=>{if(!e||!t||!T(e))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:n,value:`0x0`,data:mh.encodeFunctionData(`transfer`,[e,Xi(t,i)]),comment:`Transfer ${t} ${r} to ${e}`,abi:mh.getFunction(`transfer`)}),a},gh=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,tokenDecimals:a,onSuccess:o,onError:s})=>{let{refresh:c}=Zc(),{data:l,isLoading:u,error:f}=bc(a===void 0?r:``),p=W(()=>{let e=a??l?.decimals;if(e==null)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0},[a,l?.decimals]),m=W(()=>p===void 0?[]:hh(t,n,r,i,p),[t,n,r,i,p]),h=Cl({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${d(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{c(),o?.()},onTxFailedOrCancelled:async e=>{s?.(e instanceof Error?e.message:String(e))}});return{...h,clauses:m,isLoadingTokenInfo:u,sendTransaction:async()=>{if(p===void 0){let e=f?`Failed to load token info: ${f.message}`:`Token decimals are required`;s?.(e);return}return h.sendTransaction(m)}}},_h=(e,t)=>{if(!e||!t||!T(e))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(t)))throw Error(`Invalid amount`);let n=[];try{n.push({to:e,value:Yi(t).toString(),data:`0x`,comment:`Transfer ${t} VET to ${e}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return n},vh=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=Zc(),o=W(()=>_h(t,n),[t,n]),s=Cl({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${d(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{a(),r?.()},onTxFailedOrCancelled:async e=>{i?.(e instanceof Error?e.message:String(e))}});return{...s,clauses:o,sendTransaction:async()=>s.sendTransaction(o)}},yh=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o,delegationUrl:s})=>{let{account:c}=Q(),l=dr(),u=H(async()=>{n&&t?.forEach(async e=>{await l.cancelQueries({queryKey:e}),await l.refetchQueries({queryKey:e})}),r?.()},[n,r,l,t]),d=Cl({signerAccountAddress:c?.address,onTxConfirmed:u,suggestedMaxGas:a,onTxFailedOrCancelled:i,gasPadding:o,delegationUrl:s}),f=H(async t=>{d.sendTransaction(e(t),s)},[e,d,s]);return{...d,sendTransaction:f}},bh=10*re.SECOND,xh=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],Sh=(e,t=5)=>{let n=nr();return X({queryKey:xh(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*bh,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},Ch=(e,t)=>{let n=Vi({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},wh=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],Th=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=nr();return X({queryFn:H(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await $s({thor:o,nodeUrl:a,filterCriteria:[{criteria:{address:t,topic0:c[0]??void 0,topic1:c[1]??void 0,topic2:c[2]??void 0,topic3:c[3]??void 0,topic4:c[4]??void 0},eventAbi:s}]})).map(t=>Ch(t,e));if(l.some(({decodedData:e})=>e.eventName!==n))throw Error(`Unknown event`);return l.map(e=>i({meta:e.meta,decodedData:e.decodedData}))},[o,t,e,n,r,i,a]),queryKey:W(()=>wh({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function Eh({clauses:e,chainId:t,verifyingContract:n}){let r=[],i=[],a=[];return e.forEach(e=>{r.push(e.to??``),i.push(String(e.value)),typeof e.data==`object`&&`abi`in e.data?a.push(Ui(e.data)):a.push(e.data||`0x`)}),{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n},types:{ExecuteBatchWithAuthorization:[{name:`to`,type:`address[]`},{name:`value`,type:`uint256[]`},{name:`data`,type:`bytes[]`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`},{name:`nonce`,type:`bytes32`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteBatchWithAuthorization`,message:{to:r,value:i,data:a,validAfter:0,validBefore:Math.floor(Date.now()/1e3)+300,nonce:wn.hexlify(wn.randomBytes(32))}}}function Dh({clause:e,chainId:t,smartAccount:n}){return{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n.address??``},types:{ExecuteWithAuthorization:[{name:`to`,type:`address`},{name:`value`,type:`uint256`},{name:`data`,type:`bytes`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteWithAuthorization`,message:{validAfter:0,validBefore:Math.floor(Date.now()/1e3)+60,to:e.to,value:String(e.value),data:(typeof e.data==`object`&&`abi`in e.data?Ui(e.data):e.data)||`0x`}}}function Oh(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=nl(),{signTypedData:r}=Xn(),{network:i}=$(),{data:a}=ph();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const kh=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=Oh(),o=async e=>{let{version:t}=e;return t&&t<3?await s(e):await c(e)};async function s(o){let{clauses:s,smartAccount:c,title:l=`Sign Transaction`,description:u,buttonText:d=`Sign`}=o,f=[],p=s.map(e=>Dh({clause:e,chainId:a,smartAccount:c})),m=[];for(let i=0;i<p.length;i++){let a=p[i],o=s[i];if(!o)throw Error(`Transaction clause at index ${i} is undefined`);if(e.isConnectedWithCrossApp){let e=await n({...a,address:t?.address,types:Object.fromEntries(Object.entries(a.types).map(([e,t])=>[e,[...t]]))});m.push(e);continue}let c=o.data,f=(await r(a,{uiOptions:{title:l,description:u??(s[i].comment||(typeof c==`object`&&c&&`functionName`in c?c.functionName:` `)),buttonText:d}})).signature;m.push(f)}return c.isDeployed||f.push(Nn.callFunction(Mn.of(v(i.type).accountFactoryAddress),jn.ofAbi(Di.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(Nn.callFunction(Mn.of(c.address??``),jn.ofAbi(Oi.abi).getFunction(`executeWithAuthorization`),[e.message.to,BigInt(e.message.value),e.message.data,BigInt(e.message.validAfter),BigInt(e.message.validBefore),m[t]]))}),f}async function c(o){let{clauses:s,smartAccount:c,title:l,description:u,buttonText:d=`Sign`}=o,f=[],p=Eh({clauses:s,chainId:a,verifyingContract:c.address??``}),m;return m=e.isConnectedWithCrossApp?await n({...p,address:t?.address}):(await r(p,{uiOptions:{title:l,description:u,buttonText:d}})).signature,c.isDeployed||f.push(Nn.callFunction(Mn.of(v(i.type).accountFactoryAddress),jn.ofAbi(Di.abi).getFunction(`createAccount`),[t?.address??``])),f.push(Nn.callFunction(Mn.of(c.address??``),jn.ofAbi(Oi.abi).getFunction(`executeBatchWithAuthorization`),[p.message.to,p.message.value?.map(e=>BigInt(e))??0,p.message.data,BigInt(p.message.validAfter),BigInt(p.message.validBefore),p.message.nonce,m])),f}return{buildClausesWithAuth:o}};let Ah=function(e){return e.CUSTOM_TOKENS=`vechain_kit_custom_tokens`,e.ECOSYSTEM_SHORTCUTS=`vechain-kit-ecosystem-shortcuts`,e.CURRENCY=`vechain_kit_currency`,e.NODE_URL=`vechain_kit_node_url`,e.NETWORK=`vechain_kit_network`,e.GAS_TOKEN_PREFERENCES=`vechain_kit_gas_token_preferences`,e.SHOW_ASSETS=`vechain_kit_show_assets`,e}({});const jh=(e,t)=>{let[n,r]=G(()=>{try{let n=b(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return U(()=>{ue(e,JSON.stringify(n))},[e,n]),[n,r]},Mh=`vechain-kit-storage-change`,Nh=(e,t)=>{let[n,r]=G(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.error(`Error loading from localStorage:`,e),t}}),i=xn(!1);return U(()=>{if(!(typeof window>`u`)){if(i.current){i.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Mh,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),U(()=>{if(typeof window>`u`)return;let t=t=>{if(t.key===e&&t.newValue)try{let e=JSON.parse(t.newValue);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}catch(e){console.error(`Error parsing storage value:`,e)}},a=(t=>{if(t.detail.key===e)try{let t=window.localStorage.getItem(e);if(t){let e=JSON.parse(t);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}}catch(e){console.error(`Error parsing storage value:`,e)}});return window.addEventListener(`storage`,t),window.addEventListener(Mh,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Mh,a)}},[e,n]),[n,r,H(()=>{if(!(typeof window>`u`))try{let i=window.localStorage.getItem(e),a=i?JSON.parse(i):t;JSON.stringify(a)!==JSON.stringify(n)&&r(a)}catch(e){console.error(`Error syncing localStorage:`,e)}},[e,t,n]),H(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},Ph=()=>{let[e,t]=jh(Ah.ECOSYSTEM_SHORTCUTS,[]);return{shortcuts:e,addShortcut:n=>{e.some(e=>e.url===n.url)||t([...e,n])},removeShortcut:n=>{t(e.filter(e=>e.url!==n))},isShortcut:t=>e.some(e=>e.url===t)}},Fh=async(e,t,n,r,i)=>{let a=new URL(`estimate/clauses/${r.toLowerCase()}`,t);return a.searchParams.set(`type`,`smartaccount`),a.searchParams.set(`speed`,i),await(await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json()},Ih=async e=>{let t=new URL(`deposit/account`,e);return await(await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`}})).json()},Lh=async(e,t,n,r)=>{let i=new URL(`sign/transaction/authorized/${n.toLowerCase()}`,r);return await(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json()},Rh=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``,{gasPadding:1}),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function zh(e,t){return Ln.of(e.body,za.concatBytes(e.signature??new Uint8Array,Fn.of(t.slice(2)).bytes))}function Bh(e,t){return Ln.decode(Fn.of(e.slice(2)).bytes,t)}const Vh=()=>{let{connectedWallet:e}=Q(),{data:t}=$m(e?.address??``),{data:n}=Vm(t?.address??``,e?.address??``),{preferences:r}=Hh(),i=Ti.createInterface(),{network:a}=$(),{buildClausesWithAuth:s}=kh(),c=Ia.at(v(a.type).nodeUrl);return{sendTransactionUsingGenericDelegator:H(async({clauses:e,genericDelegatorUrl:a})=>{try{let l=r.gasTokenToUse,d=await Fh(t?.address??``,a,e,l,`medium`),f=await Ih(a),p={to:l===`VET`?f.depositAccount:o[l].address,value:l===`VET`?Yi(d.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:i.encodeFunctionData(`transfer`,[f.depositAccount,Yi(d.transactionCost?.toString()??`0`)]),comment:`Transfer ${d.transactionCost} ${l} to ${f.depositAccount}`,abi:l===`VET`?void 0:i.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:t,version:n?.version??0}),h=await Rh(m,c,u,!0),g=await Ln.of(h).signAsSender(Fn.of(u.privateKey).bytes),_=await Lh(Fn.of(g.encoded).toString(),u.address,l,a),v=zh(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:u.address??``,gasPayer:_.address}},b=await c.transactions.simulateTransaction(y.clauses,{...y.simulateTransactionOptions});for(let e=0;e<b.length;e++)if(b[e].reverted)throw Error(b[e].vmError);return(await c.transactions.sendTransaction(v)).id}catch(e){console.error(`Error sending transaction using generic delegator`,e)}throw Error(`Failed to send transaction using generic delegator, no gas tokens have sufficient balance or are enabled in Gas Token Preferences`)},[r,t,n,s,c,u])}},Hh=()=>{let[e,t]=Nh(Ah.GAS_TOKEN_PREFERENCES,a);return{preferences:e,supportedTokens:o,updatePreferences:H(e=>{t(t=>({...t,...e}))},[t]),reorderTokenPriority:H(e=>{t(t=>{let n=e.filter(e=>t.availableGasTokens.includes(e)&&!t.excludedTokens.includes(e));return{...t,tokenPriority:e,availableGasTokens:n,gasTokenToUse:n[0]??t.gasTokenToUse}})},[t]),toggleTokenExclusion:H(e=>{t(t=>{let n=t.excludedTokens.includes(e),r=n?t.excludedTokens.filter(t=>t!==e):[...t.excludedTokens,e],i=t.tokenPriority.indexOf(e),a=n?[...t.availableGasTokens.slice(0,i),e,...t.availableGasTokens.slice(i)]:t.availableGasTokens.filter(t=>t!==e);return{...t,excludedTokens:r,availableGasTokens:a,gasTokenToUse:a[0]??t.gasTokenToUse}})},[t])}},Uh=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=$m(a?.address??``),{feeDelegation:c}=$(),{balances:l}=Ks(o?.address??``),{updatePreferences:u}=Hh();return X({queryKey:[`gas-estimation`,JSON.stringify(e),JSON.stringify(n),r,i],queryFn:async()=>{let t=null;for(let a of n)try{let n=await Fh(s?.address??``,c?.genericDelegatorUrl??``,e,a,`medium`),o=n.transactionCost,d=Number(l.find(e=>e.symbol===a)?.balance||0),f=o+(r&&i&&a===i?Number(r):0);if(d>=f)return u({gasTokenToUse:a}),{...n,usedToken:a};t=Error(`Insufficient ${a} balance: has ${d}, needs ${f}`)}catch(e){t=e}throw t||Error(`All gas tokens failed estimation or have insufficient balance`)},enabled:t&&e.length>0&&!!s?.address&&!!c?.genericDelegatorUrl&&n.length>0&&l.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,retry:!1,retryDelay:1e3})},Wh=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=$m(r?.address??``),{feeDelegation:a}=$();return X({queryKey:[`gas-estimation-all-tokens`,JSON.stringify(e),JSON.stringify(t)],queryFn:async()=>{let n={};return await Promise.all(t.map(async t=>{try{n[t]={cost:(await Fh(i?.address??``,a?.genericDelegatorUrl??``,e,t,`medium`)).transactionCost||0,loading:!1}}catch(e){n[t]={cost:0,loading:!1,error:e instanceof Error?e.message:`Unknown error`}}})),n},enabled:n&&e.length>0&&!!i?.address&&!!a?.genericDelegatorUrl&&t.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1})},Gh=({valuePct:e,showSuffix:t,...n})=>{let r=B(`colors`,`vechain-kit-success`),i=B(`colors`,`vechain-kit-error`),a=B(`colors`,`vechain-kit-text-tertiary`);if(e===void 0||!Number.isFinite(e))return null;let o=e>0?`+`:``;return J(N,{spacing:1,align:`baseline`,children:[J(R,{fontSize:`xs`,fontWeight:`600`,color:e===0?a:e>0?r:i,...n,children:[o,e.toFixed(2),`%`]}),t&&q(R,{fontSize:`xs`,fontWeight:`500`,color:a,children:`24h`})]})},Kh=({symbol:t,amount:n,currencyValue:r,currentCurrency:i,isDisabled:a,onClick:o,priceChange24hPct:s,...c})=>{let l=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=B(`colors`,`vechain-kit-card`),[f]=jh(Ah.SHOW_ASSETS,!0),p=f?n.toLocaleString(void 0,{maximumFractionDigits:2}):`*`.repeat(4),m=f?sc(r,{currency:i}):`*`.repeat(4);return J(M,{height:`64px`,variant:`ghost`,bg:d,borderRadius:`xl`,justifyContent:`space-between`,isDisabled:a,px:4,py:3,w:`100%`,_hover:{bg:d,opacity:.85},_active:{bg:d,opacity:.7},_disabled:{cursor:`not-allowed`,opacity:.5},onClick:o,"data-testid":`asset-${t}`,...c,children:[J(N,{spacing:3,flex:1,minW:0,children:[x[t]?V.cloneElement(x[t],{boxSize:`36px`,borderRadius:`full`}):q(Et,{src:e[t],alt:`${t} logo`,boxSize:`36px`,borderRadius:`full`,fallback:q(j,{boxSize:`36px`,borderRadius:`full`,bg:`whiteAlpha.300`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`11px`,fontWeight:`bold`,color:l,children:t.slice(0,3)})})}),J(z,{align:`flex-start`,spacing:0,minW:0,children:[q(R,{fontWeight:`700`,fontSize:`md`,color:l,lineHeight:`short`,children:t}),J(R,{fontSize:`sm`,color:u,lineHeight:`short`,noOfLines:1,children:[p,` `,t]})]})]}),J(z,{align:`flex-end`,spacing:0,children:[q(R,{fontWeight:`700`,fontSize:`md`,color:l,lineHeight:`short`,"data-testid":`${t}-balance`,children:m}),f&&q(Gh,{valuePct:s,lineHeight:`short`})]})]})},qh=({address:e,domain:t,imageSrc:n,imageAlt:r=`Account`,hideAddress:i=!1,balance:a,tokenAddress:o})=>{let{t:s}=Y(),c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`),u=B(`colors`,`vechain-kit-card`),{isLoading:f}=wc({address:e}),{tokens:p,isLoading:m}=uc({address:e}),h=W(()=>o?p.find(e=>e.address===o):null,[p,o]),g=W(()=>a===void 0?h?Number(h.balance):0:a,[a,h]),_=h?.symbol||``;return f||m?J(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[J(N,{children:[q(Kt,{boxSize:`40px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(Kt,{height:`16px`,width:`120px`,borderRadius:`md`}),!i&&q(Kt,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),q(Kt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]}):J(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[J(N,{children:[q(Et,{src:n,alt:r,boxSize:`40px`,borderRadius:`full`,objectFit:`cover`}),q(z,{align:`start`,spacing:0,children:t?J(K,{children:[q(R,{fontWeight:`medium`,fontSize:`sm`,color:c,children:t}),!i&&q(R,{fontSize:`xs`,color:l,children:d(e,6,4)})]}):q(R,{fontWeight:`medium`,fontSize:`sm`,color:c,children:d(e,6,4)})})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),J(R,{fontSize:`xs`,color:l,children:[g.toLocaleString(void 0,{maximumFractionDigits:2}),_&&` ${_}`]})]})]})},Jh=({onClick:e,...t})=>q(Tt,{"aria-label":`FAQ`,icon:q(P,{as:Mr,fontSize:`17px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,lineHeight:`normal`,left:`10px`,top:`8px`,onClick:e,...t}),Yh=({children:e,...t})=>(Em(),q(z,{...t,children:e})),Xh=({wallet:e,props:t})=>{let n=xn(e?.image),r=xn(e?.address);return U(()=>{r.current!==e?.address&&(n.current=e?.image,r.current=e?.address)},[e?.address]),U(()=>{e?.image&&!e.isLoadingMetadata&&(n.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!n.current||e?.isLoadingMetadata?q(Kt,{rounded:`full`,width:t?.width,height:t?.height}):q(Et,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Zh=({transactionError:e,isSubmitting:t,isTxWaitingConfirmation:n,onConfirm:r,onRetry:i,transactionPendingText:a,txReceipt:o,isSubmitForm:s=!1,buttonText:c,isDisabled:l=!1,style:u,onError:d,gasEstimationError:f,hasEnoughGasBalance:p=!0,isLoadingGasEstimation:m=!1,showGasEstimationError:h=!1,context:g=`transaction`})=>{let{t:_}=Y(),{darkMode:y}=$(),{network:b}=$(),x=W(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);U(()=>{x&&d?.(x)},[x,d]);let S=W(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),C=W(()=>{if(!h||m||!(f||p))return null;if(!p&&!f)return{message:_(`You don't have any gas tokens enabled. Please enable at least one gas token in Gas Token Preferences.`)};if(f){let e=``;switch(g){case`send`:e=_(`Insufficient balance to complete this transfer and cover gas fees.`);break;case`customization`:e=_(`Insufficient balance to update your profile and cover gas fees.`);break;case`domain`:e=_(`Insufficient balance to claim this domain and cover gas fees.`);break;default:e=_(`Insufficient balance to complete this transaction and cover gas fees.`)}return{message:e}}return null},[f,p,m,h,g,_]);return J(z,{width:`full`,spacing:4,children:[x&&q(j,{p:3,borderRadius:`md`,bg:y?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:y?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:x})}),C&&!x&&q(j,{p:3,borderRadius:`md`,bg:y?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:y?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:C.message})}),q(M,{px:4,variant:x?`vechainKitSecondary`:`vechainKitPrimary`,bg:S,onClick:()=>x&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:x?_(`Retry`):c||_(`Confirm`)}),x&&o?.meta.txID&&q(jt,{isExternal:!0,fontSize:`sm`,color:y?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${v(b.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},Qh=({onClick:e,hasUnreadNotifications:t,...n})=>q(Tt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:J(j,{position:`relative`,children:[q(xr,{fontSize:`20px`}),t&&q(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),$h=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:s})=>{let{t:c}=Y(),{balances:l}=Ks(s),[u,d]=V.useState(n),[f,p]=V.useState(!1),m=B(`colors`,`vechain-kit-text-primary`),h=B(`colors`,`vechain-kit-text-secondary`),g=B(`colors`,`vechain-kit-text-tertiary`),_=B(`colors`,`vechain-kit-error`),v=e=>e?g:`transparent`,y=e=>e?m:`transparent`;V.useEffect(()=>{e&&(d(n),p(!1))},[e,n]);let b=()=>{r(u,f),t()},S=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},C=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return J(Ko,{isOpen:e,onClose:t,size:`sm`,children:[J(L,{children:[q(R,{fontSize:`lg`,fontWeight:`semibold`,color:m,children:c(`Fee token`)}),q(R,{fontSize:`sm`,fontWeight:`normal`,color:h,mt:1,children:c(`Select the token to pay the fee with`)})]}),q(F,{children:J(z,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=o[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=C(e);return q(j,{cursor:i?`not-allowed`:`pointer`,bg:v(n),border:`1px`,borderColor:y(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?v(n):h&&`#ffffff12`,borderColor:i?y(n):h},opacity:i?.5:1,onClick:()=>!i&&d(e),children:J(N,{spacing:3,justify:`space-between`,children:[J(N,{spacing:3,flex:1,children:[V.cloneElement(x[e],{boxSize:`36px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:m,children:t.symbol}),J(R,{fontSize:`xs`,color:h,children:[c(`Balance`),`:`,` `,S(e)]}),i&&q(R,{fontSize:`xs`,color:_,children:c(`Insufficient balance`)})]})]}),q(z,{align:`end`,spacing:0,children:r.loading?q(Kt,{height:`16px`,width:`60px`}):J(K,{children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,color:m,children:ce(r.cost,2)}),q(R,{fontSize:`xs`,color:h,children:t.symbol})]})})]})},e)}),u!==n&&J(bt,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[q(xt,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:m,children:c(`Use this token for future transactions`)}),q(Yt,{id:`remember-choice`,isChecked:f,onChange:e=>p(e.target.checked),color:m})]})]})}),q(It,{children:J(z,{spacing:3,w:`full`,children:[q(M,{variant:`vechainKitPrimary`,onClick:b,isDisabled:C(u),children:c(`Apply`)}),q(M,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},eg=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:s}=Y(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:f}=Hh(),{isOpen:p,onOpen:m,onClose:h}=hn(),g=B(`colors`,`vechain-kit-text-primary`),_=B(`colors`,`vechain-kit-text-secondary`),[v,y]=G(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:b,isLoading:S}=Wh({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});U(()=>{!S&&b&&y(b)},[b,S]),U(()=>{e&&y(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),U(()=>{S&&y(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[S,d.availableGasTokens]);let C=H((t,n)=>{n&&f([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,f,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:w}=Ks(u?.address??``),ee=e=>{let t=w.find(t=>t.symbol===e),n=v[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},T=e?.usedToken,E=d.availableGasTokens,D;T?D=T:a&&E.includes(a)?D=a:(D=E.find(e=>v[e]&&!v[e].loading&&!ee(e)),D||=E.find(e=>v[e]&&!v[e].loading),D||=E[0]);let O=D?v[D]:void 0,k=T&&e?.transactionCost?e.transactionCost:O?.cost||0,te=D?o[D]:void 0;return J(K,{children:[q(vt,{mt:3}),J(N,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[J(z,{align:`start`,spacing:0,w:`full`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:_,children:s(`Fee`)}),q(N,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:q(N,{justifyContent:`flex-start`,w:`full`,children:t||!T&&(!O||O.loading)||!te?J(K,{children:[q(Kt,{height:`16px`,width:`120px`,borderRadius:`md`}),q(Kt,{height:`16px`,width:`60px`,borderRadius:`md`})]}):J(K,{children:[J(R,{color:g,fontSize:`sm`,fontWeight:`semibold`,children:[ce(k,2),` `,te.symbol]}),J(R,{color:_,fontSize:`xs`,children:[`≈`,` $`,(k*.01).toFixed(2)]})]})})})]}),J(M,{onClick:m,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:_,borderColor:_,_hover:{bg:_},leftIcon:V.cloneElement(x[D||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,children:D||d.availableGasTokens[0]}),q(P,{as:Er,boxSize:5,color:_})]})]}),q($h,{isOpen:p,onClose:h,selectedToken:D||d.availableGasTokens[0],onTokenSelect:C,availableTokens:d.availableGasTokens,tokenEstimations:v,walletAddress:u?.address??``})]})},tg=ma`
206
+ `}),hp=({children:e,theme:t,bodyFont:n,headingFont:r,colorModeManager:i})=>J(da,{value:W(()=>pp(),[]),children:[q(mp,{bodyFont:n,headingFont:r}),q(pt,{theme:t,resetCSS:!1,portalZIndex:void 0,colorModeManager:i,children:e})]}),gp=yn({portalRootRef:void 0,tokens:void 0,themeConfig:void 0}),_p=()=>{let e=bn(gp);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},vp=({children:e,darkMode:t=!1,theme:n})=>{let r=xn(null),i=bn(Tg),a=i?i.theme:void 0,o=n??a,s=W(()=>To(wo(t),Eo(o,t)),[t,o]),c=W(()=>({...dp(t,o),config:{...dp(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]),l=W(()=>({type:`localStorage`,ssr:!1,get:()=>t?`dark`:`light`,set:()=>{}}),[t]);return J(gp.Provider,{value:{portalRootRef:r,tokens:s,themeConfig:o},children:[q(hp,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,colorModeManager:l,children:q(j,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})}),q(fp,{})]})},yp=yn(null),bp=()=>{let e=bn(yp);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},xp=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=G(!1),[a,o]=G(`main`),[s,c]=G(!1),{setSource:l,connectV2:u}=rr(),d=H((e,t)=>{O()&&window.vechain&&window.vechain.isInAppBrowser?(l(`veworld`),u(null)):(o(e??`main`),c(t??!1),i(!0))},[]),f=H(()=>{i(!1),o(`main`),c(!1)},[]),[p,m]=G(!1),[h,g]=G(!1),[_,v]=G(`main`),y=H((e,t)=>{v(e??`main`),g(t?.isolatedView??!1),m(!0)},[]),b=H(()=>{m(!1),v(`main`),setTimeout(()=>{g(!1)},300)},[]),[x,S]=G(!1),C=H(()=>S(!0),[]),w=H(()=>S(!1),[]),[ee,T]=G(!1),E=H(()=>T(!0),[]),D=H(()=>T(!1),[]),[k,te]=G(!1),[A,ne]=G(void 0),re=H(e=>{ne(e),te(!0)},[]),ie=H(()=>te(!1),[]);return J(yp.Provider,{value:{openConnectModal:d,closeConnectModal:f,isConnectModalOpen:r,connectModalContent:a,setConnectModalContent:o,connectModalPreventAutoClose:s,setConnectModalPreventAutoClose:c,openAccountModal:y,closeAccountModal:b,isAccountModalOpen:p,setAccountModalContent:v,accountModalContent:_,isolatedView:h,openTransactionModal:C,closeTransactionModal:w,isTransactionModalOpen:x,openTransactionToast:E,closeTransactionToast:D,isTransactionToastOpen:ee,openUpgradeSmartAccountModal:re,closeUpgradeSmartAccountModal:ie,isUpgradeSmartAccountModalOpen:k},children:[e,J(vp,{darkMode:t,theme:n,children:[q(Af,{isOpen:r,onClose:f,initialContent:a,preventAutoClose:s}),q(_f,{isOpen:p,onClose:b,initialContent:_}),q(Hf,{isOpen:k,onClose:ie,style:A})]})]})},Sp=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=bp(),{open:a,close:o}=ar();return{open:t?a:e=>n(e),close:t?o:r,isOpen:t?!1:i}},Cp=({children:e})=>q(K,{children:e}),wp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:()=>e(),close:t,isOpen:n}},Tp=({children:e})=>q(K,{children:e}),Ep=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=bp();return{open:e,close:t,isOpen:n}},Dp=({children:e})=>q(K,{children:e}),Op=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=bp();return{open:e,close:t,isOpen:n}},kp=({children:e})=>q(K,{children:e}),Ap=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=bp();return{open:n=>{e.isConnected?i(void 0,n):t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},jp=({children:e})=>q(K,{children:e}),Mp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},Np=({children:e})=>q(K,{children:e}),Pp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},Fp=({children:e})=>q(K,{children:e}),Ip=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Lp=({children:e})=>q(K,{children:e}),Rp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},zp=({children:e})=>q(K,{children:e}),Bp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Vp=({children:e})=>q(K,{children:e}),Hp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=bp();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Up=({children:e})=>q(K,{children:e}),Wp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`account-customization`,t)},close:()=>{t()},isOpen:n}},Gp=({children:e})=>q(K,{children:e}),Kp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},qp=({children:e})=>q(K,{children:e}),Jp=()=>{let{privy:e,loginMethods:t,dappKit:n}=$(),r=e?.appId===g,i=n?.allowedWallets,a=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,o=W(()=>t?t.length===0||a(`ecosystem`):!0,[t]),s=W(()=>a(`vechain`),[t]),c=W(()=>a(`dappkit`),[t]),l=W(()=>a(`passkey`),[t]),u=W(()=>a(`email`),[t]),d=W(()=>a(`google`),[t]),f=W(()=>a(`apple`),[t]),p=W(()=>a(`more`),[t]),m=W(()=>a(`github`),[t]),h={showGoogleLogin:d,showAppleLogin:f,showEmailLogin:u,showPasskey:l,showVeChainLogin:s,showDappKit:c,showVeWorld:W(()=>a(`veworld`)?i?i.includes(`veworld`):!0:!1,[t,i]),showSync2:W(()=>a(`sync2`)?i?i.includes(`sync2`):!0:!1,[t,i]),showWalletConnect:W(()=>a(`wallet-connect`)?i?i.includes(`wallet-connect`):!0:!1,[t,i]),showEcosystem:o,showMoreLogin:p,showGithubLogin:m,isOfficialVeChainApp:!1};return e?r?{...h,isOfficialVeChainApp:!0}:{...h}:{...h,showGoogleLogin:!1,showAppleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1,showGithubLogin:!1}},Yp=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=bp();return{open:()=>t(e),close:n,isOpen:r}},Xp=({children:e})=>q(K,{children:e}),Zp=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Qp=({children:e})=>q(K,{children:e}),$p=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=bp();return{open:t=>{e(`settings`,t)},close:()=>{t()},isOpen:n}},em=({children:e})=>q(K,{children:e}),tm=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{connection:o,account:s}=Q(),{requestCertificate:c}=ir(),l=wg();return{signMessage:H(async e=>{if(!s)throw Error(`Account not found`);t(!0),a(null),r(null);try{let t=null;return t=o.isConnectedWithDappKit?(await c({purpose:`agreement`,payload:{type:`text`,content:e}},{signer:s.address})).signature:await l.signMessage(e),r(t),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw a(t),t}finally{t(!1)}},[o,l,s?.address]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},nm=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{signer:o}=rr(),{connection:s}=Q(),c=wg();return{signTypedData:H(async(e,n)=>{t(!0),a(null),r(null);try{let t;if(s.isConnectedWithDappKit){let r={...e.domain,salt:e.domain?.salt?Buffer.from(e.domain.salt).toString(`hex`):void 0};t=await o.signTypedData(r,e.types,e.message,void 0,n)}else t=await c.signTypedData(e);return r(t),t}catch(e){if(e&&typeof e==`object`&&`statusCode`in e&&e.statusCode===4001){let e=Error(`User denied signature request`);throw a(e),e}let t=e instanceof Error?e:Error(typeof e==`object`?JSON.stringify(e):String(e));throw console.error(t),a(t),t}finally{t(!1)}},[s,c]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},rm=()=>{let{loginWithPasskey:e}=qn();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let im=!1;const am=()=>{let{createWallet:e}=Wn(),{initOAuth:t}=Kn({onComplete:H(async({isNewUser:t})=>{if(t&&!im){im=!0;try{await e()}catch(e){throw im=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},om=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:H(t=>{let n={timestamp:Date.now(),ecosystemApp:t};ue(e,JSON.stringify(n))},[]),getConnectionCache:H(()=>{let t=b(e);return t?JSON.parse(t):null},[]),clearConnectionCache:H(()=>{C(e)},[])}},sm=()=>{let{login:e}=nl(),{setConnectionCache:t}=om(),{data:n}=Yo([g]);return{login:async()=>{try{await e(g),t({name:`VeChain`,logoUrl:n?.[g]?.logo_url,appId:g,website:Ze})}catch(e){throw Qc({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the login window. Please click 'Try again' to open the login window or change your browser settings.`,rejectedMessage:`Login request was cancelled.`,defaultMessage:`There was an unexpected issue logging in with VeChain. Please try again or contact support.`})}}}},cm={veworld:`VeWorld`,sync2:`Sync2`,sync:`Sync`,"wallet-connect":`WalletConnect`},lm=e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;if(e&&typeof e==`object`){let t=e;if(typeof t.message==`string`)return t.message;if(typeof t.reason==`string`)return t.reason;try{return JSON.stringify(e)}catch{return``}}return``},um=(e,t)=>{let{t:n}=Y(),{setSource:r,connect:i}=rr(),a=H(async()=>{let o=cm[e]??e,s=()=>{a()};if(e===`veworld`&&typeof window<`u`&&!window.vechain){window.open(`https://www.veworld.com/discover/browser/ul/${encodeURIComponent(window.location.href)}`,`_self`);return}t({type:`loading`,props:{title:`${n(`Connecting with`)} ${o}`,loadingText:n(e===`wallet-connect`?`Scan the QR code with your wallet to continue.`:`Open your wallet and confirm the connection request.`),onTryAgain:s}});try{r(e),await i()}catch(e){let r=lm(e);if(h(r)){t(`main`);return}t({type:`error`,props:{error:r||n(`Failed to connect, please try again later.`),onTryAgain:s}})}},[e,r,i,t,n]);return{connect:a}},dm=`vechain-kit-app-hub-apps`,fm=`vechain-kit-app-hub-apps-expiry`,pm=()=>[`VECHAIN_KIT`,`appHub`,`apps`],mm=async()=>{if(typeof window<`u`)try{let e=b(dm),t=b(fm);if(e&&t){let n=parseInt(t,10);if(Date.now()<n)return JSON.parse(e)}}catch{console.warn(`Invalid app-hub cache, fetching fresh data`)}let e=new URL(`contents/apps`,Fe),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch app directories`);let n=(await t.json()).map(async e=>{if(e.type!==`dir`)return null;let t=new URL(`master/apps/${e.name}/manifest.json`,We),n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json(),r=new URL(`master/apps/${e.name}/logo.png`,We);return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:r.toString(),category:t.category,tags:t.tags||[],isVeWorldSupported:t.isVeWorldSupported||!1,repo:t.repo,contracts:t.contracts,veBetterDaoId:t.veBetterDaoId}}catch(t){return console.warn(`Error parsing manifest for ${e.name}:`,t),null}}),r=(await Promise.all(n)).filter(e=>e!==null);if(typeof window<`u`)try{ue(dm,JSON.stringify(r)),ue(fm,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return r},hm=()=>X({queryKey:pm(),queryFn:async()=>{try{return await mm()}catch(e){let t=localStorage.getItem(dm);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),gm=({abi:e,address:t,method:n})=>[`callClause`,t,n],_m=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?_m(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),vm=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?_m(r):[]],ym=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=nr();return X({queryKey:vm({abi:t,address:e,method:n,args:r}),queryFn:async()=>k({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},bm=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>X({queryKey:n,queryFn:()=>A({thor:e,calls:t}),enabled:r}),xm=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},Sm=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},Cm=()=>{let[e,t]=G(!0),n=`vechain_kit_feature_announcement_closed`;return U(()=>{b(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{ue(n,`true`),t(!1)}}},wm=()=>{let{network:e}=$();return e.nodeUrl??v(e.type).nodeUrl},Tm=()=>{let[e,t]=G(!0);return U(()=>{if(!O()){t(!1);return}let e=()=>{t(window.matchMedia(`(display-mode: standalone)`).matches||window.standalone||document.referrer.includes(`android-app://`))};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]),e},Em=()=>{U(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},Dm=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(Mn.of(t));return{balance:Wi(BigInt(n.balance)).toString(),energy:Wi(BigInt(n.energy)).toString()}},Om=e=>Ba.balance.native(e),km=e=>{let t=nr();return X({queryKey:Om(e),queryFn:()=>Dm(t,e),enabled:!!e&&Mn.isValid(e),refetchInterval:1e4})},Am=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(v(n).accountFactoryAddress,Di.abi),i;switch(t){case 1:case 2:i=r.read.accountImplementationV1();break;case 3:i=r.read.accountImplementationV3();break;default:throw Error(`Invalid version, must be between 1 and 3`)}let a=await i;if(!a)throw Error(`Failed to get account implementation address`);return a[0].toString()},jm=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],Mm=e=>{let t=nr(),{network:n}=$();return X({queryKey:jm(e,n.type),queryFn:async()=>Am(t,e,n.type),enabled:!!t&&!!e&&!!n})},Nm=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(v(t).accountFactoryAddress,Di.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},Pm=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],Fm=()=>{let e=nr(),{network:t}=$();return X({queryKey:Pm(t.type),queryFn:async()=>Nm(e,t.type),enabled:!!e&&!!t})},Im=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let r=await e.contracts.load(v(n).accountFactoryAddress,Di.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},Lm=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],Rm=e=>{let t=nr(),{network:n}=$();return X({queryKey:Lm(e,n.type),queryFn:async()=>Im(t,e,n.type),enabled:!!t&&!!e&&!!n})},zm=Di.abi,Bm=(e,t,n)=>vm({abi:zm,address:v(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),Vm=(e,t)=>{let{network:n}=$();return ym({address:v(n.type).accountFactoryAddress,abi:zm,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]}),enabled:!!e&&!!t}})},Hm=Di.abi,Um=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await k({thor:e,abi:Hm,contractAddress:v(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},Wm=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Gm=e=>{let t=nr(),{network:n}=$();return X({queryKey:Wm(e,n.type),queryFn:async()=>Um(t,e,n.type),enabled:!!t&&!!e&&!!n})},Km=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(Mn.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},qm=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Jm=e=>{let t=wm(),n=Ia.at(t);return X({queryKey:qm(e),queryFn:async()=>Km(n,e),enabled:!!n&&!!e})},Ym=()=>{let e=dr(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:Lm(i,r.type)}),e.cancelQueries({queryKey:Bm(a,i,r.type)}),e.cancelQueries({queryKey:Wm(i,r.type)}),e.cancelQueries({queryKey:Pm(r.type)}),e.cancelQueries({queryKey:th(a,i,3,r.type)}),e.cancelQueries({queryKey:ih(a,3,r.type)}),e.cancelQueries({queryKey:jm(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:Lm(i,r.type)}),e.refetchQueries({queryKey:Bm(a,i,r.type)}),e.refetchQueries({queryKey:Wm(i,r.type)}),e.refetchQueries({queryKey:Pm(r.type)}),e.refetchQueries({queryKey:th(a,i,3,r.type)}),e.refetchQueries({queryKey:ih(a,3,r.type)}),e.refetchQueries({queryKey:jm(3,r.type)})])}}},Xm=()=>{let e=dr(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Qm(n)}),e.cancelQueries({queryKey:qm(n)})]),await Promise.all([e.refetchQueries({queryKey:Qm(n)}),e.refetchQueries({queryKey:qm(n)})])}}},Zm=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(v(t).accountFactoryAddress,Di.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=Mn.of(r[0].toString()),a=await e.accounts.getAccount(i);if(!a)throw Error(`Failed to get account detail of ${i}`);return{address:i.toString(),isDeployed:a.hasCode}},Qm=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],$m=e=>{let{network:t}=$(),n=nr();return X({queryKey:Qm(e),queryFn:()=>Zm(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},eh=async(e,t,n,r,i)=>{let a=await e.contracts.load(v(i).accountFactoryAddress,Di.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${v(i).accountFactoryAddress}`);return a[0]},th=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],nh=(e,t,n)=>{let r=nr(),{network:i}=$();return X({queryKey:th(e,t,n,i.type),queryFn:async()=>eh(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},rh=async(e,t,n,r)=>{let i=await e.contracts.load(v(r).accountFactoryAddress,Di.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},ih=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],ah=(e,t)=>{let n=nr(),{network:r}=$();return X({queryKey:ih(e,t,r.type),queryFn:async()=>rh(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},oh=Oi.createInterface(),sh=({smartAccountAddress:e,targetVersion:t,onSuccess:n,onError:r})=>{let{refresh:i}=Ym(),{refresh:a}=Xm(),{data:o}=Mm(t),s=H(async()=>{if(!e||!T(e))throw Error(`Invalid smart account address`);if(!o)throw Error(`Unable to fetch implementation address for version ${t}`);return[{to:e,value:`0x0`,data:oh.encodeFunctionData(`upgradeToAndCall`,[o,`0x`]),comment:`Upgrade account to version ${t}`,abi:oh.getFunction(`upgradeToAndCall`).format(`json`)}]},[e,o,t]),c=Cl({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${d(e)} to version ${t}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([i(),a()]),n?.()},onTxFailedOrCancelled:async()=>{r?.()}});return{...c,sendTransaction:async()=>c.sendTransaction(await s())}},ch=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],lh=10*re.SECOND,uh=()=>{let e=nr();return X({queryKey:ch(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:lh})},dh=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},fh=()=>[`VECHAIN_KIT_CHAIN_ID`],ph=()=>{let e=nr();return X({queryKey:fh(),queryFn:()=>dh(e),enabled:!!e})},mh=Ti.createInterface(),hh=(e,t,n,r,i)=>{if(!e||!t||!T(e))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:n,value:`0x0`,data:mh.encodeFunctionData(`transfer`,[e,Xi(t,i)]),comment:`Transfer ${t} ${r} to ${e}`,abi:mh.getFunction(`transfer`)}),a},gh=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,tokenDecimals:a,onSuccess:o,onError:s})=>{let{refresh:c}=Zc(),{data:l,isLoading:u,error:f}=bc(a===void 0?r:``),p=W(()=>{let e=a??l?.decimals;if(e==null)return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0},[a,l?.decimals]),m=W(()=>p===void 0?[]:hh(t,n,r,i,p),[t,n,r,i,p]),h=Cl({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${d(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{c(),o?.()},onTxFailedOrCancelled:async e=>{s?.(e instanceof Error?e.message:String(e))}});return{...h,clauses:m,isLoadingTokenInfo:u,sendTransaction:async()=>{if(p===void 0){let e=f?`Failed to load token info: ${f.message}`:`Token decimals are required`;s?.(e);return}return h.sendTransaction(m)}}},_h=(e,t)=>{if(!e||!t||!T(e))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(t)))throw Error(`Invalid amount`);let n=[];try{n.push({to:e,value:Yi(t).toString(),data:`0x`,comment:`Transfer ${t} VET to ${e}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return n},vh=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=Zc(),o=W(()=>_h(t,n),[t,n]),s=Cl({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${d(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{a(),r?.()},onTxFailedOrCancelled:async e=>{i?.(e instanceof Error?e.message:String(e))}});return{...s,clauses:o,sendTransaction:async()=>s.sendTransaction(o)}},yh=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o,delegationUrl:s})=>{let{account:c}=Q(),l=dr(),u=H(async()=>{n&&t?.forEach(async e=>{await l.cancelQueries({queryKey:e}),await l.refetchQueries({queryKey:e})}),r?.()},[n,r,l,t]),d=Cl({signerAccountAddress:c?.address,onTxConfirmed:u,suggestedMaxGas:a,onTxFailedOrCancelled:i,gasPadding:o,delegationUrl:s}),f=H(async t=>{d.sendTransaction(e(t),s)},[e,d,s]);return{...d,sendTransaction:f}},bh=10*re.SECOND,xh=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],Sh=(e,t=5)=>{let n=nr();return X({queryKey:xh(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*bh,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},Ch=(e,t)=>{let n=Vi({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},wh=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],Th=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=nr();return X({queryFn:H(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await $s({thor:o,nodeUrl:a,filterCriteria:[{criteria:{address:t,topic0:c[0]??void 0,topic1:c[1]??void 0,topic2:c[2]??void 0,topic3:c[3]??void 0,topic4:c[4]??void 0},eventAbi:s}]})).map(t=>Ch(t,e));if(l.some(({decodedData:e})=>e.eventName!==n))throw Error(`Unknown event`);return l.map(e=>i({meta:e.meta,decodedData:e.decodedData}))},[o,t,e,n,r,i,a]),queryKey:W(()=>wh({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function Eh({clauses:e,chainId:t,verifyingContract:n}){let r=[],i=[],a=[];return e.forEach(e=>{r.push(e.to??``),i.push(String(e.value)),typeof e.data==`object`&&`abi`in e.data?a.push(Ui(e.data)):a.push(e.data||`0x`)}),{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n},types:{ExecuteBatchWithAuthorization:[{name:`to`,type:`address[]`},{name:`value`,type:`uint256[]`},{name:`data`,type:`bytes[]`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`},{name:`nonce`,type:`bytes32`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteBatchWithAuthorization`,message:{to:r,value:i,data:a,validAfter:0,validBefore:Math.floor(Date.now()/1e3)+300,nonce:wn.hexlify(wn.randomBytes(32))}}}function Dh({clause:e,chainId:t,smartAccount:n}){return{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n.address??``},types:{ExecuteWithAuthorization:[{name:`to`,type:`address`},{name:`value`,type:`uint256`},{name:`data`,type:`bytes`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteWithAuthorization`,message:{validAfter:0,validBefore:Math.floor(Date.now()/1e3)+60,to:e.to,value:String(e.value),data:(typeof e.data==`object`&&`abi`in e.data?Ui(e.data):e.data)||`0x`}}}function Oh(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=nl(),{signTypedData:r}=Xn(),{network:i}=$(),{data:a}=ph();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const kh=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=Oh(),o=async e=>{let{version:t}=e;return t&&t<3?await s(e):await c(e)};async function s(o){let{clauses:s,smartAccount:c,title:l=`Sign Transaction`,description:u,buttonText:d=`Sign`}=o,f=[],p=s.map(e=>Dh({clause:e,chainId:a,smartAccount:c})),m=[];for(let i=0;i<p.length;i++){let a=p[i],o=s[i];if(!o)throw Error(`Transaction clause at index ${i} is undefined`);if(e.isConnectedWithCrossApp){let e=await n({...a,address:t?.address,types:Object.fromEntries(Object.entries(a.types).map(([e,t])=>[e,[...t]]))});m.push(e);continue}let c=o.data,f=(await r(a,{uiOptions:{title:l,description:u??(s[i].comment||(typeof c==`object`&&c&&`functionName`in c?c.functionName:` `)),buttonText:d}})).signature;m.push(f)}return c.isDeployed||f.push(Nn.callFunction(Mn.of(v(i.type).accountFactoryAddress),jn.ofAbi(Di.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(Nn.callFunction(Mn.of(c.address??``),jn.ofAbi(Oi.abi).getFunction(`executeWithAuthorization`),[e.message.to,BigInt(e.message.value),e.message.data,BigInt(e.message.validAfter),BigInt(e.message.validBefore),m[t]]))}),f}async function c(o){let{clauses:s,smartAccount:c,title:l,description:u,buttonText:d=`Sign`}=o,f=[],p=Eh({clauses:s,chainId:a,verifyingContract:c.address??``}),m;return m=e.isConnectedWithCrossApp?await n({...p,address:t?.address}):(await r(p,{uiOptions:{title:l,description:u,buttonText:d}})).signature,c.isDeployed||f.push(Nn.callFunction(Mn.of(v(i.type).accountFactoryAddress),jn.ofAbi(Di.abi).getFunction(`createAccount`),[t?.address??``])),f.push(Nn.callFunction(Mn.of(c.address??``),jn.ofAbi(Oi.abi).getFunction(`executeBatchWithAuthorization`),[p.message.to,p.message.value?.map(e=>BigInt(e))??0,p.message.data,BigInt(p.message.validAfter),BigInt(p.message.validBefore),p.message.nonce,m])),f}return{buildClausesWithAuth:o}};let Ah=function(e){return e.CUSTOM_TOKENS=`vechain_kit_custom_tokens`,e.ECOSYSTEM_SHORTCUTS=`vechain-kit-ecosystem-shortcuts`,e.CURRENCY=`vechain_kit_currency`,e.NODE_URL=`vechain_kit_node_url`,e.NETWORK=`vechain_kit_network`,e.GAS_TOKEN_PREFERENCES=`vechain_kit_gas_token_preferences`,e.SHOW_ASSETS=`vechain_kit_show_assets`,e}({});const jh=(e,t)=>{let[n,r]=G(()=>{try{let n=b(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return U(()=>{ue(e,JSON.stringify(n))},[e,n]),[n,r]},Mh=`vechain-kit-storage-change`,Nh=(e,t)=>{let[n,r]=G(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.error(`Error loading from localStorage:`,e),t}}),i=xn(!1);return U(()=>{if(!(typeof window>`u`)){if(i.current){i.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Mh,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),U(()=>{if(typeof window>`u`)return;let t=t=>{if(t.key===e&&t.newValue)try{let e=JSON.parse(t.newValue);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}catch(e){console.error(`Error parsing storage value:`,e)}},a=(t=>{if(t.detail.key===e)try{let t=window.localStorage.getItem(e);if(t){let e=JSON.parse(t);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}}catch(e){console.error(`Error parsing storage value:`,e)}});return window.addEventListener(`storage`,t),window.addEventListener(Mh,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Mh,a)}},[e,n]),[n,r,H(()=>{if(!(typeof window>`u`))try{let i=window.localStorage.getItem(e),a=i?JSON.parse(i):t;JSON.stringify(a)!==JSON.stringify(n)&&r(a)}catch(e){console.error(`Error syncing localStorage:`,e)}},[e,t,n]),H(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},Ph=()=>{let[e,t]=jh(Ah.ECOSYSTEM_SHORTCUTS,[]);return{shortcuts:e,addShortcut:n=>{e.some(e=>e.url===n.url)||t([...e,n])},removeShortcut:n=>{t(e.filter(e=>e.url!==n))},isShortcut:t=>e.some(e=>e.url===t)}},Fh=async(e,t,n,r,i)=>{let a=new URL(`estimate/clauses/${r.toLowerCase()}`,t);return a.searchParams.set(`type`,`smartaccount`),a.searchParams.set(`speed`,i),await(await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json()},Ih=async e=>{let t=new URL(`deposit/account`,e);return await(await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`}})).json()},Lh=async(e,t,n,r)=>{let i=new URL(`sign/transaction/authorized/${n.toLowerCase()}`,r);return await(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json()},Rh=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``,{gasPadding:1}),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function zh(e,t){return Ln.of(e.body,za.concatBytes(e.signature??new Uint8Array,Fn.of(t.slice(2)).bytes))}function Bh(e,t){return Ln.decode(Fn.of(e.slice(2)).bytes,t)}const Vh=()=>{let{connectedWallet:e}=Q(),{data:t}=$m(e?.address??``),{data:n}=Vm(t?.address??``,e?.address??``),{preferences:r}=Hh(),i=Ti.createInterface(),{network:a}=$(),{buildClausesWithAuth:s}=kh(),c=Ia.at(v(a.type).nodeUrl);return{sendTransactionUsingGenericDelegator:H(async({clauses:e,genericDelegatorUrl:a})=>{try{let l=r.gasTokenToUse,d=await Fh(t?.address??``,a,e,l,`medium`),f=await Ih(a),p={to:l===`VET`?f.depositAccount:o[l].address,value:l===`VET`?Yi(d.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:i.encodeFunctionData(`transfer`,[f.depositAccount,Yi(d.transactionCost?.toString()??`0`)]),comment:`Transfer ${d.transactionCost} ${l} to ${f.depositAccount}`,abi:l===`VET`?void 0:i.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:t,version:n?.version??0}),h=await Rh(m,c,u,!0),g=await Ln.of(h).signAsSender(Fn.of(u.privateKey).bytes),_=await Lh(Fn.of(g.encoded).toString(),u.address,l,a),v=zh(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:u.address??``,gasPayer:_.address}},b=await c.transactions.simulateTransaction(y.clauses,{...y.simulateTransactionOptions});for(let e=0;e<b.length;e++)if(b[e].reverted)throw Error(b[e].vmError);return(await c.transactions.sendTransaction(v)).id}catch(e){console.error(`Error sending transaction using generic delegator`,e)}throw Error(`Failed to send transaction using generic delegator, no gas tokens have sufficient balance or are enabled in Gas Token Preferences`)},[r,t,n,s,c,u])}},Hh=()=>{let[e,t]=Nh(Ah.GAS_TOKEN_PREFERENCES,a);return{preferences:e,supportedTokens:o,updatePreferences:H(e=>{t(t=>({...t,...e}))},[t]),reorderTokenPriority:H(e=>{t(t=>{let n=e.filter(e=>t.availableGasTokens.includes(e)&&!t.excludedTokens.includes(e));return{...t,tokenPriority:e,availableGasTokens:n,gasTokenToUse:n[0]??t.gasTokenToUse}})},[t]),toggleTokenExclusion:H(e=>{t(t=>{let n=t.excludedTokens.includes(e),r=n?t.excludedTokens.filter(t=>t!==e):[...t.excludedTokens,e],i=t.tokenPriority.indexOf(e),a=n?[...t.availableGasTokens.slice(0,i),e,...t.availableGasTokens.slice(i)]:t.availableGasTokens.filter(t=>t!==e);return{...t,excludedTokens:r,availableGasTokens:a,gasTokenToUse:a[0]??t.gasTokenToUse}})},[t])}},Uh=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=$m(a?.address??``),{feeDelegation:c}=$(),{balances:l}=Ks(o?.address??``),{updatePreferences:u}=Hh();return X({queryKey:[`gas-estimation`,JSON.stringify(e),JSON.stringify(n),r,i],queryFn:async()=>{let t=null;for(let a of n)try{let n=await Fh(s?.address??``,c?.genericDelegatorUrl??``,e,a,`medium`),o=n.transactionCost,d=Number(l.find(e=>e.symbol===a)?.balance||0),f=o+(r&&i&&a===i?Number(r):0);if(d>=f)return u({gasTokenToUse:a}),{...n,usedToken:a};t=Error(`Insufficient ${a} balance: has ${d}, needs ${f}`)}catch(e){t=e}throw t||Error(`All gas tokens failed estimation or have insufficient balance`)},enabled:t&&e.length>0&&!!s?.address&&!!c?.genericDelegatorUrl&&n.length>0&&l.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,retry:!1,retryDelay:1e3})},Wh=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=$m(r?.address??``),{feeDelegation:a}=$();return X({queryKey:[`gas-estimation-all-tokens`,JSON.stringify(e),JSON.stringify(t)],queryFn:async()=>{let n={};return await Promise.all(t.map(async t=>{try{n[t]={cost:(await Fh(i?.address??``,a?.genericDelegatorUrl??``,e,t,`medium`)).transactionCost||0,loading:!1}}catch(e){n[t]={cost:0,loading:!1,error:e instanceof Error?e.message:`Unknown error`}}})),n},enabled:n&&e.length>0&&!!i?.address&&!!a?.genericDelegatorUrl&&t.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1})},Gh=({valuePct:e,showSuffix:t,...n})=>{let r=B(`colors`,`vechain-kit-success`),i=B(`colors`,`vechain-kit-error`),a=B(`colors`,`vechain-kit-text-tertiary`);if(e===void 0||!Number.isFinite(e))return null;let o=e>0?`+`:``;return J(N,{spacing:1,align:`baseline`,children:[J(R,{fontSize:`xs`,fontWeight:`600`,color:e===0?a:e>0?r:i,...n,children:[o,e.toFixed(2),`%`]}),t&&q(R,{fontSize:`xs`,fontWeight:`500`,color:a,children:`24h`})]})},Kh=({symbol:t,amount:n,currencyValue:r,currentCurrency:i,isDisabled:a,onClick:o,priceChange24hPct:s,...c})=>{let l=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=B(`colors`,`vechain-kit-card`),[f]=jh(Ah.SHOW_ASSETS,!0),p=f?n.toLocaleString(void 0,{maximumFractionDigits:2}):`*`.repeat(4),m=f?sc(r,{currency:i}):`*`.repeat(4);return J(M,{height:`64px`,variant:`ghost`,bg:d,borderRadius:`xl`,justifyContent:`space-between`,isDisabled:a,px:4,py:3,w:`100%`,_hover:{bg:d,opacity:.85},_active:{bg:d,opacity:.7},_disabled:{cursor:`not-allowed`,opacity:.5},onClick:o,"data-testid":`asset-${t}`,...c,children:[J(N,{spacing:3,flex:1,minW:0,children:[x[t]?V.cloneElement(x[t],{boxSize:`36px`,borderRadius:`full`}):q(Et,{src:e[t],alt:`${t} logo`,boxSize:`36px`,borderRadius:`full`,fallback:q(j,{boxSize:`36px`,borderRadius:`full`,bg:`whiteAlpha.300`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`11px`,fontWeight:`bold`,color:l,children:t.slice(0,3)})})}),J(z,{align:`flex-start`,spacing:0,minW:0,children:[q(R,{fontWeight:`700`,fontSize:`md`,color:l,lineHeight:`short`,children:t}),J(R,{fontSize:`sm`,color:u,lineHeight:`short`,noOfLines:1,children:[p,` `,t]})]})]}),J(z,{align:`flex-end`,spacing:0,children:[q(R,{fontWeight:`700`,fontSize:`md`,color:l,lineHeight:`short`,"data-testid":`${t}-balance`,children:m}),f&&q(Gh,{valuePct:s,lineHeight:`short`})]})]})},qh=({address:e,domain:t,imageSrc:n,imageAlt:r=`Account`,hideAddress:i=!1,balance:a,tokenAddress:o})=>{let{t:s}=Y(),c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`),u=B(`colors`,`vechain-kit-card`),{isLoading:f}=wc({address:e}),{tokens:p,isLoading:m}=uc({address:e}),h=W(()=>o?p.find(e=>e.address===o):null,[p,o]),g=W(()=>a===void 0?h?Number(h.balance):0:a,[a,h]),_=h?.symbol||``;return f||m?J(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[J(N,{children:[q(Kt,{boxSize:`40px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(Kt,{height:`16px`,width:`120px`,borderRadius:`md`}),!i&&q(Kt,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),q(Kt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]}):J(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[J(N,{children:[q(Et,{src:n,alt:r,boxSize:`40px`,borderRadius:`full`,objectFit:`cover`}),q(z,{align:`start`,spacing:0,children:t?J(K,{children:[q(R,{fontWeight:`medium`,fontSize:`sm`,color:c,children:t}),!i&&q(R,{fontSize:`xs`,color:l,children:d(e,6,4)})]}):q(R,{fontWeight:`medium`,fontSize:`sm`,color:c,children:d(e,6,4)})})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),J(R,{fontSize:`xs`,color:l,children:[g.toLocaleString(void 0,{maximumFractionDigits:2}),_&&` ${_}`]})]})]})},Jh=({onClick:e,...t})=>q(Tt,{"aria-label":`FAQ`,icon:q(P,{as:Mr,fontSize:`17px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,lineHeight:`normal`,left:`10px`,top:`8px`,onClick:e,...t}),Yh=({children:e,...t})=>(Em(),q(z,{...t,children:e})),Xh=({wallet:e,props:t})=>{let n=xn(e?.image),r=xn(e?.address);return U(()=>{r.current!==e?.address&&(n.current=e?.image,r.current=e?.address)},[e?.address]),U(()=>{e?.image&&!e.isLoadingMetadata&&(n.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!n.current||e?.isLoadingMetadata?q(Kt,{rounded:`full`,width:t?.width,height:t?.height}):q(Et,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Zh=({transactionError:e,isSubmitting:t,isTxWaitingConfirmation:n,onConfirm:r,onRetry:i,transactionPendingText:a,txReceipt:o,isSubmitForm:s=!1,buttonText:c,isDisabled:l=!1,style:u,onError:d,gasEstimationError:f,hasEnoughGasBalance:p=!0,isLoadingGasEstimation:m=!1,showGasEstimationError:h=!1,context:g=`transaction`})=>{let{t:_}=Y(),{darkMode:y}=$(),{network:b}=$(),x=W(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);U(()=>{x&&d?.(x)},[x,d]);let S=W(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),C=W(()=>{if(!h||m||!(f||p))return null;if(!p&&!f)return{message:_(`You don't have any gas tokens enabled. Please enable at least one gas token in Gas Token Preferences.`)};if(f){let e=``;switch(g){case`send`:e=_(`Insufficient balance to complete this transfer and cover gas fees.`);break;case`customization`:e=_(`Insufficient balance to update your profile and cover gas fees.`);break;case`domain`:e=_(`Insufficient balance to claim this domain and cover gas fees.`);break;default:e=_(`Insufficient balance to complete this transaction and cover gas fees.`)}return{message:e}}return null},[f,p,m,h,g,_]);return J(z,{width:`full`,spacing:4,children:[x&&q(j,{p:3,borderRadius:`md`,bg:y?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:y?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:x})}),C&&!x&&q(j,{p:3,borderRadius:`md`,bg:y?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:y?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:C.message})}),q(M,{px:4,variant:x?`vechainKitSecondary`:`vechainKitPrimary`,bg:S,onClick:()=>x&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:x?_(`Retry`):c||_(`Confirm`)}),x&&o?.meta.txID&&q(jt,{isExternal:!0,fontSize:`sm`,color:y?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${v(b.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},Qh=({onClick:e,hasUnreadNotifications:t,...n})=>q(Tt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:J(j,{position:`relative`,children:[q(xr,{fontSize:`20px`}),t&&q(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),$h=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:s})=>{let{t:c}=Y(),{balances:l}=Ks(s),[u,d]=V.useState(n),[f,p]=V.useState(!1),m=B(`colors`,`vechain-kit-text-primary`),h=B(`colors`,`vechain-kit-text-secondary`),g=B(`colors`,`vechain-kit-text-tertiary`),_=B(`colors`,`vechain-kit-error`),v=e=>e?g:`transparent`,y=e=>e?m:`transparent`;V.useEffect(()=>{e&&(d(n),p(!1))},[e,n]);let b=()=>{r(u,f),t()},S=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},C=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return J(Ko,{isOpen:e,onClose:t,size:`sm`,children:[J(L,{children:[q(R,{fontSize:`lg`,fontWeight:`semibold`,color:m,children:c(`Fee token`)}),q(R,{fontSize:`sm`,fontWeight:`normal`,color:h,mt:1,children:c(`Select the token to pay the fee with`)})]}),q(F,{children:J(z,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=o[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=C(e);return q(j,{cursor:i?`not-allowed`:`pointer`,bg:v(n),border:`1px`,borderColor:y(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?v(n):h&&`#ffffff12`,borderColor:i?y(n):h},opacity:i?.5:1,onClick:()=>!i&&d(e),children:J(N,{spacing:3,justify:`space-between`,children:[J(N,{spacing:3,flex:1,children:[V.cloneElement(x[e],{boxSize:`36px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:m,children:t.symbol}),J(R,{fontSize:`xs`,color:h,children:[c(`Balance`),`:`,` `,S(e)]}),i&&q(R,{fontSize:`xs`,color:_,children:c(`Insufficient balance`)})]})]}),q(z,{align:`end`,spacing:0,children:r.loading?q(Kt,{height:`16px`,width:`60px`}):J(K,{children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,color:m,children:ce(r.cost,2)}),q(R,{fontSize:`xs`,color:h,children:t.symbol})]})})]})},e)}),u!==n&&J(bt,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[q(xt,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:m,children:c(`Use this token for future transactions`)}),q(Yt,{id:`remember-choice`,isChecked:f,onChange:e=>p(e.target.checked),color:m})]})]})}),q(It,{children:J(z,{spacing:3,w:`full`,children:[q(M,{variant:`vechainKitPrimary`,onClick:b,isDisabled:C(u),children:c(`Apply`)}),q(M,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},eg=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:s}=Y(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:f}=Hh(),{isOpen:p,onOpen:m,onClose:h}=hn(),g=B(`colors`,`vechain-kit-text-primary`),_=B(`colors`,`vechain-kit-text-secondary`),[v,y]=G(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:b,isLoading:S}=Wh({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});U(()=>{!S&&b&&y(b)},[b,S]),U(()=>{e&&y(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),U(()=>{S&&y(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[S,d.availableGasTokens]);let C=H((t,n)=>{n&&f([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,f,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:w}=Ks(u?.address??``),ee=e=>{let t=w.find(t=>t.symbol===e),n=v[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},T=e?.usedToken,E=d.availableGasTokens,D;T?D=T:a&&E.includes(a)?D=a:(D=E.find(e=>v[e]&&!v[e].loading&&!ee(e)),D||=E.find(e=>v[e]&&!v[e].loading),D||=E[0]);let O=D?v[D]:void 0,k=T&&e?.transactionCost?e.transactionCost:O?.cost||0,te=D?o[D]:void 0;return J(K,{children:[q(vt,{mt:3}),J(N,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[J(z,{align:`start`,spacing:0,w:`full`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:_,children:s(`Fee`)}),q(N,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:q(N,{justifyContent:`flex-start`,w:`full`,children:t||!T&&(!O||O.loading)||!te?J(K,{children:[q(Kt,{height:`16px`,width:`120px`,borderRadius:`md`}),q(Kt,{height:`16px`,width:`60px`,borderRadius:`md`})]}):J(K,{children:[J(R,{color:g,fontSize:`sm`,fontWeight:`semibold`,children:[ce(k,2),` `,te.symbol]}),J(R,{color:_,fontSize:`xs`,children:[`≈`,` $`,(k*.01).toFixed(2)]})]})})})]}),J(M,{onClick:m,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:_,borderColor:_,_hover:{bg:_},leftIcon:V.cloneElement(x[D||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,children:D||d.availableGasTokens[0]}),q(P,{as:Er,boxSize:5,color:_})]})]}),q($h,{isOpen:p,onClose:h,selectedToken:D||d.availableGasTokens[0],onTokenSelect:C,availableTokens:d.availableGasTokens,tokenEstimations:v,walletAddress:u?.address??``})]})},tg=ma`
207
207
  from {
208
208
  transform: translateY(-100%);
209
209
  opacity: 0;