@vechain/vechain-kit 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index.d.cts +1 -1
- package/dist/assets/index.d.mts +1 -1
- package/dist/{index-CX-PoQpp.d.mts → index-BJiGRuYS.d.mts} +143 -143
- package/dist/index-BJiGRuYS.d.mts.map +1 -0
- package/dist/{index-BB3iebWm.d.mts → index-Bs6t5GxR.d.mts} +4 -4
- package/dist/{index-BB3iebWm.d.mts.map → index-Bs6t5GxR.d.mts.map} +1 -1
- package/dist/{index-DSMUkHcK.d.cts → index-u3CPquCV.d.cts} +4 -4
- package/dist/{index-DSMUkHcK.d.cts.map → index-u3CPquCV.d.cts.map} +1 -1
- package/dist/{index-BSgtiDLw.d.cts → index-wCp9v8PQ.d.cts} +50 -50
- package/dist/{index-CX-PoQpp.d.mts.map → index-wCp9v8PQ.d.cts.map} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +2 -2
- package/package.json +1 -1
- package/dist/index-BSgtiDLw.d.cts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -110,13 +110,13 @@ import{A as e,B as t,C as n,E as r,H as i,J as a,O as o,Q as s,S as c,U as l,V a
|
|
|
110
110
|
opacity: 0.5 !important;
|
|
111
111
|
}
|
|
112
112
|
`),d.length>0&&(u.textContent=d.join(`
|
|
113
|
-
`))}let Ga=null;function Ka(){return Ga||=new Ln({defaultOptions:{queries:{queryKeyHashFn:Hn,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Ga}const qa=({children:e})=>{try{if(V.useContext(Rn))return q(K,{children:e})}catch(e){console.log(e)}return q(zn,{client:Ka(),children:e})},Ja=({onClick:e,...t})=>q(lt,{"aria-label":`Back`,icon:q(N,{as:ir,fontSize:`20px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Ya=({wallet:e,label:t,style:n,showHumanAddress:r=!0})=>{let[i,a]=G(!1),[o,s]=G(!1),c=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=async(e,t)=>{await ie(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))};return q(z,{w:`full`,justifyContent:`center`,...n,children:J(z,{w:`full`,spacing:4,children:[t&&q(R,{fontSize:`sm`,color:u,children:t}),e?.domain?J(z,{spacing:2,w:`full`,children:[J(ft,{children:[q(pt,{children:q(N,{as:Ir,color:u})}),q(dt,{cursor:`pointer`,value:e.domain,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.domain||``,s)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e.domain||``,s),cursor:`pointer`,as:o?nr:dr})})]}),J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e.address??``,8,7):e.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.address??``,a)}),q(mt,{children:q(N,{color:u,cursor:`pointer`,onClick:()=>d(e.address??``,a),as:i?nr:dr})})]})]}):J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e?.address??``,6,4):e?.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e?.address??``,a)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e?.address??``,a),cursor:`pointer`,as:i?nr:dr})})]})]})})};var Xa=`2.2.0`,Za={"@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.24.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.0.3`,"@vechain/dapp-kit-react":`2.1.0-rc.2`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.4.1`,"@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`,viem:`^2.29.3`,wagmi:`^2.15.4`},Qa={"@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.2`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const $a=({...e})=>{let{darkMode:t}=$();return J(M,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[q(fe,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),J(ht,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`,isExternal:!0,pt:`1px`,children:[`v`,Xa]})]})},Z=({children:e})=>{let[t,n]=G(!1),r=$t(null),i=$t(null),a=$t(!0),{tokens:o}=dd(),s=o?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return U(()=>{let e=new IntersectionObserver(([e])=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{if(a.current){a.current=!1,n(!1);return}n(!e.isIntersecting)},50)},{threshold:0}),t=setTimeout(()=>{r.current&&e.observe(r.current)},200);return()=>{clearTimeout(t),i.current&&clearTimeout(i.current),e.disconnect()}},[]),J(K,{children:[q(A,{position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?s:`none`,style:{WebkitBackdropFilter:t?s:`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:{position:`absolute`,top:`25px`}})]})},eo=({children:e})=>q(A,{position:`sticky`,bottom:`0`,left:`0`,right:`0`,bg:B(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,boxShadow:`0px -1px 6px -3px rgb(0 0 0 / 56%)`,transition:`box-shadow 0.2s ease-in-out`,children:e}),to=({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})=>{let[d]=Jt(`(min-width: 768px)`),{portalRootRef:f}=dd(),p=B(`colors`,`vechain-kit-modal`),m=B(`colors`,`vechain-kit-overlay`),{tokens:h}=dd(),g=h?.effects?.backdropFilter?.overlay,_=h?.effects?.backdropFilter?.modal,v=l??g??`blur(3px)`,y=d?{}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`};return J(vt,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:f},trapFocus:!c,autoFocus:!c,children:[q(bt,{bg:m,backdropFilter:v}),q(yt,{role:`dialog`,"aria-modal":!c,bg:p,variant:`vechainKitBase`,sx:{backdropFilter:_,WebkitBackdropFilter:_},...y,children:n})]})},no=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},ro=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(xa[t],r).format(e)},io=(e,t)=>ro(e,Ca.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),ao=({symbol:e,amount:t,currencyValue:n,currentCurrency:r,isDisabled:i,onClick:a,...o})=>{let c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return J(j,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:i,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:a,"data-testid":`asset-${e}`,...o,children:[J(M,{children:[s[e]?V.cloneElement(s[e],{boxSize:`24px`,borderRadius:`full`}):q(ut,{src:p[e],alt:`${e} logo`,boxSize:`24px`,borderRadius:`full`,fallback:q(A,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`10px`,fontWeight:`bold`,color:c,children:e.slice(0,3)})})}),q(R,{color:c,children:e})]}),J(z,{align:`flex-end`,spacing:0,children:[J(R,{color:c,children:[t.toLocaleString(void 0,{maximumFractionDigits:2}),` `]}),q(R,{fontSize:`sm`,color:l,"data-testid":`${e}-balance`,children:io(n,{currency:r})})]})]})},oo=async e=>{let t=await fetch(`https://auth.privy.io/api/v1/apps/${e}`,{headers:{"privy-app-id":e}});if(!t.ok)throw Error(`Failed to fetch Privy app info`);return t.json()},so=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],co=e=>{let t=Array.isArray(e)?e:[e];return X({queryKey:so(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>oo(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=a.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})},lo=async()=>{try{let e=await fetch(`https://status.privy.io/summary.json`);if(!e.ok)throw Error(`Failed to fetch Privy status`);return(await e.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},uo=()=>X({queryKey:[`PRIVY_STATUS`],queryFn:lo,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}),fo=e=>[`VECHAIN_KIT_DOMAIN`,e],po=t=>{let{network:n}=$();return X({queryKey:fo(t),queryFn:async()=>{if(!t)throw Error(`Address or domain is required`);let r=await Zr(t,{networkUrl:n.nodeUrl}),i=e(t);if(!r&&!i)throw Error(`Input must be a valid domain or address`);let a=null,o=null,s=!1;return r?(a=await Gr(t,{networkUrl:n.nodeUrl}),o=t,a&&(s=await Xr(t,a,{networkUrl:n.nodeUrl}))):(o=await Hr(t,{networkUrl:n.nodeUrl}),a=t,o&&(s=await Xr(o,t,{networkUrl:n.nodeUrl}))),{address:a||void 0,domain:o||void 0,isValidAddressOrDomain:r||i,isPrimaryDomain:s}},enabled:!!t&&!!n.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})},mo=async(e,t,n)=>{let r=vi(fi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,vi(Si(n))])),i=await e.contracts.load(k(t).vetDomainsContractAddress,oi.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},ho=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],go=e=>{let t=Nn(),{network:n}=$();return X({queryKey:ho(e),queryFn:()=>mo(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})},_o=(e,t)=>{let n=Vn(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:Io(e??``,r.type)}),n.invalidateQueries({queryKey:Bo(e,r.type)}),n.invalidateQueries({queryKey:Yo(t)})])}}},vo=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:fo(t)}),e.invalidateQueries({queryKey:fo(n)}),e.invalidateQueries({queryKey:ho(r)}),e.invalidateQueries({queryKey:Po(t,`.vet`)}),e.invalidateQueries({queryKey:Po(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Bo(n)})]),await Promise.all([e.refetchQueries({queryKey:fo(t)}),e.refetchQueries({queryKey:fo(n)}),e.refetchQueries({queryKey:Po(t,`.vet`)}),e.refetchQueries({queryKey:Po(t,`.veworld.vet`)}),e.refetchQueries({queryKey:Io(r+`.`+i,a)}),e.refetchQueries({queryKey:Bo(n)}),e.refetchQueries({queryKey:ho(r)}),e.refetchQueries({queryKey:Yo(t)})])},yo=ci.createInterface(),bo=si.createInterface(),xo=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:bo.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:bo.getFunction(`setName`)}),n){a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:bo.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:bo.getFunction(`setName`)});let e=new nn.Interface([`function setAddr(bytes32 node, address addr)`]),t=nn.namehash(o);a.push({to:k(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${l(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(Co(t))a.push({to:k(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:yo.encodeFunctionData(`claim`,[e,k(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:yo.getFunction(`claim`)}),a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:bo.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:bo.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},So=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=Vn(),{account:o}=Q(),{network:s}=$(),{refresh:c}=_o(e+`.`+t,o?.address??``),l=H(()=>xo(e,t,i,o,s),[e,t,i,o,s]),u=H(async()=>{let r=`${e}.${t}`;await vo(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=fc({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())}},Co=e=>e.endsWith(`veworld.vet`),wo=si.createInterface(),To=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:k(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:wo.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:wo.getFunction(`setName`)});let t=new nn.Interface([`function setAddr(bytes32 node, address addr)`]),a=nn.namehash(e);i.push({to:k(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${l(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},Eo=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=Vn(),{account:o}=Q(),{refresh:s}=_o(e,o?.address??``),c=H(()=>To(e,r,o,i),[e,r,o,i]),l=H(async()=>{await vo(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=fc({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())}},Do=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],Oo=ln.ofAbi(ci.abi),ko=async(e,t,n)=>{let r=k(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,Oo.abi).read.isDomainProtected(n))[0]},Ao=(e,t=!0)=>{let n=Nn(),{network:r}=$();return X({queryKey:Do(e),queryFn:()=>ko(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})},jo=wi.object({name:wi.string()}),Mo=wi.object({domains:wi.array(jo)}),No=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=k(e).graphQlIndexerUrl,i=`query Registrations {
|
|
113
|
+
`))}let Ga=null;function Ka(){return Ga||=new Ln({defaultOptions:{queries:{queryKeyHashFn:Hn,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Ga}const qa=({children:e})=>{try{if(V.useContext(Rn))return q(K,{children:e})}catch(e){console.log(e)}return q(zn,{client:Ka(),children:e})},Ja=({onClick:e,...t})=>q(lt,{"aria-label":`Back`,icon:q(N,{as:ir,fontSize:`20px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Ya=({wallet:e,label:t,style:n,showHumanAddress:r=!0})=>{let[i,a]=G(!1),[o,s]=G(!1),c=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=async(e,t)=>{await ie(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))};return q(z,{w:`full`,justifyContent:`center`,...n,children:J(z,{w:`full`,spacing:4,children:[t&&q(R,{fontSize:`sm`,color:u,children:t}),e?.domain?J(z,{spacing:2,w:`full`,children:[J(ft,{children:[q(pt,{children:q(N,{as:Ir,color:u})}),q(dt,{cursor:`pointer`,value:e.domain,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.domain||``,s)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e.domain||``,s),cursor:`pointer`,as:o?nr:dr})})]}),J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e.address??``,8,7):e.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.address??``,a)}),q(mt,{children:q(N,{color:u,cursor:`pointer`,onClick:()=>d(e.address??``,a),as:i?nr:dr})})]})]}):J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e?.address??``,6,4):e?.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e?.address??``,a)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e?.address??``,a),cursor:`pointer`,as:i?nr:dr})})]})]})})};var Xa=`2.2.1`,Za={"@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.24.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.0.3`,"@vechain/dapp-kit-react":`2.1.0-rc.2`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.4.1`,"@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`,viem:`^2.29.3`,wagmi:`^2.15.4`},Qa={"@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.2`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const $a=({...e})=>{let{darkMode:t}=$();return J(M,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[q(fe,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),J(ht,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`,isExternal:!0,pt:`1px`,children:[`v`,Xa]})]})},Z=({children:e})=>{let[t,n]=G(!1),r=$t(null),i=$t(null),a=$t(!0),{tokens:o}=dd(),s=o?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return U(()=>{let e=new IntersectionObserver(([e])=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{if(a.current){a.current=!1,n(!1);return}n(!e.isIntersecting)},50)},{threshold:0}),t=setTimeout(()=>{r.current&&e.observe(r.current)},200);return()=>{clearTimeout(t),i.current&&clearTimeout(i.current),e.disconnect()}},[]),J(K,{children:[q(A,{position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?s:`none`,style:{WebkitBackdropFilter:t?s:`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:{position:`absolute`,top:`25px`}})]})},eo=({children:e})=>q(A,{position:`sticky`,bottom:`0`,left:`0`,right:`0`,bg:B(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,boxShadow:`0px -1px 6px -3px rgb(0 0 0 / 56%)`,transition:`box-shadow 0.2s ease-in-out`,children:e}),to=({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})=>{let[d]=Jt(`(min-width: 768px)`),{portalRootRef:f}=dd(),p=B(`colors`,`vechain-kit-modal`),m=B(`colors`,`vechain-kit-overlay`),{tokens:h}=dd(),g=h?.effects?.backdropFilter?.overlay,_=h?.effects?.backdropFilter?.modal,v=l??g??`blur(3px)`,y=d?{}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`};return J(vt,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:f},trapFocus:!c,autoFocus:!c,children:[q(bt,{bg:m,backdropFilter:v}),q(yt,{role:`dialog`,"aria-modal":!c,bg:p,variant:`vechainKitBase`,sx:{backdropFilter:_,WebkitBackdropFilter:_},...y,children:n})]})},no=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},ro=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(xa[t],r).format(e)},io=(e,t)=>ro(e,Ca.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),ao=({symbol:e,amount:t,currencyValue:n,currentCurrency:r,isDisabled:i,onClick:a,...o})=>{let c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return J(j,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:i,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:a,"data-testid":`asset-${e}`,...o,children:[J(M,{children:[s[e]?V.cloneElement(s[e],{boxSize:`24px`,borderRadius:`full`}):q(ut,{src:p[e],alt:`${e} logo`,boxSize:`24px`,borderRadius:`full`,fallback:q(A,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`10px`,fontWeight:`bold`,color:c,children:e.slice(0,3)})})}),q(R,{color:c,children:e})]}),J(z,{align:`flex-end`,spacing:0,children:[J(R,{color:c,children:[t.toLocaleString(void 0,{maximumFractionDigits:2}),` `]}),q(R,{fontSize:`sm`,color:l,"data-testid":`${e}-balance`,children:io(n,{currency:r})})]})]})},oo=async e=>{let t=await fetch(`https://auth.privy.io/api/v1/apps/${e}`,{headers:{"privy-app-id":e}});if(!t.ok)throw Error(`Failed to fetch Privy app info`);return t.json()},so=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],co=e=>{let t=Array.isArray(e)?e:[e];return X({queryKey:so(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>oo(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=a.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})},lo=async()=>{try{let e=await fetch(`https://status.privy.io/summary.json`);if(!e.ok)throw Error(`Failed to fetch Privy status`);return(await e.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},uo=()=>X({queryKey:[`PRIVY_STATUS`],queryFn:lo,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}),fo=e=>[`VECHAIN_KIT_DOMAIN`,e],po=t=>{let{network:n}=$();return X({queryKey:fo(t),queryFn:async()=>{if(!t)throw Error(`Address or domain is required`);let r=await Zr(t,{networkUrl:n.nodeUrl}),i=e(t);if(!r&&!i)throw Error(`Input must be a valid domain or address`);let a=null,o=null,s=!1;return r?(a=await Gr(t,{networkUrl:n.nodeUrl}),o=t,a&&(s=await Xr(t,a,{networkUrl:n.nodeUrl}))):(o=await Hr(t,{networkUrl:n.nodeUrl}),a=t,o&&(s=await Xr(o,t,{networkUrl:n.nodeUrl}))),{address:a||void 0,domain:o||void 0,isValidAddressOrDomain:r||i,isPrimaryDomain:s}},enabled:!!t&&!!n.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})},mo=async(e,t,n)=>{let r=vi(fi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,vi(Si(n))])),i=await e.contracts.load(k(t).vetDomainsContractAddress,oi.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},ho=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],go=e=>{let t=Nn(),{network:n}=$();return X({queryKey:ho(e),queryFn:()=>mo(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})},_o=(e,t)=>{let n=Vn(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:Io(e??``,r.type)}),n.invalidateQueries({queryKey:Bo(e,r.type)}),n.invalidateQueries({queryKey:Yo(t)})])}}},vo=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:fo(t)}),e.invalidateQueries({queryKey:fo(n)}),e.invalidateQueries({queryKey:ho(r)}),e.invalidateQueries({queryKey:Po(t,`.vet`)}),e.invalidateQueries({queryKey:Po(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Bo(n)})]),await Promise.all([e.refetchQueries({queryKey:fo(t)}),e.refetchQueries({queryKey:fo(n)}),e.refetchQueries({queryKey:Po(t,`.vet`)}),e.refetchQueries({queryKey:Po(t,`.veworld.vet`)}),e.refetchQueries({queryKey:Io(r+`.`+i,a)}),e.refetchQueries({queryKey:Bo(n)}),e.refetchQueries({queryKey:ho(r)}),e.refetchQueries({queryKey:Yo(t)})])},yo=ci.createInterface(),bo=si.createInterface(),xo=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:bo.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:bo.getFunction(`setName`)}),n){a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:bo.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:bo.getFunction(`setName`)});let e=new nn.Interface([`function setAddr(bytes32 node, address addr)`]),t=nn.namehash(o);a.push({to:k(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${l(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(Co(t))a.push({to:k(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:yo.encodeFunctionData(`claim`,[e,k(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:yo.getFunction(`claim`)}),a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:bo.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:bo.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},So=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=Vn(),{account:o}=Q(),{network:s}=$(),{refresh:c}=_o(e+`.`+t,o?.address??``),l=H(()=>xo(e,t,i,o,s),[e,t,i,o,s]),u=H(async()=>{let r=`${e}.${t}`;await vo(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=fc({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())}},Co=e=>e.endsWith(`veworld.vet`),wo=si.createInterface(),To=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:k(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:wo.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:wo.getFunction(`setName`)});let t=new nn.Interface([`function setAddr(bytes32 node, address addr)`]),a=nn.namehash(e);i.push({to:k(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${l(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},Eo=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=Vn(),{account:o}=Q(),{refresh:s}=_o(e,o?.address??``),c=H(()=>To(e,r,o,i),[e,r,o,i]),l=H(async()=>{await vo(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=fc({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())}},Do=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],Oo=ln.ofAbi(ci.abi),ko=async(e,t,n)=>{let r=k(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,Oo.abi).read.isDomainProtected(n))[0]},Ao=(e,t=!0)=>{let n=Nn(),{network:r}=$();return X({queryKey:Do(e),queryFn:()=>ko(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})},jo=wi.object({name:wi.string()}),Mo=wi.object({domains:wi.array(jo)}),No=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=k(e).graphQlIndexerUrl,i=`query Registrations {
|
|
114
114
|
domains(
|
|
115
115
|
where: ${n?`{owner: "${t.toLowerCase()}", parent_: {name: "${n}"}}`:`{owner: "${t.toLowerCase()}"}`}
|
|
116
116
|
) {
|
|
117
117
|
name
|
|
118
118
|
}
|
|
119
|
-
}`,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`))),Mo.parse(o.data)},Po=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],Fo=(e,t)=>{let{network:n}=$();return X({queryKey:Po(e,t),queryFn:()=>No(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})},Io=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],Lo=e=>{let{network:t}=$();return X({queryKey:Io(e??``,t.type),queryFn:async()=>e?Ur(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})},Ro=new tn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),zo=async(e,t,n)=>{if(!n)return{};let r=rn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(t).vetDomainsContractAddress,data:Ro.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return{};let{resolverAddress:a}=Ro.decodeFunctionResult(`resolver`,n);return(await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:le.map(e=>({to:a,data:Ro.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=Ro.decodeFunctionResult(`text`,t)[0];n&&(e[le[r]]=n)}catch(e){console.error(`Failed to decode text record for ${le[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},Bo=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],Vo=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:Bo(e,t.type),queryFn:()=>zo(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})},Ho=new tn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),Uo=(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=rn(r);n.push({to:e,data:Ho.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},Wo=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=H(e=>{if(!r)throw Error(`Resolver address is required`);return Uo(r,e)},[r]),a=fc({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))}},Go=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Ko=e=>{let{network:t}=$();return uf({address:k(t.type).vetDomainsContractAddress,abi:ai.abi,method:`resolver`,args:[e?yi(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},qo={Mugshot:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/mugshot.png`,Greencart:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/greencart.png`,Cleanify:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/cleanify.png`,EVearn:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/evearn.png`},Jo=()=>{let e=w(`vechain_kit_cross_app_connection`);if(!e)return null;try{let t=JSON.parse(e)?.ecosystemApp?.name;return t?qo[t]??null:null}catch{return null}},Yo=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],Xo=e=>{let{network:t}=$();return X({queryKey:Yo(e),queryFn:async()=>{if(!e||!t.nodeUrl)return Jo()??i(e??``);let n=await Hr(e,{networkUrl:t.nodeUrl});return n&&await Ur(n,{networkUrl:t.nodeUrl})||(Jo()??i(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})},Zo=new tn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),Qo=new tn([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),$o=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=rn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(e).vetDomainsContractAddress,data:Zo.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return null;let{resolverAddress:a}=Zo.decodeFunctionResult(`resolver`,n),[{data:o,reverted:s}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:a,data:Zo.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(s||o===`0x`)return null;try{let{avatar:n}=Zo.decodeFunctionResult(`text`,o),r=n===``?null:n;return r?ts(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}},es=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function ts(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return x(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:Qo.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],[{data:l,reverted:u}]=await fetch(`${n}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(u)return console.error(`Failed to fetch tokenURI`),null;let d=``;try{d=Qo.decodeFunctionResult(s?`uri`:`tokenURI`,l)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),d=sn(l)}d=x(d,t)||d,s&&(d=d.replace(`{id}`,cn(on(BigInt(o||0)),32).slice(2)));let f=await fetch(d);if(!f.ok)return console.error(`Failed to fetch metadata`),null;let p=await f.json(),m=p.image||p.image_url||p.image_data;return m?x(m,t)||m:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const ns=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:es(e??``,t.type),queryFn:async()=>e?$o(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},rs=si.createInterface(),is=(e,t)=>{let n=[];return n.push({to:k(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:rs.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(e?.address??``,4,4)}`,abi:rs.getFunction(`setName`)}),n},as=({onSuccess:e,onError:t})=>{let n=Vn(),{account:r}=Q(),{network:i}=$(),a=H(()=>is(r,i),[r,i]),o=H(async()=>{await vo(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=fc({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())}},os=e=>{let{network:t}=$(),n=k(t.type),{data:r,isLoading:i}=yf(e),{data:a,isLoading:o}=Ts(e),{data:s,isLoading:c}=js(e),{data:l,isLoading:u}=ks(n.veDelegateTokenContractAddress,e),{data:d,isLoading:f}=ks(n.gloDollarContractAddress,e),p=Ds(e),m=p.map(e=>e.data).filter(Boolean),h=p.some(e=>e.isLoading);return{balances:W(()=>{if(!e)return[];let t={vet:`0x`,vtho:n.vthoContractAddress,b3tr:n.b3trContractAddress,vot3:n.vot3ContractAddress,veDelegate:n.veDelegate,USDGLO:n.gloDollarContractAddress},i=[{address:t.vet,symbol:`VET`,balance:r?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:r?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:a?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:s?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:l?.scaled??`0`},{address:t.USDGLO,symbol:`USDGLO`,balance:d?.scaled??`0`}],o=m.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`}));return[...i,...o]},[e,r,a,s,l,d,m,t.type]),isLoading:i||o||c||u||f||h}},ss={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},cs=async(e,t,n)=>{let r=await e.contracts.load(k(n).oracleContractAddress,$r.abi).read.getLatestValue(ss[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new en(r[0].toString()).div(0xe8d4a51000).toNumber()},ls=e=>[`VECHAIN_KIT_PRICE`,e],us=e=>{let t=Nn(),{network:n}=$();return X({queryKey:ls(e),queryFn:async()=>cs(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})},ds=()=>{let{network:e}=$(),t=k(e.type),{data:n,isLoading:r}=us(`VET`),{data:i,isLoading:a}=us(`VTHO`),{data:o,isLoading:s}=us(`B3TR`),{data:c,isLoading:l}=us(`EUR`),{data:u,isLoading:d}=us(`GBP`);return{prices:W(()=>{let e={vet:`0x`,vtho:t.vthoContractAddress,b3tr:t.b3trContractAddress,vot3:t.vot3ContractAddress,veDelegate:t.veDelegate,USDGLO:t.gloDollarContractAddress};return{[e.vet]:n||0,[e.vtho]:i||0,[e.b3tr]:o||0,[e.vot3]:o||0,[e.veDelegate]:o||0,[e.USDGLO]:1}},[n,i,o,t.vthoContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,t.gloDollarContractAddress]),exchangeRates:W(()=>({eurUsdPrice:c||1,gbpUsdPrice:u||1}),[c,u]),isLoading:r||a||s||l||d}},fs=[`usd`,`eur`,`gbp`],ps=()=>{let{currentCurrency:e,setCurrency:t}=$();return U(()=>{h(`vechain_kit_currency`,e)},[e]),{currentCurrency:e,allCurrencies:fs,changeCurrency:e=>{if(!fs.includes(e)){console.error(`Invalid currency: ${e}`);return}t(e)}}},ms=({address:e=``})=>{let{balances:t,isLoading:n}=os(e),{prices:r,exchangeRates:i,isLoading:a}=ds(),{currentCurrency:o}=ps(),s=W(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,a=no(n,o,i);return{...e,priceUsd:t,valueUsd:n,valueInCurrency:a}}),[t,r,o,i]),c=W(()=>[...s].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[s]);return{tokens:s,sortedTokens:c,tokensWithBalance:W(()=>c.filter(e=>Number(e.balance)>0),[c]),isLoading:n||a}},hs=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=ms({address:e}),{currentCurrency:r}=ps(),i=W(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]);return{totalBalanceInCurrency:i,totalBalanceUsd:W(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),formattedBalance:W(()=>io(i,{currency:r}),[i,r]),isLoading:n,hasAnyBalance:t.length>0}},gs=di.abi,_s=`currentRoundId`,vs=e=>cf({abi:gs,address:e,method:_s}),ys=()=>{let{network:e}=$(),t=k(e.type).xAllocationVotingContractAddress;return uf({abi:gs,address:t,method:_s,args:[],queryOptions:{select:e=>e[0].toString()}})},bs=async(e,t)=>Jr(e,{networkUrl:t}),xs=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],Ss=e=>{let{network:t}=$();return X({queryKey:xs(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return bs(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})},Cs=()=>{let[e,t]=wp(Cp.CUSTOM_TOKENS,[]),{network:n}=$(),r=async r=>{if(!a(r)&&!s(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await bs(r,n.nodeUrl),address:r};t([...e,i])}},i=n=>{t(e.filter(e=>e.address!==n))},a=t=>e.some(e=>o(e.address,t)),s=e=>{let t={vet:`0x`,vtho:k(n.type).vthoContractAddress,b3tr:k(n.type).b3trContractAddress,vot3:k(n.type).vot3ContractAddress,veDelegate:k(n.type).veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:r,removeToken:i,isTokenIncluded:a,isDefaultToken:s}},ws=e=>[`VEBETTERDAO_BALANCE`,e,`B3TR`],Ts=e=>{let{network:t}=$();return X({queryKey:ws(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Wr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get b3tr balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},Es=(e,t)=>[`VECHAIN_KIT_BALANCE`,t,`CUSTOM_TOKEN`,e],Ds=e=>{let{network:t}=$(),{customTokens:n}=Cs();return Bn({queries:n.map(n=>({queryKey:Es(n.address,e),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 Kr(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let i=u(r[0]);return{...n,...i}}}))})},Os=(e,t)=>[`VECHAIN_KIT`,`BALANCE`,`ERC20`,e,t],ks=(e,t)=>{let{network:n}=$();return X({queryKey:Os(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let r=await Kr(e,t,{networkUrl:n.nodeUrl});if(!r)throw Error(`Failed to get vot3 balance`);let i=r[0];return u(i)},enabled:!!t&&!!n.type})},As=e=>[`VEBETTERDAO_BALANCE`,e,`VOT3`],js=e=>{let{network:t}=$();return X({queryKey:As(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Yr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},Ms=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],Ns=e=>{let{network:t}=$();return X({queryKey:Ms(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return qr(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})},Ps=di.abi,Fs=`getAppsOfRound`,Is=(e,t)=>lf({abi:Ps,address:k(t).xAllocationVotingContractAddress,method:Fs,args:[BigInt(e??0)]}),Ls=e=>{let{network:t}=$(),n=k(t.type).xAllocationVotingContractAddress;return uf({abi:Ps,address:n,method:Fs,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()}))}})},Rs=ui.abi,zs=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Bs=(e,t)=>{let n=Nn(),{network:r}=$(),i=k(r.type).xAllocationPoolContractAddress;return X({queryKey:zs(t),queryFn:async()=>(await O({thor:n,calls:e.map(e=>({abi:Rs,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})},Vs=e=>{let{data:t}=Ls(e),n=Bs(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}},Hs=({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 Pi&&i&&!g(i)?Error(t):i&&g(i)?Error(n):e instanceof Error?e:Error(r)},Us=mi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[`https://mainnet.vechain.org`]}},blockExplorers:{default:{name:`Vechain Explorer`,url:`https://explore.vechain.org`},vechainStats:{name:`Vechain Stats`,url:`https://vechainstats.com`}}}),Ws=()=>Ni({id:re,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),Gs=({privyEcosystemAppIDS:e,children:t})=>q(Ti,{config:$t(Ei({chains:[Us],ssr:!0,connectors:[Ws(),...e.map(e=>Ni({id:e,name:``,iconUrl:``}))],transports:{[Us.id]:Di()},multiInjectedProviderDiscovery:!1})).current,children:t}),Ks=()=>{let{connectAsync:e,connectors:t}=ki(),{signTypedDataAsync:n}=Mi(),{signMessageAsync:r}=ji(),{disconnectAsync:i}=Ai(),{isConnected:a}=Oi(),[o,s]=G(!1),[c,l]=G(null),u=H(async()=>{try{a&&(await i(),y()&&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||re));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 Hs({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 Hs({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}},qs=(e,t)=>{let{data:n,isLoading:r}=po(e??``),{data:i,isLoading:a}=Xo(e??``),{data:o,isLoading:s}=Vo(n?.domain??``),c=o?.header?x(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=Oi(),{logout:i}=Ks(),{loading:a}=Cn({}),{feeDelegation:s,network:c,privy:l}=$(),{user:u,authenticated:d,logout:f,ready:p}=Dn(),{data:m}=rp(),{account:h,disconnect:g}=Pn(),{getConnectionCache:_,clearConnectionCache:v}=$d(),b=_(),x=mf(),S=!!h,C=d&&!!u,w=C||t,T=C&&l?.appId===re||t&&b?.ecosystemApp?.appId===re,ee=n||r||a||!p,[E,te]=G(!1),D=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:S?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};U(()=>{let e=S||C||t;E!==e&&(te(e),e||(v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[S,C,t,v,E]);let ne=u?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,O=S?h:t?e:ne,{data:ie}=Uf(O),ae=S?h:ie?.address,oe=qs(ae??``,c.type),se=qs(O??``,c.type),k=qs(ie?.address??``,c.type),ce=ae?{address:ae,domain:oe.domain,image:oe.image,isLoadingMetadata:oe.isLoading,metadata:oe.records}:null,le=O?{address:O,domain:se.domain,image:se.image,isLoadingMetadata:se.isLoading,metadata:se.records}:null,{data:ue}=jf(ie?.address??``,le?.address??``),de=!!ie?.address&&!!ce?.address&&o(ie?.address,ce?.address),fe=H(async()=>{try{te(!1),S?g():C?await f():t&&await i(),v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[S,g,C,f,t,i,v]);return{account:ce,smartAccount:{address:ie?.address??``,domain:k.domain,image:k.image,isDeployed:ie?.isDeployed??!1,isActive:de,version:ue?.version??null,isLoadingMetadata:k.isLoading,metadata:k.records},connectedWallet:le,privyUser:u,connection:{isLoading:ee,isConnected:E,isConnectedWithSocialLogin:C,isConnectedWithDappKit:S,isConnectedWithCrossApp:t,isConnectedWithPrivy:w,isConnectedWithVeChain:T,source:D,isInAppBrowser:(y()&&window.vechain&&window.vechain.isInAppBrowser)??!1,nodeUrl:x,delegatorUrl:s?.delegatorUrl,chainId:m,network:c.type},disconnect:fe}},Js=()=>{let e=Vn(),{account:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.invalidateQueries({queryKey:[`VECHAIN_KIT_BALANCE`,n]}),e.invalidateQueries({queryKey:[`VECHAIN_KIT_PRICE`]})])}}},Ys=async(e,t)=>{let n=x(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},Xs=li.abi,Zs=e=>{let t=Nn(),{network:n}=$();return X({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=k(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,Xs),a=(await i.read.app(e))[0][3]?.toString()||``,[o]=await i.read.baseURI();return await Ys(`${o}${a}`,n.type)},enabled:!!e})},Qs=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=x(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},$s=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],ec=(e,t=!1)=>{let{network:n}=$();return X({queryKey:$s(n.type,e),queryFn:()=>Qs(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})},tc=1024*1024*10,nc=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(x(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>tc)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:b(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},rc=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],ic=e=>{let{network:t}=$();return X({queryKey:rc(t.type,e),queryFn:()=>nc(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})},ac=e=>{let{network:t}=$();return Bn({queries:e.map(e=>({queryKey:rc(t.type,e),queryFn:()=>nc(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}))})},oc=(e,t=!1)=>{let{network:n}=$();return Bn({queries:e.map(e=>({queryKey:$s(n.type,e),queryFn:async()=>Qs(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}))})},sc={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},cc=async e=>{let t=[];try{for(let n of e){let e=await Fi(n.file,sc);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},lc=({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 Fi(n,sc));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}},uc=({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 Fi(n,sc));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},dc=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)},fc=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o,delegationUrl:s})=>{let c=Nn(),{signer:l,requestTransaction:u}=Fn(),{connection:d}=Q(),{feeDelegation:f}=$(),p=mf(),m=om(),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 dc(c,[...a],e,{revision:pn.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}return(await u(a,{signer: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]),[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),te(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:T}=hp(g??``),ee=H(async e=>{if(!(!e.reverted||!e.meta.txID))return await c.transactions.getRevertReason(e.meta.txID)},[c]),[E,te]=G(),D=W(()=>{if(v)return`pending`;if(b)return`error`;if(g){if(w)return`waitingConfirmation`;if(T)return`error`;if(C)return C.reverted?`error`:`success`}return`ready`},[w,b,v,g,C,T]);U(()=>{if(D===`success`||D===`error`){if(b&&!E){te({type:`UserRejectedError`,reason:b});return}if(C?.reverted&&!E?.type){(async()=>{let e=await ee(C);te({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}C&&!C.reverted&&n?.()}},[D,C,n,ee,b]);let ne=H(()=>{_(null),y(!1),x(null),te(void 0)},[]);return{sendTransaction:S,isTransactionPending:W(()=>v||w||D===`pending`||D===`waitingConfirmation`,[v,w,D]),isWaitingForWalletConfirmation:W(()=>D===`pending`,[v,D]),txReceipt:C??null,status:D,resetStatus:ne,error:E}},pc=(e,t)=>{let{account:n}=Q(),{t:r}=Y(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=fc({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}},mc=e=>e===`0x`||e===Ci,hc=(e,t,n,r)=>{let i={},a=r.toLowerCase();for(let t of e)try{let e=pi({abi:Qr.abi,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[Ci]??{inflow:0n,outflow:0n};t.outflow+=e,i[Ci]=t}}for(let e of t){if(e.recipient.toLowerCase()!==a)continue;let t=BigInt(e.amount);if(t<=0n)continue;let n=i[Ci]??{inflow:0n,outflow:0n};n.inflow+=t,i[Ci]=n}return i},gc=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=hc(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=mc(e.fromTokenAddress),d=mc(e.toTokenAddress),f=BigInt(e.amountIn);if(u){let e=c[Ci]??{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!==Ci&&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===Ci?`VET`:e} has outflow ${n.outflow.toString()}, expected 0`}}if(t.minimumOutputAmount&&t.minimumOutputAmount>0n)if(d){let e=c[Ci]??{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`}}},_c=e=>e.startsWith(`0x`)?BigInt(e).toString():e,vc=(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`}),yc=(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[vc(t,e)]}return e},bc=e=>{try{let t=e.functionName||e.name;if(!t)throw Error(`Function name is required (either functionName or name must be provided)`);return hi({abi:yc(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`}`)}},xc=e=>{let t=bc(e.functionCall);return{to:e.to,value:_c(e.value),data:t,comment:e.comment||`Swap on aggregator`}},Sc=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=await fetch(`${e.apiBaseUrl}?${r.toString()}`);if(!i.ok)throw Error(`API request failed: ${i.status} ${i.statusText}`);let a=await i.json(),o=a.clauses.map(xc),s=BigInt(a.amountOut),c=BigInt(a.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:s,minimumOutputAmount:c,priceImpact:0,data:{clauses:o,path:a.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 gc(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},Cc={main:{supportedAddresses:[`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,`0x7C755EC0165fCD926cC6faB10E7BB16a72E9f34A`]},test:{supportedAddresses:[]},solo:{supportedAddresses:[]}},wc=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,Tc=e=>{let t={main:`https://vetrade.vet/api/quote/vck`,test:`https://vetrade.vet/api/quote/vck`,solo:`https://vetrade.vet/api/quote/vck`};return t[e]||t.main},Ec=e=>{let t=Cc[e]??Cc.main,n=Sc({name:`VeTrade.vet`,apiBaseUrl:Tc(e),network:e,getIcon:(e=`20px`)=>V.createElement(Ae,{boxSize:e}),supportedAddresses:t.supportedAddresses});return{...n,async simulateSwap(e,t,n){try{return gc(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(wc(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=ln.ofAbi(Qr.abi),o=un.of(e.fromTokenAddress),s=BigInt(e.amountIn);i.push(dn.callFunction(o,n.getFunction(`approve`),[a[0].to,s.toString()],gn.of(0n,hn.wei),{comment:`Approve ${r.aggregatorName} to access ${e.fromTokenAddress}`}))}return i.push(...a),i}}},Dc=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,Oc=()=>BigInt(Math.floor(Date.now()/1e3)+1200),kc=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[Dc(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,Dc(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,ii.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 gc(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=Oc();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=Dc(t.fromTokenAddress),s=Dc(t.toTokenAddress),c=ln.ofAbi(ii.abi),l=[];if(o)l.push(dn.callFunction(un.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],gn.of(a,hn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=ln.ofAbi(Qr.abi),u=un.of(t.fromTokenAddress),d=un.of(e.routerAddress);l.push(dn.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],gn.of(0n,hn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(dn.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],gn.of(0n,hn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(dn.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],gn.of(0n,hn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},Ac={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Ci,wrappedVET:Ci},solo:{routerAddress:Ci,wrappedVET:Ci}},jc=e=>{let t=Ac[e]??Ac.main;return kc({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Te,{boxSize:e})})},Mc=e=>[Ec(e),jc(e)],Nc=(e,t,n,r,i=1,a=!0)=>{let o=Nn(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=Ss(c===`0x`||c===Ci||!c?``:c),{data:d}=Ss(l===`0x`||l===Ci||!l?``:l),f=W(()=>!c||c===`0x`||c===Ci||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=W(()=>!l||l===`0x`||l===Ci||!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=Mc(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}},Pc=({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}=xn(),{loginWithCode:p}=Sn({onComplete:async({isNewUser:e})=>{e&&await f()}});return U(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),J(to,{isOpen:r,onClose:i,trapFocus:!1,children:[J(Z,{children:[q(L,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:2,children:[q(N,{as:Tr,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(M,{spacing:2,justify:`center`,mt:4,children:J(xt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[q(St,{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(St,{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(St,{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(St,{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(St,{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(St,{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(I,{children:J(R,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,q(j,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},Fc=()=>{let{t:e}=Y(),{darkMode:t}=$(),[n,r]=G(``),{sendCode:i,state:a}=Sn({}),o=qt(),s=async()=>{await i({email:n}),o.onOpen()};return J(K,{children:[q(st,{colSpan:4,w:`full`,children:q(z,{spacing:3,w:`full`,children:J(ft,{size:`lg`,w:`full`,children:[q(pt,{pointerEvents:`none`,height:`100%`,pl:4,children:q(N,{as:Tr,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(j,{"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(Pc,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},Ic=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Qd();return q(st,{colSpan:t??4,w:`full`,children:q(Eu,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:Ii,text:n(`Continue with Google`)})})},Lc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Qd();return q(st,{colSpan:t??4,w:`full`,children:q(Eu,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:vr,text:n(`Continue with Github`)})})},Rc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=En();return q(st,{colSpan:t||4,w:`full`,children:q(Eu,{isDark:e,onClick:r,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(ju,{})})})},zc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=ef(),[i,a]=G(),o=qt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){console.error(n(`Login failed:`),e),a(e instanceof Error?e.message:n(`Failed to connect with VeChain`))}};return J(K,{children:[q(st,{colSpan:t||4,w:`full`,children:q(Eu,{isDark:e,onClick:s,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(ju,{})})}),q(Pu,{isOpen:o.isOpen,onClose:()=>{o.onClose()},onTryAgain:()=>{s()},error:i,title:n(`Connecting to VeChain`),loadingText:n(`Please approve the request in the connection request window...`)})]})},Bc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{loginWithPasskey:r}=Xd(),[i,a]=G(),o=qt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&(console.error(e),a(e instanceof Error?e.message:n(`Failed to connect with Passkey`)))}};return J(K,{children:[q(st,{colSpan:t,w:`full`,children:q(Eu,{isDark:e,onClick:s,icon:hr,text:t&&t>=2?n(`Passkey`):void 0})}),q(Pu,{isOpen:o.isOpen,onClose:()=>{o.onClose()},error:i,title:n(`Connecting with Passkey`),loadingText:n(`Please complete the passkey authentication...`),onTryAgain:()=>{s()}})]})},Vc=({isDark:e,gridColumn:t=2})=>{let{t:n}=Y(),{open:r,onConnectionStatusChange:i}=In(),{dappKit:a}=$(),{source:o}=Fn(),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]),q(st,{colSpan:t||2,w:`full`,children:q(Eu,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?Br:e?Ee:he,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&q(N,{as:Yn})||void 0})})},Hc=({isDark:e,onViewMoreLogin:t,gridColumn:n})=>{let{t:r}=Y();return q(st,{colSpan:n,w:`full`,children:q(Eu,{isDark:e,onClick:t,icon:pr,text:n&&n>=2?r(`More`):void 0,rightIcon:q(N,{as:Yn})})})},Uc=()=>{let{loginMethods:e,darkMode:t}=$(),{login:n}=En(),{showGoogleLogin:r,showEmailLogin:i,showPasskey:a,showVeChainLogin:o,showDappKit:s,showMoreLogin:c,showGithubLogin:l,isOfficialVeChainApp:u}=Ud();return q(jt,{spacing:4,w:`full`,align:`center`,children:q(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:e?.map(({method:e,gridColumn:d})=>{switch(e){case`email`:return i&&q(Fc,{},`email`);case`google`:return r&&q(Ic,{isDark:t,gridColumn:d},`google`);case`github`:return l&&q(Lc,{isDark:t,gridColumn:d},`github`);case`vechain`:return o&&q(u?Rc:zc,{isDark:t,gridColumn:d},`vechain`);case`passkey`:return a&&q(Bc,{isDark:t,gridColumn:d},`passkey`);case`dappkit`:return s&&q(Vc,{isDark:t,gridColumn:d},`dappkit`);case`more`:return c&&q(Hc,{isDark:t,onViewMoreLogin:n,gridColumn:d},`more`);default:return null}})})})},Wc=({appsInfo:e,isLoading:t})=>{let{t:n}=Y(),r=qt();return J(K,{children:[q(j,{fontSize:`sm`,variant:`link`,onClick:()=>{r.onOpen()},children:n(`Already have an x2earn app wallet?`)}),q(Ru,{isOpen:r.isOpen,onClose:r.onClose,appsInfo:e,isLoading:t})]})},Gc=({setCurrentContent:e,onClose:t})=>{let{t:n}=Y(),{connection:r}=Q(),{loginModalUI:i,darkMode:a}=$(),{loginMethods:o,privyEcosystemAppIDS:s}=$(),{data:c,isLoading:l}=co(s),u=B(`colors`,`vechain-kit-text-secondary`),d=()=>{e(`faq`)};U(()=>{r.isConnected&&t()},[r.isConnected,t]);let f=o?.some(({method:e})=>e===`ecosystem`);return J(K,{children:[J(Z,{children:[q(zp,{onClick:d}),q(L,{children:n(`Log in or sign up`)}),q(F,{})]}),i?.logo&&q(M,{justify:`center`,children:q(ut,{src:i.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),J(P,{children:[i?.description&&q(M,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:q(R,{color:u,fontSize:`sm`,textAlign:`center`,children:i?.description})}),q(Uc,{})]}),f?q(I,{children:q(M,{justify:`center`,w:`full`,children:q(Wc,{isDark:a,appsInfo:Object.values(c||{}),isLoading:l})})}):q(I,{pt:0,pb:`5px`})]})},Kc=({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}=Kf(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:l,icon:J(A,{position:`relative`,children:[q(N,{as:Mr,fontSize:`18px`}),c&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},qc=({setCurrentContent:e,wallet:t,onClose:n})=>{let{t:r}=Y(),{network:i}=$();return J(Bp,{children:[J(Z,{children:[q(Kc,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),J(L,{children:[r(`Wallet`),i?.type!==`main`&&q(Nt,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${i?.type}`})]}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:6,children:[q(pl,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),q(hl,{onAssetsClick:()=>{e(`assets`)}}),q(vl,{setCurrentContent:e})]})}),q(I,{pt:0})]})},Jc=({onSelectToken:e,onBack:t,showAllTokens:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{currentCurrency:a}=ps(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-text-secondary`),c=B(`colors`,`vechain-kit-text-tertiary`),{account:l}=Q(),{tokensWithBalance:u,sortedTokens:d}=ms({address:l?.address??``}),[f,p]=G(``),m=W(()=>{if(n){let e=d.filter(e=>Number(e.balance)>0),t=[...d.filter(e=>Number(e.balance)===0)].sort((e,t)=>e.symbol.localeCompare(t.symbol));return[...e,...t]}return u},[n,d,u]).filter(({symbol:e})=>e.toLowerCase().includes(f.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:r(`Select Token`)}),q(Ja,{onClick:t}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:4,align:`stretch`,children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:f,onChange:e=>p(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:c})})]}),q(R,{fontSize:`lg`,fontWeight:`semibold`,color:o,mt:4,children:r(n?`All tokens`:`Your tokens`)}),m.length===0?J(z,{spacing:2,py:8,children:[q(N,{as:Fr,boxSize:12,color:c}),q(R,{fontSize:`lg`,color:o,children:r(`No tokens found`)}),q(R,{fontSize:`md`,color:s,children:r(`Try searching with a different term`)})]}):q(z,{spacing:2,align:`stretch`,children:m.map(t=>q(ao,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:a,onClick:()=>e(t)},t.address))})]})})}),q(I,{pt:0})]})},Yc=()=>{let{isolatedView:e,closeAccountModal:t}=hd();return{isolatedView:e,closeAccountModal:t}},Xc=({setCurrentContent:e,preselectedToken:t,initialAmount:n=``,initialToAddressOrDomain:r=``,onBack:i=()=>e(`main`)})=>{let{t:a}=Y(),{darkMode:o,feeDelegation:c}=$(),{currentCurrency:l}=ps(),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}=ds(),{account:_}=Q(),{isolatedView:v}=Yc(),{tokensWithBalance:y}=ms({address:_?.address??``}),[b,x]=G(t??y[0]??null),[S,C]=G(!1);U(()=>{!t&&!b&&y.length>0&&x(y[0])},[y,t,b]);let{register:w,watch:T,setValue:ee,setError:E,formState:{errors:te,isValid:D},handleSubmit:ne}=Li({defaultValues:{amount:n,toAddressOrDomain:r},mode:`onChange`}),{toAddressOrDomain:O,amount:re}=T(),ie=$t(b);U(()=>{ie.current&&b&&ie.current.address!==b.address&&ee(`amount`,``),ie.current=b},[b,ee]);let ae=W(()=>b?io(no(Number(re)*b.priceUsd,l,g),{currency:l}):``,[re,b,l,g]),{data:oe,isLoading:se}=po(O),k=()=>{b&&ee(`amount`,b.balance)},ce=()=>{i()},le=async t=>{if(b){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){E(`toAddressOrDomain`,{type:`manual`,message:a(`Invalid address or domain`)});return}if(b){let e=an(t.amount),n=c?.b3trTransfers?.minAmountInEther;if(b.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(e<an(String(n))){E(`amount`,{type:`manual`,message:a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n})});return}}catch{}if(e>an(b.balance)){E(`amount`,{type:`manual`,message:a(`Insufficient {{symbol}} balance`,{symbol:b.symbol})});return}}e({type:`send-token-summary`,props:{toAddressOrDomain:t.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:t.amount,selectedToken:b,formattedTotalAmount:ae,setCurrentContent:e}})}};return S?q(Jc,{setCurrentContent:e,onSelectToken:e=>{x(e),C(!1)},onBack:()=>{C(!1)}}):J(K,{children:[J(Z,{children:[q(L,{children:a(`Send`)}),!v&&q(Ja,{onClick:ce}),q(F,{})]}),q(P,{children:J(z,{spacing:2,align:`stretch`,position:`relative`,children:[J(M,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:a(`Amount`)}),J(R,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:k,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:d,children:[a(`Balance`),`:`,` `,Number(b?.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(A,{p:6,borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!te.amount,children:[J(M,{justify:`space-between`,children:[q(dt,{...w(`amount`,{required:a(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:a(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return a(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return b?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,ee(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),b?J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>C(!0),leftIcon:s[b.symbol]?V.cloneElement(s[b.symbol],{boxSize:`20px`,borderRadius:`full`}):q(ut,{src:p[b.symbol],alt:`${b.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:u,children:b.symbol.slice(0,3)})})}),children:[b.symbol,q(N,{as:rr,boxSize:5,color:d})]}):J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>C(!0),children:[a(`Select token`),q(N,{as:rr,boxSize:5,color:d})]})]}),b&&q(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:J(R,{color:d,children:[`≈ `,ae]})}),te.amount&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:te.amount.message})]})})}),q(M,{justify:`space-between`,mt:2,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:a(`To`)})}),q(A,{borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,p:6,width:`100%`,children:J(it,{isInvalid:!!te.toAddressOrDomain,children:[q(dt,{...w(`toAddressOrDomain`,{required:a(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?Ri(t):t;e.target.value=n,ee(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:a(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),te.toAddressOrDomain&&q(R,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:te.toAddressOrDomain.message})]})})})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!b||!D,isLoading:se,onClick:ne(le),"data-testid":`send-button`,children:a(b?`Send`:`Select Token`)})})]})},Zc=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:a,selectedToken:o,formattedTotalAmount:s})=>{let{t:c}=Y(),{account:l,connection:u,connectedWallet:d}=Q(),{data:f}=Xo(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Fp(),{isolatedView:g,closeAccountModal:_}=Yc(),v=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b}=Kf(l?.address??``,d?.address??``,3),{open:x}=Wd(),S=W(()=>f||i(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{o.symbol===`VET`?await O():await T()}catch(e){console.error(c(`Transaction failed:`),e)}},w=t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:c(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},{sendTransaction:T,txReceipt:ee,error:E,isWaitingForWalletConfirmation:te,isTransactionPending:D,clauses:ne}=lp({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,tokenAddress:o.address,tokenName:o.symbol,onSuccess:()=>{w(ee?.meta.txID??``)},onError:e=>{de(e??``)}}),{sendTransaction:O,txReceipt:re,error:ie,isWaitingForWalletConfirmation:ae,isTransactionPending:oe,clauses:se}=dp({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,onSuccess:()=>{w(re?.meta.txID??``)},onError:e=>{de(e??``)}}),k=()=>o.symbol===`VET`?re:ee,ce=te||ae,le=ce||D||oe,ue=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:o,initialAmount:a,initialToAddressOrDomain:t}})},de=e=>{console.error(`Transaction failed:`,e)},[fe,pe]=V.useState(null),[me,he]=V.useState(null),ge=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:_e,isLoading:ve,error:ye,refetch:be}=Ip({clauses:o.symbol===`VET`?se:ne,tokens:fe?[fe]:h.availableGasTokens,sendingAmount:a,sendingTokenSymbol:o.symbol,enabled:ge&&!!m?.genericDelegatorUrl}),xe=_e?.usedToken,Se=(ve||!_e)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,Ce=V.useCallback(e=>{pe(e),he(e),setTimeout(()=>be(),100)},[be]),we=!!xe&&!ye;return V.useEffect(()=>{ye&&fe&&pe(null)},[ye,fe]),J(K,{children:[J(Z,{children:[q(L,{children:`Send`}),q(Ja,{isDisabled:le,onClick:ue}),q(F,{isDisabled:le})]}),q(P,{children:q(z,{spacing:6,align:`stretch`,w:`full`,children:J(z,{spacing:4,w:`full`,children:[q(Rp,{label:c(`From`),address:l?.address??``,domain:l?.domain,imageSrc:l?.image??``,imageAlt:`From account`,balance:Number(o.balance),tokenAddress:o.address}),q(Rp,{label:c(`To`),address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:o.address}),u.isConnectedWithPrivy&&q(Gp,{estimation:_e,isLoading:ve,isLoadingTransaction:le,onTokenChange:Ce,clauses:o.symbol===`VET`?se:ne,userSelectedToken:me}),J(z,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:c(`Amount`)}),J(M,{justifyContent:`flex-start`,w:`full`,children:[J(R,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(a).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,o.symbol]}),J(R,{color:y,children:[`≈ `,s]})]})]})]})})}),q(I,{children:q(Hp,{transactionError:o.symbol===`VET`?ie:E,isSubmitting:le,isTxWaitingConfirmation:ce,onConfirm:C,transactionPendingText:c(`Sending...`),txReceipt:k(),buttonText:c(`Confirm`),isDisabled:le||Se,gasEstimationError:ye,hasEnoughGasBalance:we,isLoadingGasEstimation:ve,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},Qc=({setCurrentContent:e})=>{let{t}=Y(),{account:n}=Q(),{isolatedView:r}=Yc(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:t(`Receive`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:4,align:`center`,w:`full`,children:[q(zi,{value:n?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),q(Ya,{wallet:n,style:{w:`85%`}}),q(R,{fontSize:`sm`,textAlign:`center`,color:i,children:t(`Copy your address or scan this QR code`)}),q(R,{fontSize:`xs`,textAlign:`center`,color:a,children:t(`This address only supports VeChain assets.`)})]})}),q(I,{pt:0})]})]})},$c=({quotes:e,selectedQuote:t,toTokenAddress:n,onSelectQuote:r,onBack:i})=>{let{t:a}=Y(),{darkMode:c}=$(),{currentCurrency:l}=ps(),{account:u}=Q(),{exchangeRates:d,prices:f}=ds(),{tokens:m}=ms({address:u?.address??``}),[h,g]=G(!1),_=W(()=>n&&m.find(e=>o(e.address,n))||null,[n,m]),v=e.filter(e=>!e.reverted),y=e.filter(e=>e.reverted),b=W(()=>v.length===0?null:v.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[v]),x=W(()=>{let e=n&&f[n]||0;return v.map(t=>{let n=gi(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=no(r,l,d),a=b&&t.aggregatorName===b.aggregatorName,o=0;if(b&&!a){let e=BigInt(b.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)})},[v,n,f,l,d,b]);return J(K,{children:[J(Z,{children:[q(L,{children:a(`Found following rates`)}),q(Ja,{onClick:i}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:6,align:`stretch`,children:[x.length>0&&q(z,{spacing:2,align:`stretch`,children:x.map(e=>{let n=t?.aggregatorName===e.aggregatorName;return J(A,{p:2.5,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,borderWidth:1,borderColor:n?`blue.500`:c?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>r(e),_hover:{borderColor:n?`blue.500`:c?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(e.isBest||!e.isBest&&e.percentageDiff<0)&&q(A,{position:`absolute`,top:-1,left:0,zIndex:1,children:e.isBest?q(We,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:a(`Best`)}):J(We,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[e.percentageDiff.toFixed(2),`%`]})}),J(z,{align:`stretch`,spacing:1.5,marginTop:4,children:[J(M,{justify:`space-between`,align:`center`,children:[J(M,{spacing:1.5,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`bold`,children:e.aggregatorName})]}),q(M,{align:`center`,spacing:1.5,children:_&&J(K,{children:[s[_.symbol]?V.cloneElement(s[_.symbol],{boxSize:`24px`,borderRadius:`full`}):p[_.symbol]?q(ut,{src:p[_.symbol],alt:`${_.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,q(Ft,{label:Number(e.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:J(R,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(e.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,_.symbol]})})]})})]}),J(M,{justify:`space-between`,align:`center`,children:[q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:e.gasCostVTHO&&e.gasCostVTHO>0?`Gas: ${e.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),e.valueUsd>0&&J(R,{fontSize:`xs`,color:c?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,io(e.valueInCurrency,{currency:l})]})]})]})]},e.aggregatorName)})}),y.length>0&&J(A,{children:[J(M,{justify:`space-between`,cursor:`pointer`,onClick:()=>g(!h),py:2,children:[J(R,{fontSize:`sm`,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:[y.length,` `,a(`rate`),y.length===1?``:`s`,` `,a(`unavailable`)]}),q(N,{as:h?or:rr,boxSize:4,color:c?`whiteAlpha.600`:`blackAlpha.600`})]}),q($e,{in:h,animateOpacity:!0,children:q(z,{spacing:2,align:`stretch`,pt:2,children:y.map(e=>q(A,{p:2,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,opacity:.6,children:J(M,{justify:`space-between`,children:[J(M,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:a(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),x.length===0&&y.length===0&&q(z,{spacing:2,py:8,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:q(R,{fontSize:`lg`,children:a(`No quotes available`)})})]})})}),q(I,{})]})},el=e=>e===`0x`||e===Ci||!e,tl=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=el(n),c=el(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=Qr.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=pi({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}},nl=({setCurrentContent:e,fromTokenAddress:t,toTokenAddress:n})=>{let{t:r}=Y(),{account:i,connection:a}=Q(),{currentCurrency:c}=ps(),{network:l,feeDelegation:u,darkMode:d}=$(),{isolatedView:f,closeAccountModal:m}=Yc(),h=B(`colors`,`vechain-kit-card`),g=B(`colors`,`vechain-kit-text-primary`),_=B(`colors`,`vechain-kit-text-secondary`),v=B(`colors`,`vechain-kit-text-tertiary`),{preferences:y}=Fp(),{sortedTokens:b}=ms({address:i?.address??``}),[x,S]=G(`main`),[C,w]=G(null),[T,ee]=G(null),[E,te]=G(``),[D,ne]=G(!1),[O,re]=G(1),[ie,ae]=G(`1`),[oe,se]=G(null),[ce,le]=V.useState(null),[ue,de]=V.useState(null),[fe,pe]=V.useState([]),{prices:me,exchangeRates:he}=ds(),ge=O===1;V.useEffect(()=>{ae(O===1?`1`:O===.5?`0.5`:O===3?`3`:O.toString())},[O]),V.useEffect(()=>{if(b.length!==0){if((t||n)&&(!C||!T)){if(t&&!C){let e=b.find(e=>o(e.address,t));e&&w(e)}if(n&&!T){let e=b.find(e=>o(e.address,n));e&&ee(e)}return}if(!C&&!T){let e=b.find(e=>e.symbol===`VET`);e&&w(e);let t=b.find(e=>e.symbol===`B3TR`);if(!t)try{let e=k(l.type).b3trContractAddress;e&&(t=b.find(t=>o(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&ee(t)}}},[b,C,T,t,n,l.type]),V.useEffect(()=>{se(null)},[C?.address,T?.address,E]);let{bestQuote:_e,quotes:ve,isLoading:ye,from:be,to:xe}=Nc(C,T,E,i?.address??``,O,!!C&&!!T&&Number(E)>0),Se=W(()=>{if(!E||Number(E)<=0||!be)return 0n;try{return xi(E,be.decimals)}catch{return 0n}},[E,be?.decimals]),Ce=oe||_e,we=W(()=>{if(!Ce?.outputAmount||!xe)return`0`;try{return _i(Ce.outputAmount,xe.decimals)}catch{return`0`}},[Ce,xe?.decimals]),Te=W(()=>{if(!C||!E)return 0;let e=me[C.address]||0;return no(Number(E)*e,c,he)},[C?.address,E,me,c,he]),Ee=W(()=>{if(!T||!we)return 0;let e=me[T.address]||0;return no(Number(we)*e,c,he)},[T?.address,we,me,c,he]),De=W(()=>!C||!T||!i?.address||Se===0n?null:{fromTokenAddress:C.address,toTokenAddress:T.address,amountIn:Se.toString(),userAddress:i.address,slippageTolerance:O},[C,T,i?.address,Se,O]),Oe=Ce?.gasCostVTHO??0;V.useEffect(()=>{(async()=>{if(!Ce||!De||!Ce.aggregator){pe([]);return}try{pe(await Ce.aggregator.buildSwapTransaction(De,Ce))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),pe([])}})()},[Ce,De]);let ke=y.availableGasTokens.length>0&&(a.isConnectedWithPrivy||a.isConnectedWithVeChain)&&!u?.delegatorUrl,{data:Ae,isLoading:je,error:Me,refetch:Ne}=Ip({clauses:fe,tokens:ce?[ce]:y.availableGasTokens,sendingAmount:E,sendingTokenSymbol:C?.symbol??``,enabled:ke&&!!u?.genericDelegatorUrl&&fe.length>0}),Pe=Ae?.usedToken,Fe=(je||!Ae)&&a.isConnectedWithPrivy&&!u?.delegatorUrl,Ie=V.useCallback(e=>{le(e),de(e),setTimeout(()=>Ne(),100)},[Ne]),Le=!!Pe&&!Me;V.useEffect(()=>{Me&&ce&&le(null)},[Me,ce]);let{executeSwap:Re,isTransactionPending:ze,isWaitingForWalletConfirmation:Be,txReceipt:Ve,status:He,error:Ue}=pc(De,Ce),We=H(()=>{let t=Ve?.meta.txID??``,n=r(`Swap successful`,{defaultValue:`Swap successful`}),a;if(Ve&&C&&T&&i?.address){let e=tl(Ve,i.address,C.address,T.address);if(e&&be&&xe)try{let t=be.decimals,n=xe.decimals,i=_i(e.fromAmount,t),o=_i(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})};a=r(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(i),fromSymbol:C.symbol,toAmount:s(o),toSymbol:T.symbol,defaultValue:`You successfully swapped ${s(i)} ${C.symbol} for ${s(o)} ${T.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!a&&C&&T&&(a=r(`You successfully swapped {fromToken} for {toToken}`,{fromToken:C.symbol,toToken:T.symbol,defaultValue:`You successfully swapped ${C.symbol} for ${T.symbol}`})),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:n,description:a,onDone:()=>{f?m():e(`main`)},showSocialButtons:!0}})},[C,T,E,Ce,Ve,i?.address,e,r,f,m]),Ge=H(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[C,T,E]),[Ke,qe]=V.useState(!1);V.useEffect(()=>{if(He===`ready`){qe(!1);return}Ke||(He===`success`&&Ve&&!Ve.reverted?(qe(!0),We()):He===`error`&&Ue?Ge(Ue?.reason||Ue?.message||String(Ue)):Ve?.reverted&&Ge(`Transaction reverted`))},[He,Ve,Ue,We,Ge,Ke]);let Je=H(e=>{if(w(e),e.symbol===`VET`&&!T){let e=b.find(e=>e.symbol===`B3TR`);if(!e)try{let t=k(l.type).b3trContractAddress;t&&(e=b.find(e=>o(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&ee(e)}S(`main`)},[T,b,l.type]),Ye=H(e=>{ee(e),S(`main`)},[]),Xe=H(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&te(e)},[]),Ze=H(()=>{C&&te(C.balance)},[C]),Qe=e=>{if(!e)return null;let t=s[e.symbol],n=p[e.symbol];return{symbol:e.symbol,logoComponent:t,logoUrl:n,balance:e.balance,value:e.valueInCurrency}},et=Qe(C),nt=Qe(T);return x===`select-from-token`?q(Jc,{setCurrentContent:e,onSelectToken:Je,onBack:()=>S(`main`),showAllTokens:!1}):x===`select-quote`?q($c,{quotes:ve,selectedQuote:Ce,toTokenAddress:T?.address??null,onSelectQuote:e=>{se(e),S(`main`)},onBack:()=>S(`main`)}):x===`select-to-token`?q(Jc,{setCurrentContent:e,onSelectToken:Ye,onBack:()=>S(`main`),showAllTokens:!0}):J(K,{children:[J(Z,{children:[q(L,{children:r(`Swap`)}),!f&&q(Ja,{onClick:()=>e(`main`),isDisabled:ze||Be}),q(F,{isDisabled:ze||Be})]}),q(tt,{maxW:`container.lg`,p:0,children:q(P,{children:J(z,{spacing:2,align:`stretch`,w:`full`,children:[J(M,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:g,children:r(`From`)}),et&&J(R,{cursor:`pointer`,_hover:{color:_,textDecoration:`underline`},onClick:Ze,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:_,children:[r(`Balance`),`:`,` `,Number(et.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(A,{p:6,borderRadius:`2xl`,bg:h,children:J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,children:[q(dt,{placeholder:`0`,value:E,onChange:e=>Xe(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:et&&E&&Number(E)>Number(et.balance)?`red.500`:g}),et?J(j,{onClick:()=>S(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:et.logoComponent?V.cloneElement(et.logoComponent,{boxSize:`20px`,borderRadius:`full`}):et.logoUrl?q(ut,{src:et.logoUrl,alt:`${et.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:g,children:et.symbol.slice(0,3)})})}):void 0,children:[et.symbol,q(N,{as:rr,boxSize:5,color:_})]}):J(j,{onClick:()=>S(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:v},children:[r(`Select token`),q(N,{as:rr,boxSize:5,color:_})]})]}),et&&q(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:_,children:q(M,{spacing:2,alignItems:`center`,children:J(R,{color:_,children:[`≈`,` `,io(Te,{currency:c})]})})})]})}),q(M,{justify:`space-between`,mt:4,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:g,children:r(`To`)})}),q(A,{borderRadius:`2xl`,bg:h,children:J(z,{align:`stretch`,spacing:2,p:6,width:`100%`,children:[J(M,{justify:`space-between`,alignItems:`center`,children:[q(dt,{value:Number(we).toLocaleString(void 0,{maximumFractionDigits:Number(we)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:g}),nt?J(j,{onClick:()=>S(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:nt.logoComponent?V.cloneElement(nt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):nt.logoUrl?q(ut,{src:nt.logoUrl,alt:`${nt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:g,children:nt.symbol.slice(0,3)})})}):void 0,children:[nt.symbol,q(N,{as:rr,boxSize:5,color:_})]}):J(j,{onClick:()=>S(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:v},children:[r(`Select token`),q(N,{as:rr,boxSize:5,color:_})]})]}),nt&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:_,children:[q(M,{spacing:2,alignItems:`center`,children:J(R,{color:_,children:[`≈`,` `,io(Ee,{currency:c})]})}),nt&&J(R,{noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:_,children:[r(`Balance`),`:`,` `,Number(nt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})}),q($e,{in:D&&!!Ce,animateOpacity:!0,children:J(z,{spacing:1,align:`stretch`,p:4,borderRadius:`2xl`,bg:h,children:[Ce&&J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:_,children:[r(`Source`),`:`]}),q(j,{variant:`outline`,size:`xs`,borderRadius:`full`,px:3,h:`auto`,py:1,cursor:`pointer`,onClick:()=>S(`select-quote`),color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:Ce.aggregator?.getIcon(`12px`),children:q(R,{fontSize:`xs`,color:g,children:Ce.aggregatorName})})]}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:_,children:[r(`Slippage tolerance`),`:`]}),J(R,{fontSize:`xs`,fontWeight:`medium`,color:g,children:[O,`%`]})]}),q(z,{spacing:3,align:`stretch`,pt:2,children:J(M,{spacing:2,children:[q(j,{size:`sm`,variant:`outline`,onClick:()=>{re(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ge?`rgb(96 66 221)`:`transparent`,color:ge?`white`:_,borderColor:ge?`rgb(96 66 221)`:_,_hover:{bg:ge?`rgb(96 66 221)`:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ge?.8:1},children:`Auto`}),q(j,{size:`sm`,variant:`outline`,onClick:()=>{re(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:O===.5?`rgb(96 66 221)`:`transparent`,color:O===.5?`white`:_,borderColor:O===.5?`rgb(96 66 221)`:_,_hover:{bg:O===.5?`rgb(96 66 221)`:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:O===.5?.8:1},children:`0.5%`}),q(j,{size:`sm`,variant:`outline`,onClick:()=>{re(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:O===3?`rgb(96 66 221)`:`transparent`,color:O===3?`white`:_,borderColor:O===3?`rgb(96 66 221)`:_,_hover:{bg:O===3?`rgb(96 66 221)`:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:O===3?.8:1},children:`3%`}),J(ft,{size:`sm`,flex:1,children:[q(dt,{value:ie,onChange:e=>{let t=e.target.value;if((/^\d*\.?\d*$/.test(t)||t===``)&&(ae(t),t!==``)){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&re(e)}},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:g}),q(mt,{width:`2rem`,pointerEvents:`none`,children:q(R,{fontSize:`2xs`,color:_,children:`%`})})]})]})})]}),J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:_,children:[r(`Fee`),`:`]}),q(R,{fontSize:`xs`,fontWeight:`medium`,color:g,children:Oe>0?`${Oe.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),Ce&&q(A,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(j,{variant:`ghost`,size:`xs`,onClick:()=>ne(!D),rightIcon:q(N,{color:v,_hover:{color:_},as:D?Xn:Kn}),fontSize:`xs`,fontWeight:`light`,color:v,_hover:{color:_},children:r(D?`Hide`:`Show Advanced Options`)})}),fe.length>0&&a.isConnectedWithPrivy&&q(Gp,{estimation:Ae,isLoading:je,isLoadingTransaction:ze,onTokenChange:Ie,clauses:fe,userSelectedToken:ue})]})})}),q(I,{children:q(Hp,{buttonText:r(ye?`Loading quote...`:`Swap`),onConfirm:Re,isSubmitting:ze,isTxWaitingConfirmation:Be,transactionPendingText:r(`Swapping...`),txReceipt:Ve,transactionError:Ue,onError:e=>{Ge(e)},isDisabled:!C||!T||!E||Number(E)<=0||ye||!Ce||Ce?.reverted===!0||!!(et&&E&&Number(E)>Number(et.balance))||Fe,gasEstimationError:Me,hasEnoughGasBalance:Le,isLoadingGasEstimation:je,showGasEstimationError:!u?.delegatorUrl&&a.isConnectedWithPrivy,context:`transaction`})})]})},rl=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=Y(),{isolatedView:i}=Yc(),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(Ja,{onClick:s}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,py:8,children:[q(N,{as:Ir,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(I,{children:q(j,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},il=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:r}=Q(),{t:a}=Y(),o=qs(e.name,r.network),s=B(`colors`,`vechain-kit-card`),c=B(`colors`,`vechain-kit-card-hover`),l=B(`colors`,`vechain-kit-border`),u=B(`colors`,`vechain-kit-text-primary`),f=B(`colors`,`vechain-kit-text-secondary`),p=B(`colors`,`vechain-kit-card`);return q(_t,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${l}`,_hover:{bg:t?c:s,borderColor:l},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:J(M,{spacing:3,align:`center`,children:[q(Vp,{props:{width:`40px`,height:`40px`,src:o.image??i(e.name),alt:e.name}}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:u,fontSize:`md`,fontWeight:`500`,children:d(e.name,24,0)}),t&&q(R,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&q(Nt,{size:`sm`,bg:p,color:u,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},al=({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(_t,{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(M,{spacing:3,align:`center`,children:[q(A,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:q(N,{as:Lr,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`)},ol=({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(Ie,{allowToggle:!0,children:q(Re,{border:`none`,children:({isExpanded:u})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[q(A,{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(N,{as:u?or:rr,fontSize:`20px`,color:l})]}),q(ze,{pb:4,pt:2,children:J(gt,{spacing:2,children:[e.map(e=>q(il,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&q(al,{onUnset:n})]})})]})})})},sl=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=Y(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=Yc(),[s,c]=G(Ri(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}=go(s),{data:S,isLoading:C}=po(`${s}.veworld.vet`),{data:w,isLoading:T}=Ao(s),{data:ee,isLoading:E}=Fo(i?.address,``),te=x||C||T;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,te]);let D=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},ne=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}})},O=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},re=()=>{t(n)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&q(Ja,{onClick:re}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,children:[q(ol,{domains:ee?.domains||[],onDomainSelect:ne,onUnsetDomain:O,isLoading:E}),J(ft,{size:`lg`,children:[q(dt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(Ri(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(mt,{width:`auto`,paddingRight:`12px`,h:`full`,children:q(A,{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(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||te,onClick:D,"data-testid":`continue-button`,children:r(`Continue`)})})]})},cl=({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}=Yc(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=Kf(u?.address??``,d?.address??``,3),{open:m}=Wd(),{preferences:h}=Fp(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=as({onSuccess:()=>te()}),y=n.endsWith(`veworld.vet`),b=So({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>te()}),x=Eo({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>te()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:T,isTransactionPending:ee,clauses:E}=i?v:y?b:x,te=()=>{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)}}})},D=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},ne=()=>{D()},O=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[re,ie]=V.useState(null),[ae,oe]=V.useState(null),se=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:k,isLoading:ce,error:le,refetch:ue}=Ip({clauses:E(),tokens:re?[re]:h.availableGasTokens,enabled:se&&!!g?.genericDelegatorUrl}),de=k?.usedToken,fe=(ce||!k)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,pe=V.useCallback(e=>{ie(e),oe(e),setTimeout(()=>ue(),100)},[ue]),me=!!de&&!le;return V.useEffect(()=>{le&&re&&ie(null)},[le,re]),J(K,{children:[J(Z,{children:[q(L,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),q(Ja,{onClick:O,isDisabled:ee}),q(F,{isDisabled:ee})]}),J(P,{children:[J(z,{spacing:4,w:`full`,textAlign:`center`,children:[q(R,{fontSize:`lg`,color:s,children:o(i?`Are you sure you want to unset your current domain?`:`Are you sure you want to set your domain name to`)}),!i&&q(R,{fontSize:`xl`,fontWeight:`bold`,color:s,"data-testid":`preconfirm-domain-val`,children:`${t}`})]}),f.isConnectedWithPrivy&&q(Gp,{estimation:k,isLoading:ce,isLoadingTransaction:ee,onTokenChange:pe,clauses:E(),userSelectedToken:ae})]}),q(I,{gap:4,w:`full`,children:q(Hp,{transactionError:w,isSubmitting:ee,isTxWaitingConfirmation:T,onConfirm:D,onRetry:ne,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:ee||fe,onError:_,gasEstimationError:le,hasEnoughGasBalance:me,isLoadingGasEstimation:ce,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},ll=()=>{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(ft,{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(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:a})})]}),c.length===0?J(z,{spacing:2,py:8,color:i,children:[q(N,{as:Fr,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(Ie,{allowMultiple:!0,children:c.map((e,t)=>q(Re,{border:`none`,mb:2,children:({isExpanded:t})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[q(A,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:i,children:e.question})}),q(N,{as:t?or:rr,fontSize:`20px`,opacity:.5})]}),q(ze,{pb:4,children:q(R,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},ul=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=Y(),{isolatedView:i}=Yc(),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-border`),s=B(`colors`,`vechain-kit-border-hover`);return J(Bp,{children:[J(Z,{children:[q(L,{children:r(`Help`)}),!i&&q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:6,align:`stretch`,children:[t&&q(Ot,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:va.map(e=>q(`option`,{value:e,children:ba[e]},e))}),q(j,{as:ht,href:`https://docs.vechainkit.vechain.org/`,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:q(N,{as:mr}),children:r(`For developers`)}),q(ll,{})]})}),q(I,{pt:0})]})},dl=({leftIcon:e,rightIcon:t,title:n,wallet:r,onClick:i,leftImage:a,isActive:o=!1})=>{let{t:s}=Y(),{darkMode:c}=$();return q(j,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:i,backgroundColor:`transparent`,border:`1px solid ${c?`#ffffff29`:`#ebebeb`}`,children:J(M,{w:`full`,justify:`space-between`,children:[q(A,{minW:`40px`,justifyContent:`center`,children:a?q(ut,{justifySelf:`center`,src:a,w:`28px`,alt:`left-image`}):q(N,{as:e,fontSize:`28px`})}),J(z,{textAlign:`left`,w:`full`,flex:1,children:[q(M,{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:r?.domain?d(r?.domain??``,18,0):l(r?.address??``,6,4)})]}),q(z,{minW:`40px`,justifyContent:`flex-end`,children:J(M,{justifyContent:`flex-end`,minW:`40px`,children:[o&&q(Nt,{size:`sm`,colorScheme:`green`,children:s(`Active`)}),q(N,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},fl=({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(j,{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(M,{w:`full`,justify:`space-between`,alignItems:`center`,children:[q(A,{minW:`40px`,h:`20px`,children:i?q(ut,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):q(N,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),q(z,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:J(M,{justify:`flex-start`,alignItems:`baseline`,children:[q(R,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&q(Nt,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&q(z,{minW:`40px`,justifyContent:`flex-end`,children:q(N,{as:t,fontSize:`20px`,opacity:.5})})]})})},pl=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:r,onClose:i,mt:a,style:o})=>{let[s,c]=G(!1),{disconnect:u}=Q(),f=async()=>{await ie(e?.domain??e?.address??``)&&(c(!0),setTimeout(()=>{c(!1)},2e3))},p=()=>{u(),i()};return J(M,{mt:a,w:`full`,...o,justifyContent:`flex-start`,alignItems:`center`,children:[q(j,{w:`full`,h:12,"aria-label":`Wallet`,onClick:r,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:J(M,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[J(M,{spacing:2,justifyContent:`flex-start`,children:[q(Vp,{wallet:e,props:{width:7,height:7}}),q(R,{fontSize:n,fontWeight:`500`,children:d(e?.domain??``,22,0)||l(e?.address??``,6,4)})]}),q(N,{boxSize:5,as:ar,cursor:`pointer`,opacity:.5})]})}),q(lt,{"aria-label":`Copy address`,icon:q(N,{as:s?nr:dr}),onClick:f,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8}}),q(lt,{"aria-label":`Logout`,icon:q(N,{as:wr}),onClick:()=>t({type:`disconnect-confirm`,props:{onDisconnect:p,onBack:()=>t(`main`)}}),variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},colorScheme:`red`})]})},ml=({address:e,maxIcons:t=3,iconSize:n=20,ml:r=0,style:i,iconsGap:a=0,rightIcon:o,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=Y(),{tokensWithBalance:d}=ms({address:e}),{darkMode:f}=$(),m=B(`colors`,`vechain-kit-text-secondary`),h=a<1?`-${n/2}px`:`${a}px`,g=d.slice(0,t),_=d.length-t;return!e||d.length===0&&!c?null:J(M,{spacing:0,ml:r,...i,onClick:l,children:[J(M,{spacing:0,children:[g.map((e,t)=>q(Qe,{ml:t>0?h:`0`,zIndex:t,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:s[e.symbol]?V.cloneElement(s[e.symbol],{width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):p[e.symbol]?q(ut,{src:p[e.symbol],alt:`${e.symbol} logo`,width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):q(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:e.symbol.slice(0,3)})},e.symbol)),_>0&&q(Qe,{ml:h,zIndex:g.length,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:J(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,_]})}),d.length===0&&c&&q(R,{fontSize:`sm`,color:m,fontWeight:`700`,children:u(`No assets`)})]}),o]})},hl=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=Y(),{account:i}=Q(),{formattedBalance:a,isLoading:o}=hs({address:i?.address??``}),{refresh:s}=Js(),[c,l]=G(!1),u=B(`colors`,`vechain-kit-text-secondary`),d=async()=>{l(!0),await s(),setTimeout(()=>{l(!1)},1500)};return J(z,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[J(M,{w:`full`,justifyContent:`flex-start`,alignItems:`center`,spacing:2,role:`group`,children:[q(ct,{size:`xs`,fontWeight:`500`,color:u,children:r(`Assets`)}),q(A,{display:`flex`,alignItems:`center`,justifyContent:`center`,w:`32px`,h:`32px`,children:q(lt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:d,icon:q(N,{as:Ar,boxSize:4}),isLoading:o||c,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}})})]}),q(j,{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:[q(ct,{size:`2xl`,fontWeight:`700`,children:a}),q(M,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:q(ml,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:q(N,{as:ar,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},gl=[{icon:Zn,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{icon:Jn,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{icon:qn,label:`Receive`,onClick:e=>{e(`receive-token`)}}],_l=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=Y();return q(lt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:J(z,{spacing:4,children:[q(N,{as:e,boxSize:5,opacity:.9}),J(M,{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(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},vl=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hasAnyBalance:o}=hs({address:n?.address??``}),{data:s}=Kf(r?.address??``,i?.address??``,3),c=a.isConnectedWithPrivy&&s;return q(ot,{templateColumns:`repeat(3, 1fr)`,gap:2,w:`full`,mt:e,children:gl.map(e=>q(_l,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(o),showRedDot:c&&e.label===`Settings`},e.label))})},yl=()=>{let[e,t]=G(!0),n=`vechain_kit_feature_announcement_closed`;return U(()=>{w(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{h(n,`true`),t(!1)}}},bl=({setCurrentContent:e})=>{let{t}=Y(),{isVisible:n,closeAnnouncement:r}=yl(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return n?q(Ge,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`main`),initialContentSource:`main`}}),r()},cursor:`pointer`,_hover:{opacity:.8},children:q(Ke,{p:4,children:J(M,{justify:`space-between`,align:`flex-start`,spacing:3,children:[J(z,{align:`flex-start`,spacing:1,children:[J(M,{spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`400`,color:i,children:t(`Claim your vet domain!`)}),q(Nt,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),q(R,{fontSize:`xs`,color:a,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]}),q(lt,{size:`sm`,variant:`ghost`,colorScheme:`gray`,icon:q(ur,{}),onClick:e=>{e.stopPropagation(),r()},"aria-label":t(`Close announcement`)})]})})}):null},xl=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},Sl=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{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.`)})]})})})},Cl=()=>{let{t:e}=Y(),{getConnectionCache:t}=$d(),n=t();return J(Ge,{variant:`vechainKitBase`,w:`full`,children:[J(Je,{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(Ke,{borderRadius:`none`,children:J(z,{spacing:3,align:`stretch`,children:[J(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:zr})}),J(A,{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(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:Pr})}),J(A,{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(qe,{children:J(j,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??`https://governance.vebetterdao.org/`,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),q(N,{as:mr,ml:2})]})})]})},wl=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:n}=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=$t(null),u=$t(null),[d,f]=G(!1),{onUpload:p}=uc({compressImage:!0}),[m,h]=G(null),[g,_]=G(null),v=!!a?.domain,[y,b]=G(null),[x,S]=G(``),[C,w]=G(``),{register:T,watch:ee,formState:{errors:E,isValid:te}}=Li({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 D=ee(),ne=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 r(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 O=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),D.displayName!==x&&(e.displayName=D.displayName),D.description!==C&&(e.description=D.description),e},re=W(()=>{let e=O();return Object.keys(e).length>0},[O]),ie=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:O(),onDoneRedirectContent:t}})},ae=()=>{e(t)};return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Customization`)}),q(Ja,{onClick:ae}),q(F,{})]}),J(P,{children:[J(A,{cursor:v?`pointer`:`default`,pt:2,display:`flex`,justifyContent:`center`,position:`relative`,onClick:()=>v&&l.current?.click(),children:[q(Vp,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&q(N,{as:tr,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&q(A,{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(Sl,{}),q(fl,{title:a?.domain??n(`Choose account name`),description:n(`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:Ir,rightIcon:ar,dataTestId:`set-domain-name-button`}),J(it,{isDisabled:!v,isInvalid:!!E.displayName,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Display Name`)}),q(dt,{...T(`displayName`,{maxLength:{value:25,message:n(`Display name must be less than 25 characters`)}}),placeholder:n(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(it,{isDisabled:!v,isInvalid:!!E.description,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Description`)}),q(Pt,{...T(`description`,{maxLength:{value:100,message:n(`Description must be less than 100 characters`)}}),placeholder:n(`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 ne(e)}),q(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),q(I,{w:`full`,children:q(j,{variant:`vechainKitPrimary`,onClick:ie,isDisabled:!v||!re||!te,isLoading:d,loadingText:n(`Preparing changes...`),"data-testid":`save-changes-button`,children:n(`Save Changes`)})})]})},Tl=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=Y(),{darkMode:i,network:a,feeDelegation:o}=$(),{account:s,connectedWallet:c,connection:l}=Q(),{preferences:u}=Fp(),{data:d}=Kf(s?.address??``,c?.address??``,3),{open:f}=Wd(),{handleSubmit:p}=Li({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),m=s?.domain??``,{data:h}=Ko(m),g=Vn(),{sendTransaction:_,txReceipt:v,error:y,isWaitingForWalletConfirmation:b,isTransactionPending:S,clauses:C}=Wo({resolverAddress:h,signerAccountAddress:s?.address??``,onSuccess:async()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:v?.meta.txID,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}});try{await pe()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),w=W(()=>{let e=s?.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,s?.domain]),T=W(()=>{try{return!h||w.length===0||!C?[]:C(w)}catch(e){return console.error(`Error building clauses:`,e),[]}},[w,C,h]),[ee,E]=V.useState(null),[te,D]=V.useState(null),ne=u.availableGasTokens.length>0&&(l.isConnectedWithPrivy||l.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:O,isLoading:re,error:ie,refetch:ae}=Ip({clauses:T,tokens:ee?[ee]:u.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),oe=O?.usedToken,se=(re||!O)&&l.isConnectedWithPrivy&&!o?.delegatorUrl,k=V.useCallback(e=>{E(e),D(e),setTimeout(()=>ae(),100)},[ae]),ce=!!oe&&!ie;V.useEffect(()=>{ie&&ee&&E(null)},[ie,ee]);let le=async()=>{if(d){f();return}try{w.length>0&&await _(w)}catch(e){console.error(`Error saving changes:`,e)}},ue=(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,de=()=>{p(le)()},fe=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},pe=async()=>{t.avatarIpfsHash&&(g.setQueryData(Io(m,a.type),x(`ipfs://`+t.avatarIpfsHash,a.type)),g.setQueryData(Yo(s?.address??``),x(`ipfs://`+t.avatarIpfsHash,a.type))),await g.invalidateQueries({queryKey:Bo(m,a.type)}),await g.refetchQueries({queryKey:Bo(m,a.type)})};return J(A,{as:`form`,onSubmit:p(le),children:[J(Z,{children:[q(L,{children:r(`Confirm Changes`)}),q(Ja,{isDisabled:S,onClick:fe}),q(F,{isDisabled:S})]}),J(P,{children:[J(z,{spacing:4,align:`stretch`,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&&ue(r(`Display Name`),t.displayName),t.description&&ue(r(`Description`),t.description),t.twitter&&ue(r(`Twitter`),t.twitter),t.website&&ue(r(`Website`),t.website),t.email&&ue(r(`Email`),t.email)]}),l.isConnectedWithPrivy&&q(Gp,{estimation:O,isLoading:re,isLoadingTransaction:S,onTokenChange:k,clauses:T,userSelectedToken:te})]}),q(I,{gap:4,w:`full`,children:q(Hp,{transactionError:y,isSubmitting:S,isTxWaitingConfirmation:b,onConfirm:p(le),onRetry:de,transactionPendingText:r(`Saving changes...`),txReceipt:v,buttonText:r(`Confirm`),isDisabled:S||se,gasEstimationError:ie,hasEnoughGasBalance:ce,isLoadingGasEstimation:re,showGasEstimationError:!o?.delegatorUrl&&l.isConnectedWithPrivy,context:`customization`})})]})},El=({onEditClick:e,address:t,showHeader:n=!0,onLogout:r,showLinks:a=!0,showDescription:o=!0,showDisplayName:s=!0,showEdit:c=!0})=>{let{t:l}=Y(),{account:u,disconnect:d}=Q(),{network:f}=$(),{openAccountModal:p,closeAccountModal:m}=hd(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=qs(t,f.type),v=i(t),y=t===u?.address,b=_?.records?.url||_?.records?.[`com.x`]||_?.records?.email,x=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}};return J(z,{spacing:4,w:`full`,children:[q(A,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,background:n?`no-repeat url('${v}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),q(Vp,{wallet:{address:t,domain:_?.domain,image:_?.image,isLoadingMetadata:_?.isLoading,metadata:_?.records},props:{width:`120px`,height:`120px`}}),J(z,{w:`full`,spacing:2,children:[s&&_?.records?.display&&q(R,{fontSize:`xl`,color:h,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:_?.records?.display}),o&&_?.records?.description&&q(R,{fontSize:`sm`,color:g,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:_?.records?.description}),a&&b&&J(M,{w:`full`,justify:`center`,spacing:5,mt:4,children:[_?.records?.email&&q(ht,{href:`mailto:${_?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:q(N,{as:Tr,color:h})}),_?.records?.url&&q(ht,{href:x(_.records.url)??void 0,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`website-link`,children:q(N,{as:yr,color:h})}),_?.records?.[`com.x`]&&q(ht,{href:`https://x.com/${encodeURIComponent(String(_.records[`com.x`]))}`,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`twitter-link`,children:q(N,{as:Vi,color:h})})]}),q(Ya,{wallet:{address:t,domain:_?.domain,image:_?.image,isLoadingMetadata:_?.isLoading,metadata:_?.records},style:{mt:4}})]}),y&&c&&J(M,{w:`full`,justify:`space-between`,spacing:4,mt:4,children:[q(j,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(N,{as:Dr}),onClick:e??(()=>{p({type:`account-customization`,props:{setCurrentContent:()=>m()}})}),"data-testid":`customize-button`,children:l(`Customize`)}),q(j,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(N,{as:wr}),colorScheme:`red`,onClick:r??(()=>{p({type:`disconnect-confirm`,props:{onDisconnect:()=>{d(),m()},onBack:()=>m()}})}),"data-testid":`logout-button`,children:l(`Logout`)})]})]})},Dl=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=Yc(),{account:i,disconnect:a}=Q();return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Profile`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,spacing:2,children:[!i?.domain&&q(bl,{setCurrentContent:e}),q(El,{onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,onLogout:()=>{e?.({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}})}})]})}),q(I,{pt:0})]})},Ol=({setCurrentContent:e,handleClose:t,initialContent:n=`settings`})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Kf(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Zf({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(Ja,{onClick:()=>{e(n)}}),q(F,{})]}),q(P,{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(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:Yn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{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(I,{justifyContent:`center`,children:J(z,{spacing:3,w:`full`,children:[q(Hp,{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(j,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},kl=({setCurrentContent:e})=>{let{account:t}=Q(),{sortedTokens:n}=ms({address:t?.address}),{allowCustomTokens:r,darkMode:i}=$(),{currentCurrency:a}=ps(),o=B(`colors`,`vechain-kit-text-tertiary`),{t:s}=Y(),{isolatedView:c}=Yc(),[l,u]=G(``),d=t=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:t,onBack:()=>e(`assets`)}})},f=n.filter(({symbol:e})=>e.toLowerCase().includes(l.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:s(`Assets`)}),!c&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[J(P,{children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12,value:l,onChange:e=>u(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:o})})]}),q(z,{spacing:2,align:`stretch`,mt:2,children:f.map(e=>{let t=Number(e.balance)>0;return q(ao,{symbol:e.symbol,amount:Number(e.balance),currencyValue:e.valueInCurrency,currentCurrency:a,onClick:()=>d(e),isDisabled:!t},e.address)})})]}),q(I,{children:r&&q(j,{variant:`vechainKitSecondary`,leftIcon:q(N,{as:Dr,boxSize:4}),onClick:()=>e(`add-custom-token`),children:s(`Manage Custom Tokens`)})})]})]})},Al=({setCurrentContent:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-primary`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-card`),a=B(`colors`,`vechain-kit-overlay`),{addToken:o,removeToken:s,isTokenIncluded:c,isDefaultToken:u,customTokens:d}=Cs(),{register:f,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=Li({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(c(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:t(`Token already added`)});try{await o(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token 2:`,e),m(`newTokenAddress`,{type:`manual`,message:t(`Invalid token address`)})}}};return J(K,{children:[J(Z,{children:[q(L,{children:t(`Manage Custom Tokens`)}),q(Ja,{onClick:()=>e(`assets`)}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,position:`relative`,children:[q(A,{p:6,borderRadius:`xl`,bg:i,children:q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!g.newTokenAddress,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:n,children:t(`Token Contract Address`)}),q(dt,{...f(`newTokenAddress`,{required:t(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:t(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||t(`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`}),g.newTokenAddress&&q(R,{color:`#ef4444`,fontSize:`sm`,children:g.newTokenAddress.message})]})})}),d.length>0&&J(A,{p:4,borderRadius:`xl`,bg:a,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,mb:2,children:t(`Existing Custom Tokens`)}),q(z,{align:`stretch`,spacing:2,children:d.map(e=>J(M,{justify:`space-between`,fontSize:`sm`,p:2,borderRadius:`md`,bg:i,children:[J(M,{children:[q(ut,{src:p[e?.symbol],alt:`${e.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:n,children:e.symbol?.slice(0,3)})})}),q(R,{fontWeight:`medium`,color:n,children:e.symbol??`Unknown`})]}),q(R,{color:r,children:l(e.address??``,4,4)}),q(j,{size:`sm`,variant:`ghost`,color:n,borderRadius:`md`,p:2,onClick:()=>s(e.address),children:q(Lr,{size:16,color:n})})]},e.address))})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!_,onClick:v(y),children:t(`Add Token`)})})]})},jl=({setCurrentContent:e})=>{let{t}=Y(),{darkMode:n}=$(),{isolatedView:r}=Yc();return J(K,{children:[J(Z,{children:[q(L,{children:t(`Bridge`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(tt,{maxW:`container.lg`,children:q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[q(Oe,{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(I,{children:J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(`https://swap.vechain.energy/`,`_blank`)},children:[t(`Launch vechain.energy`),q(N,{as:mr,ml:2})]})})]})},Ml=({setCurrentContent:e})=>{let{t}=Y(),{currentCurrency:n,changeCurrency:r,allCurrencies:i}=ps(),a=Kt(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`);U(()=>{h(`settings-currency-visited`,`true`)},[]);let o=e=>{let t=n===e;return J(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>r(e),py:6,px:4,bg:t?a:void 0,children:[J(M,{spacing:3,children:[q(R,{fontSize:`xl`,children:c[e]}),q(R,{children:e.toUpperCase()})]}),t&&q(N,{as:nr,boxSize:5,color:`blue.500`})]},e)};return J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Select currency`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:i.map(e=>o(e))})}),q(I,{pt:0})]})},Nl=({setCurrentContent:e})=>{let{t,i18n:n}=Y(),r=Kt(`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(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:t?r:void 0,children:[q(R,{children:ba[e]}),t&&q(N,{as:nr,boxSize:5,color:`blue.500`})]},e)};return J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Select language`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:va.map(e=>a(e))})}),q(I,{pt:0})]})},Pl=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:o,onTouchStart:s,onTouchMove:c,onTouchEnd:l,isDragging:u,isDraggedOver:d})=>{let p=f[e],{darkMode:m}=$(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-card`);return q(A,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:u?m?`blue.500`:`blue.300`:d?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:u||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:()=>o(t),onTouchStart:e=>s(t,e),onTouchMove:c,onTouchEnd:l,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:J(M,{justify:`space-between`,children:[J(M,{opacity:n?.5:1,children:[q(A,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:q(N,{as:br,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(Mt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},Fl=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=G(null),[o,s]=G(null),c=$t([]),l=$t(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(A,{w:`full`,children:e.map((e,n)=>q(A,{ref:e=>{c.current[n]=e},children:q(Pl,{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))})},Il=({setCurrentContent:e})=>{let{t}=Y(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Fp(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=H(e=>{r(e)},[r]);return J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Gas Token Preferences`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{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(Be,{status:`warning`,borderRadius:`md`,children:[q(He,{}),q(Ve,{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(Fl,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},Ll=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=Yc(),{exportWallet:i,linkPasskey:a}=En(),{showMfaEnrollmentModal:o}=Tn(),{feeDelegation:s}=$(),{connection:c,disconnect:l,smartAccount:u,connectedWallet:d}=Q(),{data:f}=Kf(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(A,{children:[J(Z,{children:[q(L,{children:n(`Settings`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(P,{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(fl,{title:n(`Currency`),onClick:()=>{e(`change-currency`)},leftIcon:fr,rightIcon:ar}),q(fl,{title:n(`Language`),onClick:()=>{e(`change-language`)},leftIcon:Sr,rightIcon:ar}),c.isConnectedWithPrivy&&!s?.delegatorUrl&&q(fl,{title:n(`Gas Token Preferences`),onClick:()=>{e(`gas-token-settings`)},leftIcon:gr,rightIcon:ar}),q(fl,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:Nr,rightIcon:ar})]}),f&&q(z,{w:`full`,spacing:2,mt:4,children:q(fl,{title:n(`Upgrade Smart Account to V3`),description:n(`A new version is available for your account`),onClick:p,leftIcon:Mr,extraContent:q(A,{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(fl,{title:n(`Passkey`),onClick:()=>a(),leftIcon:hr}),q(fl,{title:n(`Backup`),onClick:()=>{i()},leftIcon:xr}),q(fl,{title:n(`Manage MFA`),onClick:()=>{o()},leftIcon:Pr}),q(fl,{title:n(`Login methods`),onClick:()=>{e(`privy-linked-accounts`)},leftIcon:zr,rightIcon:ar})]}),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(fl,{title:n(`Frequently asked questions`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:lr,rightIcon:ar}),q(fl,{title:n(`Connection details`),onClick:m,leftIcon:Rr,rightIcon:ar}),q(fl,{title:n(`Explore ecosystem`),onClick:()=>e(`ecosystem`),leftIcon:Cr,rightIcon:ar})]})]}),q(I,{w:`full`,children:J(z,{w:`full`,spacing:4,children:[q(nt,{}),q(fl,{title:n(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:h,onBack:()=>e(`settings`)}}),leftIcon:wr})]})})]})},Rl=({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(N,{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})]})]})},zl=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),Bl=({document:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===m.VECHAIN_KIT&&e.documentType===se.TERMS;return J(M,{children:[J(Nt,{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:zl(e.timestamp)})})]})},Vl=({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(Re,{border:`none`,mb:3,children:({isExpanded:l})=>J(K,{children:[J(Le,{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(N,{as:l?or:rr,fontSize:`20px`,color:c})]}),q(ze,{pb:4,pt:3,children:J(z,{align:`stretch`,spacing:4,children:[u?.id?J(M,{w:`full`,children:[q(N,{as:nr,color:s}),q(R,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:zl(u.timestamp)})})]}):null,q(M,{w:`full`,textAlign:`left`,children:q(R,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),q(M,{w:`full`,gap:2,children:q(z,{align:`stretch`,spacing:2,children:n.map(e=>q(Bl,{document:e},e.id))})}),a&&q(j,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Hl=()=>{let{account:e}=Q(),{t}=Y(),{darkMode:n}=$(),{agreements:r,documents:i}=nm(),a=W(()=>{let t=r?.filter(t=>o(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...E,documentType:se.TERMS,documentSource:m.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),s=W(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),c=W(()=>Object.values(a).some(e=>e.length>0),[a]),l=n?`whiteAlpha.50`:`blackAlpha.50`,u=n?`whiteAlpha.100`:`blackAlpha.100`;return c?q(z,{spacing:4,align:`stretch`,children:J(Ie,{allowMultiple:!0,children:[q(Vl,{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[se.TERMS],bg:l,hoverBg:u,currentPolicy:s[se.TERMS]}),q(Vl,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[se.PRIVACY],bg:l,hoverBg:u,currentPolicy:s[se.PRIVACY]}),q(Vl,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[se.COOKIES],bg:l,hoverBg:u,currentPolicy:s[se.COOKIES]})]})}):q(Rl,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:_r})},Ul=({onGoBack:e})=>{let{t}=Y();return J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Terms and Policies`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:q(z,{spacing:6,align:`stretch`,children:q(Hl,{})})}),q(I,{pt:0})]})},Wl=({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(Bp,{children:[J(Z,{children:[q(L,{children:a(`Logout`)}),q(Ja,{onClick:t}),r?q(F,{onClick:n}):null]}),q(P,{children:q(z,{spacing:6,align:`stretch`,children:q(R,{fontSize:`md`,textAlign:`center`,color:o,children:s})})}),q(I,{w:`full`,children:J(z,{spacing:3,w:`full`,children:[q(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:e,"data-testid":`disconnect-button`,children:a(`Confirm`)}),q(j,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},Gl=Za[`@vechain/dapp-kit-react`]||Qa[`@vechain/dapp-kit-react`]||`unknown`,Kl=Za[`@privy-io/react-auth`]||`unknown`,ql=({connectionCache:e})=>{let{t}=Y(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{source:a}=Fn(),{privy:o,network:s}=$(),c=o?.appId,{data:u,isLoading:d}=co(c||[]),{onCopy:f,hasCopied:p}=Wt(``),{data:m,isLoading:h}=uo(),{data:g,isLoading:_}=jf(r.address??``,i?.address??``),v=B(`colors`,`vechain-kit-card`),y=B(`colors`,`vechain-kit-text-secondary`),b=B(`colors`,`vechain-kit-text-primary`),x=(()=>n.isConnectedWithCrossApp&&e?.ecosystemApp?e.ecosystemApp.name:n.isConnectedWithSocialLogin&&u?Object.values(u)[0]?.name??null:n.isConnectedWithDappKit&&a?a:null)(),S=n.isConnectedWithSocialLogin&&d,C=({label:e,value:t,isLoading:n=!1,href:r})=>J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:b,children:[e,`:`]}),q(R,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:y,children:n?`Loading...`:t})]});return S?q(z,{w:`full`,h:`full`,justify:`center`,align:`center`,minH:`200px`,borderRadius:`xl`,bg:v,children:q(At,{})}):x?J(z,{p:4,bg:v,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[q(C,{label:t(`Logged in with`),value:x}),n.isConnectedWithCrossApp&&e?.timestamp&&q(C,{label:t(`At`),value:new Date(e.timestamp).toLocaleString()}),q(C,{label:t(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),q(nt,{}),q(C,{label:t(`Network`),value:s.type}),q(C,{label:t(`Node URL`),value:s.nodeUrl||k(s.type).nodeUrl}),n.isConnectedWithPrivy&&q(nt,{}),n.isConnectedWithPrivy&&J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:b,children:[t(`Embedded wallet`),`:`]}),J(M,{children:[q(R,{fontSize:`sm`,color:y,children:i?.address?l(i.address,8,7):`-`}),q(N,{color:y,onClick:()=>{i?.address&&f(i.address)},opacity:i?.address?1:.4,pointerEvents:i?.address?`auto`:`none`,cursor:`pointer`,as:p?nr:dr})]})]}),n.isConnectedWithPrivy?J(K,{children:[q(C,{label:t(`Smart Account`),value:`v${g?.version??``} ${g?.isDeployed?``:`(not deployed)`}`,isLoading:_}),q(C,{label:t(`Privy Status`),value:m||``,isLoading:h})]}):r.isDeployed&&q(C,{label:t(`Smart Account`),value:`v${g?.version??``}`,isLoading:_}),q(nt,{}),q(C,{label:t(`VeChain Kit`),value:Xa,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`}),q(C,{label:`DAppKit`,value:Gl}),q(C,{label:`Privy`,value:Kl})]}):null},Jl=()=>{let{connection:e}=Q(),{t}=Y(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=$d(),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(M,{justify:`center`,children:[q(Se,{isDark:r,w:`50px`}),q(N,{as:Er,ml:3}),e.isConnectedWithVeChain?q(fe,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&q(ut,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&q(ut,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]}):null},Yl=({onGoBack:e})=>{let{t}=Y(),{getConnectionCache:n}=$d(),r=n()??void 0;return J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Connection Details`)}),q(Ja,{onClick:()=>{e()}}),q(F,{})]}),J(P,{w:`full`,children:[q(ql,{connectionCache:r}),q(Jl,{})]}),q(I,{pt:0})]})},Xl=({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(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),q(j,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Zl=({onBack:e})=>{let{t}=Y(),{privy:n,dappKit:r}=$(),[i,a]=G(null),[o,s]=G(!1),[c,u]=G(!1),[d,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:T,linkTelegram:ee,linkFarcaster:E,linkPasskey:te,linkDiscord:D,unlinkEmail:ne,unlinkGoogle:O,unlinkApple:re,unlinkSpotify:ie,unlinkInstagram:ae,unlinkTiktok:oe,unlinkGithub:se,unlinkLinkedIn:k,unlinkTelegram:ce,unlinkFarcaster:le,unlinkPhone:ue,unlinkPasskey:de,unlinkDiscord:fe,linkWallet:pe}=Dn(),me=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]),he=e=>{switch(e){case`google_oauth`:return Ii;case`email`:return Tr;case`passkey`:return hr;case`wallet`:return Br;case`twitter_oauth`:return Vi;case`phone`:return Or;case`spotify_oauth`:return qi;case`apple_oauth`:return Ui;case`instagram_oauth`:return Gi;case`tiktok_oauth`:return Xi;case`github_oauth`:return vr;case`linkedin_oauth`:return Ki;case`telegram`:return Ji;case`farcaster`:return Hi;case`discord_oauth`:return Wi;default:return}},ge=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},_e=async e=>{if(ge()){f(!0);try{switch(e.type){case`google_oauth`:await O(e.subject);break;case`email`:await ne(e.address);break;case`passkey`:await de(e.subject);break;case`phone`:await ue(e.number);break;case`spotify_oauth`:await ie(e.subject);break;case`apple_oauth`:await re(e.subject);break;case`instagram_oauth`:await ae(e.subject);break;case`tiktok_oauth`:await oe(e.subject);break;case`github_oauth`:await se(e.subject);break;case`linkedin_oauth`:await k(e.subject);break;case`telegram`:await ce(e.subject);break;case`farcaster`:await le(e.subject);break;case`discord_oauth`:await fe(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},ve=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`${l(e.address)} - ${e.walletClientType}`;default:return``}},ye=h?.linkedAccounts?.map(e=>e.type)||[],be=n?.loginMethods||[],xe=!ye.includes(`google_oauth`)&&be.includes(`google`),Se=!ye.includes(`email`)&&be.includes(`email`),Ce=!ye.includes(`twitter_oauth`)&&be.includes(`twitter`),we=!ye.includes(`phone`)&&be.includes(`sms`),Te=!ye.includes(`spotify_oauth`)&&be.includes(`spotify`),Ee=!ye.includes(`apple_oauth`)&&be.includes(`apple`),De=!ye.includes(`instagram_oauth`)&&be.includes(`instagram`),Oe=!ye.includes(`tiktok_oauth`)&&be.includes(`tiktok`),ke=!ye.includes(`github_oauth`)&&be.includes(`github`),Ae=!ye.includes(`linkedin_oauth`)&&be.includes(`linkedin`),je=!ye.includes(`telegram`)&&be.includes(`telegram`),Me=!ye.includes(`farcaster`)&&be.includes(`farcaster`),Ne=!ye.includes(`discord_oauth`)&&be.includes(`discord`);return o?J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Select Additional Login Method`)}),q(Ja,{onClick:()=>s(!1)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:3,align:`stretch`,w:`full`,children:[q(fl,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>te(),leftIcon:hr}),xe&&q(fl,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:Ii}),Se&&q(fl,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Tr,stacked:!0}),Ce&&q(fl,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:Vi}),we&&q(fl,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:Or}),Te&&q(fl,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:qi}),Ee&&q(fl,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:Ui}),De&&q(fl,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:Gi}),Oe&&q(fl,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:Xi}),ke&&q(fl,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:vr}),Ae&&q(fl,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>T(),leftIcon:Ki}),je&&q(fl,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>ee(),leftIcon:Ji}),Me&&q(fl,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>E(),leftIcon:Hi}),Ne&&q(fl,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>D(),leftIcon:Wi}),me&&q(fl,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>pe(),leftIcon:Br}),!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),q(I,{pt:0})]}):i?J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Remove Login Method`)}),q(Ja,{onClick:()=>a(null)}),q(F,{})]}),q(P,{children:q(Xl,{accountType:i.type,accountDescription:ve(i),isLoading:d,onConfirm:()=>_e(i),onCancel:()=>a(null)})}),q(I,{pt:0})]}):J(Bp,{children:[J(Z,{children:[q(L,{children:t(`Login methods`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{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(j,{variant:`link`,mt:0,size:`sm`,onClick:()=>u(!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(rt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[J(rt,{align:`center`,gap:3,children:[q(N,{as:he(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:ve(e)})]})]}),q(j,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!ge(),onClick:()=>{e.type===`passkey`?te():a(e)},children:t(`Remove`)})]},e.type))]})}),q(I,{w:`full`,children:q(j,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:q(N,{as:kr}),isDisabled:!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne,children:t(`Add Login Method`)})})]})},Ql=[{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}],$l=()=>{let{t:e}=Y(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=eu(),{data:o}=Yf(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])},eu=()=>{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||!y())return;let n=t(e.address);w(n.initialized)||(h(n.notifications,JSON.stringify(Ql)),h(n.initialized,`true`))},[e?.address,t]);U(()=>{n()},[n]);let r=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r(),o=w(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};h(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r().filter(e=>e.id!==n);h(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:H(()=>{if(!e?.address||!y())return;let n=t(e.address),a=r();h(n.archived,JSON.stringify([...i(),...a])),h(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:H(n=>{if(!e?.address||!y())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];h(a.notifications,JSON.stringify(l)),h(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},tu=({showArchived:e})=>{let{t}=Y();return q(Rl,{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?Gn:Qn})},nu=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=Y(),i=()=>{n(e.id)};return e.isRead&&!t?null:J(Be,{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(He,{boxSize:`16px`}),J(A,{children:[q(Ue,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),q(Ve,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&q(lt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:q(ur,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},ru=({setCurrentContent:e})=>{let{t}=Y(),{isolatedView:n}=Yc(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=eu(),[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(Bp,{children:[J(Z,{children:[!n&&q(Ja,{onClick:()=>e(`main`)}),q(L,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[q(P,{children:J(z,{spacing:4,align:`stretch`,w:`full`,children:[J(M,{justify:`space-between`,children:[q(j,{variant:`ghost`,leftIcon:q(N,{as:s?Qn:Gn}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&q(j,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?q(tu,{showArchived:s}):q(z,{spacing:3,children:_.map(e=>q(nu,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),q(I,{pt:0})]})]})},iu=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`}},au=({category:e,...t})=>{let{t:n}=Y(),r=e.toLowerCase();return q(Nt,{size:`sm`,colorScheme:iu(r),borderRadius:`full`,px:2,...t,children:n(r)})},ou=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>J(Ge,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&q(A,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:q(au,{category:r})}),q(Ke,{p:a===`sm`?2:4,alignItems:`center`,children:J(z,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&q(ut,{src:t,fallbackSrc:D,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&q(R,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),su=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=Zs(e.id),{data:a,isLoading:o}=ic(r?.logo);return q(kt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:q(ou,{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}})}})})},cu=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>q(ou,{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}}),lu=({})=>{let{t:e}=Y(),{shortcuts:t}=Dp();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(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>q(st,{children:q(Ge,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:q(Ke,{p:2,alignItems:`center`,children:q(ut,{src:e.image,fallbackSrc:D,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},uu=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=Y();return J(A,{width:`full`,mb:4,children:[q(R,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),J(It,{spacing:2,children:[q(Lt,{children:q(Nt,{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(Lt,{children:q(au,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},du=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:`https://governance.vebetterdao.org/`,logo:`https://i.ibb.co/cgJBj83/vbd.png`,banner:`https://i.ibb.co/cgJBj83/vbd.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://i.ibb.co/cgJBj83/vbd.png`},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:`https://vet.domains`,logo:`https://vet.domains/assets/walletconnect.png`,banner:`https://vet.domains/assets/walletconnect.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://vet.domains/assets/walletconnect.png`},categories:[]}],fu=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=Y(),{darkMode:r,network:i}=$(),{isolatedView:a}=Yc(),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}=ys(),{data:f}=Vs(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=sf(),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=du.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}=Dp();return J(A,{children:[J(Z,{children:[q(L,{children:n(`Ecosystem`)}),!a&&q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{overflowY:`auto`,minH:`300px`,children:J(z,{spacing:6,w:`full`,children:[q(lu,{setCurrentContent:e}),S.length>0&&q(R,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),J(ft,{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(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:o})})]}),g.length>0&&q(uu,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),J(ot,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&q(K,{children:v.map(t=>q(st,{children:q(cu,{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(st,{children:q(su,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?q(st,{colSpan:2,children:q(Ye,{py:4,children:q(At,{})})}):h?q(st,{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(st,{children:q(cu,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&q(st,{colSpan:2,children:q(Ye,{py:4,children:q(R,{children:n(`No apps found in this category`)})})})]})]})}),q(I,{pt:0})]})},pu=({name:e,image:t,url:n,description:r})=>{let{t:i}=Y(),{isShortcut:a,addShortcut:o,removeShortcut:s}=Dp(),c=a(n);return q(j,{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(N,{as:c?er:$n}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},mu=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=Y();return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(Ja,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[J(rt,{direction:`column`,align:`center`,children:[s||q(ut,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&q(M,{mt:2,children:q(au,{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(I,{children:J(z,{w:`full`,spacing:4,children:[J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),q(N,{as:mr,ml:2})]}),q(pu,{name:t,image:n,url:r,description:i})]})})]})},hu=({children:e})=>q(Wn.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}),gu=({descriptionEncoded:e})=>{let{darkMode:t}=$();return J(M,{gap:2,children:[q(hu,{children:q(ht,{href:`https://twitter.com/intent/tweet?text=${e}`,isExternal:!0,children:q(A,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:q(Vi,{size:22})})})}),q(hu,{children:q(ht,{href:`https://telegram.me/share/url?url=${e}`,isExternal:!0,children:q(A,{bg:`#30abec`,p:2,borderRadius:`full`,children:q(Yi,{color:`white`,size:22})})})}),q(hu,{children:q(ht,{href:`https://wa.me/?text=${e}`,isExternal:!0,children:q(A,{bg:`#01cb37`,p:2,borderRadius:`full`,children:q(Zi,{size:22,color:`white`})})})})]})},_u=({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(At,{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(N,{as:sr,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(N,{as:cr,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=`${k(s.type).explorerUrl}/${r?.meta.txID}`;return J(A,{children:[J(Z,{children:[q(L,{children:p.title}),q(F,{isDisabled:e===`pending`&&!t?.isClosable})]}),q(P,{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(gu,{descriptionEncoded: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(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[e===`error`&&!!n&&J(j,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[q(N,{mr:2,as:Ar}),o(`Try again`)]}),e===`ready`&&q(j,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&q(j,{onClick:a,variant:`vechainKitSecondary`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&q(ht,{href:`${k(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:o(`View transaction on the explorer`)}),q(N,{size:`sm`,as:mr,color:d})]})})]})})]})},vu=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:q(_u,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})}),yu=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(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(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:cr,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(gu,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:a(`View transaction on the explorer`)}),q(N,{size:16,as:mr})]})})]})})]})},bu=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=Y(),{network:a,darkMode:o}=$(),s=k(a.type).explorerUrl;return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:sr,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:i(`View transaction on the explorer`)}),q(N,{size:16,as:mr})]})})]})})]})},xu={enter:e=>({opacity:0,x:e===`forward`?20:-20}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e===`forward`?-20:20})},Su={duration:.17,ease:[.4,0,.2,1]},Cu=e=>{if(typeof e==`string`)return e;let t=e.type,n=JSON.stringify(e.props),r=0;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);r=(r<<5)-r+t,r&=r}return`${t}-${Math.abs(r)}`},wu=({isOpen:e,onClose:t,initialContent:n=`main`})=>{$l();let{account:r}=Q(),i=$t(null),a=$t(`forward`),{accountModalContent:o,setAccountModalContent:s}=hd();U(()=>{e&&n&&s(n)},[e,n,s]);let c=(()=>{if(i.current===null||i.current===o)return a.current;let e=Cu(i.current),t=Cu(o);return t===`main`||t===`settings`&&e!==`main`||e.includes(`summary`)||e.includes(`confirm`)||e.includes(`operation`)?`backward`:`forward`})();U(()=>{a.current=c,i.current=o},[o,c]);let l=(()=>{if(typeof o==`object`)switch(o.type){case`send-token`:return q(Xc,{...o.props});case`send-token-summary`:return q(Zc,{...o.props});case`swap-token`:return q(nl,{...o.props});case`choose-name`:return q(rl,{...o.props});case`choose-name-search`:return q(sl,{...o.props});case`choose-name-summary`:return q(cl,{...o.props});case`app-overview`:return q(mu,{...o.props,setCurrentContent:s});case`disconnect-confirm`:return q(Wl,{...o.props});case`account-customization`:return q(wl,{...o.props});case`account-customization-summary`:return q(Tl,{...o.props});case`successful-operation`:return q(yu,{...o.props});case`failed-operation`:return q(bu,{...o.props});case`upgrade-smart-account`:return q(Ol,{...o.props});case`faq`:return q(ul,{...o.props});case`terms-and-privacy`:return q(Ul,{...o.props});case`ecosystem-with-category`:return q(fu,{setCurrentContent:s,selectedCategory:o.props.selectedCategory})}switch(o){case`main`:return q(qc,{setCurrentContent:s,onClose:t,wallet:r});case`settings`:return q(Ll,{setCurrentContent:s,onLogoutSuccess:()=>{t()}});case`profile`:return q(Dl,{setCurrentContent:s,onLogoutSuccess:()=>{t()}});case`assets`:return q(kl,{setCurrentContent:s});case`bridge`:return q(jl,{setCurrentContent:s});case`notifications`:return q(ru,{setCurrentContent:s});case`receive-token`:return q(Qc,{setCurrentContent:s});case`swap-token`:return q(nl,{setCurrentContent:s});case`connection-details`:return q(Yl,{onGoBack:()=>s(`settings`)});case`privy-linked-accounts`:return q(Zl,{onBack:()=>s(`settings`)});case`ecosystem`:return q(fu,{setCurrentContent:s});case`add-custom-token`:return q(Al,{setCurrentContent:s});case`change-currency`:return q(Ml,{setCurrentContent:s});case`change-language`:return q(Nl,{setCurrentContent:s});case`gas-token-settings`:return q(Il,{setCurrentContent:s});default:return null}})(),u=Cu(o);return q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:q(Un,{mode:`wait`,initial:!1,children:l&&q(Wn.div,{custom:a.current,variants:xu,initial:`enter`,animate:`center`,exit:`exit`,transition:Su,style:{width:`100%`},children:l},u)})})},Tu=({isOpen:e,onClose:t})=>{let[n,r]=G(`main`);return U(()=>{e&&r(`main`)},[e]),q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:(()=>{switch(n){case`main`:return q(Gc,{setCurrentContent:r,onClose:t});case`faq`:return q(ul,{onGoBack:()=>r(`main`)})}})()})},Eu=({onClick:e,text:t,icon:n,customIcon:r,rightIcon:i,style:a,variant:o=`loginIn`,iconWidth:s=`25px`})=>t?t?J(j,{...a,variant:o,w:`full`,onClick:e,children:[J(M,{w:`full`,justify:`flex-start`,gap:2,children:[r||q(N,{as:n,w:s,h:s}),q(R,{opacity:.9,children:t})]}),i]}):null:q(j,{...a,variant:o,w:`full`,onClick:e,children:r||q(N,{as:n,w:`20px`,h:`20px`})}),Du=({isLoading:e,buttonStyle:t})=>{let{t:n}=Y(),{loginMethods:r,darkMode:i,privyEcosystemAppIDS:a}=$(),o=r?.some(({method:e})=>e===`ecosystem`),{data:s,isLoading:c}=co(a);return q(Ct,{placement:`bottom-start`,size:`xl`,closeOnBlur:!1,variant:`vechainKitBase`,children:({isOpen:r})=>J(K,{children:[q(Dt,{children:J(j,{isLoading:e,...t,isActive:r,children:[n(`Login`),q(N,{ml:2,as:rr,transform:r?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`})]})}),J(Tt,{children:[q(wt,{children:q(Uc,{})}),q(Et,{borderTop:`none`,pb:`15px`,children:o&&q(M,{justify:`center`,w:`full`,children:q(Wc,{isDark:i,appsInfo:Object.values(s||{}),isLoading:c})})})]})]})})},Ou=({variant:e})=>{let{account:t}=Q();return t?e===`icon`?null:e===`iconAndDomain`?t.domain?q(R,{fontSize:`sm`,children:d(t?.domain??``,16,0)}):q(R,{fontSize:`sm`,children:l(t.address??``,6,4)}):e===`iconDomainAndAssets`?J(M,{spacing:4,children:[J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,"data-testid":`trimmed-address`,children:l(t.address??``,4,4)})]}),q(ml,{address:t.address??``,maxIcons:3})]}):J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,children:l(t.address??``,4,4)})]}):q(At,{})},ku=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconAndDomain`,onOpen:n,buttonStyle:r={}})=>{let{account:i}=Q(),[a]=Jt(`(min-width: 768px)`);return q(j,{...r,onClick:n,w:`full`,minH:`45px`,maxW:`fit-content`,"data-testid":`wallet-button`,children:J(M,{w:`full`,minW:`fit-content`,children:[q(Vp,{wallet:i,props:{width:30,height:30,minWidth:30,minHeight:30}}),q(Ou,{variant:a?t:e})]})})},Au=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconDomainAndAddress`,buttonStyle:n,connectionVariant:r=`modal`})=>{let{t:i}=Y(),{darkMode:a,loginMethods:o}=$(),s=o?.length===1&&o[0].method===`dappkit`,{connection:c,account:l}=Q(),{setSource:u,connectV2:d}=Pn(),[f]=Jt(`(max-width: 768px)`),p=qt(),m=qt(),{open:h}=In();return J(pd,{darkMode:a,children:[c.isConnected&&l?q(ku,{mobileVariant:e,desktopVariant:t,onOpen:m.onOpen,buttonStyle:n}):r===`popover`&&!f?q(Du,{isLoading:c.isLoading,buttonStyle:n}):q(j,{isLoading:c.isLoading,onClick:()=>{c.isInAppBrowser?(u(`veworld`),d(null)):s?h():p.onOpen()},...n,children:i(`Login`)}),q(Tu,{isOpen:p.isOpen,onClose:p.onClose}),q(wu,{isOpen:m.isOpen,onClose:m.onClose})]})},ju=()=>{let{darkMode:e}=$(),t=25/2,[n]=Jt(`(max-width: 280px)`),[r]=Jt(`(max-width: 380px)`);return J(M,{spacing:0,ml:0,children:[q(Qe,{size:`25px`,borderRadius:`full`,bg:`#F8F8F8`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:3,children:q(N,{as:Ii,fontSize:`20px`})}),!n&&q(Qe,{ml:`-${t}px`,size:`25px`,borderRadius:`full`,bg:`black`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:2,children:q(N,{as:Vi,color:`white`,fontSize:`20px`})}),!n&&!r&&q(Qe,{ml:`-${t}px`,zIndex:1,size:`25px`,borderRadius:`full`,bg:`#5865F2`,p:2,alignItems:`center`,justifyContent:`center`,children:q(N,{as:Bi,color:`white`,fontSize:`20px`})}),q(N,{zIndex:1,as:kr,color:e?`black`:`white`,fontSize:`15px`})]})},Mu=({status:e,txReceipt:t,txError:n,onTryAgain:r,description:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=k(s.type).explorerUrl,l=W(()=>n?n.reason||o(`Something went wrong. Please try again.`):null,[n,o]),u=(()=>{let t=e===`waitingConfirmation`;switch(t&&(e=`pending`),e){case`pending`:return{icon:q(At,{size:`md`,"data-testid":`pending-spinner-toast`}),title:o(t?`Processing transaction...`:`Waiting for confirmation...`),closeDisabled:!0,description:t?o(`Transaction is being processed, it can take up to 15 seconds.`):i??o(`Please confirm the transaction in your wallet.`)};case`error`:return{icon:q(N,{as:sr,color:`red.500`,fontSize:`40px`,"data-testid":`error-icon-toast`}),title:o(`Transaction failed`),closeDisabled:!1,description:l};case`success`:return{icon:q(N,{as:cr,color:`green.500`,fontSize:`40px`,"data-testid":`success-icon-toast`}),title:o(`Transaction successful!`),closeDisabled:!1,description:void 0};case`ready`:return{icon:null,title:o(`Confirm transaction`),closeDisabled:!1,description:i??o(`Confirm the transaction in your wallet to complete it.`)};default:return{icon:null,title:``,closeDisabled:!1,description:``}}})();return u?J(M,{justify:`space-between`,alignItems:`flex-start`,w:`full`,children:[q(z,{spacing:4,children:J(M,{spacing:4,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,children:[u.icon,J(z,{w:`full`,align:`flex-start`,spacing:2,children:[J(z,{spacing:1,w:`full`,children:[q(ct,{w:`full`,size:`xs`,children:u.title}),u.description&&q(R,{fontSize:`xs`,children:u.description})]}),(e===`error`||e===`ready`)&&q(j,{size:`xs`,onClick:r,children:o(e===`error`?`Try again`:`Confirm`)}),t&&e!==`pending`&&J(ht,{fontSize:`xs`,isExternal:!0,href:`${c}/${t.meta.txID}`,children:[o(`View on explorer`),` `,q(N,{as:mr})]})]})]})}),!u.closeDisabled&&q(lt,{onClick:a,variant:`ghost`,size:`sm`,borderRadius:`full`,"aria-label":`Close`,icon:q(N,{as:Vr,boxSize:4})})]}):null},Nu=({isOpen:e,onClose:t,status:n,txReceipt:r,txError:i,onTryAgain:a,description:o})=>{let{darkMode:s}=$();return e?q(A,{position:`fixed`,bottom:`5`,left:`5`,zIndex:`11111`,bg:s?`#1f1f1e`:`white`,borderRadius:`md`,p:5,boxShadow:`lg`,maxW:`sm`,minW:`300px`,children:q(Mu,{status:n,txReceipt:r,txError:i,onTryAgain:a,description:o,onClose:t})}):null},Pu=({isOpen:e,onClose:t,error:n,title:r,loadingText:i,onTryAgain:a=()=>{}})=>q(to,{isOpen:e,onClose:t,trapFocus:!1,autoFocus:!1,backdropFilter:`blur(3px)`,children:n?q(Iu,{error:n,onClose:t,onTryAgain:a}):q(Fu,{loadingText:i,title:r,onTryAgain:a})}),Fu=({loadingText:e,title:t,onTryAgain:n})=>{let{t:r}=Y(),[i,a]=V.useState(!1);return V.useEffect(()=>{let e=setTimeout(()=>{a(!0)},7e3);return()=>clearTimeout(e)},[Pi]),J(K,{children:[q(Z,{children:q(L,{children:t??r(`Connecting...`)})}),J(P,{children:[q(z,{align:`center`,p:6,gap:0,w:`full`,justifyContent:`center`,minH:`150px`,children:q(At,{size:`xl`})}),e&&!i&&q(R,{size:`sm`,textAlign:`center`,children:e}),i&&J(z,{mt:4,spacing:2,children:[q(R,{color:`orange.300`,size:`sm`,textAlign:`center`,children:r(`This is taking longer than expected.`)}),q(R,{size:`sm`,textAlign:`center`,children:r(`You may want to try establishing the connection again.`)})]})]}),q(I,{justifyContent:`center`,children:i&&J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Ar}),r(`Try again`)]})})]})},Iu=({error:e,onClose:t,onTryAgain:n})=>{let{t:r}=Y();return J(K,{children:[J(Z,{children:[q(L,{children:r(`Connection Failed`)}),q(F,{onClick:()=>{t()}})]}),q(P,{children:J(z,{align:`center`,p:6,w:`full`,justifyContent:`center`,minH:`100px`,gap:4,children:[q(Wn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:sr,color:`#ef4444`,fontSize:`60px`,opacity:.5})}),q(R,{w:`full`,size:`sm`,textAlign:`center`,children:e})]})}),q(I,{justifyContent:`center`,children:J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Ar}),r(`Try again`)]})})]})},Lu=({onClose:e,appsInfo:t,isLoading:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-primary`),[a,o]=G(),[s,c]=G(),l=qt(),{setConnectionCache:u}=$d(),{login:d}=Ks(),f=async(n,i)=>{l.onOpen();try{o(void 0),c(i);try{await d(n),l.onClose(),u({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 t=e?.message;if(t&&g(t))return Error(`Login request was cancelled.`);o((e instanceof Error?e:Error(`'An unexpected issue occurred while logging in with this app. Please try again or contact support.',`)).message)}}catch(e){console.error(r(`Login failed:`),e),o(e instanceof Error?e.message:r(`Failed to connect with ecosystem app`))}};return J(A,{children:[J(K,{children:[q(Z,{children:J(L,{children:[r(`Already have an x2earn app wallet?`),q(F,{onClick:()=>{e()}})]})}),J(P,{children:[n&&q(z,{minH:`200px`,w:`full`,justifyContent:`center`,children:q(At,{})}),!n&&t&&q(z,{spacing:4,w:`full`,pb:6,children:t.map(e=>J(j,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{f(e.id,e.name)},justifyContent:`flex-start`,children:[q(ut,{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:i,children:r(`No application from VeChain ecosystem is available to login.`)})]}),q(I,{pt:0})]}),q(Pu,{isOpen:l.isOpen,onClose:()=>{l.onClose()},error:a,title:`${r(`Connecting with`)} ${s}`,loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:()=>{if(s){let e=t.find(e=>e.name===s);e&&f(e.id,e.name)}}})]})},Ru=({isOpen:e,onClose:t,appsInfo:n,isLoading:r})=>q(to,{isOpen:e,onClose:t,backdropFilter:`blur(3px)`,children:q(Lu,{onClose:t,appsInfo:n,isLoading:r})}),zu=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`);return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(Wn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:cr,fontSize:`100px`,color:l})}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n}),i&&e&&J(z,{mt:2,children:[q(R,{fontSize:`xs`,children:a(`Share on`)}),q(gu,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:a(`View transaction on the explorer`)}),q(N,{size:16,as:mr})]})})]})})]})},Bu=({setCurrentContent:e,handleClose:t,style:n})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Kf(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Zf({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()},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(F,{})]}),q(P,{children:J(z,{spacing:10,align:`stretch`,justifyContent:`center`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(`To continue interacting with VeChain blockchain and complete your operation, your smart account needs to be upgraded to the latest version (v3).`)}),J(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:Yn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{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(I,{justifyContent:`center`,children:q(z,{spacing:3,w:`full`,children:q(Hp,{style:n,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})})})]})},Vu=({isOpen:e,onClose:t,style:n})=>{let[r,i]=G(`upgrade-smart-account`);return U(()=>{e&&i(`upgrade-smart-account`)},[e]),q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,size:n?.modalSize,children:(()=>{if(typeof r==`object`)switch(r.type){case`successful-operation`:return q(zu,{...r.props})}else if(r===`upgrade-smart-account`)return q(Bu,{setCurrentContent:i,handleClose:t,style:n})})()})},{definePartsStyle:Hu,defineMultiStyleConfig:Uu}=Rt(ra.keys),Wu=e=>({vechainKitBase:Hu({dialog:{scrollbarWidth:`none`,overflow:`scroll`,overflowX:`hidden`,maxHeight:`600px`,rounded:e.modal.rounded??e.borders.radius.modal,backgroundColor:e.colors.background.modal,backdropFilter:e.effects.backdropFilter.modal,border:e.colors.border.modal},overlay:{backgroundColor:e.colors.background.overlay,backdropFilter:e.effects.backdropFilter.overlay},closeButton:{borderRadius:e.borders.radius.full,color:e.colors.text.primary,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8}},header:{w:`full`,color:e.colors.text.primary,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.bold,textAlign:`center`}})}),Gu=e=>Uu({variants:Wu(e),defaultProps:{variant:`vechainKitBase`}}),{definePartsStyle:Ku,defineMultiStyleConfig:qu}=Rt(na.keys),Ju=e=>({vechainKitBase:Ku({container:{backgroundColor:e.colors.background.card,borderRadius:e.borders.radius.medium,width:`full`,border:`none`},body:{p:5,width:`full`},header:{p:5,width:`full`,borderRadius:`${e.borders.radius.medium} ${e.borders.radius.medium} 0 0`},footer:{width:`full`,borderRadius:`0 0 ${e.borders.radius.medium} ${e.borders.radius.medium}`}}),featureAnnouncement:Ku({body:{backgroundColor:e.buttons.button.bg,borderRadius:e.borders.radius.medium,color:e.colors.text.secondary},container:{borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}}),vechainKitAppCard:Ku({body:{height:`full`,borderRadius:e.borders.radius.medium,backgroundColor:e.colors.background.cardElevated,border:`1px solid ${e.colors.border.default}`},container:{height:`150px`,borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}})}),Yu=e=>qu({variants:Ju(e),defaultProps:{variant:`vechainKitBase`}}),Xu=Bt({borderRadius:`12px`}),Zu=e=>({loginIn:Bt(()=>({bg:e.buttons.loginButton.bg,color:e.buttons.loginButton.color,border:e.buttons.loginButton.border,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,rounded:e.buttons.loginButton.rounded??e.borders.radius.large,backdropFilter:e.buttons.loginButton.backdropFilter,_hover:{opacity:.5,_disabled:{opacity:.5,bg:e.buttons.loginButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.loginButton.bg},transition:`all 0.2s`})),loginWithVechain:Bt(()=>({color:`white`,bg:`#1a1a1a`,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,borderRadius:e.borders.radius.large,border:`1px solid ${e.colors.border.button}`,_hover:{opacity:.5,_disabled:{opacity:.5,bg:`#1a1a1a`}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:`#1a1a1a`},_dark:{color:`#1a1a1a`,bg:`white`,_hover:{_disabled:{bg:`white`}},_disabled:{bg:`white`}},transition:`all 0.2s`})),vechainKitPrimary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.primaryButton.rounded??e.borders.radius.large,bg:e.buttons.primaryButton.bg,color:e.buttons.primaryButton.color,border:e.buttons.primaryButton.border,backdropFilter:e.buttons.primaryButton.backdropFilter,_hover:{...e.buttons.primaryButton.hoverBg?{bg:e.buttons.primaryButton.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.primaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.primaryButton.bg},transition:`all 0.2s`})),vechainKitSecondary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.button.rounded??e.borders.radius.large,bg:e.buttons.button.bg,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,backdropFilter:e.buttons.button.backdropFilter,_hover:{...e.buttons.button.hoverBg?{bg:e.buttons.button.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),vechainKitTertiary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.tertiaryButton.rounded??e.borders.radius.large,bg:e.buttons.tertiaryButton.bg,color:e.buttons.tertiaryButton.color,border:e.buttons.tertiaryButton.border===`none`?`none`:e.buttons.tertiaryButton.border,backdropFilter:e.buttons.tertiaryButton.backdropFilter,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.tertiaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.tertiaryButton.bg},transition:`all 0.2s`})),vechainKitLogout:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,borderRadius:e.borders.radius.xl,p:0,bg:e.colors.error+`1f`,_hover:{bg:e.colors.error+`5e`,color:e.colors.error},transition:`all 0.2s`,color:e.colors.error})),actionButton:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,bg:e.buttons.button.bg,borderRadius:e.borders.radius.xl,p:0,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`1px solid ${e.colors.border.button}`:e.buttons.button.border,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),ghost:Bt(()=>({bg:`transparent`,color:e.colors.text.primary,border:`none`,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8},transition:`all 0.2s`})),link:Bt(()=>({color:e.colors.text.primary,_hover:{color:e.colors.text.secondary,textDecoration:`underline`},_active:{color:e.colors.text.primary},transition:`all 0.2s`}))}),Qu=e=>Vt({baseStyle:Xu,variants:Zu(e)}),{definePartsStyle:$u,defineMultiStyleConfig:ed}=Rt(ia.keys),td=e=>({vechainKitBase:$u({popper:{zIndex:1e3},content:{borderRadius:e.borders.radius.xl,border:`none`,backgroundColor:e.colors.background.modal,boxShadow:`0px 4px 16px rgba(0, 0, 0, 0.12)`,minWidth:`380px`},body:{padding:`16px`}})}),nd=e=>ed({variants:td(e),defaultProps:{variant:`vechainKitBase`}}),rd=(e,t)=>({useSystemColorMode:!1,disableTransitionOnChange:!1,components:{Modal:Gu(t),Card:Yu(t),Button:Qu(t),Popover:nd(t)},styles:{global:()=>({})},semanticTokens:{colors:{"chakra-placeholder-color":t.colors.text.tertiary,"vechain-kit-modal":t.colors.background.modal,"vechain-kit-overlay":t.colors.background.overlay,"vechain-kit-card":e?`rgba(0, 0, 0, 0.3)`:`rgba(0, 0, 0, 0.05)`,"vechain-kit-card-elevated":e?`rgba(0, 0, 0, 0.4)`:`rgba(0, 0, 0, 0.08)`,"vechain-kit-sticky-header":t.colors.background.stickyHeader,"vechain-kit-text-primary":t.colors.text.primary,"vechain-kit-text-secondary":t.colors.text.secondary,"vechain-kit-text-tertiary":t.colors.text.tertiary,"vechain-kit-border":t.colors.border.default,"vechain-kit-border-hover":t.colors.border.hover,"vechain-kit-border-focus":t.colors.border.focus,"vechain-kit-success":t.colors.success,"vechain-kit-error":t.colors.error,"vechain-kit-warning":t.colors.warning},effects:{"vechain-kit-backdrop-filter-modal":t.effects.backdropFilter.modal,"vechain-kit-backdrop-filter-overlay":t.effects.backdropFilter.overlay,"vechain-kit-backdrop-filter-sticky-header":t.effects.backdropFilter.stickyHeader},config:{cssVarPrefix:`vechain-kit`}},fonts:Ut.fonts,fontSizes:{...Ut.fontSizes,sm:t.fonts.sizes.small,md:t.fonts.sizes.medium,lg:t.fonts.sizes.large},fontWeights:{...Ut.fontWeights,normal:t.fonts.weights.normal,medium:t.fonts.weights.medium,bold:t.fonts.weights.bold},colors:Ut.colors,space:Ut.space}),id=(e,t)=>{let n=Ht(rd(e,Ra(La(e),za(t,e))));return n.styles.global=()=>({}),n.__cssVars&&(n.__cssVars.global=()=>({})),n},{ToastContainer:ad}=zt(),od=()=>ta({key:`vechain-kit`,prepend:!0}),sd=({bodyFont:e,headingFont:t})=>q($i,{styles:ea`
|
|
119
|
+
}`,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`))),Mo.parse(o.data)},Po=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],Fo=(e,t)=>{let{network:n}=$();return X({queryKey:Po(e,t),queryFn:()=>No(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})},Io=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],Lo=e=>{let{network:t}=$();return X({queryKey:Io(e??``,t.type),queryFn:async()=>e?Ur(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})},Ro=new tn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),zo=async(e,t,n)=>{if(!n)return{};let r=rn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(t).vetDomainsContractAddress,data:Ro.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return{};let{resolverAddress:a}=Ro.decodeFunctionResult(`resolver`,n);return(await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:le.map(e=>({to:a,data:Ro.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=Ro.decodeFunctionResult(`text`,t)[0];n&&(e[le[r]]=n)}catch(e){console.error(`Failed to decode text record for ${le[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},Bo=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],Vo=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:Bo(e,t.type),queryFn:()=>zo(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})},Ho=new tn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),Uo=(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=rn(r);n.push({to:e,data:Ho.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},Wo=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=H(e=>{if(!r)throw Error(`Resolver address is required`);return Uo(r,e)},[r]),a=fc({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))}},Go=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Ko=e=>{let{network:t}=$();return df({address:k(t.type).vetDomainsContractAddress,abi:ai.abi,method:`resolver`,args:[e?yi(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},qo={Mugshot:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/mugshot.png`,Greencart:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/greencart.png`,Cleanify:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/cleanify.png`,EVearn:`https://prod-vechainkit-docs-images-bucket.s3.eu-west-1.amazonaws.com/evearn.png`},Jo=()=>{let e=w(`vechain_kit_cross_app_connection`);if(!e)return null;try{let t=JSON.parse(e)?.ecosystemApp?.name;return t?qo[t]??null:null}catch{return null}},Yo=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],Xo=e=>{let{network:t}=$();return X({queryKey:Yo(e),queryFn:async()=>{if(!e||!t.nodeUrl)return Jo()??i(e??``);let n=await Hr(e,{networkUrl:t.nodeUrl});return n&&await Ur(n,{networkUrl:t.nodeUrl})||(Jo()??i(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})},Zo=new tn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),Qo=new tn([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),$o=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=rn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(e).vetDomainsContractAddress,data:Zo.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return null;let{resolverAddress:a}=Zo.decodeFunctionResult(`resolver`,n),[{data:o,reverted:s}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:a,data:Zo.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(s||o===`0x`)return null;try{let{avatar:n}=Zo.decodeFunctionResult(`text`,o),r=n===``?null:n;return r?ts(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}},es=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function ts(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return x(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:Qo.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],[{data:l,reverted:u}]=await fetch(`${n}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(u)return console.error(`Failed to fetch tokenURI`),null;let d=``;try{d=Qo.decodeFunctionResult(s?`uri`:`tokenURI`,l)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),d=sn(l)}d=x(d,t)||d,s&&(d=d.replace(`{id}`,cn(on(BigInt(o||0)),32).slice(2)));let f=await fetch(d);if(!f.ok)return console.error(`Failed to fetch metadata`),null;let p=await f.json(),m=p.image||p.image_url||p.image_data;return m?x(m,t)||m:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const ns=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:es(e??``,t.type),queryFn:async()=>e?$o(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},rs=si.createInterface(),is=(e,t)=>{let n=[];return n.push({to:k(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:rs.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(e?.address??``,4,4)}`,abi:rs.getFunction(`setName`)}),n},as=({onSuccess:e,onError:t})=>{let n=Vn(),{account:r}=Q(),{network:i}=$(),a=H(()=>is(r,i),[r,i]),o=H(async()=>{await vo(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=fc({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())}},os=e=>{let{network:t}=$(),n=k(t.type),{data:r,isLoading:i}=bf(e),{data:a,isLoading:o}=Ts(e),{data:s,isLoading:c}=js(e),{data:l,isLoading:u}=ks(n.veDelegateTokenContractAddress,e),{data:d,isLoading:f}=ks(n.gloDollarContractAddress,e),p=Ds(e),m=p.map(e=>e.data).filter(Boolean),h=p.some(e=>e.isLoading);return{balances:W(()=>{if(!e)return[];let t={vet:`0x`,vtho:n.vthoContractAddress,b3tr:n.b3trContractAddress,vot3:n.vot3ContractAddress,veDelegate:n.veDelegate,USDGLO:n.gloDollarContractAddress},i=[{address:t.vet,symbol:`VET`,balance:r?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:r?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:a?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:s?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:l?.scaled??`0`},{address:t.USDGLO,symbol:`USDGLO`,balance:d?.scaled??`0`}],o=m.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`}));return[...i,...o]},[e,r,a,s,l,d,m,t.type]),isLoading:i||o||c||u||f||h}},ss={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},cs=async(e,t,n)=>{let r=await e.contracts.load(k(n).oracleContractAddress,$r.abi).read.getLatestValue(ss[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new en(r[0].toString()).div(0xe8d4a51000).toNumber()},ls=e=>[`VECHAIN_KIT_PRICE`,e],us=e=>{let t=Nn(),{network:n}=$();return X({queryKey:ls(e),queryFn:async()=>cs(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})},ds=()=>{let{network:e}=$(),t=k(e.type),{data:n,isLoading:r}=us(`VET`),{data:i,isLoading:a}=us(`VTHO`),{data:o,isLoading:s}=us(`B3TR`),{data:c,isLoading:l}=us(`EUR`),{data:u,isLoading:d}=us(`GBP`);return{prices:W(()=>{let e={vet:`0x`,vtho:t.vthoContractAddress,b3tr:t.b3trContractAddress,vot3:t.vot3ContractAddress,veDelegate:t.veDelegate,USDGLO:t.gloDollarContractAddress};return{[e.vet]:n||0,[e.vtho]:i||0,[e.b3tr]:o||0,[e.vot3]:o||0,[e.veDelegate]:o||0,[e.USDGLO]:1}},[n,i,o,t.vthoContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,t.gloDollarContractAddress]),exchangeRates:W(()=>({eurUsdPrice:c||1,gbpUsdPrice:u||1}),[c,u]),isLoading:r||a||s||l||d}},fs=[`usd`,`eur`,`gbp`],ps=()=>{let{currentCurrency:e,setCurrency:t}=$();return U(()=>{h(`vechain_kit_currency`,e)},[e]),{currentCurrency:e,allCurrencies:fs,changeCurrency:e=>{if(!fs.includes(e)){console.error(`Invalid currency: ${e}`);return}t(e)}}},ms=({address:e=``})=>{let{balances:t,isLoading:n}=os(e),{prices:r,exchangeRates:i,isLoading:a}=ds(),{currentCurrency:o}=ps(),s=W(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,a=no(n,o,i);return{...e,priceUsd:t,valueUsd:n,valueInCurrency:a}}),[t,r,o,i]),c=W(()=>[...s].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[s]);return{tokens:s,sortedTokens:c,tokensWithBalance:W(()=>c.filter(e=>Number(e.balance)>0),[c]),isLoading:n||a}},hs=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=ms({address:e}),{currentCurrency:r}=ps(),i=W(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]);return{totalBalanceInCurrency:i,totalBalanceUsd:W(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),formattedBalance:W(()=>io(i,{currency:r}),[i,r]),isLoading:n,hasAnyBalance:t.length>0}},gs=di.abi,_s=`currentRoundId`,vs=e=>cf({abi:gs,address:e,method:_s}),ys=()=>{let{network:e}=$(),t=k(e.type).xAllocationVotingContractAddress;return df({abi:gs,address:t,method:_s,args:[],queryOptions:{select:e=>e[0].toString()}})},bs=async(e,t)=>Jr(e,{networkUrl:t}),xs=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],Ss=e=>{let{network:t}=$();return X({queryKey:xs(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return bs(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})},Cs=()=>{let[e,t]=Tp(wp.CUSTOM_TOKENS,[]),{network:n}=$(),r=async r=>{if(!a(r)&&!s(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await bs(r,n.nodeUrl),address:r};t([...e,i])}},i=n=>{t(e.filter(e=>e.address!==n))},a=t=>e.some(e=>o(e.address,t)),s=e=>{let t={vet:`0x`,vtho:k(n.type).vthoContractAddress,b3tr:k(n.type).b3trContractAddress,vot3:k(n.type).vot3ContractAddress,veDelegate:k(n.type).veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:r,removeToken:i,isTokenIncluded:a,isDefaultToken:s}},ws=e=>[`VEBETTERDAO_BALANCE`,e,`B3TR`],Ts=e=>{let{network:t}=$();return X({queryKey:ws(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Wr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get b3tr balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},Es=(e,t)=>[`VECHAIN_KIT_BALANCE`,t,`CUSTOM_TOKEN`,e],Ds=e=>{let{network:t}=$(),{customTokens:n}=Cs();return Bn({queries:n.map(n=>({queryKey:Es(n.address,e),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 Kr(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let i=u(r[0]);return{...n,...i}}}))})},Os=(e,t)=>[`VECHAIN_KIT`,`BALANCE`,`ERC20`,e,t],ks=(e,t)=>{let{network:n}=$();return X({queryKey:Os(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let r=await Kr(e,t,{networkUrl:n.nodeUrl});if(!r)throw Error(`Failed to get vot3 balance`);let i=r[0];return u(i)},enabled:!!t&&!!n.type})},As=e=>[`VEBETTERDAO_BALANCE`,e,`VOT3`],js=e=>{let{network:t}=$();return X({queryKey:As(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Yr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},Ms=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],Ns=e=>{let{network:t}=$();return X({queryKey:Ms(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return qr(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})},Ps=di.abi,Fs=`getAppsOfRound`,Is=(e,t)=>uf({abi:Ps,address:k(t).xAllocationVotingContractAddress,method:Fs,args:[BigInt(e??0)]}),Ls=e=>{let{network:t}=$(),n=k(t.type).xAllocationVotingContractAddress;return df({abi:Ps,address:n,method:Fs,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()}))}})},Rs=ui.abi,zs=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Bs=(e,t)=>{let n=Nn(),{network:r}=$(),i=k(r.type).xAllocationPoolContractAddress;return X({queryKey:zs(t),queryFn:async()=>(await O({thor:n,calls:e.map(e=>({abi:Rs,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})},Vs=e=>{let{data:t}=Ls(e),n=Bs(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}},Hs=({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 Pi&&i&&!g(i)?Error(t):i&&g(i)?Error(n):e instanceof Error?e:Error(r)},Us=mi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[`https://mainnet.vechain.org`]}},blockExplorers:{default:{name:`Vechain Explorer`,url:`https://explore.vechain.org`},vechainStats:{name:`Vechain Stats`,url:`https://vechainstats.com`}}}),Ws=()=>Ni({id:re,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),Gs=({privyEcosystemAppIDS:e,children:t})=>q(Ti,{config:$t(Ei({chains:[Us],ssr:!0,connectors:[Ws(),...e.map(e=>Ni({id:e,name:``,iconUrl:``}))],transports:{[Us.id]:Di()},multiInjectedProviderDiscovery:!1})).current,children:t}),Ks=()=>{let{connectAsync:e,connectors:t}=ki(),{signTypedDataAsync:n}=Mi(),{signMessageAsync:r}=ji(),{disconnectAsync:i}=Ai(),{isConnected:a}=Oi(),[o,s]=G(!1),[c,l]=G(null),u=H(async()=>{try{a&&(await i(),y()&&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||re));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 Hs({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 Hs({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}},qs=(e,t)=>{let{data:n,isLoading:r}=po(e??``),{data:i,isLoading:a}=Xo(e??``),{data:o,isLoading:s}=Vo(n?.domain??``),c=o?.header?x(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=Oi(),{logout:i}=Ks(),{loading:a}=Cn({}),{feeDelegation:s,network:c,privy:l}=$(),{user:u,authenticated:d,logout:f,ready:p}=Dn(),{data:m}=ip(),{account:h,disconnect:g}=Pn(),{getConnectionCache:_,clearConnectionCache:v}=$d(),b=_(),x=hf(),S=!!h,C=d&&!!u,w=C||t,T=C&&l?.appId===re||t&&b?.ecosystemApp?.appId===re,ee=n||r||a||!p,[E,te]=G(!1),D=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:S?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};U(()=>{let e=S||C||t;E!==e&&(te(e),e||(v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[S,C,t,v,E]);let ne=u?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,O=S?h:t?e:ne,{data:ie}=Wf(O),ae=S?h:ie?.address,oe=qs(ae??``,c.type),se=qs(O??``,c.type),k=qs(ie?.address??``,c.type),ce=ae?{address:ae,domain:oe.domain,image:oe.image,isLoadingMetadata:oe.isLoading,metadata:oe.records}:null,le=O?{address:O,domain:se.domain,image:se.image,isLoadingMetadata:se.isLoading,metadata:se.records}:null,{data:ue}=Mf(ie?.address??``,le?.address??``),de=!!ie?.address&&!!ce?.address&&o(ie?.address,ce?.address),fe=H(async()=>{try{te(!1),S?g():C?await f():t&&await i(),v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[S,g,C,f,t,i,v]);return{account:ce,smartAccount:{address:ie?.address??``,domain:k.domain,image:k.image,isDeployed:ie?.isDeployed??!1,isActive:de,version:ue?.version??null,isLoadingMetadata:k.isLoading,metadata:k.records},connectedWallet:le,privyUser:u,connection:{isLoading:ee,isConnected:E,isConnectedWithSocialLogin:C,isConnectedWithDappKit:S,isConnectedWithCrossApp:t,isConnectedWithPrivy:w,isConnectedWithVeChain:T,source:D,isInAppBrowser:(y()&&window.vechain&&window.vechain.isInAppBrowser)??!1,nodeUrl:x,delegatorUrl:s?.delegatorUrl,chainId:m,network:c.type},disconnect:fe}},Js=()=>{let e=Vn(),{account:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.invalidateQueries({queryKey:[`VECHAIN_KIT_BALANCE`,n]}),e.invalidateQueries({queryKey:[`VECHAIN_KIT_PRICE`]})])}}},Ys=async(e,t)=>{let n=x(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},Xs=li.abi,Zs=e=>{let t=Nn(),{network:n}=$();return X({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=k(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,Xs),a=(await i.read.app(e))[0][3]?.toString()||``,[o]=await i.read.baseURI();return await Ys(`${o}${a}`,n.type)},enabled:!!e})},Qs=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=x(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},$s=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],ec=(e,t=!1)=>{let{network:n}=$();return X({queryKey:$s(n.type,e),queryFn:()=>Qs(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})},tc=1024*1024*10,nc=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(x(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>tc)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:b(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},rc=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],ic=e=>{let{network:t}=$();return X({queryKey:rc(t.type,e),queryFn:()=>nc(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})},ac=e=>{let{network:t}=$();return Bn({queries:e.map(e=>({queryKey:rc(t.type,e),queryFn:()=>nc(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}))})},oc=(e,t=!1)=>{let{network:n}=$();return Bn({queries:e.map(e=>({queryKey:$s(n.type,e),queryFn:async()=>Qs(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}))})},sc={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},cc=async e=>{let t=[];try{for(let n of e){let e=await Fi(n.file,sc);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},lc=({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 Fi(n,sc));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}},uc=({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 Fi(n,sc));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},dc=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)},fc=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o,delegationUrl:s})=>{let c=Nn(),{signer:l,requestTransaction:u}=Fn(),{connection:d}=Q(),{feeDelegation:f}=$(),p=hf(),m=sm(),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 dc(c,[...a],e,{revision:pn.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}return(await u(a,{signer: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]),[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),te(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:T}=gp(g??``),ee=H(async e=>{if(!(!e.reverted||!e.meta.txID))return await c.transactions.getRevertReason(e.meta.txID)},[c]),[E,te]=G(),D=W(()=>{if(v)return`pending`;if(b)return`error`;if(g){if(w)return`waitingConfirmation`;if(T)return`error`;if(C)return C.reverted?`error`:`success`}return`ready`},[w,b,v,g,C,T]);U(()=>{if(D===`success`||D===`error`){if(b&&!E){te({type:`UserRejectedError`,reason:b});return}if(C?.reverted&&!E?.type){(async()=>{let e=await ee(C);te({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}C&&!C.reverted&&n?.()}},[D,C,n,ee,b]);let ne=H(()=>{_(null),y(!1),x(null),te(void 0)},[]);return{sendTransaction:S,isTransactionPending:W(()=>v||w||D===`pending`||D===`waitingConfirmation`,[v,w,D]),isWaitingForWalletConfirmation:W(()=>D===`pending`,[v,D]),txReceipt:C??null,status:D,resetStatus:ne,error:E}},pc=(e,t)=>{let{account:n}=Q(),{t:r}=Y(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=fc({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}},mc=e=>e===`0x`||e===Ci,hc=(e,t,n,r)=>{let i={},a=r.toLowerCase();for(let t of e)try{let e=pi({abi:Qr.abi,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[Ci]??{inflow:0n,outflow:0n};t.outflow+=e,i[Ci]=t}}for(let e of t){if(e.recipient.toLowerCase()!==a)continue;let t=BigInt(e.amount);if(t<=0n)continue;let n=i[Ci]??{inflow:0n,outflow:0n};n.inflow+=t,i[Ci]=n}return i},gc=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=hc(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=mc(e.fromTokenAddress),d=mc(e.toTokenAddress),f=BigInt(e.amountIn);if(u){let e=c[Ci]??{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!==Ci&&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===Ci?`VET`:e} has outflow ${n.outflow.toString()}, expected 0`}}if(t.minimumOutputAmount&&t.minimumOutputAmount>0n)if(d){let e=c[Ci]??{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`}}},_c=e=>e.startsWith(`0x`)?BigInt(e).toString():e,vc=(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`}),yc=(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[vc(t,e)]}return e},bc=e=>{try{let t=e.functionName||e.name;if(!t)throw Error(`Function name is required (either functionName or name must be provided)`);return hi({abi:yc(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`}`)}},xc=e=>{let t=bc(e.functionCall);return{to:e.to,value:_c(e.value),data:t,comment:e.comment||`Swap on aggregator`}},Sc=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=await fetch(`${e.apiBaseUrl}?${r.toString()}`);if(!i.ok)throw Error(`API request failed: ${i.status} ${i.statusText}`);let a=await i.json(),o=a.clauses.map(xc),s=BigInt(a.amountOut),c=BigInt(a.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:s,minimumOutputAmount:c,priceImpact:0,data:{clauses:o,path:a.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 gc(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},Cc={main:{supportedAddresses:[`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,`0x7C755EC0165fCD926cC6faB10E7BB16a72E9f34A`]},test:{supportedAddresses:[]},solo:{supportedAddresses:[]}},wc=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,Tc=e=>{let t={main:`https://vetrade.vet/api/quote/vck`,test:`https://vetrade.vet/api/quote/vck`,solo:`https://vetrade.vet/api/quote/vck`};return t[e]||t.main},Ec=e=>{let t=Cc[e]??Cc.main,n=Sc({name:`VeTrade.vet`,apiBaseUrl:Tc(e),network:e,getIcon:(e=`20px`)=>V.createElement(Ae,{boxSize:e}),supportedAddresses:t.supportedAddresses});return{...n,async simulateSwap(e,t,n){try{return gc(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(wc(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=ln.ofAbi(Qr.abi),o=un.of(e.fromTokenAddress),s=BigInt(e.amountIn);i.push(dn.callFunction(o,n.getFunction(`approve`),[a[0].to,s.toString()],gn.of(0n,hn.wei),{comment:`Approve ${r.aggregatorName} to access ${e.fromTokenAddress}`}))}return i.push(...a),i}}},Dc=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,Oc=()=>BigInt(Math.floor(Date.now()/1e3)+1200),kc=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[Dc(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,Dc(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,ii.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 gc(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=Oc();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=Dc(t.fromTokenAddress),s=Dc(t.toTokenAddress),c=ln.ofAbi(ii.abi),l=[];if(o)l.push(dn.callFunction(un.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],gn.of(a,hn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=ln.ofAbi(Qr.abi),u=un.of(t.fromTokenAddress),d=un.of(e.routerAddress);l.push(dn.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],gn.of(0n,hn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(dn.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],gn.of(0n,hn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(dn.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],gn.of(0n,hn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},Ac={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Ci,wrappedVET:Ci},solo:{routerAddress:Ci,wrappedVET:Ci}},jc=e=>{let t=Ac[e]??Ac.main;return kc({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Te,{boxSize:e})})},Mc=e=>[Ec(e),jc(e)],Nc=(e,t,n,r,i=1,a=!0)=>{let o=Nn(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=Ss(c===`0x`||c===Ci||!c?``:c),{data:d}=Ss(l===`0x`||l===Ci||!l?``:l),f=W(()=>!c||c===`0x`||c===Ci||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=W(()=>!l||l===`0x`||l===Ci||!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=Mc(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}},Pc=({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}=xn(),{loginWithCode:p}=Sn({onComplete:async({isNewUser:e})=>{e&&await f()}});return U(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),J(to,{isOpen:r,onClose:i,trapFocus:!1,children:[J(Z,{children:[q(L,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:2,children:[q(N,{as:Tr,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(M,{spacing:2,justify:`center`,mt:4,children:J(xt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[q(St,{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(St,{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(St,{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(St,{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(St,{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(St,{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(I,{children:J(R,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,q(j,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},Fc=()=>{let{t:e}=Y(),{darkMode:t}=$(),[n,r]=G(``),{sendCode:i,state:a}=Sn({}),o=qt(),s=async()=>{await i({email:n}),o.onOpen()};return J(K,{children:[q(st,{colSpan:4,w:`full`,children:q(z,{spacing:3,w:`full`,children:J(ft,{size:`lg`,w:`full`,children:[q(pt,{pointerEvents:`none`,height:`100%`,pl:4,children:q(N,{as:Tr,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(j,{"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(Pc,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},Ic=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Qd();return q(st,{colSpan:t??4,w:`full`,children:q(Eu,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:Ii,text:n(`Continue with Google`)})})},Lc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Qd();return q(st,{colSpan:t??4,w:`full`,children:q(Eu,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:vr,text:n(`Continue with Github`)})})},Rc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=En();return q(st,{colSpan:t||4,w:`full`,children:q(Eu,{isDark:e,onClick:r,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(ju,{})})})},zc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=ef(),[i,a]=G(),o=qt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){console.error(n(`Login failed:`),e),a(e instanceof Error?e.message:n(`Failed to connect with VeChain`))}};return J(K,{children:[q(st,{colSpan:t||4,w:`full`,children:q(Eu,{isDark:e,onClick:s,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(ju,{})})}),q(Pu,{isOpen:o.isOpen,onClose:()=>{o.onClose()},onTryAgain:()=>{s()},error:i,title:n(`Connecting to VeChain`),loadingText:n(`Please approve the request in the connection request window...`)})]})},Bc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{loginWithPasskey:r}=Xd(),[i,a]=G(),o=qt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&(console.error(e),a(e instanceof Error?e.message:n(`Failed to connect with Passkey`)))}};return J(K,{children:[q(st,{colSpan:t,w:`full`,children:q(Eu,{isDark:e,onClick:s,icon:hr,text:t&&t>=2?n(`Passkey`):void 0})}),q(Pu,{isOpen:o.isOpen,onClose:()=>{o.onClose()},error:i,title:n(`Connecting with Passkey`),loadingText:n(`Please complete the passkey authentication...`),onTryAgain:()=>{s()}})]})},Vc=({isDark:e,gridColumn:t=2})=>{let{t:n}=Y(),{open:r,onConnectionStatusChange:i}=In(),{dappKit:a}=$(),{source:o}=Fn(),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]),q(st,{colSpan:t||2,w:`full`,children:q(Eu,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?Br:e?Ee:he,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&q(N,{as:Yn})||void 0})})},Hc=({isDark:e,onViewMoreLogin:t,gridColumn:n})=>{let{t:r}=Y();return q(st,{colSpan:n,w:`full`,children:q(Eu,{isDark:e,onClick:t,icon:pr,text:n&&n>=2?r(`More`):void 0,rightIcon:q(N,{as:Yn})})})},Uc=()=>{let{loginMethods:e,darkMode:t}=$(),{login:n}=En(),{showGoogleLogin:r,showEmailLogin:i,showPasskey:a,showVeChainLogin:o,showDappKit:s,showMoreLogin:c,showGithubLogin:l,isOfficialVeChainApp:u}=Ud();return q(jt,{spacing:4,w:`full`,align:`center`,children:q(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:e?.map(({method:e,gridColumn:d})=>{switch(e){case`email`:return i&&q(Fc,{},`email`);case`google`:return r&&q(Ic,{isDark:t,gridColumn:d},`google`);case`github`:return l&&q(Lc,{isDark:t,gridColumn:d},`github`);case`vechain`:return o&&q(u?Rc:zc,{isDark:t,gridColumn:d},`vechain`);case`passkey`:return a&&q(Bc,{isDark:t,gridColumn:d},`passkey`);case`dappkit`:return s&&q(Vc,{isDark:t,gridColumn:d},`dappkit`);case`more`:return c&&q(Hc,{isDark:t,onViewMoreLogin:n,gridColumn:d},`more`);default:return null}})})})},Wc=({appsInfo:e,isLoading:t})=>{let{t:n}=Y(),r=qt();return J(K,{children:[q(j,{fontSize:`sm`,variant:`link`,onClick:()=>{r.onOpen()},children:n(`Already have an x2earn app wallet?`)}),q(Ru,{isOpen:r.isOpen,onClose:r.onClose,appsInfo:e,isLoading:t})]})},Gc=({setCurrentContent:e,onClose:t})=>{let{t:n}=Y(),{connection:r}=Q(),{loginModalUI:i,darkMode:a}=$(),{loginMethods:o,privyEcosystemAppIDS:s}=$(),{data:c,isLoading:l}=co(s),u=B(`colors`,`vechain-kit-text-secondary`),d=()=>{e(`faq`)};U(()=>{r.isConnected&&t()},[r.isConnected,t]);let f=o?.some(({method:e})=>e===`ecosystem`);return J(K,{children:[J(Z,{children:[q(Bp,{onClick:d}),q(L,{children:n(`Log in or sign up`)}),q(F,{})]}),i?.logo&&q(M,{justify:`center`,children:q(ut,{src:i.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),J(P,{children:[i?.description&&q(M,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:q(R,{color:u,fontSize:`sm`,textAlign:`center`,children:i?.description})}),q(Uc,{})]}),f?q(I,{children:q(M,{justify:`center`,w:`full`,children:q(Wc,{isDark:a,appsInfo:Object.values(c||{}),isLoading:l})})}):q(I,{pt:0,pb:`5px`})]})},Kc=({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}=qf(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:l,icon:J(A,{position:`relative`,children:[q(N,{as:Mr,fontSize:`18px`}),c&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},qc=({setCurrentContent:e,wallet:t,onClose:n})=>{let{t:r}=Y(),{network:i}=$();return J(Vp,{children:[J(Z,{children:[q(Kc,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),J(L,{children:[r(`Wallet`),i?.type!==`main`&&q(Nt,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${i?.type}`})]}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:6,children:[q(pl,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),q(hl,{onAssetsClick:()=>{e(`assets`)}}),q(vl,{setCurrentContent:e})]})}),q(I,{pt:0})]})},Jc=({onSelectToken:e,onBack:t,showAllTokens:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{currentCurrency:a}=ps(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-text-secondary`),c=B(`colors`,`vechain-kit-text-tertiary`),{account:l}=Q(),{tokensWithBalance:u,sortedTokens:d}=ms({address:l?.address??``}),[f,p]=G(``),m=W(()=>{if(n){let e=d.filter(e=>Number(e.balance)>0),t=[...d.filter(e=>Number(e.balance)===0)].sort((e,t)=>e.symbol.localeCompare(t.symbol));return[...e,...t]}return u},[n,d,u]).filter(({symbol:e})=>e.toLowerCase().includes(f.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:r(`Select Token`)}),q(Ja,{onClick:t}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:4,align:`stretch`,children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:f,onChange:e=>p(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:c})})]}),q(R,{fontSize:`lg`,fontWeight:`semibold`,color:o,mt:4,children:r(n?`All tokens`:`Your tokens`)}),m.length===0?J(z,{spacing:2,py:8,children:[q(N,{as:Fr,boxSize:12,color:c}),q(R,{fontSize:`lg`,color:o,children:r(`No tokens found`)}),q(R,{fontSize:`md`,color:s,children:r(`Try searching with a different term`)})]}):q(z,{spacing:2,align:`stretch`,children:m.map(t=>q(ao,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:a,onClick:()=>e(t)},t.address))})]})})}),q(I,{pt:0})]})},Yc=()=>{let{isolatedView:e,closeAccountModal:t}=hd();return{isolatedView:e,closeAccountModal:t}},Xc=({setCurrentContent:e,preselectedToken:t,initialAmount:n=``,initialToAddressOrDomain:r=``,onBack:i=()=>e(`main`)})=>{let{t:a}=Y(),{darkMode:o,feeDelegation:c}=$(),{currentCurrency:l}=ps(),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}=ds(),{account:_}=Q(),{isolatedView:v}=Yc(),{tokensWithBalance:y}=ms({address:_?.address??``}),[b,x]=G(t??y[0]??null),[S,C]=G(!1);U(()=>{!t&&!b&&y.length>0&&x(y[0])},[y,t,b]);let{register:w,watch:T,setValue:ee,setError:E,formState:{errors:te,isValid:D},handleSubmit:ne}=Li({defaultValues:{amount:n,toAddressOrDomain:r},mode:`onChange`}),{toAddressOrDomain:O,amount:re}=T(),ie=$t(b);U(()=>{ie.current&&b&&ie.current.address!==b.address&&ee(`amount`,``),ie.current=b},[b,ee]);let ae=W(()=>b?io(no(Number(re)*b.priceUsd,l,g),{currency:l}):``,[re,b,l,g]),{data:oe,isLoading:se}=po(O),k=()=>{b&&ee(`amount`,b.balance)},ce=()=>{i()},le=async t=>{if(b){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){E(`toAddressOrDomain`,{type:`manual`,message:a(`Invalid address or domain`)});return}if(b){let e=an(t.amount),n=c?.b3trTransfers?.minAmountInEther;if(b.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(e<an(String(n))){E(`amount`,{type:`manual`,message:a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n})});return}}catch{}if(e>an(b.balance)){E(`amount`,{type:`manual`,message:a(`Insufficient {{symbol}} balance`,{symbol:b.symbol})});return}}e({type:`send-token-summary`,props:{toAddressOrDomain:t.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:t.amount,selectedToken:b,formattedTotalAmount:ae,setCurrentContent:e}})}};return S?q(Jc,{setCurrentContent:e,onSelectToken:e=>{x(e),C(!1)},onBack:()=>{C(!1)}}):J(K,{children:[J(Z,{children:[q(L,{children:a(`Send`)}),!v&&q(Ja,{onClick:ce}),q(F,{})]}),q(P,{children:J(z,{spacing:2,align:`stretch`,position:`relative`,children:[J(M,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:a(`Amount`)}),J(R,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:k,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:d,children:[a(`Balance`),`:`,` `,Number(b?.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(A,{p:6,borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!te.amount,children:[J(M,{justify:`space-between`,children:[q(dt,{...w(`amount`,{required:a(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:a(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return a(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return b?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,ee(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),b?J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>C(!0),leftIcon:s[b.symbol]?V.cloneElement(s[b.symbol],{boxSize:`20px`,borderRadius:`full`}):q(ut,{src:p[b.symbol],alt:`${b.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:u,children:b.symbol.slice(0,3)})})}),children:[b.symbol,q(N,{as:rr,boxSize:5,color:d})]}):J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>C(!0),children:[a(`Select token`),q(N,{as:rr,boxSize:5,color:d})]})]}),b&&q(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:J(R,{color:d,children:[`≈ `,ae]})}),te.amount&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:te.amount.message})]})})}),q(M,{justify:`space-between`,mt:2,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:u,children:a(`To`)})}),q(A,{borderRadius:`2xl`,bg:h,children:q(z,{align:`stretch`,spacing:2,p:6,width:`100%`,children:J(it,{isInvalid:!!te.toAddressOrDomain,children:[q(dt,{...w(`toAddressOrDomain`,{required:a(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?Ri(t):t;e.target.value=n,ee(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:a(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),te.toAddressOrDomain&&q(R,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:te.toAddressOrDomain.message})]})})})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!b||!D,isLoading:se,onClick:ne(le),"data-testid":`send-button`,children:a(b?`Send`:`Select Token`)})})]})},Zc=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:a,selectedToken:o,formattedTotalAmount:s})=>{let{t:c}=Y(),{account:l,connection:u,connectedWallet:d}=Q(),{data:f}=Xo(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Ip(),{isolatedView:g,closeAccountModal:_}=Yc(),v=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b}=qf(l?.address??``,d?.address??``,3),{open:x}=Wd(),S=W(()=>f||i(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{o.symbol===`VET`?await O():await T()}catch(e){console.error(c(`Transaction failed:`),e)}},w=t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:c(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},{sendTransaction:T,txReceipt:ee,error:E,isWaitingForWalletConfirmation:te,isTransactionPending:D,clauses:ne}=up({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,tokenAddress:o.address,tokenName:o.symbol,onSuccess:()=>{w(ee?.meta.txID??``)},onError:e=>{de(e??``)}}),{sendTransaction:O,txReceipt:re,error:ie,isWaitingForWalletConfirmation:ae,isTransactionPending:oe,clauses:se}=fp({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,onSuccess:()=>{w(re?.meta.txID??``)},onError:e=>{de(e??``)}}),k=()=>o.symbol===`VET`?re:ee,ce=te||ae,le=ce||D||oe,ue=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:o,initialAmount:a,initialToAddressOrDomain:t}})},de=e=>{console.error(`Transaction failed:`,e)},[fe,pe]=V.useState(null),[me,he]=V.useState(null),ge=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:_e,isLoading:ve,error:ye,refetch:be}=Lp({clauses:o.symbol===`VET`?se:ne,tokens:fe?[fe]:h.availableGasTokens,sendingAmount:a,sendingTokenSymbol:o.symbol,enabled:ge&&!!m?.genericDelegatorUrl}),xe=_e?.usedToken,Se=(ve||!_e)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,Ce=V.useCallback(e=>{pe(e),he(e),setTimeout(()=>be(),100)},[be]),we=!!xe&&!ye;return V.useEffect(()=>{ye&&fe&&pe(null)},[ye,fe]),J(K,{children:[J(Z,{children:[q(L,{children:`Send`}),q(Ja,{isDisabled:le,onClick:ue}),q(F,{isDisabled:le})]}),q(P,{children:q(z,{spacing:6,align:`stretch`,w:`full`,children:J(z,{spacing:4,w:`full`,children:[q(zp,{label:c(`From`),address:l?.address??``,domain:l?.domain,imageSrc:l?.image??``,imageAlt:`From account`,balance:Number(o.balance),tokenAddress:o.address}),q(zp,{label:c(`To`),address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:o.address}),u.isConnectedWithPrivy&&q(Kp,{estimation:_e,isLoading:ve,isLoadingTransaction:le,onTokenChange:Ce,clauses:o.symbol===`VET`?se:ne,userSelectedToken:me}),J(z,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:c(`Amount`)}),J(M,{justifyContent:`flex-start`,w:`full`,children:[J(R,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(a).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,o.symbol]}),J(R,{color:y,children:[`≈ `,s]})]})]})]})})}),q(I,{children:q(Up,{transactionError:o.symbol===`VET`?ie:E,isSubmitting:le,isTxWaitingConfirmation:ce,onConfirm:C,transactionPendingText:c(`Sending...`),txReceipt:k(),buttonText:c(`Confirm`),isDisabled:le||Se,gasEstimationError:ye,hasEnoughGasBalance:we,isLoadingGasEstimation:ve,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},Qc=({setCurrentContent:e})=>{let{t}=Y(),{account:n}=Q(),{isolatedView:r}=Yc(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:t(`Receive`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:4,align:`center`,w:`full`,children:[q(zi,{value:n?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),q(Ya,{wallet:n,style:{w:`85%`}}),q(R,{fontSize:`sm`,textAlign:`center`,color:i,children:t(`Copy your address or scan this QR code`)}),q(R,{fontSize:`xs`,textAlign:`center`,color:a,children:t(`This address only supports VeChain assets.`)})]})}),q(I,{pt:0})]})]})},$c=({quotes:e,selectedQuote:t,toTokenAddress:n,onSelectQuote:r,onBack:i})=>{let{t:a}=Y(),{darkMode:c}=$(),{currentCurrency:l}=ps(),{account:u}=Q(),{exchangeRates:d,prices:f}=ds(),{tokens:m}=ms({address:u?.address??``}),[h,g]=G(!1),_=W(()=>n&&m.find(e=>o(e.address,n))||null,[n,m]),v=e.filter(e=>!e.reverted),y=e.filter(e=>e.reverted),b=W(()=>v.length===0?null:v.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[v]),x=W(()=>{let e=n&&f[n]||0;return v.map(t=>{let n=gi(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=no(r,l,d),a=b&&t.aggregatorName===b.aggregatorName,o=0;if(b&&!a){let e=BigInt(b.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)})},[v,n,f,l,d,b]);return J(K,{children:[J(Z,{children:[q(L,{children:a(`Found following rates`)}),q(Ja,{onClick:i}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:6,align:`stretch`,children:[x.length>0&&q(z,{spacing:2,align:`stretch`,children:x.map(e=>{let n=t?.aggregatorName===e.aggregatorName;return J(A,{p:2.5,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,borderWidth:1,borderColor:n?`blue.500`:c?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>r(e),_hover:{borderColor:n?`blue.500`:c?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(e.isBest||!e.isBest&&e.percentageDiff<0)&&q(A,{position:`absolute`,top:-1,left:0,zIndex:1,children:e.isBest?q(We,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:a(`Best`)}):J(We,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[e.percentageDiff.toFixed(2),`%`]})}),J(z,{align:`stretch`,spacing:1.5,marginTop:4,children:[J(M,{justify:`space-between`,align:`center`,children:[J(M,{spacing:1.5,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`bold`,children:e.aggregatorName})]}),q(M,{align:`center`,spacing:1.5,children:_&&J(K,{children:[s[_.symbol]?V.cloneElement(s[_.symbol],{boxSize:`24px`,borderRadius:`full`}):p[_.symbol]?q(ut,{src:p[_.symbol],alt:`${_.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,q(Ft,{label:Number(e.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:J(R,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(e.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,_.symbol]})})]})})]}),J(M,{justify:`space-between`,align:`center`,children:[q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:e.gasCostVTHO&&e.gasCostVTHO>0?`Gas: ${e.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),e.valueUsd>0&&J(R,{fontSize:`xs`,color:c?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,io(e.valueInCurrency,{currency:l})]})]})]})]},e.aggregatorName)})}),y.length>0&&J(A,{children:[J(M,{justify:`space-between`,cursor:`pointer`,onClick:()=>g(!h),py:2,children:[J(R,{fontSize:`sm`,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:[y.length,` `,a(`rate`),y.length===1?``:`s`,` `,a(`unavailable`)]}),q(N,{as:h?or:rr,boxSize:4,color:c?`whiteAlpha.600`:`blackAlpha.600`})]}),q($e,{in:h,animateOpacity:!0,children:q(z,{spacing:2,align:`stretch`,pt:2,children:y.map(e=>q(A,{p:2,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,opacity:.6,children:J(M,{justify:`space-between`,children:[J(M,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:a(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),x.length===0&&y.length===0&&q(z,{spacing:2,py:8,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:q(R,{fontSize:`lg`,children:a(`No quotes available`)})})]})})}),q(I,{})]})},el=e=>e===`0x`||e===Ci||!e,tl=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=el(n),c=el(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=Qr.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=pi({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}},nl=({setCurrentContent:e,fromTokenAddress:t,toTokenAddress:n})=>{let{t:r}=Y(),{account:i,connection:a}=Q(),{currentCurrency:c}=ps(),{network:l,feeDelegation:u,darkMode:d}=$(),{isolatedView:f,closeAccountModal:m}=Yc(),h=B(`colors`,`vechain-kit-card`),g=B(`colors`,`vechain-kit-text-primary`),_=B(`colors`,`vechain-kit-text-secondary`),v=B(`colors`,`vechain-kit-text-tertiary`),{preferences:y}=Ip(),{sortedTokens:b}=ms({address:i?.address??``}),[x,S]=G(`main`),[C,w]=G(null),[T,ee]=G(null),[E,te]=G(``),[D,ne]=G(!1),[O,re]=G(1),[ie,ae]=G(`1`),[oe,se]=G(null),[ce,le]=V.useState(null),[ue,de]=V.useState(null),[fe,pe]=V.useState([]),{prices:me,exchangeRates:he}=ds(),ge=O===1;V.useEffect(()=>{ae(O===1?`1`:O===.5?`0.5`:O===3?`3`:O.toString())},[O]),V.useEffect(()=>{if(b.length!==0){if((t||n)&&(!C||!T)){if(t&&!C){let e=b.find(e=>o(e.address,t));e&&w(e)}if(n&&!T){let e=b.find(e=>o(e.address,n));e&&ee(e)}return}if(!C&&!T){let e=b.find(e=>e.symbol===`VET`);e&&w(e);let t=b.find(e=>e.symbol===`B3TR`);if(!t)try{let e=k(l.type).b3trContractAddress;e&&(t=b.find(t=>o(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&ee(t)}}},[b,C,T,t,n,l.type]),V.useEffect(()=>{se(null)},[C?.address,T?.address,E]);let{bestQuote:_e,quotes:ve,isLoading:ye,from:be,to:xe}=Nc(C,T,E,i?.address??``,O,!!C&&!!T&&Number(E)>0),Se=W(()=>{if(!E||Number(E)<=0||!be)return 0n;try{return xi(E,be.decimals)}catch{return 0n}},[E,be?.decimals]),Ce=oe||_e,we=W(()=>{if(!Ce?.outputAmount||!xe)return`0`;try{return _i(Ce.outputAmount,xe.decimals)}catch{return`0`}},[Ce,xe?.decimals]),Te=W(()=>{if(!C||!E)return 0;let e=me[C.address]||0;return no(Number(E)*e,c,he)},[C?.address,E,me,c,he]),Ee=W(()=>{if(!T||!we)return 0;let e=me[T.address]||0;return no(Number(we)*e,c,he)},[T?.address,we,me,c,he]),De=W(()=>!C||!T||!i?.address||Se===0n?null:{fromTokenAddress:C.address,toTokenAddress:T.address,amountIn:Se.toString(),userAddress:i.address,slippageTolerance:O},[C,T,i?.address,Se,O]),Oe=Ce?.gasCostVTHO??0;V.useEffect(()=>{(async()=>{if(!Ce||!De||!Ce.aggregator){pe([]);return}try{pe(await Ce.aggregator.buildSwapTransaction(De,Ce))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),pe([])}})()},[Ce,De]);let ke=y.availableGasTokens.length>0&&(a.isConnectedWithPrivy||a.isConnectedWithVeChain)&&!u?.delegatorUrl,{data:Ae,isLoading:je,error:Me,refetch:Ne}=Lp({clauses:fe,tokens:ce?[ce]:y.availableGasTokens,sendingAmount:E,sendingTokenSymbol:C?.symbol??``,enabled:ke&&!!u?.genericDelegatorUrl&&fe.length>0}),Pe=Ae?.usedToken,Fe=(je||!Ae)&&a.isConnectedWithPrivy&&!u?.delegatorUrl,Ie=V.useCallback(e=>{le(e),de(e),setTimeout(()=>Ne(),100)},[Ne]),Le=!!Pe&&!Me;V.useEffect(()=>{Me&&ce&&le(null)},[Me,ce]);let{executeSwap:Re,isTransactionPending:ze,isWaitingForWalletConfirmation:Be,txReceipt:Ve,status:He,error:Ue}=pc(De,Ce),We=H(()=>{let t=Ve?.meta.txID??``,n=r(`Swap successful`,{defaultValue:`Swap successful`}),a;if(Ve&&C&&T&&i?.address){let e=tl(Ve,i.address,C.address,T.address);if(e&&be&&xe)try{let t=be.decimals,n=xe.decimals,i=_i(e.fromAmount,t),o=_i(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})};a=r(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(i),fromSymbol:C.symbol,toAmount:s(o),toSymbol:T.symbol,defaultValue:`You successfully swapped ${s(i)} ${C.symbol} for ${s(o)} ${T.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!a&&C&&T&&(a=r(`You successfully swapped {fromToken} for {toToken}`,{fromToken:C.symbol,toToken:T.symbol,defaultValue:`You successfully swapped ${C.symbol} for ${T.symbol}`})),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:n,description:a,onDone:()=>{f?m():e(`main`)},showSocialButtons:!0}})},[C,T,E,Ce,Ve,i?.address,e,r,f,m]),Ge=H(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[C,T,E]),[Ke,qe]=V.useState(!1);V.useEffect(()=>{if(He===`ready`){qe(!1);return}Ke||(He===`success`&&Ve&&!Ve.reverted?(qe(!0),We()):He===`error`&&Ue?Ge(Ue?.reason||Ue?.message||String(Ue)):Ve?.reverted&&Ge(`Transaction reverted`))},[He,Ve,Ue,We,Ge,Ke]);let Je=H(e=>{if(w(e),e.symbol===`VET`&&!T){let e=b.find(e=>e.symbol===`B3TR`);if(!e)try{let t=k(l.type).b3trContractAddress;t&&(e=b.find(e=>o(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&ee(e)}S(`main`)},[T,b,l.type]),Ye=H(e=>{ee(e),S(`main`)},[]),Xe=H(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&te(e)},[]),Ze=H(()=>{C&&te(C.balance)},[C]),Qe=e=>{if(!e)return null;let t=s[e.symbol],n=p[e.symbol];return{symbol:e.symbol,logoComponent:t,logoUrl:n,balance:e.balance,value:e.valueInCurrency}},et=Qe(C),nt=Qe(T);return x===`select-from-token`?q(Jc,{setCurrentContent:e,onSelectToken:Je,onBack:()=>S(`main`),showAllTokens:!1}):x===`select-quote`?q($c,{quotes:ve,selectedQuote:Ce,toTokenAddress:T?.address??null,onSelectQuote:e=>{se(e),S(`main`)},onBack:()=>S(`main`)}):x===`select-to-token`?q(Jc,{setCurrentContent:e,onSelectToken:Ye,onBack:()=>S(`main`),showAllTokens:!0}):J(K,{children:[J(Z,{children:[q(L,{children:r(`Swap`)}),!f&&q(Ja,{onClick:()=>e(`main`),isDisabled:ze||Be}),q(F,{isDisabled:ze||Be})]}),q(tt,{maxW:`container.lg`,p:0,children:q(P,{children:J(z,{spacing:2,align:`stretch`,w:`full`,children:[J(M,{justify:`space-between`,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:g,children:r(`From`)}),et&&J(R,{cursor:`pointer`,_hover:{color:_,textDecoration:`underline`},onClick:Ze,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:_,children:[r(`Balance`),`:`,` `,Number(et.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),q(A,{p:6,borderRadius:`2xl`,bg:h,children:J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,children:[q(dt,{placeholder:`0`,value:E,onChange:e=>Xe(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:et&&E&&Number(E)>Number(et.balance)?`red.500`:g}),et?J(j,{onClick:()=>S(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:et.logoComponent?V.cloneElement(et.logoComponent,{boxSize:`20px`,borderRadius:`full`}):et.logoUrl?q(ut,{src:et.logoUrl,alt:`${et.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:g,children:et.symbol.slice(0,3)})})}):void 0,children:[et.symbol,q(N,{as:rr,boxSize:5,color:_})]}):J(j,{onClick:()=>S(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:v},children:[r(`Select token`),q(N,{as:rr,boxSize:5,color:_})]})]}),et&&q(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:_,children:q(M,{spacing:2,alignItems:`center`,children:J(R,{color:_,children:[`≈`,` `,io(Te,{currency:c})]})})})]})}),q(M,{justify:`space-between`,mt:4,children:q(R,{fontSize:`md`,fontWeight:`bold`,color:g,children:r(`To`)})}),q(A,{borderRadius:`2xl`,bg:h,children:J(z,{align:`stretch`,spacing:2,p:6,width:`100%`,children:[J(M,{justify:`space-between`,alignItems:`center`,children:[q(dt,{value:Number(we).toLocaleString(void 0,{maximumFractionDigits:Number(we)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:g}),nt?J(j,{onClick:()=>S(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:nt.logoComponent?V.cloneElement(nt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):nt.logoUrl?q(ut,{src:nt.logoUrl,alt:`${nt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:g,children:nt.symbol.slice(0,3)})})}):void 0,children:[nt.symbol,q(N,{as:rr,boxSize:5,color:_})]}):J(j,{onClick:()=>S(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`,color:v},children:[r(`Select token`),q(N,{as:rr,boxSize:5,color:_})]})]}),nt&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:_,children:[q(M,{spacing:2,alignItems:`center`,children:J(R,{color:_,children:[`≈`,` `,io(Ee,{currency:c})]})}),nt&&J(R,{noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:_,children:[r(`Balance`),`:`,` `,Number(nt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})}),q($e,{in:D&&!!Ce,animateOpacity:!0,children:J(z,{spacing:1,align:`stretch`,p:4,borderRadius:`2xl`,bg:h,children:[Ce&&J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:_,children:[r(`Source`),`:`]}),q(j,{variant:`outline`,size:`xs`,borderRadius:`full`,px:3,h:`auto`,py:1,cursor:`pointer`,onClick:()=>S(`select-quote`),color:_,borderColor:_,_hover:{bg:d?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:Ce.aggregator?.getIcon(`12px`),children:q(R,{fontSize:`xs`,color:g,children:Ce.aggregatorName})})]}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:_,children:[r(`Slippage tolerance`),`:`]}),J(R,{fontSize:`xs`,fontWeight:`medium`,color:g,children:[O,`%`]})]}),q(z,{spacing:3,align:`stretch`,pt:2,children:J(M,{spacing:2,children:[q(j,{size:`sm`,variant:`outline`,onClick:()=>{re(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ge?`rgb(96 66 221)`:`transparent`,color:ge?`white`:_,borderColor:ge?`rgb(96 66 221)`:_,_hover:{bg:ge?`rgb(96 66 221)`:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:ge?.8:1},children:`Auto`}),q(j,{size:`sm`,variant:`outline`,onClick:()=>{re(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:O===.5?`rgb(96 66 221)`:`transparent`,color:O===.5?`white`:_,borderColor:O===.5?`rgb(96 66 221)`:_,_hover:{bg:O===.5?`rgb(96 66 221)`:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:O===.5?.8:1},children:`0.5%`}),q(j,{size:`sm`,variant:`outline`,onClick:()=>{re(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:O===3?`rgb(96 66 221)`:`transparent`,color:O===3?`white`:_,borderColor:O===3?`rgb(96 66 221)`:_,_hover:{bg:O===3?`rgb(96 66 221)`:d?`whiteAlpha.300`:`blackAlpha.300`,opacity:O===3?.8:1},children:`3%`}),J(ft,{size:`sm`,flex:1,children:[q(dt,{value:ie,onChange:e=>{let t=e.target.value;if((/^\d*\.?\d*$/.test(t)||t===``)&&(ae(t),t!==``)){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&re(e)}},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:g}),q(mt,{width:`2rem`,pointerEvents:`none`,children:q(R,{fontSize:`2xs`,color:_,children:`%`})})]})]})})]}),J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:_,children:[r(`Fee`),`:`]}),q(R,{fontSize:`xs`,fontWeight:`medium`,color:g,children:Oe>0?`${Oe.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),Ce&&q(A,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(j,{variant:`ghost`,size:`xs`,onClick:()=>ne(!D),rightIcon:q(N,{color:v,_hover:{color:_},as:D?Xn:Kn}),fontSize:`xs`,fontWeight:`light`,color:v,_hover:{color:_},children:r(D?`Hide`:`Show Advanced Options`)})}),fe.length>0&&a.isConnectedWithPrivy&&q(Kp,{estimation:Ae,isLoading:je,isLoadingTransaction:ze,onTokenChange:Ie,clauses:fe,userSelectedToken:ue})]})})}),q(I,{children:q(Up,{buttonText:r(ye?`Loading quote...`:`Swap`),onConfirm:Re,isSubmitting:ze,isTxWaitingConfirmation:Be,transactionPendingText:r(`Swapping...`),txReceipt:Ve,transactionError:Ue,onError:e=>{Ge(e)},isDisabled:!C||!T||!E||Number(E)<=0||ye||!Ce||Ce?.reverted===!0||!!(et&&E&&Number(E)>Number(et.balance))||Fe,gasEstimationError:Me,hasEnoughGasBalance:Le,isLoadingGasEstimation:je,showGasEstimationError:!u?.delegatorUrl&&a.isConnectedWithPrivy,context:`transaction`})})]})},rl=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=Y(),{isolatedView:i}=Yc(),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(Ja,{onClick:s}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,py:8,children:[q(N,{as:Ir,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(I,{children:q(j,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},il=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:r}=Q(),{t:a}=Y(),o=qs(e.name,r.network),s=B(`colors`,`vechain-kit-card`),c=B(`colors`,`vechain-kit-card-hover`),l=B(`colors`,`vechain-kit-border`),u=B(`colors`,`vechain-kit-text-primary`),f=B(`colors`,`vechain-kit-text-secondary`),p=B(`colors`,`vechain-kit-card`);return q(_t,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${l}`,_hover:{bg:t?c:s,borderColor:l},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:J(M,{spacing:3,align:`center`,children:[q(Hp,{props:{width:`40px`,height:`40px`,src:o.image??i(e.name),alt:e.name}}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:u,fontSize:`md`,fontWeight:`500`,children:d(e.name,24,0)}),t&&q(R,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&q(Nt,{size:`sm`,bg:p,color:u,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},al=({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(_t,{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(M,{spacing:3,align:`center`,children:[q(A,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:q(N,{as:Lr,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`)},ol=({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(Ie,{allowToggle:!0,children:q(Re,{border:`none`,children:({isExpanded:u})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[q(A,{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(N,{as:u?or:rr,fontSize:`20px`,color:l})]}),q(ze,{pb:4,pt:2,children:J(gt,{spacing:2,children:[e.map(e=>q(il,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&q(al,{onUnset:n})]})})]})})})},sl=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=Y(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=Yc(),[s,c]=G(Ri(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}=go(s),{data:S,isLoading:C}=po(`${s}.veworld.vet`),{data:w,isLoading:T}=Ao(s),{data:ee,isLoading:E}=Fo(i?.address,``),te=x||C||T;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,te]);let D=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},ne=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}})},O=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},re=()=>{t(n)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&q(Ja,{onClick:re}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,children:[q(ol,{domains:ee?.domains||[],onDomainSelect:ne,onUnsetDomain:O,isLoading:E}),J(ft,{size:`lg`,children:[q(dt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(Ri(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(mt,{width:`auto`,paddingRight:`12px`,h:`full`,children:q(A,{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(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||te,onClick:D,"data-testid":`continue-button`,children:r(`Continue`)})})]})},cl=({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}=Yc(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=qf(u?.address??``,d?.address??``,3),{open:m}=Wd(),{preferences:h}=Ip(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=as({onSuccess:()=>te()}),y=n.endsWith(`veworld.vet`),b=So({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>te()}),x=Eo({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>te()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:T,isTransactionPending:ee,clauses:E}=i?v:y?b:x,te=()=>{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)}}})},D=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},ne=()=>{D()},O=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[re,ie]=V.useState(null),[ae,oe]=V.useState(null),se=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:k,isLoading:ce,error:le,refetch:ue}=Lp({clauses:E(),tokens:re?[re]:h.availableGasTokens,enabled:se&&!!g?.genericDelegatorUrl}),de=k?.usedToken,fe=(ce||!k)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,pe=V.useCallback(e=>{ie(e),oe(e),setTimeout(()=>ue(),100)},[ue]),me=!!de&&!le;return V.useEffect(()=>{le&&re&&ie(null)},[le,re]),J(K,{children:[J(Z,{children:[q(L,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),q(Ja,{onClick:O,isDisabled:ee}),q(F,{isDisabled:ee})]}),J(P,{children:[J(z,{spacing:4,w:`full`,textAlign:`center`,children:[q(R,{fontSize:`lg`,color:s,children:o(i?`Are you sure you want to unset your current domain?`:`Are you sure you want to set your domain name to`)}),!i&&q(R,{fontSize:`xl`,fontWeight:`bold`,color:s,"data-testid":`preconfirm-domain-val`,children:`${t}`})]}),f.isConnectedWithPrivy&&q(Kp,{estimation:k,isLoading:ce,isLoadingTransaction:ee,onTokenChange:pe,clauses:E(),userSelectedToken:ae})]}),q(I,{gap:4,w:`full`,children:q(Up,{transactionError:w,isSubmitting:ee,isTxWaitingConfirmation:T,onConfirm:D,onRetry:ne,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:ee||fe,onError:_,gasEstimationError:le,hasEnoughGasBalance:me,isLoadingGasEstimation:ce,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},ll=()=>{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(ft,{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(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:a})})]}),c.length===0?J(z,{spacing:2,py:8,color:i,children:[q(N,{as:Fr,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(Ie,{allowMultiple:!0,children:c.map((e,t)=>q(Re,{border:`none`,mb:2,children:({isExpanded:t})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[q(A,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:i,children:e.question})}),q(N,{as:t?or:rr,fontSize:`20px`,opacity:.5})]}),q(ze,{pb:4,children:q(R,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},ul=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=Y(),{isolatedView:i}=Yc(),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-border`),s=B(`colors`,`vechain-kit-border-hover`);return J(Vp,{children:[J(Z,{children:[q(L,{children:r(`Help`)}),!i&&q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:6,align:`stretch`,children:[t&&q(Ot,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:va.map(e=>q(`option`,{value:e,children:ba[e]},e))}),q(j,{as:ht,href:`https://docs.vechainkit.vechain.org/`,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:q(N,{as:mr}),children:r(`For developers`)}),q(ll,{})]})}),q(I,{pt:0})]})},dl=({leftIcon:e,rightIcon:t,title:n,wallet:r,onClick:i,leftImage:a,isActive:o=!1})=>{let{t:s}=Y(),{darkMode:c}=$();return q(j,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:i,backgroundColor:`transparent`,border:`1px solid ${c?`#ffffff29`:`#ebebeb`}`,children:J(M,{w:`full`,justify:`space-between`,children:[q(A,{minW:`40px`,justifyContent:`center`,children:a?q(ut,{justifySelf:`center`,src:a,w:`28px`,alt:`left-image`}):q(N,{as:e,fontSize:`28px`})}),J(z,{textAlign:`left`,w:`full`,flex:1,children:[q(M,{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:r?.domain?d(r?.domain??``,18,0):l(r?.address??``,6,4)})]}),q(z,{minW:`40px`,justifyContent:`flex-end`,children:J(M,{justifyContent:`flex-end`,minW:`40px`,children:[o&&q(Nt,{size:`sm`,colorScheme:`green`,children:s(`Active`)}),q(N,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},fl=({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(j,{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(M,{w:`full`,justify:`space-between`,alignItems:`center`,children:[q(A,{minW:`40px`,h:`20px`,children:i?q(ut,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):q(N,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),q(z,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:J(M,{justify:`flex-start`,alignItems:`baseline`,children:[q(R,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&q(Nt,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&q(z,{minW:`40px`,justifyContent:`flex-end`,children:q(N,{as:t,fontSize:`20px`,opacity:.5})})]})})},pl=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:r,onClose:i,mt:a,style:o})=>{let[s,c]=G(!1),{disconnect:u}=Q(),f=async()=>{await ie(e?.domain??e?.address??``)&&(c(!0),setTimeout(()=>{c(!1)},2e3))},p=()=>{u(),i()};return J(M,{mt:a,w:`full`,...o,justifyContent:`flex-start`,alignItems:`center`,children:[q(j,{w:`full`,h:12,"aria-label":`Wallet`,onClick:r,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:J(M,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[J(M,{spacing:2,justifyContent:`flex-start`,children:[q(Hp,{wallet:e,props:{width:7,height:7}}),q(R,{fontSize:n,fontWeight:`500`,children:d(e?.domain??``,22,0)||l(e?.address??``,6,4)})]}),q(N,{boxSize:5,as:ar,cursor:`pointer`,opacity:.5})]})}),q(lt,{"aria-label":`Copy address`,icon:q(N,{as:s?nr:dr}),onClick:f,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8}}),q(lt,{"aria-label":`Logout`,icon:q(N,{as:wr}),onClick:()=>t({type:`disconnect-confirm`,props:{onDisconnect:p,onBack:()=>t(`main`)}}),variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},colorScheme:`red`})]})},ml=({address:e,maxIcons:t=3,iconSize:n=20,ml:r=0,style:i,iconsGap:a=0,rightIcon:o,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=Y(),{tokensWithBalance:d}=ms({address:e}),{darkMode:f}=$(),m=B(`colors`,`vechain-kit-text-secondary`),h=a<1?`-${n/2}px`:`${a}px`,g=d.slice(0,t),_=d.length-t;return!e||d.length===0&&!c?null:J(M,{spacing:0,ml:r,...i,onClick:l,children:[J(M,{spacing:0,children:[g.map((e,t)=>q(Qe,{ml:t>0?h:`0`,zIndex:t,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:s[e.symbol]?V.cloneElement(s[e.symbol],{width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):p[e.symbol]?q(ut,{src:p[e.symbol],alt:`${e.symbol} logo`,width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):q(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:e.symbol.slice(0,3)})},e.symbol)),_>0&&q(Qe,{ml:h,zIndex:g.length,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:J(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,_]})}),d.length===0&&c&&q(R,{fontSize:`sm`,color:m,fontWeight:`700`,children:u(`No assets`)})]}),o]})},hl=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=Y(),{account:i}=Q(),{formattedBalance:a,isLoading:o}=hs({address:i?.address??``}),{refresh:s}=Js(),[c,l]=G(!1),u=B(`colors`,`vechain-kit-text-secondary`),d=async()=>{l(!0),await s(),setTimeout(()=>{l(!1)},1500)};return J(z,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[J(M,{w:`full`,justifyContent:`flex-start`,alignItems:`center`,spacing:2,role:`group`,children:[q(ct,{size:`xs`,fontWeight:`500`,color:u,children:r(`Assets`)}),q(A,{display:`flex`,alignItems:`center`,justifyContent:`center`,w:`32px`,h:`32px`,children:q(lt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:d,icon:q(N,{as:Ar,boxSize:4}),isLoading:o||c,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}})})]}),q(j,{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:[q(ct,{size:`2xl`,fontWeight:`700`,children:a}),q(M,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:q(ml,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:q(N,{as:ar,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},gl=[{icon:Zn,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{icon:Jn,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{icon:qn,label:`Receive`,onClick:e=>{e(`receive-token`)}}],_l=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=Y();return q(lt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:J(z,{spacing:4,children:[q(N,{as:e,boxSize:5,opacity:.9}),J(M,{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(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},vl=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hasAnyBalance:o}=hs({address:n?.address??``}),{data:s}=qf(r?.address??``,i?.address??``,3),c=a.isConnectedWithPrivy&&s;return q(ot,{templateColumns:`repeat(3, 1fr)`,gap:2,w:`full`,mt:e,children:gl.map(e=>q(_l,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(o),showRedDot:c&&e.label===`Settings`},e.label))})},yl=()=>{let[e,t]=G(!0),n=`vechain_kit_feature_announcement_closed`;return U(()=>{w(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{h(n,`true`),t(!1)}}},bl=({setCurrentContent:e})=>{let{t}=Y(),{isVisible:n,closeAnnouncement:r}=yl(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return n?q(Ge,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`main`),initialContentSource:`main`}}),r()},cursor:`pointer`,_hover:{opacity:.8},children:q(Ke,{p:4,children:J(M,{justify:`space-between`,align:`flex-start`,spacing:3,children:[J(z,{align:`flex-start`,spacing:1,children:[J(M,{spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`400`,color:i,children:t(`Claim your vet domain!`)}),q(Nt,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),q(R,{fontSize:`xs`,color:a,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]}),q(lt,{size:`sm`,variant:`ghost`,colorScheme:`gray`,icon:q(ur,{}),onClick:e=>{e.stopPropagation(),r()},"aria-label":t(`Close announcement`)})]})})}):null},xl=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},Sl=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{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.`)})]})})})},Cl=()=>{let{t:e}=Y(),{getConnectionCache:t}=$d(),n=t();return J(Ge,{variant:`vechainKitBase`,w:`full`,children:[J(Je,{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(Ke,{borderRadius:`none`,children:J(z,{spacing:3,align:`stretch`,children:[J(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:zr})}),J(A,{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(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:Pr})}),J(A,{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(qe,{children:J(j,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??`https://governance.vebetterdao.org/`,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),q(N,{as:mr,ml:2})]})})]})},wl=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:n}=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=$t(null),u=$t(null),[d,f]=G(!1),{onUpload:p}=uc({compressImage:!0}),[m,h]=G(null),[g,_]=G(null),v=!!a?.domain,[y,b]=G(null),[x,S]=G(``),[C,w]=G(``),{register:T,watch:ee,formState:{errors:E,isValid:te}}=Li({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 D=ee(),ne=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 r(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 O=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),D.displayName!==x&&(e.displayName=D.displayName),D.description!==C&&(e.description=D.description),e},re=W(()=>{let e=O();return Object.keys(e).length>0},[O]),ie=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:O(),onDoneRedirectContent:t}})},ae=()=>{e(t)};return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Customization`)}),q(Ja,{onClick:ae}),q(F,{})]}),J(P,{children:[J(A,{cursor:v?`pointer`:`default`,pt:2,display:`flex`,justifyContent:`center`,position:`relative`,onClick:()=>v&&l.current?.click(),children:[q(Hp,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&q(N,{as:tr,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&q(A,{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(Sl,{}),q(fl,{title:a?.domain??n(`Choose account name`),description:n(`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:Ir,rightIcon:ar,dataTestId:`set-domain-name-button`}),J(it,{isDisabled:!v,isInvalid:!!E.displayName,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Display Name`)}),q(dt,{...T(`displayName`,{maxLength:{value:25,message:n(`Display name must be less than 25 characters`)}}),placeholder:n(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(it,{isDisabled:!v,isInvalid:!!E.description,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Description`)}),q(Pt,{...T(`description`,{maxLength:{value:100,message:n(`Description must be less than 100 characters`)}}),placeholder:n(`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 ne(e)}),q(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),q(I,{w:`full`,children:q(j,{variant:`vechainKitPrimary`,onClick:ie,isDisabled:!v||!re||!te,isLoading:d,loadingText:n(`Preparing changes...`),"data-testid":`save-changes-button`,children:n(`Save Changes`)})})]})},Tl=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=Y(),{darkMode:i,network:a,feeDelegation:o}=$(),{account:s,connectedWallet:c,connection:l}=Q(),{preferences:u}=Ip(),{data:d}=qf(s?.address??``,c?.address??``,3),{open:f}=Wd(),{handleSubmit:p}=Li({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),m=s?.domain??``,{data:h}=Ko(m),g=Vn(),{sendTransaction:_,txReceipt:v,error:y,isWaitingForWalletConfirmation:b,isTransactionPending:S,clauses:C}=Wo({resolverAddress:h,signerAccountAddress:s?.address??``,onSuccess:async()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:v?.meta.txID,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}});try{await pe()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),w=W(()=>{let e=s?.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,s?.domain]),T=W(()=>{try{return!h||w.length===0||!C?[]:C(w)}catch(e){return console.error(`Error building clauses:`,e),[]}},[w,C,h]),[ee,E]=V.useState(null),[te,D]=V.useState(null),ne=u.availableGasTokens.length>0&&(l.isConnectedWithPrivy||l.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:O,isLoading:re,error:ie,refetch:ae}=Lp({clauses:T,tokens:ee?[ee]:u.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),oe=O?.usedToken,se=(re||!O)&&l.isConnectedWithPrivy&&!o?.delegatorUrl,k=V.useCallback(e=>{E(e),D(e),setTimeout(()=>ae(),100)},[ae]),ce=!!oe&&!ie;V.useEffect(()=>{ie&&ee&&E(null)},[ie,ee]);let le=async()=>{if(d){f();return}try{w.length>0&&await _(w)}catch(e){console.error(`Error saving changes:`,e)}},ue=(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,de=()=>{p(le)()},fe=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},pe=async()=>{t.avatarIpfsHash&&(g.setQueryData(Io(m,a.type),x(`ipfs://`+t.avatarIpfsHash,a.type)),g.setQueryData(Yo(s?.address??``),x(`ipfs://`+t.avatarIpfsHash,a.type))),await g.invalidateQueries({queryKey:Bo(m,a.type)}),await g.refetchQueries({queryKey:Bo(m,a.type)})};return J(A,{as:`form`,onSubmit:p(le),children:[J(Z,{children:[q(L,{children:r(`Confirm Changes`)}),q(Ja,{isDisabled:S,onClick:fe}),q(F,{isDisabled:S})]}),J(P,{children:[J(z,{spacing:4,align:`stretch`,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&&ue(r(`Display Name`),t.displayName),t.description&&ue(r(`Description`),t.description),t.twitter&&ue(r(`Twitter`),t.twitter),t.website&&ue(r(`Website`),t.website),t.email&&ue(r(`Email`),t.email)]}),l.isConnectedWithPrivy&&q(Kp,{estimation:O,isLoading:re,isLoadingTransaction:S,onTokenChange:k,clauses:T,userSelectedToken:te})]}),q(I,{gap:4,w:`full`,children:q(Up,{transactionError:y,isSubmitting:S,isTxWaitingConfirmation:b,onConfirm:p(le),onRetry:de,transactionPendingText:r(`Saving changes...`),txReceipt:v,buttonText:r(`Confirm`),isDisabled:S||se,gasEstimationError:ie,hasEnoughGasBalance:ce,isLoadingGasEstimation:re,showGasEstimationError:!o?.delegatorUrl&&l.isConnectedWithPrivy,context:`customization`})})]})},El=({onEditClick:e,address:t,showHeader:n=!0,onLogout:r,showLinks:a=!0,showDescription:o=!0,showDisplayName:s=!0,showEdit:c=!0})=>{let{t:l}=Y(),{account:u,disconnect:d}=Q(),{network:f}=$(),{openAccountModal:p,closeAccountModal:m}=hd(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=qs(t,f.type),v=i(t),y=t===u?.address,b=_?.records?.url||_?.records?.[`com.x`]||_?.records?.email,x=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}};return J(z,{spacing:4,w:`full`,children:[q(A,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,background:n?`no-repeat url('${v}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),q(Hp,{wallet:{address:t,domain:_?.domain,image:_?.image,isLoadingMetadata:_?.isLoading,metadata:_?.records},props:{width:`120px`,height:`120px`}}),J(z,{w:`full`,spacing:2,children:[s&&_?.records?.display&&q(R,{fontSize:`xl`,color:h,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:_?.records?.display}),o&&_?.records?.description&&q(R,{fontSize:`sm`,color:g,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:_?.records?.description}),a&&b&&J(M,{w:`full`,justify:`center`,spacing:5,mt:4,children:[_?.records?.email&&q(ht,{href:`mailto:${_?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:q(N,{as:Tr,color:h})}),_?.records?.url&&q(ht,{href:x(_.records.url)??void 0,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`website-link`,children:q(N,{as:yr,color:h})}),_?.records?.[`com.x`]&&q(ht,{href:`https://x.com/${encodeURIComponent(String(_.records[`com.x`]))}`,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`twitter-link`,children:q(N,{as:Vi,color:h})})]}),q(Ya,{wallet:{address:t,domain:_?.domain,image:_?.image,isLoadingMetadata:_?.isLoading,metadata:_?.records},style:{mt:4}})]}),y&&c&&J(M,{w:`full`,justify:`space-between`,spacing:4,mt:4,children:[q(j,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(N,{as:Dr}),onClick:e??(()=>{p({type:`account-customization`,props:{setCurrentContent:()=>m()}})}),"data-testid":`customize-button`,children:l(`Customize`)}),q(j,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:q(N,{as:wr}),colorScheme:`red`,onClick:r??(()=>{p({type:`disconnect-confirm`,props:{onDisconnect:()=>{d(),m()},onBack:()=>m()}})}),"data-testid":`logout-button`,children:l(`Logout`)})]})]})},Dl=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=Yc(),{account:i,disconnect:a}=Q();return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Profile`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,spacing:2,children:[!i?.domain&&q(bl,{setCurrentContent:e}),q(El,{onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,onLogout:()=>{e?.({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}})}})]})}),q(I,{pt:0})]})},Ol=({setCurrentContent:e,handleClose:t,initialContent:n=`settings`})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=qf(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Qf({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(Ja,{onClick:()=>{e(n)}}),q(F,{})]}),q(P,{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(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:Yn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{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(I,{justifyContent:`center`,children:J(z,{spacing:3,w:`full`,children:[q(Up,{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(j,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},kl=({setCurrentContent:e})=>{let{account:t}=Q(),{sortedTokens:n}=ms({address:t?.address}),{allowCustomTokens:r,darkMode:i}=$(),{currentCurrency:a}=ps(),o=B(`colors`,`vechain-kit-text-tertiary`),{t:s}=Y(),{isolatedView:c}=Yc(),[l,u]=G(``),d=t=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:t,onBack:()=>e(`assets`)}})},f=n.filter(({symbol:e})=>e.toLowerCase().includes(l.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:s(`Assets`)}),!c&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[J(P,{children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12,value:l,onChange:e=>u(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:o})})]}),q(z,{spacing:2,align:`stretch`,mt:2,children:f.map(e=>{let t=Number(e.balance)>0;return q(ao,{symbol:e.symbol,amount:Number(e.balance),currencyValue:e.valueInCurrency,currentCurrency:a,onClick:()=>d(e),isDisabled:!t},e.address)})})]}),q(I,{children:r&&q(j,{variant:`vechainKitSecondary`,leftIcon:q(N,{as:Dr,boxSize:4}),onClick:()=>e(`add-custom-token`),children:s(`Manage Custom Tokens`)})})]})]})},Al=({setCurrentContent:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-primary`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-card`),a=B(`colors`,`vechain-kit-overlay`),{addToken:o,removeToken:s,isTokenIncluded:c,isDefaultToken:u,customTokens:d}=Cs(),{register:f,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=Li({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(c(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:t(`Token already added`)});try{await o(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token 2:`,e),m(`newTokenAddress`,{type:`manual`,message:t(`Invalid token address`)})}}};return J(K,{children:[J(Z,{children:[q(L,{children:t(`Manage Custom Tokens`)}),q(Ja,{onClick:()=>e(`assets`)}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,position:`relative`,children:[q(A,{p:6,borderRadius:`xl`,bg:i,children:q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!g.newTokenAddress,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:n,children:t(`Token Contract Address`)}),q(dt,{...f(`newTokenAddress`,{required:t(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:t(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||t(`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`}),g.newTokenAddress&&q(R,{color:`#ef4444`,fontSize:`sm`,children:g.newTokenAddress.message})]})})}),d.length>0&&J(A,{p:4,borderRadius:`xl`,bg:a,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,mb:2,children:t(`Existing Custom Tokens`)}),q(z,{align:`stretch`,spacing:2,children:d.map(e=>J(M,{justify:`space-between`,fontSize:`sm`,p:2,borderRadius:`md`,bg:i,children:[J(M,{children:[q(ut,{src:p[e?.symbol],alt:`${e.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:n,children:e.symbol?.slice(0,3)})})}),q(R,{fontWeight:`medium`,color:n,children:e.symbol??`Unknown`})]}),q(R,{color:r,children:l(e.address??``,4,4)}),q(j,{size:`sm`,variant:`ghost`,color:n,borderRadius:`md`,p:2,onClick:()=>s(e.address),children:q(Lr,{size:16,color:n})})]},e.address))})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!_,onClick:v(y),children:t(`Add Token`)})})]})},jl=({setCurrentContent:e})=>{let{t}=Y(),{darkMode:n}=$(),{isolatedView:r}=Yc();return J(K,{children:[J(Z,{children:[q(L,{children:t(`Bridge`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(tt,{maxW:`container.lg`,children:q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[q(Oe,{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(I,{children:J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(`https://swap.vechain.energy/`,`_blank`)},children:[t(`Launch vechain.energy`),q(N,{as:mr,ml:2})]})})]})},Ml=({setCurrentContent:e})=>{let{t}=Y(),{currentCurrency:n,changeCurrency:r,allCurrencies:i}=ps(),a=Kt(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`);U(()=>{h(`settings-currency-visited`,`true`)},[]);let o=e=>{let t=n===e;return J(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>r(e),py:6,px:4,bg:t?a:void 0,children:[J(M,{spacing:3,children:[q(R,{fontSize:`xl`,children:c[e]}),q(R,{children:e.toUpperCase()})]}),t&&q(N,{as:nr,boxSize:5,color:`blue.500`})]},e)};return J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Select currency`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:i.map(e=>o(e))})}),q(I,{pt:0})]})},Nl=({setCurrentContent:e})=>{let{t,i18n:n}=Y(),r=Kt(`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(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:t?r:void 0,children:[q(R,{children:ba[e]}),t&&q(N,{as:nr,boxSize:5,color:`blue.500`})]},e)};return J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Select language`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:va.map(e=>a(e))})}),q(I,{pt:0})]})},Pl=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:o,onTouchStart:s,onTouchMove:c,onTouchEnd:l,isDragging:u,isDraggedOver:d})=>{let p=f[e],{darkMode:m}=$(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-card`);return q(A,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:u?m?`blue.500`:`blue.300`:d?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:u||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:()=>o(t),onTouchStart:e=>s(t,e),onTouchMove:c,onTouchEnd:l,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:J(M,{justify:`space-between`,children:[J(M,{opacity:n?.5:1,children:[q(A,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:q(N,{as:br,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(Mt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},Fl=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=G(null),[o,s]=G(null),c=$t([]),l=$t(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(A,{w:`full`,children:e.map((e,n)=>q(A,{ref:e=>{c.current[n]=e},children:q(Pl,{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))})},Il=({setCurrentContent:e})=>{let{t}=Y(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Ip(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=H(e=>{r(e)},[r]);return J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Gas Token Preferences`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{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(Be,{status:`warning`,borderRadius:`md`,children:[q(He,{}),q(Ve,{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(Fl,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},Ll=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=Yc(),{exportWallet:i,linkPasskey:a}=En(),{showMfaEnrollmentModal:o}=Tn(),{feeDelegation:s}=$(),{connection:c,disconnect:l,smartAccount:u,connectedWallet:d}=Q(),{data:f}=qf(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(A,{children:[J(Z,{children:[q(L,{children:n(`Settings`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(P,{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(fl,{title:n(`Currency`),onClick:()=>{e(`change-currency`)},leftIcon:fr,rightIcon:ar}),q(fl,{title:n(`Language`),onClick:()=>{e(`change-language`)},leftIcon:Sr,rightIcon:ar}),c.isConnectedWithPrivy&&!s?.delegatorUrl&&q(fl,{title:n(`Gas Token Preferences`),onClick:()=>{e(`gas-token-settings`)},leftIcon:gr,rightIcon:ar}),q(fl,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:Nr,rightIcon:ar})]}),f&&q(z,{w:`full`,spacing:2,mt:4,children:q(fl,{title:n(`Upgrade Smart Account to V3`),description:n(`A new version is available for your account`),onClick:p,leftIcon:Mr,extraContent:q(A,{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(fl,{title:n(`Passkey`),onClick:()=>a(),leftIcon:hr}),q(fl,{title:n(`Backup`),onClick:()=>{i()},leftIcon:xr}),q(fl,{title:n(`Manage MFA`),onClick:()=>{o()},leftIcon:Pr}),q(fl,{title:n(`Login methods`),onClick:()=>{e(`privy-linked-accounts`)},leftIcon:zr,rightIcon:ar})]}),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(fl,{title:n(`Frequently asked questions`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:lr,rightIcon:ar}),q(fl,{title:n(`Connection details`),onClick:m,leftIcon:Rr,rightIcon:ar}),q(fl,{title:n(`Explore ecosystem`),onClick:()=>e(`ecosystem`),leftIcon:Cr,rightIcon:ar})]})]}),q(I,{w:`full`,children:J(z,{w:`full`,spacing:4,children:[q(nt,{}),q(fl,{title:n(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:h,onBack:()=>e(`settings`)}}),leftIcon:wr})]})})]})},Rl=({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(N,{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})]})]})},zl=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),Bl=({document:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===m.VECHAIN_KIT&&e.documentType===se.TERMS;return J(M,{children:[J(Nt,{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:zl(e.timestamp)})})]})},Vl=({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(Re,{border:`none`,mb:3,children:({isExpanded:l})=>J(K,{children:[J(Le,{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(N,{as:l?or:rr,fontSize:`20px`,color:c})]}),q(ze,{pb:4,pt:3,children:J(z,{align:`stretch`,spacing:4,children:[u?.id?J(M,{w:`full`,children:[q(N,{as:nr,color:s}),q(R,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:zl(u.timestamp)})})]}):null,q(M,{w:`full`,textAlign:`left`,children:q(R,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),q(M,{w:`full`,gap:2,children:q(z,{align:`stretch`,spacing:2,children:n.map(e=>q(Bl,{document:e},e.id))})}),a&&q(j,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Hl=()=>{let{account:e}=Q(),{t}=Y(),{darkMode:n}=$(),{agreements:r,documents:i}=rm(),a=W(()=>{let t=r?.filter(t=>o(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...E,documentType:se.TERMS,documentSource:m.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),s=W(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),c=W(()=>Object.values(a).some(e=>e.length>0),[a]),l=n?`whiteAlpha.50`:`blackAlpha.50`,u=n?`whiteAlpha.100`:`blackAlpha.100`;return c?q(z,{spacing:4,align:`stretch`,children:J(Ie,{allowMultiple:!0,children:[q(Vl,{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[se.TERMS],bg:l,hoverBg:u,currentPolicy:s[se.TERMS]}),q(Vl,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[se.PRIVACY],bg:l,hoverBg:u,currentPolicy:s[se.PRIVACY]}),q(Vl,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[se.COOKIES],bg:l,hoverBg:u,currentPolicy:s[se.COOKIES]})]})}):q(Rl,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:_r})},Ul=({onGoBack:e})=>{let{t}=Y();return J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Terms and Policies`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:q(z,{spacing:6,align:`stretch`,children:q(Hl,{})})}),q(I,{pt:0})]})},Wl=({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(Vp,{children:[J(Z,{children:[q(L,{children:a(`Logout`)}),q(Ja,{onClick:t}),r?q(F,{onClick:n}):null]}),q(P,{children:q(z,{spacing:6,align:`stretch`,children:q(R,{fontSize:`md`,textAlign:`center`,color:o,children:s})})}),q(I,{w:`full`,children:J(z,{spacing:3,w:`full`,children:[q(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:e,"data-testid":`disconnect-button`,children:a(`Confirm`)}),q(j,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},Gl=Za[`@vechain/dapp-kit-react`]||Qa[`@vechain/dapp-kit-react`]||`unknown`,Kl=Za[`@privy-io/react-auth`]||`unknown`,ql=({connectionCache:e})=>{let{t}=Y(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{source:a}=Fn(),{privy:o,network:s}=$(),c=o?.appId,{data:u,isLoading:d}=co(c||[]),{onCopy:f,hasCopied:p}=Wt(``),{data:m,isLoading:h}=uo(),{data:g,isLoading:_}=Mf(r.address??``,i?.address??``),v=B(`colors`,`vechain-kit-card`),y=B(`colors`,`vechain-kit-text-secondary`),b=B(`colors`,`vechain-kit-text-primary`),x=(()=>n.isConnectedWithCrossApp&&e?.ecosystemApp?e.ecosystemApp.name:n.isConnectedWithSocialLogin&&u?Object.values(u)[0]?.name??null:n.isConnectedWithDappKit&&a?a:null)(),S=n.isConnectedWithSocialLogin&&d,C=({label:e,value:t,isLoading:n=!1,href:r})=>J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:b,children:[e,`:`]}),q(R,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:y,children:n?`Loading...`:t})]});return S?q(z,{w:`full`,h:`full`,justify:`center`,align:`center`,minH:`200px`,borderRadius:`xl`,bg:v,children:q(At,{})}):x?J(z,{p:4,bg:v,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[q(C,{label:t(`Logged in with`),value:x}),n.isConnectedWithCrossApp&&e?.timestamp&&q(C,{label:t(`At`),value:new Date(e.timestamp).toLocaleString()}),q(C,{label:t(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),q(nt,{}),q(C,{label:t(`Network`),value:s.type}),q(C,{label:t(`Node URL`),value:s.nodeUrl||k(s.type).nodeUrl}),n.isConnectedWithPrivy&&q(nt,{}),n.isConnectedWithPrivy&&J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:b,children:[t(`Embedded wallet`),`:`]}),J(M,{children:[q(R,{fontSize:`sm`,color:y,children:i?.address?l(i.address,8,7):`-`}),q(N,{color:y,onClick:()=>{i?.address&&f(i.address)},opacity:i?.address?1:.4,pointerEvents:i?.address?`auto`:`none`,cursor:`pointer`,as:p?nr:dr})]})]}),n.isConnectedWithPrivy?J(K,{children:[q(C,{label:t(`Smart Account`),value:`v${g?.version??``} ${g?.isDeployed?``:`(not deployed)`}`,isLoading:_}),q(C,{label:t(`Privy Status`),value:m||``,isLoading:h})]}):r.isDeployed&&q(C,{label:t(`Smart Account`),value:`v${g?.version??``}`,isLoading:_}),q(nt,{}),q(C,{label:t(`VeChain Kit`),value:Xa,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`}),q(C,{label:`DAppKit`,value:Gl}),q(C,{label:`Privy`,value:Kl})]}):null},Jl=()=>{let{connection:e}=Q(),{t}=Y(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=$d(),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(M,{justify:`center`,children:[q(Se,{isDark:r,w:`50px`}),q(N,{as:Er,ml:3}),e.isConnectedWithVeChain?q(fe,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&q(ut,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&q(ut,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]}):null},Yl=({onGoBack:e})=>{let{t}=Y(),{getConnectionCache:n}=$d(),r=n()??void 0;return J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Connection Details`)}),q(Ja,{onClick:()=>{e()}}),q(F,{})]}),J(P,{w:`full`,children:[q(ql,{connectionCache:r}),q(Jl,{})]}),q(I,{pt:0})]})},Xl=({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(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),q(j,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Zl=({onBack:e})=>{let{t}=Y(),{privy:n,dappKit:r}=$(),[i,a]=G(null),[o,s]=G(!1),[c,u]=G(!1),[d,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:T,linkTelegram:ee,linkFarcaster:E,linkPasskey:te,linkDiscord:D,unlinkEmail:ne,unlinkGoogle:O,unlinkApple:re,unlinkSpotify:ie,unlinkInstagram:ae,unlinkTiktok:oe,unlinkGithub:se,unlinkLinkedIn:k,unlinkTelegram:ce,unlinkFarcaster:le,unlinkPhone:ue,unlinkPasskey:de,unlinkDiscord:fe,linkWallet:pe}=Dn(),me=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]),he=e=>{switch(e){case`google_oauth`:return Ii;case`email`:return Tr;case`passkey`:return hr;case`wallet`:return Br;case`twitter_oauth`:return Vi;case`phone`:return Or;case`spotify_oauth`:return qi;case`apple_oauth`:return Ui;case`instagram_oauth`:return Gi;case`tiktok_oauth`:return Xi;case`github_oauth`:return vr;case`linkedin_oauth`:return Ki;case`telegram`:return Ji;case`farcaster`:return Hi;case`discord_oauth`:return Wi;default:return}},ge=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},_e=async e=>{if(ge()){f(!0);try{switch(e.type){case`google_oauth`:await O(e.subject);break;case`email`:await ne(e.address);break;case`passkey`:await de(e.subject);break;case`phone`:await ue(e.number);break;case`spotify_oauth`:await ie(e.subject);break;case`apple_oauth`:await re(e.subject);break;case`instagram_oauth`:await ae(e.subject);break;case`tiktok_oauth`:await oe(e.subject);break;case`github_oauth`:await se(e.subject);break;case`linkedin_oauth`:await k(e.subject);break;case`telegram`:await ce(e.subject);break;case`farcaster`:await le(e.subject);break;case`discord_oauth`:await fe(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},ve=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`${l(e.address)} - ${e.walletClientType}`;default:return``}},ye=h?.linkedAccounts?.map(e=>e.type)||[],be=n?.loginMethods||[],xe=!ye.includes(`google_oauth`)&&be.includes(`google`),Se=!ye.includes(`email`)&&be.includes(`email`),Ce=!ye.includes(`twitter_oauth`)&&be.includes(`twitter`),we=!ye.includes(`phone`)&&be.includes(`sms`),Te=!ye.includes(`spotify_oauth`)&&be.includes(`spotify`),Ee=!ye.includes(`apple_oauth`)&&be.includes(`apple`),De=!ye.includes(`instagram_oauth`)&&be.includes(`instagram`),Oe=!ye.includes(`tiktok_oauth`)&&be.includes(`tiktok`),ke=!ye.includes(`github_oauth`)&&be.includes(`github`),Ae=!ye.includes(`linkedin_oauth`)&&be.includes(`linkedin`),je=!ye.includes(`telegram`)&&be.includes(`telegram`),Me=!ye.includes(`farcaster`)&&be.includes(`farcaster`),Ne=!ye.includes(`discord_oauth`)&&be.includes(`discord`);return o?J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Select Additional Login Method`)}),q(Ja,{onClick:()=>s(!1)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:3,align:`stretch`,w:`full`,children:[q(fl,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>te(),leftIcon:hr}),xe&&q(fl,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:Ii}),Se&&q(fl,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Tr,stacked:!0}),Ce&&q(fl,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:Vi}),we&&q(fl,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:Or}),Te&&q(fl,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:qi}),Ee&&q(fl,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:Ui}),De&&q(fl,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:Gi}),Oe&&q(fl,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:Xi}),ke&&q(fl,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:vr}),Ae&&q(fl,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>T(),leftIcon:Ki}),je&&q(fl,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>ee(),leftIcon:Ji}),Me&&q(fl,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>E(),leftIcon:Hi}),Ne&&q(fl,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>D(),leftIcon:Wi}),me&&q(fl,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>pe(),leftIcon:Br}),!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),q(I,{pt:0})]}):i?J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Remove Login Method`)}),q(Ja,{onClick:()=>a(null)}),q(F,{})]}),q(P,{children:q(Xl,{accountType:i.type,accountDescription:ve(i),isLoading:d,onConfirm:()=>_e(i),onCancel:()=>a(null)})}),q(I,{pt:0})]}):J(Vp,{children:[J(Z,{children:[q(L,{children:t(`Login methods`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{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(j,{variant:`link`,mt:0,size:`sm`,onClick:()=>u(!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(rt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[J(rt,{align:`center`,gap:3,children:[q(N,{as:he(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:ve(e)})]})]}),q(j,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!ge(),onClick:()=>{e.type===`passkey`?te():a(e)},children:t(`Remove`)})]},e.type))]})}),q(I,{w:`full`,children:q(j,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:q(N,{as:kr}),isDisabled:!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne,children:t(`Add Login Method`)})})]})},Ql=[{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}],$l=()=>{let{t:e}=Y(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=eu(),{data:o}=Xf(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])},eu=()=>{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||!y())return;let n=t(e.address);w(n.initialized)||(h(n.notifications,JSON.stringify(Ql)),h(n.initialized,`true`))},[e?.address,t]);U(()=>{n()},[n]);let r=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r(),o=w(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};h(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r().filter(e=>e.id!==n);h(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:H(()=>{if(!e?.address||!y())return;let n=t(e.address),a=r();h(n.archived,JSON.stringify([...i(),...a])),h(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:H(n=>{if(!e?.address||!y())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];h(a.notifications,JSON.stringify(l)),h(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},tu=({showArchived:e})=>{let{t}=Y();return q(Rl,{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?Gn:Qn})},nu=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=Y(),i=()=>{n(e.id)};return e.isRead&&!t?null:J(Be,{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(He,{boxSize:`16px`}),J(A,{children:[q(Ue,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),q(Ve,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&q(lt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:q(ur,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},ru=({setCurrentContent:e})=>{let{t}=Y(),{isolatedView:n}=Yc(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=eu(),[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(Vp,{children:[J(Z,{children:[!n&&q(Ja,{onClick:()=>e(`main`)}),q(L,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[q(P,{children:J(z,{spacing:4,align:`stretch`,w:`full`,children:[J(M,{justify:`space-between`,children:[q(j,{variant:`ghost`,leftIcon:q(N,{as:s?Qn:Gn}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&q(j,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?q(tu,{showArchived:s}):q(z,{spacing:3,children:_.map(e=>q(nu,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),q(I,{pt:0})]})]})},iu=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`}},au=({category:e,...t})=>{let{t:n}=Y(),r=e.toLowerCase();return q(Nt,{size:`sm`,colorScheme:iu(r),borderRadius:`full`,px:2,...t,children:n(r)})},ou=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>J(Ge,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&q(A,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:q(au,{category:r})}),q(Ke,{p:a===`sm`?2:4,alignItems:`center`,children:J(z,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&q(ut,{src:t,fallbackSrc:D,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&q(R,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),su=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=Zs(e.id),{data:a,isLoading:o}=ic(r?.logo);return q(kt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:q(ou,{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}})}})})},cu=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>q(ou,{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}}),lu=({})=>{let{t:e}=Y(),{shortcuts:t}=Op();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(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>q(st,{children:q(Ge,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:q(Ke,{p:2,alignItems:`center`,children:q(ut,{src:e.image,fallbackSrc:D,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},uu=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=Y();return J(A,{width:`full`,mb:4,children:[q(R,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),J(It,{spacing:2,children:[q(Lt,{children:q(Nt,{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(Lt,{children:q(au,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},du=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:`https://governance.vebetterdao.org/`,logo:`https://i.ibb.co/cgJBj83/vbd.png`,banner:`https://i.ibb.co/cgJBj83/vbd.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://i.ibb.co/cgJBj83/vbd.png`},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:`https://vet.domains`,logo:`https://vet.domains/assets/walletconnect.png`,banner:`https://vet.domains/assets/walletconnect.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://vet.domains/assets/walletconnect.png`},categories:[]}],fu=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=Y(),{darkMode:r,network:i}=$(),{isolatedView:a}=Yc(),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}=ys(),{data:f}=Vs(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=sf(),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=du.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}=Op();return J(A,{children:[J(Z,{children:[q(L,{children:n(`Ecosystem`)}),!a&&q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{overflowY:`auto`,minH:`300px`,children:J(z,{spacing:6,w:`full`,children:[q(lu,{setCurrentContent:e}),S.length>0&&q(R,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),J(ft,{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(pt,{h:`56px`,w:`56px`,pl:4,children:q(jr,{color:o})})]}),g.length>0&&q(uu,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),J(ot,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&q(K,{children:v.map(t=>q(st,{children:q(cu,{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(st,{children:q(su,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?q(st,{colSpan:2,children:q(Ye,{py:4,children:q(At,{})})}):h?q(st,{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(st,{children:q(cu,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&q(st,{colSpan:2,children:q(Ye,{py:4,children:q(R,{children:n(`No apps found in this category`)})})})]})]})}),q(I,{pt:0})]})},pu=({name:e,image:t,url:n,description:r})=>{let{t:i}=Y(),{isShortcut:a,addShortcut:o,removeShortcut:s}=Op(),c=a(n);return q(j,{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(N,{as:c?er:$n}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},mu=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=Y();return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(Ja,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[J(rt,{direction:`column`,align:`center`,children:[s||q(ut,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&q(M,{mt:2,children:q(au,{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(I,{children:J(z,{w:`full`,spacing:4,children:[J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),q(N,{as:mr,ml:2})]}),q(pu,{name:t,image:n,url:r,description:i})]})})]})},hu=({children:e})=>q(Wn.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}),gu=({descriptionEncoded:e})=>{let{darkMode:t}=$();return J(M,{gap:2,children:[q(hu,{children:q(ht,{href:`https://twitter.com/intent/tweet?text=${e}`,isExternal:!0,children:q(A,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:q(Vi,{size:22})})})}),q(hu,{children:q(ht,{href:`https://telegram.me/share/url?url=${e}`,isExternal:!0,children:q(A,{bg:`#30abec`,p:2,borderRadius:`full`,children:q(Yi,{color:`white`,size:22})})})}),q(hu,{children:q(ht,{href:`https://wa.me/?text=${e}`,isExternal:!0,children:q(A,{bg:`#01cb37`,p:2,borderRadius:`full`,children:q(Zi,{size:22,color:`white`})})})})]})},_u=({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(At,{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(N,{as:sr,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(N,{as:cr,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=`${k(s.type).explorerUrl}/${r?.meta.txID}`;return J(A,{children:[J(Z,{children:[q(L,{children:p.title}),q(F,{isDisabled:e===`pending`&&!t?.isClosable})]}),q(P,{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(gu,{descriptionEncoded: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(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[e===`error`&&!!n&&J(j,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[q(N,{mr:2,as:Ar}),o(`Try again`)]}),e===`ready`&&q(j,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&q(j,{onClick:a,variant:`vechainKitSecondary`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&q(ht,{href:`${k(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:o(`View transaction on the explorer`)}),q(N,{size:`sm`,as:mr,color:d})]})})]})})]})},vu=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:q(_u,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})}),yu=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(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(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:cr,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(gu,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:a(`View transaction on the explorer`)}),q(N,{size:16,as:mr})]})})]})})]})},bu=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=Y(),{network:a,darkMode:o}=$(),s=k(a.type).explorerUrl;return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:sr,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:i(`View transaction on the explorer`)}),q(N,{size:16,as:mr})]})})]})})]})},xu={enter:e=>({opacity:0,x:e===`forward`?20:-20}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e===`forward`?-20:20})},Su={duration:.17,ease:[.4,0,.2,1]},Cu=e=>{if(typeof e==`string`)return e;let t=e.type,n=JSON.stringify(e.props),r=0;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);r=(r<<5)-r+t,r&=r}return`${t}-${Math.abs(r)}`},wu=({isOpen:e,onClose:t,initialContent:n=`main`})=>{$l();let{account:r}=Q(),i=$t(null),a=$t(`forward`),{accountModalContent:o,setAccountModalContent:s}=hd();U(()=>{e&&n&&s(n)},[e,n,s]);let c=(()=>{if(i.current===null||i.current===o)return a.current;let e=Cu(i.current),t=Cu(o);return t===`main`||t===`settings`&&e!==`main`||e.includes(`summary`)||e.includes(`confirm`)||e.includes(`operation`)?`backward`:`forward`})();U(()=>{a.current=c,i.current=o},[o,c]);let l=(()=>{if(typeof o==`object`)switch(o.type){case`send-token`:return q(Xc,{...o.props});case`send-token-summary`:return q(Zc,{...o.props});case`swap-token`:return q(nl,{...o.props});case`choose-name`:return q(rl,{...o.props});case`choose-name-search`:return q(sl,{...o.props});case`choose-name-summary`:return q(cl,{...o.props});case`app-overview`:return q(mu,{...o.props,setCurrentContent:s});case`disconnect-confirm`:return q(Wl,{...o.props});case`account-customization`:return q(wl,{...o.props});case`account-customization-summary`:return q(Tl,{...o.props});case`successful-operation`:return q(yu,{...o.props});case`failed-operation`:return q(bu,{...o.props});case`upgrade-smart-account`:return q(Ol,{...o.props});case`faq`:return q(ul,{...o.props});case`terms-and-privacy`:return q(Ul,{...o.props});case`ecosystem-with-category`:return q(fu,{setCurrentContent:s,selectedCategory:o.props.selectedCategory})}switch(o){case`main`:return q(qc,{setCurrentContent:s,onClose:t,wallet:r});case`settings`:return q(Ll,{setCurrentContent:s,onLogoutSuccess:()=>{t()}});case`profile`:return q(Dl,{setCurrentContent:s,onLogoutSuccess:()=>{t()}});case`assets`:return q(kl,{setCurrentContent:s});case`bridge`:return q(jl,{setCurrentContent:s});case`notifications`:return q(ru,{setCurrentContent:s});case`receive-token`:return q(Qc,{setCurrentContent:s});case`swap-token`:return q(nl,{setCurrentContent:s});case`connection-details`:return q(Yl,{onGoBack:()=>s(`settings`)});case`privy-linked-accounts`:return q(Zl,{onBack:()=>s(`settings`)});case`ecosystem`:return q(fu,{setCurrentContent:s});case`add-custom-token`:return q(Al,{setCurrentContent:s});case`change-currency`:return q(Ml,{setCurrentContent:s});case`change-language`:return q(Nl,{setCurrentContent:s});case`gas-token-settings`:return q(Il,{setCurrentContent:s});default:return null}})(),u=Cu(o);return q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:q(Un,{mode:`wait`,initial:!1,children:l&&q(Wn.div,{custom:a.current,variants:xu,initial:`enter`,animate:`center`,exit:`exit`,transition:Su,style:{width:`100%`},children:l},u)})})},Tu=({isOpen:e,onClose:t})=>{let[n,r]=G(`main`);return U(()=>{e&&r(`main`)},[e]),q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:(()=>{switch(n){case`main`:return q(Gc,{setCurrentContent:r,onClose:t});case`faq`:return q(ul,{onGoBack:()=>r(`main`)})}})()})},Eu=({onClick:e,text:t,icon:n,customIcon:r,rightIcon:i,style:a,variant:o=`loginIn`,iconWidth:s=`25px`})=>t?t?J(j,{...a,variant:o,w:`full`,onClick:e,children:[J(M,{w:`full`,justify:`flex-start`,gap:2,children:[r||q(N,{as:n,w:s,h:s}),q(R,{opacity:.9,children:t})]}),i]}):null:q(j,{...a,variant:o,w:`full`,onClick:e,children:r||q(N,{as:n,w:`20px`,h:`20px`})}),Du=({isLoading:e,buttonStyle:t})=>{let{t:n}=Y(),{loginMethods:r,darkMode:i,privyEcosystemAppIDS:a}=$(),o=r?.some(({method:e})=>e===`ecosystem`),{data:s,isLoading:c}=co(a);return q(Ct,{placement:`bottom-start`,size:`xl`,closeOnBlur:!1,variant:`vechainKitBase`,children:({isOpen:r})=>J(K,{children:[q(Dt,{children:J(j,{isLoading:e,...t,isActive:r,children:[n(`Login`),q(N,{ml:2,as:rr,transform:r?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`})]})}),J(Tt,{children:[q(wt,{children:q(Uc,{})}),q(Et,{borderTop:`none`,pb:`15px`,children:o&&q(M,{justify:`center`,w:`full`,children:q(Wc,{isDark:i,appsInfo:Object.values(s||{}),isLoading:c})})})]})]})})},Ou=({variant:e})=>{let{account:t}=Q();return t?e===`icon`?null:e===`iconAndDomain`?t.domain?q(R,{fontSize:`sm`,children:d(t?.domain??``,16,0)}):q(R,{fontSize:`sm`,children:l(t.address??``,6,4)}):e===`iconDomainAndAssets`?J(M,{spacing:4,children:[J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,"data-testid":`trimmed-address`,children:l(t.address??``,4,4)})]}),q(ml,{address:t.address??``,maxIcons:3})]}):J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,children:l(t.address??``,4,4)})]}):q(At,{})},ku=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconAndDomain`,onOpen:n,buttonStyle:r={}})=>{let{account:i}=Q(),[a]=Jt(`(min-width: 768px)`);return q(j,{...r,onClick:n,w:`full`,minH:`45px`,maxW:`fit-content`,"data-testid":`wallet-button`,children:J(M,{w:`full`,minW:`fit-content`,children:[q(Hp,{wallet:i,props:{width:30,height:30,minWidth:30,minHeight:30}}),q(Ou,{variant:a?t:e})]})})},Au=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconDomainAndAddress`,buttonStyle:n,connectionVariant:r=`modal`})=>{let{t:i}=Y(),{darkMode:a,loginMethods:o}=$(),s=o?.length===1&&o[0].method===`dappkit`,{connection:c,account:l}=Q(),{setSource:u,connectV2:d}=Pn(),[f]=Jt(`(max-width: 768px)`),p=qt(),m=qt(),{open:h}=In();return J(pd,{darkMode:a,children:[c.isConnected&&l?q(ku,{mobileVariant:e,desktopVariant:t,onOpen:m.onOpen,buttonStyle:n}):r===`popover`&&!f?q(Du,{isLoading:c.isLoading,buttonStyle:n}):q(j,{isLoading:c.isLoading,onClick:()=>{c.isInAppBrowser?(u(`veworld`),d(null)):s?h():p.onOpen()},...n,children:i(`Login`)}),q(Tu,{isOpen:p.isOpen,onClose:p.onClose}),q(wu,{isOpen:m.isOpen,onClose:m.onClose})]})},ju=()=>{let{darkMode:e}=$(),t=25/2,[n]=Jt(`(max-width: 280px)`),[r]=Jt(`(max-width: 380px)`);return J(M,{spacing:0,ml:0,children:[q(Qe,{size:`25px`,borderRadius:`full`,bg:`#F8F8F8`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:3,children:q(N,{as:Ii,fontSize:`20px`})}),!n&&q(Qe,{ml:`-${t}px`,size:`25px`,borderRadius:`full`,bg:`black`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:2,children:q(N,{as:Vi,color:`white`,fontSize:`20px`})}),!n&&!r&&q(Qe,{ml:`-${t}px`,zIndex:1,size:`25px`,borderRadius:`full`,bg:`#5865F2`,p:2,alignItems:`center`,justifyContent:`center`,children:q(N,{as:Bi,color:`white`,fontSize:`20px`})}),q(N,{zIndex:1,as:kr,color:e?`black`:`white`,fontSize:`15px`})]})},Mu=({status:e,txReceipt:t,txError:n,onTryAgain:r,description:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=k(s.type).explorerUrl,l=W(()=>n?n.reason||o(`Something went wrong. Please try again.`):null,[n,o]),u=(()=>{let t=e===`waitingConfirmation`;switch(t&&(e=`pending`),e){case`pending`:return{icon:q(At,{size:`md`,"data-testid":`pending-spinner-toast`}),title:o(t?`Processing transaction...`:`Waiting for confirmation...`),closeDisabled:!0,description:t?o(`Transaction is being processed, it can take up to 15 seconds.`):i??o(`Please confirm the transaction in your wallet.`)};case`error`:return{icon:q(N,{as:sr,color:`red.500`,fontSize:`40px`,"data-testid":`error-icon-toast`}),title:o(`Transaction failed`),closeDisabled:!1,description:l};case`success`:return{icon:q(N,{as:cr,color:`green.500`,fontSize:`40px`,"data-testid":`success-icon-toast`}),title:o(`Transaction successful!`),closeDisabled:!1,description:void 0};case`ready`:return{icon:null,title:o(`Confirm transaction`),closeDisabled:!1,description:i??o(`Confirm the transaction in your wallet to complete it.`)};default:return{icon:null,title:``,closeDisabled:!1,description:``}}})();return u?J(M,{justify:`space-between`,alignItems:`flex-start`,w:`full`,children:[q(z,{spacing:4,children:J(M,{spacing:4,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,children:[u.icon,J(z,{w:`full`,align:`flex-start`,spacing:2,children:[J(z,{spacing:1,w:`full`,children:[q(ct,{w:`full`,size:`xs`,children:u.title}),u.description&&q(R,{fontSize:`xs`,children:u.description})]}),(e===`error`||e===`ready`)&&q(j,{size:`xs`,onClick:r,children:o(e===`error`?`Try again`:`Confirm`)}),t&&e!==`pending`&&J(ht,{fontSize:`xs`,isExternal:!0,href:`${c}/${t.meta.txID}`,children:[o(`View on explorer`),` `,q(N,{as:mr})]})]})]})}),!u.closeDisabled&&q(lt,{onClick:a,variant:`ghost`,size:`sm`,borderRadius:`full`,"aria-label":`Close`,icon:q(N,{as:Vr,boxSize:4})})]}):null},Nu=({isOpen:e,onClose:t,status:n,txReceipt:r,txError:i,onTryAgain:a,description:o})=>{let{darkMode:s}=$();return e?q(A,{position:`fixed`,bottom:`5`,left:`5`,zIndex:`11111`,bg:s?`#1f1f1e`:`white`,borderRadius:`md`,p:5,boxShadow:`lg`,maxW:`sm`,minW:`300px`,children:q(Mu,{status:n,txReceipt:r,txError:i,onTryAgain:a,description:o,onClose:t})}):null},Pu=({isOpen:e,onClose:t,error:n,title:r,loadingText:i,onTryAgain:a=()=>{}})=>q(to,{isOpen:e,onClose:t,trapFocus:!1,autoFocus:!1,backdropFilter:`blur(3px)`,children:n?q(Iu,{error:n,onClose:t,onTryAgain:a}):q(Fu,{loadingText:i,title:r,onTryAgain:a})}),Fu=({loadingText:e,title:t,onTryAgain:n})=>{let{t:r}=Y(),[i,a]=V.useState(!1);return V.useEffect(()=>{let e=setTimeout(()=>{a(!0)},7e3);return()=>clearTimeout(e)},[Pi]),J(K,{children:[q(Z,{children:q(L,{children:t??r(`Connecting...`)})}),J(P,{children:[q(z,{align:`center`,p:6,gap:0,w:`full`,justifyContent:`center`,minH:`150px`,children:q(At,{size:`xl`})}),e&&!i&&q(R,{size:`sm`,textAlign:`center`,children:e}),i&&J(z,{mt:4,spacing:2,children:[q(R,{color:`orange.300`,size:`sm`,textAlign:`center`,children:r(`This is taking longer than expected.`)}),q(R,{size:`sm`,textAlign:`center`,children:r(`You may want to try establishing the connection again.`)})]})]}),q(I,{justifyContent:`center`,children:i&&J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Ar}),r(`Try again`)]})})]})},Iu=({error:e,onClose:t,onTryAgain:n})=>{let{t:r}=Y();return J(K,{children:[J(Z,{children:[q(L,{children:r(`Connection Failed`)}),q(F,{onClick:()=>{t()}})]}),q(P,{children:J(z,{align:`center`,p:6,w:`full`,justifyContent:`center`,minH:`100px`,gap:4,children:[q(Wn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:sr,color:`#ef4444`,fontSize:`60px`,opacity:.5})}),q(R,{w:`full`,size:`sm`,textAlign:`center`,children:e})]})}),q(I,{justifyContent:`center`,children:J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Ar}),r(`Try again`)]})})]})},Lu=({onClose:e,appsInfo:t,isLoading:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-primary`),[a,o]=G(),[s,c]=G(),l=qt(),{setConnectionCache:u}=$d(),{login:d}=Ks(),f=async(n,i)=>{l.onOpen();try{o(void 0),c(i);try{await d(n),l.onClose(),u({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 t=e?.message;if(t&&g(t))return Error(`Login request was cancelled.`);o((e instanceof Error?e:Error(`'An unexpected issue occurred while logging in with this app. Please try again or contact support.',`)).message)}}catch(e){console.error(r(`Login failed:`),e),o(e instanceof Error?e.message:r(`Failed to connect with ecosystem app`))}};return J(A,{children:[J(K,{children:[q(Z,{children:J(L,{children:[r(`Already have an x2earn app wallet?`),q(F,{onClick:()=>{e()}})]})}),J(P,{children:[n&&q(z,{minH:`200px`,w:`full`,justifyContent:`center`,children:q(At,{})}),!n&&t&&q(z,{spacing:4,w:`full`,pb:6,children:t.map(e=>J(j,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{f(e.id,e.name)},justifyContent:`flex-start`,children:[q(ut,{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:i,children:r(`No application from VeChain ecosystem is available to login.`)})]}),q(I,{pt:0})]}),q(Pu,{isOpen:l.isOpen,onClose:()=>{l.onClose()},error:a,title:`${r(`Connecting with`)} ${s}`,loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:()=>{if(s){let e=t.find(e=>e.name===s);e&&f(e.id,e.name)}}})]})},Ru=({isOpen:e,onClose:t,appsInfo:n,isLoading:r})=>q(to,{isOpen:e,onClose:t,backdropFilter:`blur(3px)`,children:q(Lu,{onClose:t,appsInfo:n,isLoading:r})}),zu=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`);return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(Wn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:cr,fontSize:`100px`,color:l})}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n}),i&&e&&J(z,{mt:2,children:[q(R,{fontSize:`xs`,children:a(`Share on`)}),q(gu,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:a(`View transaction on the explorer`)}),q(N,{size:16,as:mr})]})})]})})]})},Bu=({setCurrentContent:e,handleClose:t,style:n})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=qf(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Qf({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()},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(F,{})]}),q(P,{children:J(z,{spacing:10,align:`stretch`,justifyContent:`center`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(`To continue interacting with VeChain blockchain and complete your operation, your smart account needs to be upgraded to the latest version (v3).`)}),J(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:Yn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{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(I,{justifyContent:`center`,children:q(z,{spacing:3,w:`full`,children:q(Up,{style:n,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})})})]})},Vu=({isOpen:e,onClose:t,style:n})=>{let[r,i]=G(`upgrade-smart-account`);return U(()=>{e&&i(`upgrade-smart-account`)},[e]),q(to,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,size:n?.modalSize,children:(()=>{if(typeof r==`object`)switch(r.type){case`successful-operation`:return q(zu,{...r.props})}else if(r===`upgrade-smart-account`)return q(Bu,{setCurrentContent:i,handleClose:t,style:n})})()})},{definePartsStyle:Hu,defineMultiStyleConfig:Uu}=Rt(ra.keys),Wu=e=>({vechainKitBase:Hu({dialog:{scrollbarWidth:`none`,overflow:`scroll`,overflowX:`hidden`,maxHeight:`600px`,rounded:e.modal.rounded??e.borders.radius.modal,backgroundColor:e.colors.background.modal,backdropFilter:e.effects.backdropFilter.modal,border:e.colors.border.modal},overlay:{backgroundColor:e.colors.background.overlay,backdropFilter:e.effects.backdropFilter.overlay},closeButton:{borderRadius:e.borders.radius.full,color:e.colors.text.primary,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8}},header:{w:`full`,color:e.colors.text.primary,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.bold,textAlign:`center`}})}),Gu=e=>Uu({variants:Wu(e),defaultProps:{variant:`vechainKitBase`}}),{definePartsStyle:Ku,defineMultiStyleConfig:qu}=Rt(na.keys),Ju=e=>({vechainKitBase:Ku({container:{backgroundColor:e.colors.background.card,borderRadius:e.borders.radius.medium,width:`full`,border:`none`},body:{p:5,width:`full`},header:{p:5,width:`full`,borderRadius:`${e.borders.radius.medium} ${e.borders.radius.medium} 0 0`},footer:{width:`full`,borderRadius:`0 0 ${e.borders.radius.medium} ${e.borders.radius.medium}`}}),featureAnnouncement:Ku({body:{backgroundColor:e.buttons.button.bg,borderRadius:e.borders.radius.medium,color:e.colors.text.secondary},container:{borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}}),vechainKitAppCard:Ku({body:{height:`full`,borderRadius:e.borders.radius.medium,backgroundColor:e.colors.background.cardElevated,border:`1px solid ${e.colors.border.default}`},container:{height:`150px`,borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}})}),Yu=e=>qu({variants:Ju(e),defaultProps:{variant:`vechainKitBase`}}),Xu=Bt({borderRadius:`12px`}),Zu=e=>({loginIn:Bt(()=>({bg:e.buttons.loginButton.bg,color:e.buttons.loginButton.color,border:e.buttons.loginButton.border,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,rounded:e.buttons.loginButton.rounded??e.borders.radius.large,backdropFilter:e.buttons.loginButton.backdropFilter,_hover:{opacity:.5,_disabled:{opacity:.5,bg:e.buttons.loginButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.loginButton.bg},transition:`all 0.2s`})),loginWithVechain:Bt(()=>({color:`white`,bg:`#1a1a1a`,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,borderRadius:e.borders.radius.large,border:`1px solid ${e.colors.border.button}`,_hover:{opacity:.5,_disabled:{opacity:.5,bg:`#1a1a1a`}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:`#1a1a1a`},_dark:{color:`#1a1a1a`,bg:`white`,_hover:{_disabled:{bg:`white`}},_disabled:{bg:`white`}},transition:`all 0.2s`})),vechainKitPrimary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.primaryButton.rounded??e.borders.radius.large,bg:e.buttons.primaryButton.bg,color:e.buttons.primaryButton.color,border:e.buttons.primaryButton.border,backdropFilter:e.buttons.primaryButton.backdropFilter,_hover:{...e.buttons.primaryButton.hoverBg?{bg:e.buttons.primaryButton.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.primaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.primaryButton.bg},transition:`all 0.2s`})),vechainKitSecondary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.button.rounded??e.borders.radius.large,bg:e.buttons.button.bg,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,backdropFilter:e.buttons.button.backdropFilter,_hover:{...e.buttons.button.hoverBg?{bg:e.buttons.button.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),vechainKitTertiary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.tertiaryButton.rounded??e.borders.radius.large,bg:e.buttons.tertiaryButton.bg,color:e.buttons.tertiaryButton.color,border:e.buttons.tertiaryButton.border===`none`?`none`:e.buttons.tertiaryButton.border,backdropFilter:e.buttons.tertiaryButton.backdropFilter,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.tertiaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.tertiaryButton.bg},transition:`all 0.2s`})),vechainKitLogout:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,borderRadius:e.borders.radius.xl,p:0,bg:e.colors.error+`1f`,_hover:{bg:e.colors.error+`5e`,color:e.colors.error},transition:`all 0.2s`,color:e.colors.error})),actionButton:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,bg:e.buttons.button.bg,borderRadius:e.borders.radius.xl,p:0,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`1px solid ${e.colors.border.button}`:e.buttons.button.border,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),ghost:Bt(()=>({bg:`transparent`,color:e.colors.text.primary,border:`none`,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8},transition:`all 0.2s`})),link:Bt(()=>({color:e.colors.text.primary,_hover:{color:e.colors.text.secondary,textDecoration:`underline`},_active:{color:e.colors.text.primary},transition:`all 0.2s`}))}),Qu=e=>Vt({baseStyle:Xu,variants:Zu(e)}),{definePartsStyle:$u,defineMultiStyleConfig:ed}=Rt(ia.keys),td=e=>({vechainKitBase:$u({popper:{zIndex:1e3},content:{borderRadius:e.borders.radius.xl,border:`none`,backgroundColor:e.colors.background.modal,boxShadow:`0px 4px 16px rgba(0, 0, 0, 0.12)`,minWidth:`380px`},body:{padding:`16px`}})}),nd=e=>ed({variants:td(e),defaultProps:{variant:`vechainKitBase`}}),rd=(e,t)=>({useSystemColorMode:!1,disableTransitionOnChange:!1,components:{Modal:Gu(t),Card:Yu(t),Button:Qu(t),Popover:nd(t)},styles:{global:()=>({})},semanticTokens:{colors:{"chakra-placeholder-color":t.colors.text.tertiary,"vechain-kit-modal":t.colors.background.modal,"vechain-kit-overlay":t.colors.background.overlay,"vechain-kit-card":e?`rgba(0, 0, 0, 0.3)`:`rgba(0, 0, 0, 0.05)`,"vechain-kit-card-elevated":e?`rgba(0, 0, 0, 0.4)`:`rgba(0, 0, 0, 0.08)`,"vechain-kit-sticky-header":t.colors.background.stickyHeader,"vechain-kit-text-primary":t.colors.text.primary,"vechain-kit-text-secondary":t.colors.text.secondary,"vechain-kit-text-tertiary":t.colors.text.tertiary,"vechain-kit-border":t.colors.border.default,"vechain-kit-border-hover":t.colors.border.hover,"vechain-kit-border-focus":t.colors.border.focus,"vechain-kit-success":t.colors.success,"vechain-kit-error":t.colors.error,"vechain-kit-warning":t.colors.warning},effects:{"vechain-kit-backdrop-filter-modal":t.effects.backdropFilter.modal,"vechain-kit-backdrop-filter-overlay":t.effects.backdropFilter.overlay,"vechain-kit-backdrop-filter-sticky-header":t.effects.backdropFilter.stickyHeader},config:{cssVarPrefix:`vechain-kit`}},fonts:Ut.fonts,fontSizes:{...Ut.fontSizes,sm:t.fonts.sizes.small,md:t.fonts.sizes.medium,lg:t.fonts.sizes.large},fontWeights:{...Ut.fontWeights,normal:t.fonts.weights.normal,medium:t.fonts.weights.medium,bold:t.fonts.weights.bold},colors:Ut.colors,space:Ut.space}),id=(e,t)=>{let n=Ht(rd(e,Ra(La(e),za(t,e))));return n.styles.global=()=>({}),n.__cssVars&&(n.__cssVars.global=()=>({})),n},{ToastContainer:ad}=zt(),od=()=>ta({key:`vechain-kit`,prepend:!0}),sd=({bodyFont:e,headingFont:t})=>q($i,{styles:ea`
|
|
120
120
|
/* define CSS layers with proper priority order */
|
|
121
121
|
@layer vechain-kit, host-app;
|
|
122
122
|
|
|
@@ -189,7 +189,7 @@ import{A as e,B as t,C as n,E as r,H as i,J as a,O as o,Q as s,S as c,U as l,V a
|
|
|
189
189
|
font-family: ${t} !important;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
`}),cd=({children:e,theme:t,bodyFont:n,headingFont:r})=>J(Qi,{value:W(()=>od(),[]),children:[q(sd,{bodyFont:n,headingFont:r}),q(Xe,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),ld=({darkMode:e})=>{try{if(S(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return q(et,{initialColorMode:e?`dark`:`light`})},ud=Zt({portalRootRef:void 0,tokens:void 0}),dd=()=>{let e=Qt(ud);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},fd=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:n}=Gt();return U(()=>{let r=e?`dark`:`light`;n!==r&&t(r)},[e]),q(K,{})},pd=({children:e,darkMode:t=!1,theme:n})=>{let r=$t(null),i=Qt(sm),a=i?i.theme:void 0,o=n??a,s=W(()=>Ra(La(t),za(o,t)),[t,o]),c=W(()=>({...id(t,o),config:{...id(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]);return J(ud.Provider,{value:{portalRootRef:r,tokens:s},children:[q(ld,{darkMode:t}),J(cd,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,children:[q(fd,{darkMode:t}),q(A,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})]}),q(ad,{})]})},md=Zt(null),hd=()=>{let e=Qt(md);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},gd=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=G(!1),{setSource:a,connectV2:o}=Pn(),s=H(()=>{y()&&window.vechain&&window.vechain.isInAppBrowser?(a(`veworld`),o(null)):i(!0)},[]),c=H(()=>i(!1),[]),[l,u]=G(!1),[d,f]=G(!1),p=H((e,t)=>{O(e??`main`),f(t?.isolatedView??!1),u(!0)},[]),m=H(()=>{u(!1),setTimeout(()=>{f(!1)},300)},[]),[h,g]=G(!1),_=H(()=>g(!0),[]),v=H(()=>g(!1),[]),[b,x]=G(!1),S=H(()=>x(!0),[]),C=H(()=>x(!1),[]),[w,T]=G(!1),[ee,E]=G(void 0),te=H(e=>{E(e),T(!0)},[]),D=H(()=>T(!1),[]),[ne,O]=G(`main`);return J(md.Provider,{value:{openConnectModal:s,closeConnectModal:c,isConnectModalOpen:r,openAccountModal:p,closeAccountModal:m,isAccountModalOpen:l,setAccountModalContent:O,accountModalContent:ne,isolatedView:d,openTransactionModal:_,closeTransactionModal:v,isTransactionModalOpen:h,openTransactionToast:S,closeTransactionToast:C,isTransactionToastOpen:b,openUpgradeSmartAccountModal:te,closeUpgradeSmartAccountModal:D,isUpgradeSmartAccountModalOpen:w},children:[e,J(pd,{darkMode:t,theme:n,children:[q(Tu,{isOpen:r,onClose:c}),q(wu,{isOpen:l,onClose:m,initialContent:ne}),q(Vu,{isOpen:w,onClose:D,style:ee})]})]})},_d=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=hd(),{open:a,close:o}=In();return{open:t?a:n,close:t?o:r,isOpen:t?!1:i}},vd=({children:e})=>q(K,{children:e}),yd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:()=>e(),close:t,isOpen:n}},bd=({children:e})=>q(K,{children:e}),xd=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=hd();return{open:e,close:t,isOpen:n}},Sd=({children:e})=>q(K,{children:e}),Cd=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=hd();return{open:e,close:t,isOpen:n}},wd=({children:e})=>q(K,{children:e}),Td=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=hd();return{open:()=>{e.isConnected?i():t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},Ed=({children:e})=>q(K,{children:e}),Dd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},Od=({children:e})=>q(K,{children:e}),kd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},Ad=({children:e})=>q(K,{children:e}),jd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Md=({children:e})=>q(K,{children:e}),Nd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},Pd=({children:e})=>q(K,{children:e}),Fd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Id=({children:e})=>q(K,{children:e}),Ld=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Rd=({children:e})=>q(K,{children:e}),zd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Bd=({children:e})=>q(K,{children:e}),Vd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Hd=({children:e})=>q(K,{children:e}),Ud=()=>{let{privy:e,loginMethods:t}=$(),n=e?.appId===re,r=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,i=W(()=>t?t.length===0||r(`ecosystem`):!0,[t]),a=W(()=>r(`vechain`),[t]),o=W(()=>r(`dappkit`),[t]),s=W(()=>r(`passkey`),[t]),c=W(()=>r(`email`),[t]),l={showGoogleLogin:W(()=>r(`google`),[t]),showEmailLogin:c,showPasskey:s,showVeChainLogin:a,showDappKit:o,showEcosystem:i,showMoreLogin:W(()=>r(`more`),[t]),showGithubLogin:W(()=>r(`github`),[t]),isOfficialVeChainApp:!1};return e?n?{...l,isOfficialVeChainApp:!0}:{...l}:{...l,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},Wd=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=hd();return{open:()=>t(e),close:n,isOpen:r}},Gd=({children:e})=>q(K,{children:e}),Kd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},qd=({children:e})=>q(K,{children:e}),Jd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{connection:o,account:s}=Q(),{requestCertificate:c}=Fn(),l=om();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]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},Yd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{signer:o}=Pn(),{connection:s}=Q(),c=om();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)},[])}},Xd=()=>{let{loginWithPasskey:e}=wn();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Zd=!1;const Qd=()=>{let{createWallet:e}=xn(),{initOAuth:t}=Cn({onComplete:H(async({isNewUser:t})=>{if(t&&!Zd){Zd=!0;try{await e()}catch(e){throw Zd=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},$d=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:H(t=>{let n={timestamp:Date.now(),ecosystemApp:t};h(e,JSON.stringify(n))},[]),getConnectionCache:H(()=>{let t=w(e);return t?JSON.parse(t):null},[]),clearConnectionCache:H(()=>{T(e)},[])}},ef=()=>{let{login:e}=Ks(),{setConnectionCache:t}=$d(),{data:n}=co([re]);return{login:async()=>{try{await e(re),t({name:`VeChain`,logoUrl:n?.[re]?.logo_url,appId:re,website:`https://governance.vebetterdao.org`})}catch(e){throw Hs({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.`})}}}},tf=`vechain-kit-app-hub-apps`,nf=`vechain-kit-app-hub-apps-expiry`,rf=`https://raw.githubusercontent.com/vechain/app-hub/master`,af=()=>[`VECHAIN_KIT`,`appHub`,`apps`],of=async()=>{if(typeof window<`u`)try{let e=w(tf),t=w(nf);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=await fetch(`https://api.github.com/repos/vechain/app-hub/contents/apps`);if(!e.ok)throw Error(`Failed to fetch app directories`);let t=(await e.json()).map(async e=>{if(e.type!==`dir`)return null;let t=`${rf}/apps/${e.name}/manifest.json`,n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json();return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:`${rf}/apps/${e.name}/logo.png`,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}}),n=(await Promise.all(t)).filter(e=>e!==null);if(typeof window<`u`)try{h(tf,JSON.stringify(n)),h(nf,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return n},sf=()=>X({queryKey:af(),queryFn:async()=>{try{return await of()}catch(e){let t=localStorage.getItem(tf);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),cf=({abi:e,address:t,method:n})=>[`callClause`,t,n],lf=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?[r]:[]],uf=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=Nn();return X({queryKey:lf({abi:t,address:e,method:n,args:r}),queryFn:async()=>ee({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},df=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>X({queryKey:n,queryFn:()=>O({thor:e,calls:t}),enabled:r}),ff=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},pf=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},mf=()=>{let{network:e}=$();return e.nodeUrl??k(e.type).nodeUrl},hf=()=>{let[e,t]=G(!0);return U(()=>{if(!y()){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},gf=()=>{U(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},_f=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(un.of(t));return{balance:gi(BigInt(n.balance)).toString(),energy:gi(BigInt(n.energy)).toString()}},vf=e=>[`VECHAIN_KIT_BALANCE`,e],yf=e=>{let t=Nn();return X({queryKey:vf(e),queryFn:()=>_f(t,e),enabled:!!e&&un.isValid(e),refetchInterval:1e4})},bf=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(k(n).accountFactoryAddress,ti.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()},xf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],Sf=e=>{let t=Nn(),{network:n}=$();return X({queryKey:xf(e,n.type),queryFn:async()=>bf(t,e,n.type),enabled:!!t&&!!e&&!!n})},Cf=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},wf=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],Tf=()=>{let e=Nn(),{network:t}=$();return X({queryKey:wf(t.type),queryFn:async()=>Cf(e,t.type),enabled:!!e&&!!t})},Ef=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(k(n).accountFactoryAddress,ti.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},Df=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],Of=e=>{let t=Nn(),{network:n}=$();return X({queryKey:Df(e,n.type),queryFn:async()=>Ef(t,e,n.type),enabled:!!t&&!!e&&!!n})},kf=ti.abi,Af=(e,t,n)=>lf({abi:kf,address:k(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),jf=(e,t)=>{let{network:n}=$();return uf({address:k(n.type).accountFactoryAddress,abi:kf,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]})}})},Mf=ti.abi,Nf=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await ee({thor:e,abi:Mf,contractAddress:k(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},Pf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Ff=e=>{let t=Nn(),{network:n}=$();return X({queryKey:Pf(e,n.type),queryFn:async()=>Nf(t,e,n.type),enabled:!!t&&!!e&&!!n})},If=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(un.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},Lf=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Rf=e=>{let t=mf(),n=sa.at(t);return X({queryKey:Lf(e),queryFn:async()=>If(n,e),enabled:!!n&&!!e})},zf=()=>{let e=Vn(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:Df(i,r.type)}),e.cancelQueries({queryKey:Af(a,i,r.type)}),e.cancelQueries({queryKey:Pf(i,r.type)}),e.cancelQueries({queryKey:wf(r.type)}),e.cancelQueries({queryKey:Gf(a,i,3,r.type)}),e.cancelQueries({queryKey:Jf(a,3,r.type)}),e.cancelQueries({queryKey:xf(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:Df(i,r.type)}),e.refetchQueries({queryKey:Af(a,i,r.type)}),e.refetchQueries({queryKey:Pf(i,r.type)}),e.refetchQueries({queryKey:wf(r.type)}),e.refetchQueries({queryKey:Gf(a,i,3,r.type)}),e.refetchQueries({queryKey:Jf(a,3,r.type)}),e.refetchQueries({queryKey:xf(3,r.type)})])}}},Bf=()=>{let e=Vn(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Hf(n)}),e.cancelQueries({queryKey:Lf(n)})]),await Promise.all([e.refetchQueries({queryKey:Hf(n)}),e.refetchQueries({queryKey:Lf(n)})])}}},Vf=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=un.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}},Hf=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Uf=e=>{let{network:t}=$(),n=Nn();return X({queryKey:Hf(e),queryFn:()=>Vf(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},Wf=async(e,t,n,r,i)=>{let a=await e.contracts.load(k(i).accountFactoryAddress,ti.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${k(i).accountFactoryAddress}`);return a[0]},Gf=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],Kf=(e,t,n)=>{let r=Nn(),{network:i}=$();return X({queryKey:Gf(e,t,n,i.type),queryFn:async()=>Wf(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},qf=async(e,t,n,r)=>{let i=await e.contracts.load(k(r).accountFactoryAddress,ti.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},Jf=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Yf=(e,t)=>{let n=Nn(),{network:r}=$();return X({queryKey:Jf(e,t,r.type),queryFn:async()=>qf(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Xf=ri.createInterface(),Zf=({smartAccountAddress:t,targetVersion:n,onSuccess:r,onError:i})=>{let{refresh:a}=zf(),{refresh:o}=Bf(),{data:s}=Sf(n),c=H(async()=>{if(!t||!e(t))throw Error(`Invalid smart account address`);if(!s)throw Error(`Unable to fetch implementation address for version ${n}`);return[{to:t,value:`0x0`,data:Xf.encodeFunctionData(`upgradeToAndCall`,[s,`0x`]),comment:`Upgrade account to version ${n}`,abi:Xf.getFunction(`upgradeToAndCall`).format(`json`)}]},[t,s,n]),u=fc({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${l(t)} to version ${n}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([a(),o()]),r?.()},onTxFailedOrCancelled:async()=>{i?.()}});return{...u,sendTransaction:async()=>u.sendTransaction(await c())}},Qf=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],$f=10*te.SECOND,ep=()=>{let e=Nn();return X({queryKey:Qf(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:$f})},tp=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},np=()=>[`VECHAIN_KIT_CHAIN_ID`],rp=()=>{let e=Nn();return X({queryKey:np(),queryFn:()=>tp(e),enabled:!!e})},ip=1e3,ap=async({thor:e,order:t=`asc`,offset:n=0,limit:r=ip,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},op=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await ap({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:ip,order:n,offset:s});if(o.push(...c),c.length<ip)return o;s+=ip}},sp=Qr.createInterface(),cp=(t,n,r,i)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:r,value:`0x0`,data:sp.encodeFunctionData(`transfer`,[t,bi(n)]),comment:`Transfer ${n} ${i} to ${t}`,abi:sp.getFunction(`transfer`)}),a},lp=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,onSuccess:a,onError:o})=>{let{refresh:s}=Js(),c=W(()=>cp(t,n,r,i),[t,n,r,i]),u=fc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${l(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c)}},up=(t,n)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(n)))throw Error(`Invalid amount`);let r=[];try{r.push({to:t,value:bi(n).toString(),data:`0x`,comment:`Transfer ${n} VET to ${t}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return r},dp=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=Js(),o=W(()=>up(t,n),[t,n]),s=fc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${l(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)}},fp=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o,delegationUrl:s})=>{let{account:c}=Q(),l=Vn(),u=H(async()=>{n&&t?.forEach(async e=>{await l.cancelQueries({queryKey:e}),await l.refetchQueries({queryKey:e})}),r?.()},[n,r,l,t]),d=fc({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}},pp=10*te.SECOND,mp=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],hp=(e,t=5)=>{let n=Nn();return X({queryKey:mp(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*pp,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},gp=(e,t)=>{let n=pi({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},_p=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],vp=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=Nn();return X({queryFn:H(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await op({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=>gp(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(()=>_p({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function yp({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(hi(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:nn.hexlify(nn.randomBytes(32))}}}function bp({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?hi(e.data):e.data)||`0x`}}}function xp(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=Ks(),{signTypedData:r}=Dn(),{network:i}=$(),{data:a}=rp();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const Sp=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=xp(),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=>bp({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(dn.callFunction(un.of(k(i.type).accountFactoryAddress),ln.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(dn.callFunction(un.of(c.address??``),ln.ofAbi(ni.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=yp({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(dn.callFunction(un.of(k(i.type).accountFactoryAddress),ln.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),f.push(dn.callFunction(un.of(c.address??``),ln.ofAbi(ni.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 Cp=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}({});const wp=(e,t)=>{let[n,r]=G(()=>{try{let n=w(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return U(()=>{h(e,JSON.stringify(n))},[e,n]),[n,r]},Tp=`vechain-kit-storage-change`,Ep=(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=$t(!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(Tp,{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(Tp,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Tp,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])]},Dp=()=>{let[e,t]=wp(Cp.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)}},Op=async(e,t,n,r,i)=>await(await fetch(t+`estimate/clauses/`+r.toLowerCase()+`?type=smartaccount&speed=`+i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json(),kp=async e=>await(await fetch(e+`deposit/account`,{method:`GET`,headers:{"Content-Type":`application/json`}})).json(),Ap=async(e,t,n,r)=>await(await fetch(r+`sign/transaction/authorized/`+n.toLowerCase(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json(),jp=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function Mp(e,t){return mn.of(e.body,ua.concatBytes(e.signature??new Uint8Array,fn.of(t.slice(2)).bytes))}function Np(e,t){return mn.decode(fn.of(e.slice(2)).bytes,t)}const Pp=()=>{let{connectedWallet:e}=Q(),{data:n}=Uf(e?.address??``),{data:r}=jf(n?.address??``,e?.address??``),{preferences:i}=Fp(),a=Qr.createInterface(),{network:o}=$(),{buildClausesWithAuth:s}=Sp(),c=sa.at(k(o.type).nodeUrl);return{sendTransactionUsingGenericDelegator:H(async({clauses:e,genericDelegatorUrl:o})=>{try{let l=i.gasTokenToUse,u=await Op(n?.address??``,o,e,l,`medium`),d=await kp(o),p={to:l===`VET`?d.depositAccount:f[l].address,value:l===`VET`?bi(u.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:a.encodeFunctionData(`transfer`,[d.depositAccount,bi(u.transactionCost?.toString()??`0`)]),comment:`Transfer ${u.transactionCost} ${l} to ${d.depositAccount}`,abi:l===`VET`?void 0:a.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:n,version:r?.version??0}),h=await jp(m,c,t,!0),g=await mn.of(h).signAsSender(fn.of(t.privateKey).bytes),_=await Ap(fn.of(g.encoded).toString(),t.address,l,o),v=Mp(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:t.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`)},[i,n,r,s,c,t])}},Fp=()=>{let[e,t]=Ep(Cp.GAS_TOKEN_PREFERENCES,ne);return{preferences:e,supportedTokens:f,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])}},Ip=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=Uf(a?.address??``),{feeDelegation:c}=$(),{balances:l}=os(o?.address??``),{updatePreferences:u}=Fp();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 Op(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})},Lp=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=Uf(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 Op(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})},Rp=({label:e,address:t,domain:n,imageSrc:r,imageAlt:i=`Account`,hideAddress:a=!1,balance:o,tokenAddress:s})=>{let{t:c}=Y(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-card`),{isLoading:p}=hs({address:t}),{tokens:m,isLoading:h}=ms({address:t}),g=W(()=>s?m.find(e=>e.address===s):null,[m,s]),_=W(()=>o===void 0?g?Number(g.balance):0:o,[o,g]),v=g?.symbol||``;return p||h?J(A,{w:`full`,p:2,borderRadius:`2xl`,bg:f,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(kt,{boxSize:`40px`,borderRadius:`xl`}),J(z,{align:`start`,spacing:0,children:[q(kt,{height:`16px`,width:`120px`,borderRadius:`md`}),!a&&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:u,children:c(`Balance`)}),q(kt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]})]}):J(A,{w:`full`,p:2,borderRadius:`2xl`,bg:f,wordBreak:`break-word`,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(ut,{src:r,alt:i,boxSize:`40px`,borderRadius:`xl`,objectFit:`cover`}),q(z,{align:`start`,spacing:0,children:n?J(K,{children:[q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-domain`,children:n}),!a&&q(R,{fontSize:`xs`,color:d,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})]}):q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,children:c(`Balance`)}),J(R,{fontSize:`xs`,color:d,children:[_.toLocaleString(void 0,{maximumFractionDigits:2}),v&&` ${v}`]})]})]})]})},zp=({onClick:e,...t})=>q(lt,{"aria-label":`FAQ`,icon:q(N,{as:lr,fontSize:`17px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Bp=({children:e,...t})=>(gf(),q(z,{...t,children:e})),Vp=({wallet:e,props:t})=>{let n=$t(e?.image);return 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(ut,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Hp=({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:v}=$(),{network:y}=$(),b=W(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);U(()=>{b&&d?.(b)},[b,d]);let x=W(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),S=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:[b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`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:b})}),S&&!b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`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:S.message})}),q(j,{px:4,variant:b?`vechainKitSecondary`:`vechainKitPrimary`,bg:x,onClick:()=>b&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:b?_(`Retry`):c||_(`Confirm`)}),b&&o?.meta.txID&&q(ht,{isExternal:!0,fontSize:`sm`,color:v?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${k(y.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},Up=({onClick:e,hasUnreadNotifications:t,...n})=>q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:J(A,{position:`relative`,children:[q(Qn,{fontSize:`20px`}),t&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),Wp=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:o})=>{let{t:c}=Y(),{balances:l}=os(o),[u,d]=V.useState(n),[p,m]=V.useState(!1),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-text-tertiary`),y=B(`colors`,`vechain-kit-error`),b=e=>e?_:`transparent`,x=e=>e?h:`transparent`;V.useEffect(()=>{e&&(d(n),m(!1))},[e,n]);let S=()=>{r(u,p),t()},C=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},w=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return J(to,{isOpen:e,onClose:t,size:`sm`,children:[J(L,{children:[q(R,{fontSize:`lg`,fontWeight:`semibold`,color:h,children:c(`Fee token`)}),q(R,{fontSize:`sm`,fontWeight:`normal`,color:g,mt:1,children:c(`Select the token to pay the fee with`)})]}),q(P,{children:J(z,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=f[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=w(e);return q(A,{cursor:i?`not-allowed`:`pointer`,bg:b(n),border:`1px`,borderColor:x(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?b(n):g&&`#ffffff12`,borderColor:i?x(n):g},opacity:i?.5:1,onClick:()=>!i&&d(e),children:J(M,{spacing:3,justify:`space-between`,children:[J(M,{spacing:3,flex:1,children:[V.cloneElement(s[e],{boxSize:`36px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:t.symbol}),J(R,{fontSize:`xs`,color:g,children:[c(`Balance`),`:`,` `,C(e)]}),i&&q(R,{fontSize:`xs`,color:y,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:h,children:v(r.cost,2)}),q(R,{fontSize:`xs`,color:g,children:t.symbol})]})})]})},e)}),u!==n&&J(it,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[q(at,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:h,children:c(`Use this token for future transactions`)}),q(Mt,{id:`remember-choice`,isChecked:p,onChange:e=>m(e.target.checked),color:h})]})]})}),q(I,{children:J(z,{spacing:3,w:`full`,children:[q(j,{variant:`vechainKitPrimary`,onClick:S,isDisabled:w(u),children:c(`Apply`)}),q(j,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},Gp=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:o}=Y(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:p}=Fp(),{isOpen:m,onOpen:h,onClose:g}=qt(),_=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),[b,x]=G(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:S,isLoading:C}=Lp({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});U(()=>{!C&&S&&x(S)},[S,C]),U(()=>{e&&x(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),U(()=>{C&&x(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[C,d.availableGasTokens]);let w=H((t,n)=>{n&&p([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,p,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:T}=os(u?.address??``),ee=e=>{let t=T.find(t=>t.symbol===e),n=b[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},E=e?.usedToken,te=d.availableGasTokens,D;E?D=E:a&&te.includes(a)?D=a:(D=te.find(e=>b[e]&&!b[e].loading&&!ee(e)),D||=te.find(e=>b[e]&&!b[e].loading),D||=te[0]);let ne=D?b[D]:void 0,O=E&&e?.transactionCost?e.transactionCost:ne?.cost||0,re=D?f[D]:void 0;return J(K,{children:[q(nt,{mt:3}),J(M,{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:y,children:o(`Fee`)}),q(M,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:q(M,{justifyContent:`flex-start`,w:`full`,children:t||!E&&(!ne||ne.loading)||!re?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:_,fontSize:`sm`,fontWeight:`semibold`,children:[v(O,2),` `,re.symbol]}),J(R,{color:y,fontSize:`xs`,children:[`≈`,` $`,(O*.01).toFixed(2)]})]})})})]}),J(j,{onClick:h,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:y,borderColor:y,_hover:{bg:y},leftIcon:V.cloneElement(s[D||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,children:D||d.availableGasTokens[0]}),q(N,{as:rr,boxSize:5,color:y})]})]}),q(Wp,{isOpen:m,onClose:g,selectedToken:D||d.availableGasTokens[0],onTokenSelect:w,availableTokens:d.availableGasTokens,tokenEstimations:b,walletAddress:u?.address??``})]})},Kp=({isOpen:e,onClose:t,steps:n,activeStep:r,goToPrevious:i,setActiveStep:a,disableBackButton:o,disableCloseButton:s,closeOnOverlayClick:c=!0,isCloseable:l=!0})=>{let u=()=>{a(0),t()},[d]=Jt(`(min-width: 1060px)`),f=n[r],p=r===0,m=!p&&!o||f?.title||d&&!s;return f?q(to,{closeOnOverlayClick:c,isOpen:e,onClose:u,isCloseable:l,blockScrollOnMount:!0,children:q(Ge,{p:0,bg:`none`,children:J(Ke,{p:0,children:[m?J(Z,{children:[f?.title?q(L,{children:f.title}):null,!p&&!o?q(Ja,{onClick:i}):null,d&&!s?q(F,{onClick:t}):null]}):null,f?.description?q(R,{fontSize:{base:14,md:16},fontWeight:400,px:4,children:f?.description}):null,q(Wn.div,{initial:`hidden`,animate:`visible`,style:{width:`100%`},children:f.content},f.key)]})})}):null},qp=({document:e,register:t,isText:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),a=e.displayName??r(`Policy`),o=i?`whiteAlpha.400`:`blackAlpha.400`,s=i?`blue.300`:`blue.500`,c=i?`blue.200`:`blue.700`,l=(()=>{if(!e.documentType)return a;switch(e.documentType){case`terms`:return e.displayName||`Terms of Service`;case`privacy`:return e.displayName||`Privacy Policy`;case`cookies`:return e.displayName||`Cookie Policy`;default:return e.displayName||`Legal Document`}})();return n?J(ht,{href:e.url,isExternal:!0,color:`blue.500`,textDecoration:`underline`,_hover:{color:`blue.300`,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[q(dt,{...t(e.id,{required:e.required}),type:`checkbox`,hidden:!0}),l,q(N,{as:mr,ml:1,boxSize:3})]},e.id):q(M,{width:`full`,borderRadius:`md`,transition:`all 0.2s`,children:J(M,{align:`flex-start`,spacing:3,width:`full`,children:[q(Ze,{mt:`2px`,size:`md`,colorScheme:`blue`,borderColor:o,...t(e.id,{required:e.required}),"data-testid":`tnc-checkbox`}),J(R,{fontSize:`xs`,children:[r(`I have read and agree to `),J(ht,{href:e.url,isExternal:!0,color:s,textDecoration:`underline`,_hover:{color:c,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[l,q(N,{as:mr,ml:1})]}),e.required&&q(R,{as:`span`,color:`red.500`,fontWeight:`bold`,children:`*`})]})]})},e.id)},Jp=({onAgree:e,onReject:t,onlyOptionalDocuments:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{documentsNotAgreed:a}=nm(),{requiredDocuments:o,optionalDocuments:s}=W(()=>a.reduce((e,t)=>(t.required?e.requiredDocuments.push(t):e.optionalDocuments.push(t),e),{requiredDocuments:[],optionalDocuments:[]}),[a]),{handleSubmit:c,register:l,formState:{isValid:u},watch:d}=Li({defaultValues:W(()=>a.reduce((e,t)=>(e[t.id]=t.required,e),{}),[a])}),f=d(),p=W(()=>a.filter(e=>f[e.id]),[a,f]),m=a?.length===p.length,h=H(t=>{let n=new Set(Object.entries(t).filter(([e,t])=>t).map(([e])=>e));return e(a.filter(e=>n.has(e.id)))},[a,e]),g=i?`#3a3a3a`:`#eaeaea`,_=i?`#2a2a2a`:`#f5f5f5`,v=i?`gray.300`:`gray.600`,y=i?`0 2px 8px rgba(0, 0, 0, 0.2)`:`0 2px 8px rgba(0, 0, 0, 0.05)`,b=o.length>0,x=s.length>0,S=W(()=>{let e=s.filter(e=>f[e.id]).length;return r(m?`Accept all`:n&&e===0?`Ignore and continue`:b&&!x||b&&e===0?`Accept`:`Accept selected`)},[n,m,s,f]),C=e=>e===o.length-2&&o.length>1?r(` and `):`, `;return q(jt,{width:`full`,children:J(`form`,{onSubmit:c(h),children:[q(Z,{children:q(L,{children:r(`Terms and Policies`)})}),q(P,{children:J(z,{align:`stretch`,spacing:5,width:`full`,children:[b&&J(R,{as:`span`,fontSize:`sm`,children:[r(`By continuing, you agree to`),` `,o.map((e,t)=>J(Xt,{children:[q(qp,{document:e,register:l,isText:!0},e.id),t<o.length-1?C(t):null]},e.id)),`.`,` `,r(`Please take a moment to review all the policies, with acceptance being mandatory to continue.`)]}),n&&q(R,{fontSize:`sm`,color:v,mb:3,children:q(vn,{i18nKey:`<bold>Your privacy matters.</bold> You’re in control, accept to enable optional features like cookies that help us enhance your experience.`,components:{bold:q(R,{as:`span`,fontWeight:`semibold`,color:v})}})}),x&&J(jt,{p:4,borderRadius:`xl`,bg:_,borderWidth:`1px`,borderColor:g,boxShadow:y,spacing:5,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:v,children:r(`Optional`)}),q(z,{align:`stretch`,spacing:4,children:s.map(e=>q(qp,{document:e,register:l},e.id))})]})]})}),q(I,{children:J(z,{width:`full`,spacing:3,children:[q(j,{variant:`vechainKitPrimary`,width:`full`,type:`submit`,isDisabled:!u,"data-testid":`accept-tnc-button`,children:S}),!n&&q(j,{variant:`ghost`,width:`full`,onClick:t,"data-testid":`reject-tnc-button`,colorScheme:`red`,children:r(`Reject and logout`)})]})})]})})};var Yp=function(e){return e.REVIEW_DOCUMENTS=`REVIEW_DOCUMENTS`,e.REJECT_DOCUMENTS=`REJECT_DOCUMENTS`,e}(Yp||{});const Xp=({isOpen:e,onAgree:t,handleLogout:n,onlyOptionalDocuments:r})=>{let{t:i}=Y(),{activeStep:a,goToPrevious:o,setActiveStep:s,goToNext:c}=Yt({index:0,count:Object.keys(Yp).length}),l=()=>{s(0)},u=()=>{c()},d=()=>{n(),l()};return q(Kp,{isOpen:e,onClose:()=>{},goToPrevious:o,goToNext:c,setActiveStep:s,steps:W(()=>[{key:Yp.REVIEW_DOCUMENTS,content:q(Jp,{onAgree:t,onReject:u,onlyOptionalDocuments:r})},{key:Yp.REJECT_DOCUMENTS,content:q(Wl,{onDisconnect:d,onBack:o,onClose:o,text:i(`Are you sure you want to reject the policies and disconnect?`),showCloseButton:!1})}],[Jp,Wl,t,d]),disableCloseButton:!0,disableBackButton:!0,isCloseable:!1,closeOnOverlayClick:!1,activeStep:a})},Zp=e=>`${e.documentType}-${e.url.replace(/[^\w-]+/g,`-`)}-v${e.version}`,Qp=e=>e.map(e=>({...e,id:Zp(e)})),$p=e=>e.filter(e=>!e.required),em=(e,t)=>{let n=Date.now();return e.map(e=>({...e,walletAddress:t,timestamp:n}))},tm=Zt(void 0),nm=()=>Qt(tm)||{hasAgreedToRequiredDocuments:!0,agreements:[],walletAddress:void 0,documents:[],documentsNotAgreed:[]},rm=({children:e})=>{let{connection:t,account:n,disconnect:r}=Q(),{darkMode:i,legalDocuments:a,theme:s}=$(),[c,l]=Ep(`vechain-kit-legal-documents`,[]),[u,d]=Ep(`vechain-kit-legal-documents-optional-reject`,[]),[f,p]=G(!1),h=H((e,t)=>u.some(n=>o(n.walletAddress,t)&&n.id===e.id),[u]),[g,_]=W(()=>{let e=Qp([{items:a?.cookiePolicy||[],type:se.COOKIES,source:m.APPLICATION},{items:a?.privacyPolicy||[],type:se.PRIVACY,source:m.APPLICATION},{items:a?.termsAndConditions||[],type:se.TERMS,source:m.APPLICATION}].flatMap(e=>e.items.map(t=>({...t,documentType:e.type,documentSource:e.source}))));return[e,e.filter(e=>e.required)]},[a]),v=W(()=>n?.address?g.filter(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)?!1:!u.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)):[],[g,n?.address,c,u]),y=W(()=>!_.length||!n?.address?!0:_.every(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)),[_,c,n?.address]),b=W(()=>{if(!n?.address||!v?.length)return!1;let e=$p(v);return e.length===0?!1:e.some(e=>!h(e,n.address))},[v,n?.address,$p,h]),x=W(()=>y&&b,[y,b]);W(()=>{let e=new Set(c.map(e=>e.id));return g.some(t=>e.has(t.id))},[g,c]),U(()=>{t.isConnected&&n?.address?p(!y||b):p(!1)},[t.isConnected,n?.address,y,b]);let S=H((e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return;let r=em(n,t);l([...c.filter(e=>!o(e.walletAddress,t)||!n.some(t=>t.id===e.id)),...r])},[c,em]),C=H(e=>{if(!n?.address)return;let t=$p(v);if(t.length===0)return;let r=e.map(e=>e.id),i=t.filter(e=>!r.includes(e.id));if(!i?.length)return;let a=em(i,n.address);d(e=>[...e,...a])},[n?.address,v,$p,em]),w=H(e=>{if(!n?.address)return;let t=Array.isArray(e)?e:[e];t.length>0&&S(t,n.address),C(t),p(!1)},[n?.address,S,C]);return J(tm.Provider,{value:{hasAgreedToRequiredDocuments:y,agreements:c,walletAddress:n?.address,documents:g,documentsNotAgreed:v},children:[e,q(pd,{darkMode:i,theme:s,children:q(Xp,{isOpen:f,onAgree:w,handleLogout:x?()=>{}:()=>{r(),p(!1)},onlyOptionalDocuments:x})})]})},im=Zt(null),am=({children:e,nodeUrl:n,delegatorUrl:r=_(),delegateAllTransactions:i,genericDelegator:a})=>{let{signTypedData:o,exportWallet:s,signMessage:c}=Dn(),{signTypedData:l,signMessage:u}=Ks(),{connection:d,connectedWallet:f}=Q(),{network:p}=$(),{data:m}=Uf(f?.address??``),{data:h}=jf(m?.address??``,f?.address??``),{data:g}=Ff(f?.address??``),{buildClausesWithAuth:v}=Sp(),{sendTransactionUsingGenericDelegator:y}=Pp(),b=sa.at(n),x=async(e,i,a,o)=>{if(!m?.address)throw Error(`Smart account address is not set`);let s=new ca(b,a??new aa([{privateKey:Buffer.from(t.privateKey.slice(2),`hex`),address:t.address}],{gasPayer:{gasPayerServiceUrl:i??r}}),!0),c=o??await s.getSigner(t.address),l=la.transactionBodyToTransactionRequestInput(e,t.address),u=await c.signTransaction(l),{id:d}=await fetch(`${n}/transactions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({raw:u})}).then(e=>e.json());return d},S=H(async({txClauses:e=[],title:n=`Sign Transaction`,description:i,buttonText:o=`Sign`,delegationUrl:s})=>{if(!m||m&&!m.address||!f||f&&!f.address)throw Error(`Address or embedded wallet is missing`);if(a&&!s)return await y({clauses:e,genericDelegatorUrl:r??``});let c=await v({clauses:e,smartAccount:m,version:g?1:h?.version??3,title:n,description:i,buttonText:o}),l={clauses:c,simulateTransactionOptions:{caller:t.address}},u=await b.transactions.simulateTransaction(l.clauses,{...l.simulateTransactionOptions});for(let e=0;e<u.length;e++)if(u[e].reverted)return console.error(`simulatedTx1[i].vmError: ${u[e].vmError}`),u[e].vmError;return await x(await jp(c,b,t,!0),s)},[y,a,m,f,r,v,g,h,b]);return q(im.Provider,{value:{accountFactory:k(p.type).accountFactoryAddress,sendTransaction:S,signMessage:async e=>d.isConnectedWithCrossApp?await u(e):(await c({message:e})).signature,signTypedData:async e=>d.isConnectedWithCrossApp?await l({...e,address:f?.address,types:Object.fromEntries(Object.entries(e.types).map(([e,t])=>[e,[...t]]))}):(await o(e)).signature,exportWallet:s,delegateAllTransactions:i},children:e})},om=()=>{let e=Qt(im);if(!e)throw Error(`usePrivyWalletProvider must be used within a PrivyWalletProvider`);return e},sm=Zt(null),$=()=>{let e=Qt(sm);if(!e)throw Error(`useVeChainKitConfig must be used within VeChainKit`);return e},cm=e=>{let t=[],n={...e};if(n.dappKit||={allowedWallets:[`veworld`]},(n.privy!==void 0||n.loginMethods?.some(e=>e.method===`vechain`||e.method===`ecosystem`))&&(n.feeDelegation?!n.feeDelegation.delegatorUrl&&!n.feeDelegation.genericDelegatorUrl&&(n.feeDelegation.genericDelegatorUrl=_()):n.feeDelegation={genericDelegatorUrl:_()}),!n.network||!n.network.type)n.network={type:`main`};else{let e=n.network.type;[`main`,`test`,`solo`].includes(e)||t.push(`network.type must be either "main", "test" or "solo"`)}if(n.loginMethods||=[{method:`vechain`,gridColumn:4},{method:`ecosystem`,gridColumn:4},{method:`dappkit`,gridColumn:4}],n.loginMethods&&!n.privy){let e=n.loginMethods.filter(e=>[`email`,`google`,`passkey`,`more`].includes(e.method));e.length>0&&t.push(`Login methods ${e.map(e=>`"${e.method}"`).join(`, `)} require Privy configuration. Please either remove these methods or configure the privy prop.`)}if(n?.legalDocuments&&(n.legalDocuments.termsAndConditions&&n.legalDocuments.termsAndConditions.forEach(e=>{C(e.url)||t.push(`legalDocuments.termsAndConditions.url is invalid: ${e.url}`)}),n.legalDocuments.privacyPolicy&&n.legalDocuments.privacyPolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.privacyPolicy.url is invalid: ${e.url}`)}),n.legalDocuments.cookiePolicy&&n.legalDocuments.cookiePolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.cookiePolicy.url is invalid: ${e.url}`)})),t.length>0)throw Error(`VeChainKit Configuration Error:
|
|
192
|
+
`}),cd=({children:e,theme:t,bodyFont:n,headingFont:r})=>J(Qi,{value:W(()=>od(),[]),children:[q(sd,{bodyFont:n,headingFont:r}),q(Xe,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),ld=({darkMode:e})=>{try{if(S(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return q(et,{initialColorMode:e?`dark`:`light`})},ud=Zt({portalRootRef:void 0,tokens:void 0}),dd=()=>{let e=Qt(ud);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},fd=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:n}=Gt();return U(()=>{let r=e?`dark`:`light`;n!==r&&t(r)},[e]),q(K,{})},pd=({children:e,darkMode:t=!1,theme:n})=>{let r=$t(null),i=Qt(cm),a=i?i.theme:void 0,o=n??a,s=W(()=>Ra(La(t),za(o,t)),[t,o]),c=W(()=>({...id(t,o),config:{...id(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]);return J(ud.Provider,{value:{portalRootRef:r,tokens:s},children:[q(ld,{darkMode:t}),J(cd,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,children:[q(fd,{darkMode:t}),q(A,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})]}),q(ad,{})]})},md=Zt(null),hd=()=>{let e=Qt(md);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},gd=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=G(!1),{setSource:a,connectV2:o}=Pn(),s=H(()=>{y()&&window.vechain&&window.vechain.isInAppBrowser?(a(`veworld`),o(null)):i(!0)},[]),c=H(()=>i(!1),[]),[l,u]=G(!1),[d,f]=G(!1),p=H((e,t)=>{O(e??`main`),f(t?.isolatedView??!1),u(!0)},[]),m=H(()=>{u(!1),setTimeout(()=>{f(!1)},300)},[]),[h,g]=G(!1),_=H(()=>g(!0),[]),v=H(()=>g(!1),[]),[b,x]=G(!1),S=H(()=>x(!0),[]),C=H(()=>x(!1),[]),[w,T]=G(!1),[ee,E]=G(void 0),te=H(e=>{E(e),T(!0)},[]),D=H(()=>T(!1),[]),[ne,O]=G(`main`);return J(md.Provider,{value:{openConnectModal:s,closeConnectModal:c,isConnectModalOpen:r,openAccountModal:p,closeAccountModal:m,isAccountModalOpen:l,setAccountModalContent:O,accountModalContent:ne,isolatedView:d,openTransactionModal:_,closeTransactionModal:v,isTransactionModalOpen:h,openTransactionToast:S,closeTransactionToast:C,isTransactionToastOpen:b,openUpgradeSmartAccountModal:te,closeUpgradeSmartAccountModal:D,isUpgradeSmartAccountModalOpen:w},children:[e,J(pd,{darkMode:t,theme:n,children:[q(Tu,{isOpen:r,onClose:c}),q(wu,{isOpen:l,onClose:m,initialContent:ne}),q(Vu,{isOpen:w,onClose:D,style:ee})]})]})},_d=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=hd(),{open:a,close:o}=In();return{open:t?a:n,close:t?o:r,isOpen:t?!1:i}},vd=({children:e})=>q(K,{children:e}),yd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:()=>e(),close:t,isOpen:n}},bd=({children:e})=>q(K,{children:e}),xd=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=hd();return{open:e,close:t,isOpen:n}},Sd=({children:e})=>q(K,{children:e}),Cd=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=hd();return{open:e,close:t,isOpen:n}},wd=({children:e})=>q(K,{children:e}),Td=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=hd();return{open:()=>{e.isConnected?i():t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},Ed=({children:e})=>q(K,{children:e}),Dd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},Od=({children:e})=>q(K,{children:e}),kd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},Ad=({children:e})=>q(K,{children:e}),jd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Md=({children:e})=>q(K,{children:e}),Nd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},Pd=({children:e})=>q(K,{children:e}),Fd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Id=({children:e})=>q(K,{children:e}),Ld=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Rd=({children:e})=>q(K,{children:e}),zd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=hd();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Bd=({children:e})=>q(K,{children:e}),Vd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Hd=({children:e})=>q(K,{children:e}),Ud=()=>{let{privy:e,loginMethods:t}=$(),n=e?.appId===re,r=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,i=W(()=>t?t.length===0||r(`ecosystem`):!0,[t]),a=W(()=>r(`vechain`),[t]),o=W(()=>r(`dappkit`),[t]),s=W(()=>r(`passkey`),[t]),c=W(()=>r(`email`),[t]),l={showGoogleLogin:W(()=>r(`google`),[t]),showEmailLogin:c,showPasskey:s,showVeChainLogin:a,showDappKit:o,showEcosystem:i,showMoreLogin:W(()=>r(`more`),[t]),showGithubLogin:W(()=>r(`github`),[t]),isOfficialVeChainApp:!1};return e?n?{...l,isOfficialVeChainApp:!0}:{...l}:{...l,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},Wd=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=hd();return{open:()=>t(e),close:n,isOpen:r}},Gd=({children:e})=>q(K,{children:e}),Kd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=hd();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},qd=({children:e})=>q(K,{children:e}),Jd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{connection:o,account:s}=Q(),{requestCertificate:c}=Fn(),l=sm();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]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},Yd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{signer:o}=Pn(),{connection:s}=Q(),c=sm();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)},[])}},Xd=()=>{let{loginWithPasskey:e}=wn();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Zd=!1;const Qd=()=>{let{createWallet:e}=xn(),{initOAuth:t}=Cn({onComplete:H(async({isNewUser:t})=>{if(t&&!Zd){Zd=!0;try{await e()}catch(e){throw Zd=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},$d=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:H(t=>{let n={timestamp:Date.now(),ecosystemApp:t};h(e,JSON.stringify(n))},[]),getConnectionCache:H(()=>{let t=w(e);return t?JSON.parse(t):null},[]),clearConnectionCache:H(()=>{T(e)},[])}},ef=()=>{let{login:e}=Ks(),{setConnectionCache:t}=$d(),{data:n}=co([re]);return{login:async()=>{try{await e(re),t({name:`VeChain`,logoUrl:n?.[re]?.logo_url,appId:re,website:`https://governance.vebetterdao.org`})}catch(e){throw Hs({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.`})}}}},tf=`vechain-kit-app-hub-apps`,nf=`vechain-kit-app-hub-apps-expiry`,rf=`https://raw.githubusercontent.com/vechain/app-hub/master`,af=()=>[`VECHAIN_KIT`,`appHub`,`apps`],of=async()=>{if(typeof window<`u`)try{let e=w(tf),t=w(nf);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=await fetch(`https://api.github.com/repos/vechain/app-hub/contents/apps`);if(!e.ok)throw Error(`Failed to fetch app directories`);let t=(await e.json()).map(async e=>{if(e.type!==`dir`)return null;let t=`${rf}/apps/${e.name}/manifest.json`,n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json();return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:`${rf}/apps/${e.name}/logo.png`,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}}),n=(await Promise.all(t)).filter(e=>e!==null);if(typeof window<`u`)try{h(tf,JSON.stringify(n)),h(nf,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return n},sf=()=>X({queryKey:af(),queryFn:async()=>{try{return await of()}catch(e){let t=localStorage.getItem(tf);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),cf=({abi:e,address:t,method:n})=>[`callClause`,t,n],lf=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?lf(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),uf=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?lf(r):[]],df=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=Nn();return X({queryKey:uf({abi:t,address:e,method:n,args:r}),queryFn:async()=>ee({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},ff=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>X({queryKey:n,queryFn:()=>O({thor:e,calls:t}),enabled:r}),pf=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},mf=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},hf=()=>{let{network:e}=$();return e.nodeUrl??k(e.type).nodeUrl},gf=()=>{let[e,t]=G(!0);return U(()=>{if(!y()){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},_f=()=>{U(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},vf=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(un.of(t));return{balance:gi(BigInt(n.balance)).toString(),energy:gi(BigInt(n.energy)).toString()}},yf=e=>[`VECHAIN_KIT_BALANCE`,e],bf=e=>{let t=Nn();return X({queryKey:yf(e),queryFn:()=>vf(t,e),enabled:!!e&&un.isValid(e),refetchInterval:1e4})},xf=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(k(n).accountFactoryAddress,ti.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()},Sf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],Cf=e=>{let t=Nn(),{network:n}=$();return X({queryKey:Sf(e,n.type),queryFn:async()=>xf(t,e,n.type),enabled:!!t&&!!e&&!!n})},wf=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},Tf=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],Ef=()=>{let e=Nn(),{network:t}=$();return X({queryKey:Tf(t.type),queryFn:async()=>wf(e,t.type),enabled:!!e&&!!t})},Df=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(k(n).accountFactoryAddress,ti.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},Of=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],kf=e=>{let t=Nn(),{network:n}=$();return X({queryKey:Of(e,n.type),queryFn:async()=>Df(t,e,n.type),enabled:!!t&&!!e&&!!n})},Af=ti.abi,jf=(e,t,n)=>uf({abi:Af,address:k(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),Mf=(e,t)=>{let{network:n}=$();return df({address:k(n.type).accountFactoryAddress,abi:Af,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]})}})},Nf=ti.abi,Pf=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await ee({thor:e,abi:Nf,contractAddress:k(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},Ff=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],If=e=>{let t=Nn(),{network:n}=$();return X({queryKey:Ff(e,n.type),queryFn:async()=>Pf(t,e,n.type),enabled:!!t&&!!e&&!!n})},Lf=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(un.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},Rf=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],zf=e=>{let t=hf(),n=sa.at(t);return X({queryKey:Rf(e),queryFn:async()=>Lf(n,e),enabled:!!n&&!!e})},Bf=()=>{let e=Vn(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:Of(i,r.type)}),e.cancelQueries({queryKey:jf(a,i,r.type)}),e.cancelQueries({queryKey:Ff(i,r.type)}),e.cancelQueries({queryKey:Tf(r.type)}),e.cancelQueries({queryKey:Kf(a,i,3,r.type)}),e.cancelQueries({queryKey:Yf(a,3,r.type)}),e.cancelQueries({queryKey:Sf(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:Of(i,r.type)}),e.refetchQueries({queryKey:jf(a,i,r.type)}),e.refetchQueries({queryKey:Ff(i,r.type)}),e.refetchQueries({queryKey:Tf(r.type)}),e.refetchQueries({queryKey:Kf(a,i,3,r.type)}),e.refetchQueries({queryKey:Yf(a,3,r.type)}),e.refetchQueries({queryKey:Sf(3,r.type)})])}}},Vf=()=>{let e=Vn(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Uf(n)}),e.cancelQueries({queryKey:Rf(n)})]),await Promise.all([e.refetchQueries({queryKey:Uf(n)}),e.refetchQueries({queryKey:Rf(n)})])}}},Hf=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=un.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}},Uf=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Wf=e=>{let{network:t}=$(),n=Nn();return X({queryKey:Uf(e),queryFn:()=>Hf(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},Gf=async(e,t,n,r,i)=>{let a=await e.contracts.load(k(i).accountFactoryAddress,ti.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${k(i).accountFactoryAddress}`);return a[0]},Kf=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],qf=(e,t,n)=>{let r=Nn(),{network:i}=$();return X({queryKey:Kf(e,t,n,i.type),queryFn:async()=>Gf(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},Jf=async(e,t,n,r)=>{let i=await e.contracts.load(k(r).accountFactoryAddress,ti.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},Yf=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Xf=(e,t)=>{let n=Nn(),{network:r}=$();return X({queryKey:Yf(e,t,r.type),queryFn:async()=>Jf(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Zf=ri.createInterface(),Qf=({smartAccountAddress:t,targetVersion:n,onSuccess:r,onError:i})=>{let{refresh:a}=Bf(),{refresh:o}=Vf(),{data:s}=Cf(n),c=H(async()=>{if(!t||!e(t))throw Error(`Invalid smart account address`);if(!s)throw Error(`Unable to fetch implementation address for version ${n}`);return[{to:t,value:`0x0`,data:Zf.encodeFunctionData(`upgradeToAndCall`,[s,`0x`]),comment:`Upgrade account to version ${n}`,abi:Zf.getFunction(`upgradeToAndCall`).format(`json`)}]},[t,s,n]),u=fc({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${l(t)} to version ${n}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([a(),o()]),r?.()},onTxFailedOrCancelled:async()=>{i?.()}});return{...u,sendTransaction:async()=>u.sendTransaction(await c())}},$f=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],ep=10*te.SECOND,tp=()=>{let e=Nn();return X({queryKey:$f(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:ep})},np=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},rp=()=>[`VECHAIN_KIT_CHAIN_ID`],ip=()=>{let e=Nn();return X({queryKey:rp(),queryFn:()=>np(e),enabled:!!e})},ap=1e3,op=async({thor:e,order:t=`asc`,offset:n=0,limit:r=ap,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},sp=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await op({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:ap,order:n,offset:s});if(o.push(...c),c.length<ap)return o;s+=ap}},cp=Qr.createInterface(),lp=(t,n,r,i)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:r,value:`0x0`,data:cp.encodeFunctionData(`transfer`,[t,bi(n)]),comment:`Transfer ${n} ${i} to ${t}`,abi:cp.getFunction(`transfer`)}),a},up=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,onSuccess:a,onError:o})=>{let{refresh:s}=Js(),c=W(()=>lp(t,n,r,i),[t,n,r,i]),u=fc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${l(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c)}},dp=(t,n)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(n)))throw Error(`Invalid amount`);let r=[];try{r.push({to:t,value:bi(n).toString(),data:`0x`,comment:`Transfer ${n} VET to ${t}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return r},fp=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=Js(),o=W(()=>dp(t,n),[t,n]),s=fc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${l(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)}},pp=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o,delegationUrl:s})=>{let{account:c}=Q(),l=Vn(),u=H(async()=>{n&&t?.forEach(async e=>{await l.cancelQueries({queryKey:e}),await l.refetchQueries({queryKey:e})}),r?.()},[n,r,l,t]),d=fc({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}},mp=10*te.SECOND,hp=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],gp=(e,t=5)=>{let n=Nn();return X({queryKey:hp(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*mp,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},_p=(e,t)=>{let n=pi({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},vp=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],yp=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=Nn();return X({queryFn:H(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await sp({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=>_p(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(()=>vp({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function bp({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(hi(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:nn.hexlify(nn.randomBytes(32))}}}function xp({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?hi(e.data):e.data)||`0x`}}}function Sp(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=Ks(),{signTypedData:r}=Dn(),{network:i}=$(),{data:a}=ip();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const Cp=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=Sp(),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=>xp({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(dn.callFunction(un.of(k(i.type).accountFactoryAddress),ln.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(dn.callFunction(un.of(c.address??``),ln.ofAbi(ni.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=bp({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(dn.callFunction(un.of(k(i.type).accountFactoryAddress),ln.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),f.push(dn.callFunction(un.of(c.address??``),ln.ofAbi(ni.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 wp=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}({});const Tp=(e,t)=>{let[n,r]=G(()=>{try{let n=w(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return U(()=>{h(e,JSON.stringify(n))},[e,n]),[n,r]},Ep=`vechain-kit-storage-change`,Dp=(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=$t(!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(Ep,{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(Ep,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Ep,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])]},Op=()=>{let[e,t]=Tp(wp.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)}},kp=async(e,t,n,r,i)=>await(await fetch(t+`estimate/clauses/`+r.toLowerCase()+`?type=smartaccount&speed=`+i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json(),Ap=async e=>await(await fetch(e+`deposit/account`,{method:`GET`,headers:{"Content-Type":`application/json`}})).json(),jp=async(e,t,n,r)=>await(await fetch(r+`sign/transaction/authorized/`+n.toLowerCase(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json(),Mp=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function Np(e,t){return mn.of(e.body,ua.concatBytes(e.signature??new Uint8Array,fn.of(t.slice(2)).bytes))}function Pp(e,t){return mn.decode(fn.of(e.slice(2)).bytes,t)}const Fp=()=>{let{connectedWallet:e}=Q(),{data:n}=Wf(e?.address??``),{data:r}=Mf(n?.address??``,e?.address??``),{preferences:i}=Ip(),a=Qr.createInterface(),{network:o}=$(),{buildClausesWithAuth:s}=Cp(),c=sa.at(k(o.type).nodeUrl);return{sendTransactionUsingGenericDelegator:H(async({clauses:e,genericDelegatorUrl:o})=>{try{let l=i.gasTokenToUse,u=await kp(n?.address??``,o,e,l,`medium`),d=await Ap(o),p={to:l===`VET`?d.depositAccount:f[l].address,value:l===`VET`?bi(u.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:a.encodeFunctionData(`transfer`,[d.depositAccount,bi(u.transactionCost?.toString()??`0`)]),comment:`Transfer ${u.transactionCost} ${l} to ${d.depositAccount}`,abi:l===`VET`?void 0:a.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:n,version:r?.version??0}),h=await Mp(m,c,t,!0),g=await mn.of(h).signAsSender(fn.of(t.privateKey).bytes),_=await jp(fn.of(g.encoded).toString(),t.address,l,o),v=Np(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:t.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`)},[i,n,r,s,c,t])}},Ip=()=>{let[e,t]=Dp(wp.GAS_TOKEN_PREFERENCES,ne);return{preferences:e,supportedTokens:f,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])}},Lp=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=Wf(a?.address??``),{feeDelegation:c}=$(),{balances:l}=os(o?.address??``),{updatePreferences:u}=Ip();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 kp(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})},Rp=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=Wf(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 kp(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})},zp=({label:e,address:t,domain:n,imageSrc:r,imageAlt:i=`Account`,hideAddress:a=!1,balance:o,tokenAddress:s})=>{let{t:c}=Y(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-card`),{isLoading:p}=hs({address:t}),{tokens:m,isLoading:h}=ms({address:t}),g=W(()=>s?m.find(e=>e.address===s):null,[m,s]),_=W(()=>o===void 0?g?Number(g.balance):0:o,[o,g]),v=g?.symbol||``;return p||h?J(A,{w:`full`,p:2,borderRadius:`2xl`,bg:f,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(kt,{boxSize:`40px`,borderRadius:`xl`}),J(z,{align:`start`,spacing:0,children:[q(kt,{height:`16px`,width:`120px`,borderRadius:`md`}),!a&&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:u,children:c(`Balance`)}),q(kt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]})]}):J(A,{w:`full`,p:2,borderRadius:`2xl`,bg:f,wordBreak:`break-word`,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(ut,{src:r,alt:i,boxSize:`40px`,borderRadius:`xl`,objectFit:`cover`}),q(z,{align:`start`,spacing:0,children:n?J(K,{children:[q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-domain`,children:n}),!a&&q(R,{fontSize:`xs`,color:d,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})]}):q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,children:c(`Balance`)}),J(R,{fontSize:`xs`,color:d,children:[_.toLocaleString(void 0,{maximumFractionDigits:2}),v&&` ${v}`]})]})]})]})},Bp=({onClick:e,...t})=>q(lt,{"aria-label":`FAQ`,icon:q(N,{as:lr,fontSize:`17px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Vp=({children:e,...t})=>(_f(),q(z,{...t,children:e})),Hp=({wallet:e,props:t})=>{let n=$t(e?.image);return 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(ut,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Up=({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:v}=$(),{network:y}=$(),b=W(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);U(()=>{b&&d?.(b)},[b,d]);let x=W(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),S=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:[b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`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:b})}),S&&!b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`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:S.message})}),q(j,{px:4,variant:b?`vechainKitSecondary`:`vechainKitPrimary`,bg:x,onClick:()=>b&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:b?_(`Retry`):c||_(`Confirm`)}),b&&o?.meta.txID&&q(ht,{isExternal:!0,fontSize:`sm`,color:v?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${k(y.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},Wp=({onClick:e,hasUnreadNotifications:t,...n})=>q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:J(A,{position:`relative`,children:[q(Qn,{fontSize:`20px`}),t&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),Gp=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:o})=>{let{t:c}=Y(),{balances:l}=os(o),[u,d]=V.useState(n),[p,m]=V.useState(!1),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-text-tertiary`),y=B(`colors`,`vechain-kit-error`),b=e=>e?_:`transparent`,x=e=>e?h:`transparent`;V.useEffect(()=>{e&&(d(n),m(!1))},[e,n]);let S=()=>{r(u,p),t()},C=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},w=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return J(to,{isOpen:e,onClose:t,size:`sm`,children:[J(L,{children:[q(R,{fontSize:`lg`,fontWeight:`semibold`,color:h,children:c(`Fee token`)}),q(R,{fontSize:`sm`,fontWeight:`normal`,color:g,mt:1,children:c(`Select the token to pay the fee with`)})]}),q(P,{children:J(z,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=f[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=w(e);return q(A,{cursor:i?`not-allowed`:`pointer`,bg:b(n),border:`1px`,borderColor:x(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?b(n):g&&`#ffffff12`,borderColor:i?x(n):g},opacity:i?.5:1,onClick:()=>!i&&d(e),children:J(M,{spacing:3,justify:`space-between`,children:[J(M,{spacing:3,flex:1,children:[V.cloneElement(s[e],{boxSize:`36px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:t.symbol}),J(R,{fontSize:`xs`,color:g,children:[c(`Balance`),`:`,` `,C(e)]}),i&&q(R,{fontSize:`xs`,color:y,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:h,children:v(r.cost,2)}),q(R,{fontSize:`xs`,color:g,children:t.symbol})]})})]})},e)}),u!==n&&J(it,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[q(at,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:h,children:c(`Use this token for future transactions`)}),q(Mt,{id:`remember-choice`,isChecked:p,onChange:e=>m(e.target.checked),color:h})]})]})}),q(I,{children:J(z,{spacing:3,w:`full`,children:[q(j,{variant:`vechainKitPrimary`,onClick:S,isDisabled:w(u),children:c(`Apply`)}),q(j,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},Kp=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:o}=Y(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:p}=Ip(),{isOpen:m,onOpen:h,onClose:g}=qt(),_=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),[b,x]=G(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:S,isLoading:C}=Rp({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});U(()=>{!C&&S&&x(S)},[S,C]),U(()=>{e&&x(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),U(()=>{C&&x(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[C,d.availableGasTokens]);let w=H((t,n)=>{n&&p([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,p,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:T}=os(u?.address??``),ee=e=>{let t=T.find(t=>t.symbol===e),n=b[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},E=e?.usedToken,te=d.availableGasTokens,D;E?D=E:a&&te.includes(a)?D=a:(D=te.find(e=>b[e]&&!b[e].loading&&!ee(e)),D||=te.find(e=>b[e]&&!b[e].loading),D||=te[0]);let ne=D?b[D]:void 0,O=E&&e?.transactionCost?e.transactionCost:ne?.cost||0,re=D?f[D]:void 0;return J(K,{children:[q(nt,{mt:3}),J(M,{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:y,children:o(`Fee`)}),q(M,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:q(M,{justifyContent:`flex-start`,w:`full`,children:t||!E&&(!ne||ne.loading)||!re?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:_,fontSize:`sm`,fontWeight:`semibold`,children:[v(O,2),` `,re.symbol]}),J(R,{color:y,fontSize:`xs`,children:[`≈`,` $`,(O*.01).toFixed(2)]})]})})})]}),J(j,{onClick:h,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:y,borderColor:y,_hover:{bg:y},leftIcon:V.cloneElement(s[D||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,children:D||d.availableGasTokens[0]}),q(N,{as:rr,boxSize:5,color:y})]})]}),q(Gp,{isOpen:m,onClose:g,selectedToken:D||d.availableGasTokens[0],onTokenSelect:w,availableTokens:d.availableGasTokens,tokenEstimations:b,walletAddress:u?.address??``})]})},qp=({isOpen:e,onClose:t,steps:n,activeStep:r,goToPrevious:i,setActiveStep:a,disableBackButton:o,disableCloseButton:s,closeOnOverlayClick:c=!0,isCloseable:l=!0})=>{let u=()=>{a(0),t()},[d]=Jt(`(min-width: 1060px)`),f=n[r],p=r===0,m=!p&&!o||f?.title||d&&!s;return f?q(to,{closeOnOverlayClick:c,isOpen:e,onClose:u,isCloseable:l,blockScrollOnMount:!0,children:q(Ge,{p:0,bg:`none`,children:J(Ke,{p:0,children:[m?J(Z,{children:[f?.title?q(L,{children:f.title}):null,!p&&!o?q(Ja,{onClick:i}):null,d&&!s?q(F,{onClick:t}):null]}):null,f?.description?q(R,{fontSize:{base:14,md:16},fontWeight:400,px:4,children:f?.description}):null,q(Wn.div,{initial:`hidden`,animate:`visible`,style:{width:`100%`},children:f.content},f.key)]})})}):null},Jp=({document:e,register:t,isText:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),a=e.displayName??r(`Policy`),o=i?`whiteAlpha.400`:`blackAlpha.400`,s=i?`blue.300`:`blue.500`,c=i?`blue.200`:`blue.700`,l=(()=>{if(!e.documentType)return a;switch(e.documentType){case`terms`:return e.displayName||`Terms of Service`;case`privacy`:return e.displayName||`Privacy Policy`;case`cookies`:return e.displayName||`Cookie Policy`;default:return e.displayName||`Legal Document`}})();return n?J(ht,{href:e.url,isExternal:!0,color:`blue.500`,textDecoration:`underline`,_hover:{color:`blue.300`,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[q(dt,{...t(e.id,{required:e.required}),type:`checkbox`,hidden:!0}),l,q(N,{as:mr,ml:1,boxSize:3})]},e.id):q(M,{width:`full`,borderRadius:`md`,transition:`all 0.2s`,children:J(M,{align:`flex-start`,spacing:3,width:`full`,children:[q(Ze,{mt:`2px`,size:`md`,colorScheme:`blue`,borderColor:o,...t(e.id,{required:e.required}),"data-testid":`tnc-checkbox`}),J(R,{fontSize:`xs`,children:[r(`I have read and agree to `),J(ht,{href:e.url,isExternal:!0,color:s,textDecoration:`underline`,_hover:{color:c,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[l,q(N,{as:mr,ml:1})]}),e.required&&q(R,{as:`span`,color:`red.500`,fontWeight:`bold`,children:`*`})]})]})},e.id)},Yp=({onAgree:e,onReject:t,onlyOptionalDocuments:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{documentsNotAgreed:a}=rm(),{requiredDocuments:o,optionalDocuments:s}=W(()=>a.reduce((e,t)=>(t.required?e.requiredDocuments.push(t):e.optionalDocuments.push(t),e),{requiredDocuments:[],optionalDocuments:[]}),[a]),{handleSubmit:c,register:l,formState:{isValid:u},watch:d}=Li({defaultValues:W(()=>a.reduce((e,t)=>(e[t.id]=t.required,e),{}),[a])}),f=d(),p=W(()=>a.filter(e=>f[e.id]),[a,f]),m=a?.length===p.length,h=H(t=>{let n=new Set(Object.entries(t).filter(([e,t])=>t).map(([e])=>e));return e(a.filter(e=>n.has(e.id)))},[a,e]),g=i?`#3a3a3a`:`#eaeaea`,_=i?`#2a2a2a`:`#f5f5f5`,v=i?`gray.300`:`gray.600`,y=i?`0 2px 8px rgba(0, 0, 0, 0.2)`:`0 2px 8px rgba(0, 0, 0, 0.05)`,b=o.length>0,x=s.length>0,S=W(()=>{let e=s.filter(e=>f[e.id]).length;return r(m?`Accept all`:n&&e===0?`Ignore and continue`:b&&!x||b&&e===0?`Accept`:`Accept selected`)},[n,m,s,f]),C=e=>e===o.length-2&&o.length>1?r(` and `):`, `;return q(jt,{width:`full`,children:J(`form`,{onSubmit:c(h),children:[q(Z,{children:q(L,{children:r(`Terms and Policies`)})}),q(P,{children:J(z,{align:`stretch`,spacing:5,width:`full`,children:[b&&J(R,{as:`span`,fontSize:`sm`,children:[r(`By continuing, you agree to`),` `,o.map((e,t)=>J(Xt,{children:[q(Jp,{document:e,register:l,isText:!0},e.id),t<o.length-1?C(t):null]},e.id)),`.`,` `,r(`Please take a moment to review all the policies, with acceptance being mandatory to continue.`)]}),n&&q(R,{fontSize:`sm`,color:v,mb:3,children:q(vn,{i18nKey:`<bold>Your privacy matters.</bold> You’re in control, accept to enable optional features like cookies that help us enhance your experience.`,components:{bold:q(R,{as:`span`,fontWeight:`semibold`,color:v})}})}),x&&J(jt,{p:4,borderRadius:`xl`,bg:_,borderWidth:`1px`,borderColor:g,boxShadow:y,spacing:5,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:v,children:r(`Optional`)}),q(z,{align:`stretch`,spacing:4,children:s.map(e=>q(Jp,{document:e,register:l},e.id))})]})]})}),q(I,{children:J(z,{width:`full`,spacing:3,children:[q(j,{variant:`vechainKitPrimary`,width:`full`,type:`submit`,isDisabled:!u,"data-testid":`accept-tnc-button`,children:S}),!n&&q(j,{variant:`ghost`,width:`full`,onClick:t,"data-testid":`reject-tnc-button`,colorScheme:`red`,children:r(`Reject and logout`)})]})})]})})};var Xp=function(e){return e.REVIEW_DOCUMENTS=`REVIEW_DOCUMENTS`,e.REJECT_DOCUMENTS=`REJECT_DOCUMENTS`,e}(Xp||{});const Zp=({isOpen:e,onAgree:t,handleLogout:n,onlyOptionalDocuments:r})=>{let{t:i}=Y(),{activeStep:a,goToPrevious:o,setActiveStep:s,goToNext:c}=Yt({index:0,count:Object.keys(Xp).length}),l=()=>{s(0)},u=()=>{c()},d=()=>{n(),l()};return q(qp,{isOpen:e,onClose:()=>{},goToPrevious:o,goToNext:c,setActiveStep:s,steps:W(()=>[{key:Xp.REVIEW_DOCUMENTS,content:q(Yp,{onAgree:t,onReject:u,onlyOptionalDocuments:r})},{key:Xp.REJECT_DOCUMENTS,content:q(Wl,{onDisconnect:d,onBack:o,onClose:o,text:i(`Are you sure you want to reject the policies and disconnect?`),showCloseButton:!1})}],[Yp,Wl,t,d]),disableCloseButton:!0,disableBackButton:!0,isCloseable:!1,closeOnOverlayClick:!1,activeStep:a})},Qp=e=>`${e.documentType}-${e.url.replace(/[^\w-]+/g,`-`)}-v${e.version}`,$p=e=>e.map(e=>({...e,id:Qp(e)})),em=e=>e.filter(e=>!e.required),tm=(e,t)=>{let n=Date.now();return e.map(e=>({...e,walletAddress:t,timestamp:n}))},nm=Zt(void 0),rm=()=>Qt(nm)||{hasAgreedToRequiredDocuments:!0,agreements:[],walletAddress:void 0,documents:[],documentsNotAgreed:[]},im=({children:e})=>{let{connection:t,account:n,disconnect:r}=Q(),{darkMode:i,legalDocuments:a,theme:s}=$(),[c,l]=Dp(`vechain-kit-legal-documents`,[]),[u,d]=Dp(`vechain-kit-legal-documents-optional-reject`,[]),[f,p]=G(!1),h=H((e,t)=>u.some(n=>o(n.walletAddress,t)&&n.id===e.id),[u]),[g,_]=W(()=>{let e=$p([{items:a?.cookiePolicy||[],type:se.COOKIES,source:m.APPLICATION},{items:a?.privacyPolicy||[],type:se.PRIVACY,source:m.APPLICATION},{items:a?.termsAndConditions||[],type:se.TERMS,source:m.APPLICATION}].flatMap(e=>e.items.map(t=>({...t,documentType:e.type,documentSource:e.source}))));return[e,e.filter(e=>e.required)]},[a]),v=W(()=>n?.address?g.filter(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)?!1:!u.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)):[],[g,n?.address,c,u]),y=W(()=>!_.length||!n?.address?!0:_.every(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)),[_,c,n?.address]),b=W(()=>{if(!n?.address||!v?.length)return!1;let e=em(v);return e.length===0?!1:e.some(e=>!h(e,n.address))},[v,n?.address,em,h]),x=W(()=>y&&b,[y,b]);W(()=>{let e=new Set(c.map(e=>e.id));return g.some(t=>e.has(t.id))},[g,c]),U(()=>{t.isConnected&&n?.address?p(!y||b):p(!1)},[t.isConnected,n?.address,y,b]);let S=H((e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return;let r=tm(n,t);l([...c.filter(e=>!o(e.walletAddress,t)||!n.some(t=>t.id===e.id)),...r])},[c,tm]),C=H(e=>{if(!n?.address)return;let t=em(v);if(t.length===0)return;let r=e.map(e=>e.id),i=t.filter(e=>!r.includes(e.id));if(!i?.length)return;let a=tm(i,n.address);d(e=>[...e,...a])},[n?.address,v,em,tm]),w=H(e=>{if(!n?.address)return;let t=Array.isArray(e)?e:[e];t.length>0&&S(t,n.address),C(t),p(!1)},[n?.address,S,C]);return J(nm.Provider,{value:{hasAgreedToRequiredDocuments:y,agreements:c,walletAddress:n?.address,documents:g,documentsNotAgreed:v},children:[e,q(pd,{darkMode:i,theme:s,children:q(Zp,{isOpen:f,onAgree:w,handleLogout:x?()=>{}:()=>{r(),p(!1)},onlyOptionalDocuments:x})})]})},am=Zt(null),om=({children:e,nodeUrl:n,delegatorUrl:r=_(),delegateAllTransactions:i,genericDelegator:a})=>{let{signTypedData:o,exportWallet:s,signMessage:c}=Dn(),{signTypedData:l,signMessage:u}=Ks(),{connection:d,connectedWallet:f}=Q(),{network:p}=$(),{data:m}=Wf(f?.address??``),{data:h}=Mf(m?.address??``,f?.address??``),{data:g}=If(f?.address??``),{buildClausesWithAuth:v}=Cp(),{sendTransactionUsingGenericDelegator:y}=Fp(),b=sa.at(n),x=async(e,i,a,o)=>{if(!m?.address)throw Error(`Smart account address is not set`);let s=new ca(b,a??new aa([{privateKey:Buffer.from(t.privateKey.slice(2),`hex`),address:t.address}],{gasPayer:{gasPayerServiceUrl:i??r}}),!0),c=o??await s.getSigner(t.address),l=la.transactionBodyToTransactionRequestInput(e,t.address),u=await c.signTransaction(l),{id:d}=await fetch(`${n}/transactions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({raw:u})}).then(e=>e.json());return d},S=H(async({txClauses:e=[],title:n=`Sign Transaction`,description:i,buttonText:o=`Sign`,delegationUrl:s})=>{if(!m||m&&!m.address||!f||f&&!f.address)throw Error(`Address or embedded wallet is missing`);if(a&&!s)return await y({clauses:e,genericDelegatorUrl:r??``});let c=await v({clauses:e,smartAccount:m,version:g?1:h?.version??3,title:n,description:i,buttonText:o}),l={clauses:c,simulateTransactionOptions:{caller:t.address}},u=await b.transactions.simulateTransaction(l.clauses,{...l.simulateTransactionOptions});for(let e=0;e<u.length;e++)if(u[e].reverted)return console.error(`simulatedTx1[i].vmError: ${u[e].vmError}`),u[e].vmError;return await x(await Mp(c,b,t,!0),s)},[y,a,m,f,r,v,g,h,b]);return q(am.Provider,{value:{accountFactory:k(p.type).accountFactoryAddress,sendTransaction:S,signMessage:async e=>d.isConnectedWithCrossApp?await u(e):(await c({message:e})).signature,signTypedData:async e=>d.isConnectedWithCrossApp?await l({...e,address:f?.address,types:Object.fromEntries(Object.entries(e.types).map(([e,t])=>[e,[...t]]))}):(await o(e)).signature,exportWallet:s,delegateAllTransactions:i},children:e})},sm=()=>{let e=Qt(am);if(!e)throw Error(`usePrivyWalletProvider must be used within a PrivyWalletProvider`);return e},cm=Zt(null),$=()=>{let e=Qt(cm);if(!e)throw Error(`useVeChainKitConfig must be used within VeChainKit`);return e},lm=e=>{let t=[],n={...e};if(n.dappKit||={allowedWallets:[`veworld`]},(n.privy!==void 0||n.loginMethods?.some(e=>e.method===`vechain`||e.method===`ecosystem`))&&(n.feeDelegation?!n.feeDelegation.delegatorUrl&&!n.feeDelegation.genericDelegatorUrl&&(n.feeDelegation.genericDelegatorUrl=_()):n.feeDelegation={genericDelegatorUrl:_()}),!n.network||!n.network.type)n.network={type:`main`};else{let e=n.network.type;[`main`,`test`,`solo`].includes(e)||t.push(`network.type must be either "main", "test" or "solo"`)}if(n.loginMethods||=[{method:`vechain`,gridColumn:4},{method:`ecosystem`,gridColumn:4},{method:`dappkit`,gridColumn:4}],n.loginMethods&&!n.privy){let e=n.loginMethods.filter(e=>[`email`,`google`,`passkey`,`more`].includes(e.method));e.length>0&&t.push(`Login methods ${e.map(e=>`"${e.method}"`).join(`, `)} require Privy configuration. Please either remove these methods or configure the privy prop.`)}if(n?.legalDocuments&&(n.legalDocuments.termsAndConditions&&n.legalDocuments.termsAndConditions.forEach(e=>{C(e.url)||t.push(`legalDocuments.termsAndConditions.url is invalid: ${e.url}`)}),n.legalDocuments.privacyPolicy&&n.legalDocuments.privacyPolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.privacyPolicy.url is invalid: ${e.url}`)}),n.legalDocuments.cookiePolicy&&n.legalDocuments.cookiePolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.cookiePolicy.url is invalid: ${e.url}`)})),t.length>0)throw Error(`VeChainKit Configuration Error:
|
|
193
193
|
`+t.join(`
|
|
194
|
-
`));return n},lm=`vechain_kit_currency`,um=e=>{let{children:t,privy:n,feeDelegation:r,dappKit:i,loginModalUI:o,loginMethods:s,darkMode:c=!1,i18n:l,language:u=`en`,network:d,allowCustomTokens:f,legalDocuments:p,defaultCurrency:m=`usd`,theme:g,onLanguageChange:_,onCurrencyChange:v}=cm(e),y=d?.type??`main`,b=d?.nodeUrl??k(y).nodeUrl,x={...d,type:y,nodeUrl:b},S=i??{allowedWallets:[`veworld`]},[C,T]=G(()=>typeof window<`u`&&w(`i18nextLng`)||u),[ee,E]=G(()=>{try{return w(lm)||m}catch{return m}}),te=$t(!1),D=$t(!1),ne=s,O=W(()=>ne?.find(e=>e.method===`ecosystem`)?.allowedApps??a.map(e=>e.id),[ne]),re,ie;n?(re=n.appId,ie=n.clientId):(re=`clzdb5k0b02b9qvzjm6jpknsc`,ie=`client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF`),U(()=>{wa(Ca),l&&Object.keys(l).forEach(e=>{Ca.addResourceBundle(e,`translation`,l[e],!0,!0)});let e=(typeof window<`u`?w(`i18nextLng`):null)||C;e&&Ca.language!==e&&(te.current=!0,Ca.changeLanguage(e),e!==C&&T(e),te.current=!1)},[]),U(()=>{let e=typeof window<`u`?w(`i18nextLng`):null;u&&!e&&u!==C&&(te.current=!0,Ca.changeLanguage(u),T(u),te.current=!1)},[u,C]),U(()=>{let e=e=>{!te.current&&e!==C&&(T(e),_?.(e))};return Ca.on(`languageChanged`,e),()=>{Ca.off(`languageChanged`,e)}},[C,_]),U(()=>{let e=w(lm);m&&!e&&m!==ee&&(D.current=!0,E(m),h(lm,m),D.current=!1)},[m,ee]),U(()=>{let e=()=>{try{let e=w(lm);if(e&&e!==ee&&!D.current){let t=e;E(t),v?.(t)}}catch{}};e();let t=t=>{t.key===lm&&t.newValue&&e()};window.addEventListener(`storage`,t);let n=setInterval(e,500);return()=>{window.removeEventListener(`storage`,t),clearInterval(n)}},[ee,v]);let ae=e=>{te.current=!0,Ca.changeLanguage(e),T(e),te.current=!1},se=e=>{D.current=!0,E(e),h(lm,e),D.current=!1};U(()=>{h(oe.NETWORK,y)},[y]);let ce=W(()=>Ra(La(c),za(g,c)),[g,c]),le=W(()=>Va(ce,c),[ce,c]),ue=W(()=>Ha(ce,c),[ce,c]);return U(()=>{let e=Ba(ce.colors.background.card,c),t=Ba(ce.colors.background.cardElevated,c),n=c?`transparent`:`#ffffff`,r=c?`transparent`:`#ffffff`,i=c?`transparent`:`#ffffff`;Wa(ue,ce.effects.backdropFilter.modal,e,t,n,r,i,ce.colors.border.default)},[ue,ce.effects.backdropFilter.modal,ce.colors.background.card,ce.colors.background.cardElevated,ce.colors.border.default,c]),U(()=>{Ua()},[]),J(qa,{children:[q(kn,{initialIsOpen:!1}),q(Gs,{privyEcosystemAppIDS:O,children:q(sm.Provider,{value:{privy:n,privyEcosystemAppIDS:O,feeDelegation:r,dappKit:S,loginModalUI:o,loginMethods:ne,darkMode:c,i18n:l,currentLanguage:C,network:x,allowCustomTokens:f,legalDocuments:p,currentCurrency:ee,theme:g,setLanguage:ae,setCurrency:se},children:q(bn,{appId:re,clientId:ie,config:{loginMethodsAndOrder:{primary:n?.loginMethods.slice(0,4)??[],overflow:n?.loginMethods.slice(4)??[]},externalWallets:{walletConnect:{enabled:!1}},appearance:{theme:c?`dark`:`light`,accentColor:n?.appearance.accentColor??(ce.buttons.primaryButton.bg?.startsWith(`#`)?ce.buttons.primaryButton.bg:c?`#3182CE`:`#2B6CB0`),loginMessage:n?.appearance.loginMessage,logo:n?.appearance.logo},embeddedWallets:{createOnLogin:n?.embeddedWallets?.createOnLogin??`all-users`},passkeys:{shouldUnlinkOnUnenrollMfa:!1}},children:q(An,{node:x.nodeUrl,v2Api:{enabled:S.v2Api?.enabled??!0,external:S.v2Api?.external??!1},i18n:l,language:C,logLevel:S.logLevel,modalParent:S.modalParent,onSourceClick:S.onSourceClick,usePersistence:S.usePersistence??!0,allowedWallets:S.allowedWallets,walletConnectOptions:S.walletConnectOptions,themeMode:c?`DARK`:`LIGHT`,themeVariables:S.themeVariables?{...le,...S.themeVariables}:le,children:q(am,{nodeUrl:x.nodeUrl,delegatorUrl:r?.delegatorUrl??r?.genericDelegatorUrl,delegateAllTransactions:r?.delegateAllTransactions??!1,genericDelegator:!!(!r?.delegatorUrl&&r?.genericDelegatorUrl),children:q(gd,{children:q(rm,{children:t})})})})})})})]})};export{Vp as AccountAvatar,Bd as AccountCustomizationModalProvider,dl as AccountDetailsButton,qc as AccountMainContent,wu as AccountModal,bd as AccountModalProvider,pl as AccountSelector,fl as ActionButton,Ya as AddressDisplay,Rp as AddressDisplayCard,ao as AssetButton,kl as AssetsContent,hl as BalanceSection,to as BaseModal,Te as BetterSwapLogo,jl as BridgeContent,c as CURRENCY_SYMBOLS,Ml as ChangeCurrencyContent,rl as ChooseNameContent,Od as ChooseNameModalProvider,sl as ChooseNameSearchContent,cl as ChooseNameSummaryContent,fd as ColorModeSync,Tu as ConnectModal,vd as ConnectModalProvider,Du as ConnectPopover,Eu as ConnectionButton,Cl as CrossAppConnectionSecurityCard,wl as CustomizationContent,Tl as CustomizationSummaryContent,jn as DAppKitWalletButton,Vc as DappKitButton,Wl as DisconnectConfirmContent,Sl as DomainRequiredAlert,le as ENS_TEXT_RECORDS,Wc as EcosystemButton,Ru as EcosystemModal,Fc as EmailLoginButton,xl as ExchangeWarningAlert,Pd as ExploreEcosystemModalProvider,ul as FAQContent,Rd as FAQModalProvider,bl as FeatureAnnouncementCard,Gp as GasFeeSummary,Wp as GasFeeTokenSelector,Il as GasTokenSettingsContent,Ne as GitHubLogo,pe as GoogleLogo,Nl as LanguageSettingsContent,qp as LegalDocumentItem,m as LegalDocumentSource,se as LegalDocumentType,Xp as LegalDocumentsModal,rm as LegalDocumentsProvider,Cp as LocalStorageKey,Pu as LoginLoadingModal,Lc as LoginWithGithubButton,Ic as LoginWithGoogleButton,tc as MAX_IMAGE_SIZE,Gc as MainContent,Al as ManageCustomTokenContent,Ja as ModalBackButton,zp as ModalFAQButton,Up as ModalNotificationButton,gd as ModalProvider,n as NFTMediaType,Id as NotificationsModalProvider,ss as PRICE_FEED_IDS,Bc as PasskeyLoginButton,Hc as PrivyButton,Se as PrivyLogo,am as PrivyWalletProvider,Dl as ProfileContent,qd as ProfileModalProvider,vl as QuickActionsSection,Hd as ReceiveModalProvider,Qc as ReceiveTokenContent,Bp as ScrollToTopWrapper,Jc as SelectTokenContent,Xc as SendTokenContent,Ad as SendTokenModalProvider,Zc as SendTokenSummaryContent,Ll as SettingsContent,gu as ShareButtons,ju as SocialIcons,eo as StickyFooterContainer,Z as StickyHeaderContainer,nl as SwapTokenContent,Md as SwapTokenModalProvider,Ul as TermsAndPrivacyContent,oa as ThorClient,Hp as TransactionButtonAndStatus,vu as TransactionModal,_u as TransactionModalContent,Sd as TransactionModalProvider,Nu as TransactionToast,wd as TransactionToastProvider,de as TwitterLogo,Ol as UpgradeSmartAccountContent,Vu as UpgradeSmartAccountModal,Gd as UpgradeSmartAccountModalProvider,_e as VETLogo,ke as VTHOLogo,Ce as VeBetterIcon,je as VeBetterIconDark,ve as VeBetterIconLight,ye as VeBetterLogo,De as VeBetterLogoDark,we as VeBetterLogoLight,sm as VeChainKitContext,um as VeChainKitProvider,zc as VeChainLoginButton,Rc as VeChainWithPrivyLoginButton,ce as VePassportUserStatus,Ae as VeTradeLogo,he as VeWorldLogoDark,Ee as VeWorldLogoLight,Oe as VechainEnergy,xe as VechainIcon,be as VechainIconDark,me as VechainIconLight,pd as VechainKitThemeProvider,fe as VechainLogo,Pe as VechainLogoDark,Fe as VechainLogoHorizontalDark,Me as VechainLogoHorizontalLight,ge as VechainLogoLight,$a as VersionFooter,Au as WalletButton,Ed as WalletModalProvider,yp as buildBatchAuthorizationTypedData,ae as buildCallClauses,Uo as buildClauses,cp as buildERC20Clauses,bp as buildSingleAuthorizationTypedData,up as buildVETClauses,To as buildVetDomainClauses,ue as calculateTotalCost,cc as compressImages,Qf as currentBlockQueryKey,gp as decodeEventLog,Np as decodeRawTx,Ap as delegateAuthorized,jp as estimateAndBuildTxBody,Op as estimateGas,ee as executeCallClause,O as executeMultipleClausesCall,of as fetchAppHubApps,oo as fetchPrivyAppInfo,lo as fetchPrivyStatus,v as formatGasCost,Ef as getAccountAddress,Df as getAccountAddressQueryKey,_f as getAccountBalance,vf as getAccountBalanceQueryKey,bf as getAccountImplementationAddress,xf as getAccountImplementationAddressQueryKey,Af as getAccountVersionQueryKey,op as getAllEventLogs,af as getAppHubAppsQueryKey,$o as getAvatarLegacy,es as getAvatarLegacyQueryKey,Yo as getAvatarOfAddressQueryKey,Io as getAvatarQueryKey,ws as getB3trBalanceQueryKey,cf as getCallClauseQueryKey,lf as getCallClauseQueryKeyWithArgs,tp as getChainId,np as getChainIdQueryKey,k as getConfig,Cf as getCurrentAccountImplementationVersion,wf as getCurrentAccountImplementationVersionQueryKey,vs as getCurrentAllocationsRoundIdQueryKey,Es as getCustomTokenBalanceQueryKey,xs as getCustomTokenInfoQueryKey,kp as getDepositAccount,No as getDomainsOfAddress,Po as getDomainsOfAddressQueryKey,ho as getEnsRecordExistsQueryKey,Os as getErc20BalanceQueryKey,ap as getEventLogs,_p as getEventsKey,Nf as getHasV1SmartAccount,Pf as getHasV1SmartAccountQueryKey,nc as getIpfsImage,rc as getIpfsImageQueryKey,Qs as getIpfsMetadata,$s as getIpfsMetadataQueryKey,If as getIsDeployed,Lf as getIsDeployedQueryKey,Do as getIsDomainProtectedQueryKey,Ms as getIsPersonQueryKey,so as getPrivyAppInfoQueryKey,Go as getResolverAddressQueryKey,Is as getRoundXAppsQueryKey,Vf as getSmartAccount,Hf as getSmartAccountQueryKey,zo as getTextRecords,Bo as getTextRecordsQueryKey,bs as getTokenInfo,cs as getTokenUsdPrice,ls as getTokenUsdPriceQueryKey,Wf as getUpgradeRequired,qf as getUpgradeRequiredForAccount,Jf as getUpgradeRequiredForAccountQueryKey,Gf as getUpgradeRequiredQueryKey,fo as getVechainDomainQueryKey,As as getVot3BalanceQueryKey,Ys as getXAppMetadata,zs as getXAppsSharesQueryKey,sc as imageCompressionOptions,Mp as signVip191Transaction,mp as txReceiptQueryKey,yf as useAccountBalance,zd as useAccountCustomizationModal,Sf as useAccountImplementationAddress,yd as useAccountModal,Yc as useAccountModalOptions,sf as useAppHubApps,Sp as useBuildClauses,fp as useBuildTransaction,uf as useCallClause,Dd as useChooseNameModal,So as useClaimVeWorldSubdomain,Eo as useClaimVetDomain,_d as useConnectModal,$d as useCrossAppConnectionCache,ps as useCurrency,Tf as useCurrentAccountImplementationVersion,ys as useCurrentAllocationsRoundId,ep as useCurrentBlock,pf as useCurrentCurrency,ff as useCurrentLanguage,Cs as useCustomTokens,Pn as useDAppKitWallet,In as useDAppKitWalletModal,Dp as useEcosystemShortcuts,go as useEnsRecordExists,Lp as useEstimateAllTokens,vp as useEvents,Nd as useExploreEcosystemModal,Ld as useFAQModal,yl as useFeatureAnnouncement,co as useFetchAppInfo,uo as useFetchPrivyStatus,Fp as useGasTokenSelection,Pp as useGenericDelegator,Ip as useGenericDelegatorFeeEstimation,Of as useGetAccountAddress,jf as useGetAccountVersion,Lo as useGetAvatar,ns as useGetAvatarLegacy,Xo as useGetAvatarOfAddress,Ts as useGetB3trBalance,rp as useGetChainId,Ds as useGetCustomTokenBalances,Ss as useGetCustomTokenInfo,Fo as useGetDomainsOfAddress,ks as useGetErc20Balance,mf as useGetNodeUrl,Ko as useGetResolverAddress,Vo as useGetTextRecords,us as useGetTokenUsdPrice,js as useGetVot3Balance,Ff as useHasV1SmartAccount,ic as useIpfsImage,ac as useIpfsImageList,ec as useIpfsMetadata,oc as useIpfsMetadatas,Ao as useIsDomainProtected,hf as useIsPWA,Ns as useIsPerson,Rf as useIsSmartAccountDeployed,nm as useLegalDocuments,wp as useLocalStorage,Ud as useLoginModalContent,Qd as useLoginWithOAuth,Xd as useLoginWithPasskey,ef as useLoginWithVeChain,Tn as useMfaEnrollment,hd as useModal,Vs as useMostVotedAppsInRound,df as useMultipleClausesCall,$l as useNotificationAlerts,eu as useNotifications,Fd as useNotificationsModal,En as usePrivy,om as usePrivyWalletProvider,Kd as useProfileModal,Vd as useReceiveModal,Js as useRefreshBalances,zf as useRefreshFactoryQueries,_o as useRefreshMetadata,Bf as useRefreshSmartAccountQueries,Ls as useRoundXApps,gf as useScrollToTop,kd as useSendTokenModal,fc as useSendTransaction,On as useSetWalletRecovery,Jd as useSignMessage,Yd as useSignTypedData,uc as useSingleImageUpload,Uf as useSmartAccount,Nc as useSwapQuotes,jd as useSwapTokenModal,pc as useSwapTransaction,Ep as useSyncableLocalStorage,Mn as useThor,os as useTokenBalances,ds as useTokenPrices,ms as useTokensWithValues,hs as useTotalBalance,xd as useTransactionModal,Cd as useTransactionToast,lp as useTransferERC20,dp as useTransferVET,hp as useTxReceipt,as as useUnsetDomain,Wo as useUpdateTextRecord,Kf as useUpgradeRequired,Yf as useUpgradeRequiredForAccount,Zf as useUpgradeSmartAccount,Wd as useUpgradeSmartAccountModal,lc as useUploadImages,$ as useVeChainKitConfig,po as useVechainDomain,dd as useVechainKitThemeConfig,Q as useWallet,qs as useWalletMetadata,Td as useWalletModal,Zs as useXAppMetadata,Bs as useXAppsShares};
|
|
194
|
+
`));return n},um=`vechain_kit_currency`,dm=e=>{let{children:t,privy:n,feeDelegation:r,dappKit:i,loginModalUI:o,loginMethods:s,darkMode:c=!1,i18n:l,language:u=`en`,network:d,allowCustomTokens:f,legalDocuments:p,defaultCurrency:m=`usd`,theme:g,onLanguageChange:_,onCurrencyChange:v}=lm(e),y=d?.type??`main`,b=d?.nodeUrl??k(y).nodeUrl,x={...d,type:y,nodeUrl:b},S=i??{allowedWallets:[`veworld`]},[C,T]=G(()=>typeof window<`u`&&w(`i18nextLng`)||u),[ee,E]=G(()=>{try{return w(um)||m}catch{return m}}),te=$t(!1),D=$t(!1),ne=s,O=W(()=>ne?.find(e=>e.method===`ecosystem`)?.allowedApps??a.map(e=>e.id),[ne]),re,ie;n?(re=n.appId,ie=n.clientId):(re=`clzdb5k0b02b9qvzjm6jpknsc`,ie=`client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF`),U(()=>{wa(Ca),l&&Object.keys(l).forEach(e=>{Ca.addResourceBundle(e,`translation`,l[e],!0,!0)});let e=(typeof window<`u`?w(`i18nextLng`):null)||C;e&&Ca.language!==e&&(te.current=!0,Ca.changeLanguage(e),e!==C&&T(e),te.current=!1)},[]),U(()=>{let e=typeof window<`u`?w(`i18nextLng`):null;u&&!e&&u!==C&&(te.current=!0,Ca.changeLanguage(u),T(u),te.current=!1)},[u,C]),U(()=>{let e=e=>{!te.current&&e!==C&&(T(e),_?.(e))};return Ca.on(`languageChanged`,e),()=>{Ca.off(`languageChanged`,e)}},[C,_]),U(()=>{let e=w(um);m&&!e&&m!==ee&&(D.current=!0,E(m),h(um,m),D.current=!1)},[m,ee]),U(()=>{let e=()=>{try{let e=w(um);if(e&&e!==ee&&!D.current){let t=e;E(t),v?.(t)}}catch{}};e();let t=t=>{t.key===um&&t.newValue&&e()};window.addEventListener(`storage`,t);let n=setInterval(e,500);return()=>{window.removeEventListener(`storage`,t),clearInterval(n)}},[ee,v]);let ae=e=>{te.current=!0,Ca.changeLanguage(e),T(e),te.current=!1},se=e=>{D.current=!0,E(e),h(um,e),D.current=!1};U(()=>{h(oe.NETWORK,y)},[y]);let ce=W(()=>Ra(La(c),za(g,c)),[g,c]),le=W(()=>Va(ce,c),[ce,c]),ue=W(()=>Ha(ce,c),[ce,c]);return U(()=>{let e=Ba(ce.colors.background.card,c),t=Ba(ce.colors.background.cardElevated,c),n=c?`transparent`:`#ffffff`,r=c?`transparent`:`#ffffff`,i=c?`transparent`:`#ffffff`;Wa(ue,ce.effects.backdropFilter.modal,e,t,n,r,i,ce.colors.border.default)},[ue,ce.effects.backdropFilter.modal,ce.colors.background.card,ce.colors.background.cardElevated,ce.colors.border.default,c]),U(()=>{Ua()},[]),J(qa,{children:[q(kn,{initialIsOpen:!1}),q(Gs,{privyEcosystemAppIDS:O,children:q(cm.Provider,{value:{privy:n,privyEcosystemAppIDS:O,feeDelegation:r,dappKit:S,loginModalUI:o,loginMethods:ne,darkMode:c,i18n:l,currentLanguage:C,network:x,allowCustomTokens:f,legalDocuments:p,currentCurrency:ee,theme:g,setLanguage:ae,setCurrency:se},children:q(bn,{appId:re,clientId:ie,config:{loginMethodsAndOrder:{primary:n?.loginMethods.slice(0,4)??[],overflow:n?.loginMethods.slice(4)??[]},externalWallets:{walletConnect:{enabled:!1}},appearance:{theme:c?`dark`:`light`,accentColor:n?.appearance.accentColor??(ce.buttons.primaryButton.bg?.startsWith(`#`)?ce.buttons.primaryButton.bg:c?`#3182CE`:`#2B6CB0`),loginMessage:n?.appearance.loginMessage,logo:n?.appearance.logo},embeddedWallets:{createOnLogin:n?.embeddedWallets?.createOnLogin??`all-users`},passkeys:{shouldUnlinkOnUnenrollMfa:!1}},children:q(An,{node:x.nodeUrl,v2Api:{enabled:S.v2Api?.enabled??!0,external:S.v2Api?.external??!1},i18n:l,language:C,logLevel:S.logLevel,modalParent:S.modalParent,onSourceClick:S.onSourceClick,usePersistence:S.usePersistence??!0,allowedWallets:S.allowedWallets,walletConnectOptions:S.walletConnectOptions,themeMode:c?`DARK`:`LIGHT`,themeVariables:S.themeVariables?{...le,...S.themeVariables}:le,children:q(om,{nodeUrl:x.nodeUrl,delegatorUrl:r?.delegatorUrl??r?.genericDelegatorUrl,delegateAllTransactions:r?.delegateAllTransactions??!1,genericDelegator:!!(!r?.delegatorUrl&&r?.genericDelegatorUrl),children:q(gd,{children:q(im,{children:t})})})})})})})]})};export{Hp as AccountAvatar,Bd as AccountCustomizationModalProvider,dl as AccountDetailsButton,qc as AccountMainContent,wu as AccountModal,bd as AccountModalProvider,pl as AccountSelector,fl as ActionButton,Ya as AddressDisplay,zp as AddressDisplayCard,ao as AssetButton,kl as AssetsContent,hl as BalanceSection,to as BaseModal,Te as BetterSwapLogo,jl as BridgeContent,c as CURRENCY_SYMBOLS,Ml as ChangeCurrencyContent,rl as ChooseNameContent,Od as ChooseNameModalProvider,sl as ChooseNameSearchContent,cl as ChooseNameSummaryContent,fd as ColorModeSync,Tu as ConnectModal,vd as ConnectModalProvider,Du as ConnectPopover,Eu as ConnectionButton,Cl as CrossAppConnectionSecurityCard,wl as CustomizationContent,Tl as CustomizationSummaryContent,jn as DAppKitWalletButton,Vc as DappKitButton,Wl as DisconnectConfirmContent,Sl as DomainRequiredAlert,le as ENS_TEXT_RECORDS,Wc as EcosystemButton,Ru as EcosystemModal,Fc as EmailLoginButton,xl as ExchangeWarningAlert,Pd as ExploreEcosystemModalProvider,ul as FAQContent,Rd as FAQModalProvider,bl as FeatureAnnouncementCard,Kp as GasFeeSummary,Gp as GasFeeTokenSelector,Il as GasTokenSettingsContent,Ne as GitHubLogo,pe as GoogleLogo,Nl as LanguageSettingsContent,Jp as LegalDocumentItem,m as LegalDocumentSource,se as LegalDocumentType,Zp as LegalDocumentsModal,im as LegalDocumentsProvider,wp as LocalStorageKey,Pu as LoginLoadingModal,Lc as LoginWithGithubButton,Ic as LoginWithGoogleButton,tc as MAX_IMAGE_SIZE,Gc as MainContent,Al as ManageCustomTokenContent,Ja as ModalBackButton,Bp as ModalFAQButton,Wp as ModalNotificationButton,gd as ModalProvider,n as NFTMediaType,Id as NotificationsModalProvider,ss as PRICE_FEED_IDS,Bc as PasskeyLoginButton,Hc as PrivyButton,Se as PrivyLogo,om as PrivyWalletProvider,Dl as ProfileContent,qd as ProfileModalProvider,vl as QuickActionsSection,Hd as ReceiveModalProvider,Qc as ReceiveTokenContent,Vp as ScrollToTopWrapper,Jc as SelectTokenContent,Xc as SendTokenContent,Ad as SendTokenModalProvider,Zc as SendTokenSummaryContent,Ll as SettingsContent,gu as ShareButtons,ju as SocialIcons,eo as StickyFooterContainer,Z as StickyHeaderContainer,nl as SwapTokenContent,Md as SwapTokenModalProvider,Ul as TermsAndPrivacyContent,oa as ThorClient,Up as TransactionButtonAndStatus,vu as TransactionModal,_u as TransactionModalContent,Sd as TransactionModalProvider,Nu as TransactionToast,wd as TransactionToastProvider,de as TwitterLogo,Ol as UpgradeSmartAccountContent,Vu as UpgradeSmartAccountModal,Gd as UpgradeSmartAccountModalProvider,_e as VETLogo,ke as VTHOLogo,Ce as VeBetterIcon,je as VeBetterIconDark,ve as VeBetterIconLight,ye as VeBetterLogo,De as VeBetterLogoDark,we as VeBetterLogoLight,cm as VeChainKitContext,dm as VeChainKitProvider,zc as VeChainLoginButton,Rc as VeChainWithPrivyLoginButton,ce as VePassportUserStatus,Ae as VeTradeLogo,he as VeWorldLogoDark,Ee as VeWorldLogoLight,Oe as VechainEnergy,xe as VechainIcon,be as VechainIconDark,me as VechainIconLight,pd as VechainKitThemeProvider,fe as VechainLogo,Pe as VechainLogoDark,Fe as VechainLogoHorizontalDark,Me as VechainLogoHorizontalLight,ge as VechainLogoLight,$a as VersionFooter,Au as WalletButton,Ed as WalletModalProvider,bp as buildBatchAuthorizationTypedData,ae as buildCallClauses,Uo as buildClauses,lp as buildERC20Clauses,xp as buildSingleAuthorizationTypedData,dp as buildVETClauses,To as buildVetDomainClauses,ue as calculateTotalCost,cc as compressImages,$f as currentBlockQueryKey,_p as decodeEventLog,Pp as decodeRawTx,jp as delegateAuthorized,Mp as estimateAndBuildTxBody,kp as estimateGas,ee as executeCallClause,O as executeMultipleClausesCall,of as fetchAppHubApps,oo as fetchPrivyAppInfo,lo as fetchPrivyStatus,v as formatGasCost,Df as getAccountAddress,Of as getAccountAddressQueryKey,vf as getAccountBalance,yf as getAccountBalanceQueryKey,xf as getAccountImplementationAddress,Sf as getAccountImplementationAddressQueryKey,jf as getAccountVersionQueryKey,sp as getAllEventLogs,af as getAppHubAppsQueryKey,$o as getAvatarLegacy,es as getAvatarLegacyQueryKey,Yo as getAvatarOfAddressQueryKey,Io as getAvatarQueryKey,ws as getB3trBalanceQueryKey,cf as getCallClauseQueryKey,uf as getCallClauseQueryKeyWithArgs,np as getChainId,rp as getChainIdQueryKey,k as getConfig,wf as getCurrentAccountImplementationVersion,Tf as getCurrentAccountImplementationVersionQueryKey,vs as getCurrentAllocationsRoundIdQueryKey,Es as getCustomTokenBalanceQueryKey,xs as getCustomTokenInfoQueryKey,Ap as getDepositAccount,No as getDomainsOfAddress,Po as getDomainsOfAddressQueryKey,ho as getEnsRecordExistsQueryKey,Os as getErc20BalanceQueryKey,op as getEventLogs,vp as getEventsKey,Pf as getHasV1SmartAccount,Ff as getHasV1SmartAccountQueryKey,nc as getIpfsImage,rc as getIpfsImageQueryKey,Qs as getIpfsMetadata,$s as getIpfsMetadataQueryKey,Lf as getIsDeployed,Rf as getIsDeployedQueryKey,Do as getIsDomainProtectedQueryKey,Ms as getIsPersonQueryKey,so as getPrivyAppInfoQueryKey,Go as getResolverAddressQueryKey,Is as getRoundXAppsQueryKey,Hf as getSmartAccount,Uf as getSmartAccountQueryKey,zo as getTextRecords,Bo as getTextRecordsQueryKey,bs as getTokenInfo,cs as getTokenUsdPrice,ls as getTokenUsdPriceQueryKey,Gf as getUpgradeRequired,Jf as getUpgradeRequiredForAccount,Yf as getUpgradeRequiredForAccountQueryKey,Kf as getUpgradeRequiredQueryKey,fo as getVechainDomainQueryKey,As as getVot3BalanceQueryKey,Ys as getXAppMetadata,zs as getXAppsSharesQueryKey,sc as imageCompressionOptions,Np as signVip191Transaction,hp as txReceiptQueryKey,bf as useAccountBalance,zd as useAccountCustomizationModal,Cf as useAccountImplementationAddress,yd as useAccountModal,Yc as useAccountModalOptions,sf as useAppHubApps,Cp as useBuildClauses,pp as useBuildTransaction,df as useCallClause,Dd as useChooseNameModal,So as useClaimVeWorldSubdomain,Eo as useClaimVetDomain,_d as useConnectModal,$d as useCrossAppConnectionCache,ps as useCurrency,Ef as useCurrentAccountImplementationVersion,ys as useCurrentAllocationsRoundId,tp as useCurrentBlock,mf as useCurrentCurrency,pf as useCurrentLanguage,Cs as useCustomTokens,Pn as useDAppKitWallet,In as useDAppKitWalletModal,Op as useEcosystemShortcuts,go as useEnsRecordExists,Rp as useEstimateAllTokens,yp as useEvents,Nd as useExploreEcosystemModal,Ld as useFAQModal,yl as useFeatureAnnouncement,co as useFetchAppInfo,uo as useFetchPrivyStatus,Ip as useGasTokenSelection,Fp as useGenericDelegator,Lp as useGenericDelegatorFeeEstimation,kf as useGetAccountAddress,Mf as useGetAccountVersion,Lo as useGetAvatar,ns as useGetAvatarLegacy,Xo as useGetAvatarOfAddress,Ts as useGetB3trBalance,ip as useGetChainId,Ds as useGetCustomTokenBalances,Ss as useGetCustomTokenInfo,Fo as useGetDomainsOfAddress,ks as useGetErc20Balance,hf as useGetNodeUrl,Ko as useGetResolverAddress,Vo as useGetTextRecords,us as useGetTokenUsdPrice,js as useGetVot3Balance,If as useHasV1SmartAccount,ic as useIpfsImage,ac as useIpfsImageList,ec as useIpfsMetadata,oc as useIpfsMetadatas,Ao as useIsDomainProtected,gf as useIsPWA,Ns as useIsPerson,zf as useIsSmartAccountDeployed,rm as useLegalDocuments,Tp as useLocalStorage,Ud as useLoginModalContent,Qd as useLoginWithOAuth,Xd as useLoginWithPasskey,ef as useLoginWithVeChain,Tn as useMfaEnrollment,hd as useModal,Vs as useMostVotedAppsInRound,ff as useMultipleClausesCall,$l as useNotificationAlerts,eu as useNotifications,Fd as useNotificationsModal,En as usePrivy,sm as usePrivyWalletProvider,Kd as useProfileModal,Vd as useReceiveModal,Js as useRefreshBalances,Bf as useRefreshFactoryQueries,_o as useRefreshMetadata,Vf as useRefreshSmartAccountQueries,Ls as useRoundXApps,_f as useScrollToTop,kd as useSendTokenModal,fc as useSendTransaction,On as useSetWalletRecovery,Jd as useSignMessage,Yd as useSignTypedData,uc as useSingleImageUpload,Wf as useSmartAccount,Nc as useSwapQuotes,jd as useSwapTokenModal,pc as useSwapTransaction,Dp as useSyncableLocalStorage,Mn as useThor,os as useTokenBalances,ds as useTokenPrices,ms as useTokensWithValues,hs as useTotalBalance,xd as useTransactionModal,Cd as useTransactionToast,up as useTransferERC20,fp as useTransferVET,gp as useTxReceipt,as as useUnsetDomain,Wo as useUpdateTextRecord,qf as useUpgradeRequired,Xf as useUpgradeRequiredForAccount,Qf as useUpgradeSmartAccount,Wd as useUpgradeSmartAccountModal,lc as useUploadImages,$ as useVeChainKitConfig,po as useVechainDomain,dd as useVechainKitThemeConfig,Q as useWallet,qs as useWalletMetadata,Td as useWalletModal,Zs as useXAppMetadata,Bs as useXAppsShares};
|
|
195
195
|
//# sourceMappingURL=index.mjs.map
|