@vechain/vechain-kit 2.6.2 → 2.6.3
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-CWViOs1U.d.mts → index--hSO7Xv4.d.mts} +4 -4
- package/dist/{index-CWViOs1U.d.mts.map → index--hSO7Xv4.d.mts.map} +1 -1
- package/dist/{index-w0Yyp3-t.d.mts → index-3EuDo9II.d.mts} +147 -147
- package/dist/{index-w0Yyp3-t.d.mts.map → index-3EuDo9II.d.mts.map} +1 -1
- package/dist/{index-I8fe7GR2.d.cts → index-Cf1aBaTL.d.cts} +4 -4
- package/dist/{index-I8fe7GR2.d.cts.map → index-Cf1aBaTL.d.cts.map} +1 -1
- package/dist/{index-DShXeWMB.d.cts → index-o92cc2nW.d.cts} +101 -101
- package/dist/{index-DShXeWMB.d.cts.map → index-o92cc2nW.d.cts.map} +1 -1
- package/dist/index.cjs +3 -3
- 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 +3 -3
- 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 +2 -2
package/dist/index.cjs
CHANGED
|
@@ -118,7 +118,7 @@ const e=require(`./assets-DNJsQD7_.cjs`),t=require(`./utils-CzaSErgL.cjs`);let n
|
|
|
118
118
|
opacity: 0.5 !important;
|
|
119
119
|
}
|
|
120
120
|
`),d.length>0&&(u.textContent=d.join(`
|
|
121
|
-
`))}let Fe=null;function Ie(){return Fe||=new p.QueryClient({defaultOptions:{queries:{queryKeyHashFn:m.hashFn,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Fe}const Le=({children:e})=>{try{if(r.default.useContext(p.QueryClientContext))return(0,i.jsx)(i.Fragment,{children:e})}catch(e){console.log(e)}return(0,i.jsx)(p.QueryClientProvider,{client:Ie(),children:e})},J=({onClick:e,...t})=>(0,i.jsx)(n.IconButton,{"aria-label":`Back`,icon:(0,i.jsx)(n.Icon,{as:g.LuChevronLeft,fontSize:`20px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,onClick:e,lineHeight:`0`,...t}),Re=({wallet:e,label:a,style:o,showHumanAddress:s=!0,setCurrentContent:c,onLogout:u})=>{let{t:d}=(0,l.useTranslation)(),[f,p]=(0,r.useState)(!1),[m,h]=(0,r.useState)(!1),_=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),v=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),y=(0,n.useColorModeValue)(`#ebebeb`,`#ffffff0a`),b=(0,n.useColorModeValue)(`#ffffff`,`transparent`),x=async(e,n)=>{await t.lt(e)&&(n(!0),setTimeout(()=>{n(!1)},2e3))},S=()=>{c&&(e?.domain?c({type:`choose-name-search`,props:{name:``,setCurrentContent:c,initialContentSource:`profile`}}):c({type:`choose-name`,props:{setCurrentContent:c,initialContentSource:`profile`,onBack:()=>c(`profile`)}}))};return(0,i.jsx)(n.VStack,{w:`full`,justifyContent:`center`,...o,children:(0,i.jsxs)(n.VStack,{w:`full`,spacing:4,children:[a&&(0,i.jsx)(n.Text,{fontSize:`sm`,color:v,children:a}),(0,i.jsxs)(n.VStack,{spacing:2,w:`full`,children:[e?.domain&&(0,i.jsxs)(n.HStack,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:y,borderRadius:`md`,bg:b,children:[(0,i.jsx)(n.Icon,{as:g.LuSquareUser,color:v}),(0,i.jsx)(n.Text,{flex:1,fontSize:`sm`,fontWeight:`700`,color:_,noOfLines:1,children:m?d(`Copied!`):e.domain}),(0,i.jsxs)(n.HStack,{spacing:2,children:[c&&(0,i.jsx)(n.IconButton,{icon:(0,i.jsx)(g.LuPencil,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:S,"aria-label":`Edit domain`}),(0,i.jsx)(n.IconButton,{icon:m?(0,i.jsx)(g.LuCheck,{}):(0,i.jsx)(g.LuCopy,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:()=>x(e.domain||``,h),"aria-label":`Copy domain`})]})]}),(0,i.jsxs)(n.HStack,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:y,borderRadius:`md`,bg:b,children:[(0,i.jsx)(n.Icon,{as:g.LuWallet,color:v}),(0,i.jsx)(n.Text,{flex:1,fontSize:`sm`,fontWeight:`700`,color:_,noOfLines:1,children:f?d(`Copied!`):s?t.W(e?.address??``,8,7):e?.address}),(0,i.jsxs)(n.HStack,{spacing:2,children:[(0,i.jsx)(n.IconButton,{icon:(0,i.jsx)(g.LuLogOut,{}),onClick:()=>c?.({type:`disconnect-confirm`,props:{onDisconnect:()=>u?.(),onBack:()=>c?.(`profile`)}}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`}),(0,i.jsx)(n.IconButton,{icon:f?(0,i.jsx)(g.LuCheck,{}):(0,i.jsx)(g.LuCopy,{}),onClick:()=>x(e?.address??``,p),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`})]})]})]})]})})};var ze=`2.6.2`,Be={"@adraffy/ens-normalize":`^1.11.0`,"@chakra-ui/react":`^2.8.2`,"@emotion/styled":`^11.14.1`,"@privy-io/cross-app-connect":`0.2.2`,"@privy-io/react-auth":`2.25.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.1.0`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.6.0-rc`,"@wagmi/core":`^2.17.2`,"bignumber.js":`^9.1.2`,"browser-image-compression":`^2.0.2`,dotenv:`^16.4.7`,ethers:`^6.13.5`,"framer-motion":`^11.15.0`,i18next:`^24.2.1`,"i18next-browser-languagedetector":`^8.0.2`,net:`^1.0.2`,process:`^0.11.10`,react:`^18.2.0`,"react-device-detect":`^2.2.3`,"react-hook-form":`^7.54.2`,"react-i18next":`^15.4.0`,"react-icons":`^5.4.0`,"react-qrcode-logo":`^3.0.0`,vaul:`^1.1.2`,viem:`^2.29.3`,wagmi:`^2.15.4`},Ve={"@chakra-ui/react":`^2.8.2`,"@emotion/react":`^11.0.0`,"@emotion/styled":`^11.0.0`,"@tanstack/react-query":`^5.64.2`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const He=({...t})=>{let{darkMode:r}=$();return(0,i.jsxs)(n.HStack,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...t,children:[(0,i.jsx)(e.J,{isDark:r,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),(0,i.jsxs)(n.Link,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${ze}`,isExternal:!0,pt:`1px`,children:[`v`,ze]})]})},Ue=(0,r.createContext)({hasContentBelow:!1}),We=()=>(0,r.useContext)(Ue),Y=({children:e})=>{let[t,a]=(0,r.useState)(!1),o=(0,r.useRef)(null),s=(0,r.useRef)(null),c=(0,r.useRef)(null),l=(0,r.useRef)(!0),{tokens:u}=so(),d=u?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return(0,r.useEffect)(()=>{let e=e=>{if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t);if(e.overflowY===`auto`||e.overflowY===`scroll`||e.overflow===`auto`||e.overflow===`scroll`)return t;t=t.parentElement}return null},t=([e])=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{if(l.current){l.current=!1,a(!1);return}a(!e.isIntersecting)},50)},n=e(s.current),r={threshold:0};n&&(r.root=n,r.rootMargin=`0px`);let i=new IntersectionObserver(t,r),u=setTimeout(()=>{o.current&&i.observe(o.current)},200);return()=>{clearTimeout(u),c.current&&clearTimeout(c.current),i.disconnect()}},[]),(0,i.jsxs)(Ue.Provider,{value:{hasContentBelow:t},children:[(0,i.jsx)(n.Box,{ref:s,position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?d:`none`,style:{WebkitBackdropFilter:t?d:`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}),(0,i.jsx)(`div`,{ref:o,style:{height:`1px`,width:`100%`,pointerEvents:`none`,visibility:`hidden`,marginTop:`-1px`}})]})},Ge=({children:e})=>(0,i.jsx)(n.Box,{position:`absolute`,bottom:`0`,left:`0`,right:`0`,bg:(0,n.useToken)(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,w:`full`,children:e}),Ke=({scrollableContainerRef:e,observerRef:t})=>{let a=(0,n.useToken)(`colors`,`vechain-kit-border`),{tokens:o}=so(),s=o?.effects?.backdropFilter?.stickyHeader??`blur(20px)`,[c,l]=(0,r.useState)(!1),u=(0,r.useRef)(null),d=(0,r.useRef)(!0);return(0,r.useEffect)(()=>{let n=([e])=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{if(d.current){d.current=!1,l(!1);return}l(!e.isIntersecting)},50)},r={threshold:0};e.current&&(r.root=e.current,r.rootMargin=`0px`);let i=new IntersectionObserver(n,r),a=setTimeout(()=>{t.current&&i.observe(t.current)},200);return()=>{clearTimeout(a),u.current&&clearTimeout(u.current),i.disconnect()}},[e,t]),(0,i.jsx)(n.Box,{position:`sticky`,top:`0`,w:`full`,backdropFilter:c?s:`none`,style:{WebkitBackdropFilter:c?s:`none`},zIndex:999,transition:`backdrop-filter 0.2s ease-in-out`,children:(0,i.jsx)(n.Box,{mx:`auto`,w:`34px`,h:`5px`,bg:a,mt:4,rounded:`full`})})},qe=({isOpen:e,onClose:t,children:a,ariaTitle:o,ariaDescription:s,isDismissable:c=!0,minHeight:l,maxHeight:u=`68vh`,closeThreshold:d=.5})=>{let f=(0,n.useToken)(`colors`,`vechain-kit-modal`),p=(0,n.useToken)(`colors`,`vechain-kit-overlay`),m=(0,r.useRef)(null),h=(0,r.useRef)(null),{tokens:g}=so(),v=g?.effects?.backdropFilter?.overlay,y=g?.colors?.border?.modal||`none`;return(0,i.jsx)(_.Drawer.Root,{dismissible:c,shouldScaleBackground:!0,repositionInputs:!1,open:e,closeThreshold:d,onOpenChange:e=>{e||t()},children:(0,i.jsxs)(_.Drawer.Portal,{children:[(0,i.jsx)(_.Drawer.Overlay,{style:{zIndex:100,position:`fixed`,top:0,right:0,bottom:0,left:0,backgroundColor:p,backdropFilter:v,WebkitBackdropFilter:v}}),(0,i.jsxs)(_.Drawer.Content,{"aria-description":s,style:{zIndex:101,backgroundColor:f,borderRadius:`24px 24px 0 0`,border:y,position:`fixed`,bottom:0,left:0,right:0,...l&&{minHeight:l},maxHeight:u,display:`flex`,flexDirection:`column`},children:[(0,i.jsx)(_.Drawer.Title,{style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:0},children:o}),(0,i.jsxs)(n.Box,{ref:m,flex:`1`,overflowY:`auto`,children:[(0,i.jsx)(Ke,{scrollableContainerRef:m,observerRef:h}),(0,i.jsx)(`div`,{ref:h,style:{height:`1px`,width:`100%`,visibility:`hidden`,marginTop:`-1px`}}),a]})]})]})})},Je=({isOpen:e,onClose:t,children:r,size:a=`sm`,isCentered:o=!0,motionPreset:s=`slideInBottom`,closeOnOverlayClick:c=!0,blockScrollOnMount:l=!1,allowExternalFocus:u=!1,backdropFilter:d,isCloseable:f=!0,useBottomSheetOnMobile:p,mobileMinHeight:m,mobileMaxHeight:h=`57vh`,desktopMinHeight:g,desktopMaxHeight:_})=>{let[v]=(0,n.useMediaQuery)(`(min-width: 768px)`),{portalRootRef:y,themeConfig:b,tokens:x}=so(),S=p??b?.modal?.useBottomSheetOnMobile??!1,C=(0,n.useToken)(`colors`,`vechain-kit-modal`),w=(0,n.useToken)(`colors`,`vechain-kit-overlay`),T=x?.effects?.backdropFilter?.overlay,E=x?.effects?.backdropFilter?.modal,D=d??T??`blur(3px)`,O=v?{minHeight:g,maxHeight:_}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`,minHeight:m,maxHeight:h},k=(0,i.jsxs)(n.Modal,{motionPreset:s,isOpen:e,onClose:t,isCentered:o,size:a,returnFocusOnClose:!1,blockScrollOnMount:l,closeOnOverlayClick:c&&f,preserveScrollBarGap:!0,portalProps:{containerRef:y},trapFocus:!u,autoFocus:!u,variant:`vechainKitBase`,children:[(0,i.jsx)(n.ModalOverlay,{bg:w,backdropFilter:D}),(0,i.jsx)(n.ModalContent,{role:`dialog`,"aria-modal":!u,bg:C,sx:{backdropFilter:E,WebkitBackdropFilter:E},...O,children:r})]});return(0,i.jsx)(i.Fragment,{children:!v&&S?(0,i.jsx)(n.Modal,{isOpen:e,onClose:t,size:a,blockScrollOnMount:!1,trapFocus:!1,children:(0,i.jsx)(qe,{isOpen:e,onClose:t,ariaTitle:`Dialog`,ariaDescription:`Dialog content area`,isDismissable:f,minHeight:m,maxHeight:h,children:r})}):k})},Ye=async t=>{let n=new URL(`/api/v1/apps/${t}`,e.h),r=await fetch(n,{headers:{"privy-app-id":t}});if(!r.ok)throw Error(`Failed to fetch Privy app info`);return r.json()},Xe=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],Ze=e=>{let n=Array.isArray(e)?e:[e];return(0,p.useQuery)({queryKey:Xe(e),queryFn:async()=>{let e=await Promise.all(n.map(e=>Ye(e)));return Object.fromEntries(e.map((e,r)=>{let i=n[r],a=t.Y.find(e=>e.id===i);return[i,{...e,website:a?.website}]}))},enabled:n.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})},Qe=async()=>{try{let t=new URL(`summary.json`,e.g),n=await fetch(t);if(!n.ok)throw Error(`Failed to fetch Privy status`);return(await n.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},$e=()=>(0,p.useQuery)({queryKey:[`PRIVY_STATUS`],queryFn:Qe,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}),et=e=>[`VECHAIN_KIT_DOMAIN`,e],tt=e=>{let{network:n}=$();return(0,p.useQuery)({queryKey:et(e),queryFn:async()=>{if(!e)throw Error(`Address or domain is required`);if(n.type!==`main`&&n.type!==`test`){let n=t.j(e);return{address:n?e:void 0,domain:void 0,isValidAddressOrDomain:n,isPrimaryDomain:!1}}let r=await(0,v.isValidDomain)(e,{networkUrl:n.nodeUrl}),i=t.j(e);if(!r&&!i)throw Error(`Input must be a valid domain or address`);let a=null,o=null,s=!1;return r?(a=await(0,v.getDomainAddress)(e,{networkUrl:n.nodeUrl}),o=e,a&&(s=await(0,v.isPrimaryDomain)(e,a,{networkUrl:n.nodeUrl}))):(o=await(0,v.getAddressDomain)(e,{networkUrl:n.nodeUrl}),a=e,o&&(s=await(0,v.isPrimaryDomain)(o,e,{networkUrl:n.nodeUrl}))),{address:a||void 0,domain:o||void 0,isValidAddressOrDomain:r||i,isPrimaryDomain:s}},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 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})},nt=async(e,n,r)=>{let i=(0,b.keccak256)((0,b.concat)([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,(0,b.keccak256)((0,b.toBytes)(r))])),a=await e.contracts.load(t.bt(n).vetDomainsContractAddress,y.VetDomainsRegistry__factory.abi).read.recordExists(i);if(!a)throw Error(`Failed to get ENS record exists for ${r}`);return a[0]},rt=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],it=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:rt(e),queryFn:()=>nt(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})},at=(e,t)=>{let n=(0,p.useQueryClient)(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:wt(e??``,r.type)}),n.invalidateQueries({queryKey:Ot(e,r.type)}),n.invalidateQueries({queryKey:Rt(t)})])}}},ot=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:et(t)}),e.invalidateQueries({queryKey:et(n)}),e.invalidateQueries({queryKey:rt(r)}),e.invalidateQueries({queryKey:St(t,`.vet`)}),e.invalidateQueries({queryKey:St(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Ot(n)})]),await Promise.all([e.refetchQueries({queryKey:et(t)}),e.refetchQueries({queryKey:et(n)}),e.refetchQueries({queryKey:St(t,`.vet`)}),e.refetchQueries({queryKey:St(t,`.veworld.vet`)}),e.refetchQueries({queryKey:wt(r+`.`+i,a)}),e.refetchQueries({queryKey:Ot(n)}),e.refetchQueries({queryKey:rt(r)}),e.refetchQueries({queryKey:Rt(t)})])},st=y.VeworldSubdomainClaimer__factory.createInterface(),ct=y.VetDomainsReverseRegistrar__factory.createInterface(),lt=(e,n,r,i,a)=>{let s=[];if(!e)throw Error(`Invalid subdomain`);let c=`${e}.${n}`;if(s.push({to:t.bt(a.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ct.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${t.W(i?.address??``,4,4)}`,abi:ct.getFunction(`setName`)}),r){s.push({to:t.bt(a.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ct.encodeFunctionData(`setName`,[c]),comment:`Setting your VeChain nickname to ${c}`,abi:ct.getFunction(`setName`)});let e=new o.ethers.Interface([`function setAddr(bytes32 node, address addr)`]),n=o.ethers.namehash(c);s.push({to:t.bt(a.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[n,i?.address||``]),comment:`Setting the address for ${c} to ${t.W(i?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(dt(n))s.push({to:t.bt(a.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:st.encodeFunctionData(`claim`,[e,t.bt(a.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${n}`,abi:st.getFunction(`claim`)}),s.push({to:t.bt(a.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ct.encodeFunctionData(`setName`,[e+`.`+n]),comment:`Set ${e}.${n} as the VeChain nickname of the account ${t.W(i?.address??``,4,4)}`,abi:ct.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return s},ut=({subdomain:e,domain:t,onSuccess:n,onError:i,alreadyOwned:a=!1})=>{let o=(0,p.useQueryClient)(),{account:s}=X(),{network:c}=$(),{refresh:l}=at(e+`.`+t,s?.address??``),u=(0,r.useCallback)(()=>lt(e,t,a,s,c),[e,t,a,s,c]),d=(0,r.useCallback)(async()=>{let r=`${e}.${t}`;await ot(o,s?.address??``,r,e,t,c.type),l(),n?.()},[n,e,t,o,s,c.type,l]),f=lr({signerAccountAddress:s?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e}.${t} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:d,onTxFailedOrCancelled:()=>{i?.()}});return{...f,clauses:u,sendTransaction:async()=>f.sendTransaction(u())}},dt=e=>e.endsWith(`veworld.vet`),ft=y.VetDomainsReverseRegistrar__factory.createInterface(),pt=(e,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid domain`);if(n){a.push({to:t.bt(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ft.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:ft.getFunction(`setName`)});let n=new o.ethers.Interface([`function setAddr(bytes32 node, address addr)`]),s=o.ethers.namehash(e);a.push({to:t.bt(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:n.encodeFunctionData(`setAddr`,[s,r?.address||``]),comment:`Setting the address for ${e} to ${t.W(r?.address??``,4,4)}`,abi:n.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return a},mt=({domain:e,onSuccess:t,onError:n,alreadyOwned:i=!1})=>{let{network:a}=$(),o=(0,p.useQueryClient)(),{account:s}=X(),{refresh:c}=at(e,s?.address??``),l=(0,r.useCallback)(()=>pt(e,i,s,a),[e,i,s,a]),u=(0,r.useCallback)(async()=>{await ot(o,s?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,a.type),c(),t?.()},[t,e,o,s,a.type,c]),d=lr({signerAccountAddress:s?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:u,onTxFailedOrCancelled:n});return{...d,clauses:l,sendTransaction:async()=>d.sendTransaction(l())}},ht=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],gt=s.ABIContract.ofAbi(y.VeworldSubdomainClaimer__factory.abi),_t=async(e,n,r)=>{let i=t.bt(n).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(i,gt.abi).read.isDomainProtected(r))[0]},vt=(e,t=!0)=>{let n=(0,f.useThor)(),{network:r}=$();return(0,p.useQuery)({queryKey:ht(e),queryFn:()=>_t(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})},yt=x.z.object({name:x.z.string()}),bt=x.z.object({domains:x.z.array(yt)}),xt=async(e,n,r)=>{if(!n)throw Error(`Address is required`);let i=t.bt(e).graphQlIndexerUrl,a=`query Registrations {
|
|
121
|
+
`))}let Fe=null;function Ie(){return Fe||=new p.QueryClient({defaultOptions:{queries:{queryKeyHashFn:m.hashFn,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Fe}const Le=({children:e})=>{try{if(r.default.useContext(p.QueryClientContext))return(0,i.jsx)(i.Fragment,{children:e})}catch(e){console.log(e)}return(0,i.jsx)(p.QueryClientProvider,{client:Ie(),children:e})},J=({onClick:e,...t})=>(0,i.jsx)(n.IconButton,{"aria-label":`Back`,icon:(0,i.jsx)(n.Icon,{as:g.LuChevronLeft,fontSize:`20px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,onClick:e,lineHeight:`0`,...t}),Re=({wallet:e,label:a,style:o,showHumanAddress:s=!0,setCurrentContent:c,onLogout:u})=>{let{t:d}=(0,l.useTranslation)(),[f,p]=(0,r.useState)(!1),[m,h]=(0,r.useState)(!1),_=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),v=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),y=(0,n.useColorModeValue)(`#ebebeb`,`#ffffff0a`),b=(0,n.useColorModeValue)(`#ffffff`,`transparent`),x=async(e,n)=>{await t.lt(e)&&(n(!0),setTimeout(()=>{n(!1)},2e3))},S=()=>{c&&(e?.domain?c({type:`choose-name-search`,props:{name:``,setCurrentContent:c,initialContentSource:`profile`}}):c({type:`choose-name`,props:{setCurrentContent:c,initialContentSource:`profile`,onBack:()=>c(`profile`)}}))};return(0,i.jsx)(n.VStack,{w:`full`,justifyContent:`center`,...o,children:(0,i.jsxs)(n.VStack,{w:`full`,spacing:4,children:[a&&(0,i.jsx)(n.Text,{fontSize:`sm`,color:v,children:a}),(0,i.jsxs)(n.VStack,{spacing:2,w:`full`,children:[e?.domain&&(0,i.jsxs)(n.HStack,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:y,borderRadius:`md`,bg:b,children:[(0,i.jsx)(n.Icon,{as:g.LuSquareUser,color:v}),(0,i.jsx)(n.Text,{flex:1,fontSize:`sm`,fontWeight:`700`,color:_,noOfLines:1,children:m?d(`Copied!`):e.domain}),(0,i.jsxs)(n.HStack,{spacing:2,children:[c&&(0,i.jsx)(n.IconButton,{icon:(0,i.jsx)(g.LuPencil,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:S,"aria-label":`Edit domain`}),(0,i.jsx)(n.IconButton,{icon:m?(0,i.jsx)(g.LuCheck,{}):(0,i.jsx)(g.LuCopy,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:()=>x(e.domain||``,h),"aria-label":`Copy domain`})]})]}),(0,i.jsxs)(n.HStack,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:y,borderRadius:`md`,bg:b,children:[(0,i.jsx)(n.Icon,{as:g.LuWallet,color:v}),(0,i.jsx)(n.Text,{flex:1,fontSize:`sm`,fontWeight:`700`,color:_,noOfLines:1,children:f?d(`Copied!`):s?t.W(e?.address??``,8,7):e?.address}),(0,i.jsxs)(n.HStack,{spacing:2,children:[(0,i.jsx)(n.IconButton,{icon:(0,i.jsx)(g.LuLogOut,{}),onClick:()=>c?.({type:`disconnect-confirm`,props:{onDisconnect:()=>u?.(),onBack:()=>c?.(`profile`)}}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`}),(0,i.jsx)(n.IconButton,{icon:f?(0,i.jsx)(g.LuCheck,{}):(0,i.jsx)(g.LuCopy,{}),onClick:()=>x(e?.address??``,p),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`})]})]})]})]})})};var ze=`2.6.3`,Be={"@adraffy/ens-normalize":`^1.11.0`,"@chakra-ui/react":`^2.8.2`,"@emotion/styled":`^11.14.1`,"@privy-io/cross-app-connect":`0.2.2`,"@privy-io/react-auth":`2.25.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.3.0`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.6.0-rc`,"@wagmi/core":`^2.17.2`,"bignumber.js":`^9.1.2`,"browser-image-compression":`^2.0.2`,dotenv:`^16.4.7`,ethers:`^6.13.5`,"framer-motion":`^11.15.0`,i18next:`^24.2.1`,"i18next-browser-languagedetector":`^8.0.2`,net:`^1.0.2`,process:`^0.11.10`,react:`^18.2.0`,"react-device-detect":`^2.2.3`,"react-hook-form":`^7.54.2`,"react-i18next":`^15.4.0`,"react-icons":`^5.4.0`,"react-qrcode-logo":`^3.0.0`,vaul:`^1.1.2`,viem:`^2.29.3`,wagmi:`^2.15.4`},Ve={"@chakra-ui/react":`^2.8.2`,"@emotion/react":`^11.0.0`,"@emotion/styled":`^11.0.0`,"@tanstack/react-query":`^5.64.2`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const He=({...t})=>{let{darkMode:r}=$();return(0,i.jsxs)(n.HStack,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...t,children:[(0,i.jsx)(e.J,{isDark:r,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),(0,i.jsxs)(n.Link,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${ze}`,isExternal:!0,pt:`1px`,children:[`v`,ze]})]})},Ue=(0,r.createContext)({hasContentBelow:!1}),We=()=>(0,r.useContext)(Ue),Y=({children:e})=>{let[t,a]=(0,r.useState)(!1),o=(0,r.useRef)(null),s=(0,r.useRef)(null),c=(0,r.useRef)(null),l=(0,r.useRef)(!0),{tokens:u}=so(),d=u?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return(0,r.useEffect)(()=>{let e=e=>{if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t);if(e.overflowY===`auto`||e.overflowY===`scroll`||e.overflow===`auto`||e.overflow===`scroll`)return t;t=t.parentElement}return null},t=([e])=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{if(l.current){l.current=!1,a(!1);return}a(!e.isIntersecting)},50)},n=e(s.current),r={threshold:0};n&&(r.root=n,r.rootMargin=`0px`);let i=new IntersectionObserver(t,r),u=setTimeout(()=>{o.current&&i.observe(o.current)},200);return()=>{clearTimeout(u),c.current&&clearTimeout(c.current),i.disconnect()}},[]),(0,i.jsxs)(Ue.Provider,{value:{hasContentBelow:t},children:[(0,i.jsx)(n.Box,{ref:s,position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?d:`none`,style:{WebkitBackdropFilter:t?d:`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}),(0,i.jsx)(`div`,{ref:o,style:{height:`1px`,width:`100%`,pointerEvents:`none`,visibility:`hidden`,marginTop:`-1px`}})]})},Ge=({children:e})=>(0,i.jsx)(n.Box,{position:`absolute`,bottom:`0`,left:`0`,right:`0`,bg:(0,n.useToken)(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,w:`full`,children:e}),Ke=({scrollableContainerRef:e,observerRef:t})=>{let a=(0,n.useToken)(`colors`,`vechain-kit-border`),{tokens:o}=so(),s=o?.effects?.backdropFilter?.stickyHeader??`blur(20px)`,[c,l]=(0,r.useState)(!1),u=(0,r.useRef)(null),d=(0,r.useRef)(!0);return(0,r.useEffect)(()=>{let n=([e])=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{if(d.current){d.current=!1,l(!1);return}l(!e.isIntersecting)},50)},r={threshold:0};e.current&&(r.root=e.current,r.rootMargin=`0px`);let i=new IntersectionObserver(n,r),a=setTimeout(()=>{t.current&&i.observe(t.current)},200);return()=>{clearTimeout(a),u.current&&clearTimeout(u.current),i.disconnect()}},[e,t]),(0,i.jsx)(n.Box,{position:`sticky`,top:`0`,w:`full`,backdropFilter:c?s:`none`,style:{WebkitBackdropFilter:c?s:`none`},zIndex:999,transition:`backdrop-filter 0.2s ease-in-out`,children:(0,i.jsx)(n.Box,{mx:`auto`,w:`34px`,h:`5px`,bg:a,mt:4,rounded:`full`})})},qe=({isOpen:e,onClose:t,children:a,ariaTitle:o,ariaDescription:s,isDismissable:c=!0,minHeight:l,maxHeight:u=`68vh`,closeThreshold:d=.5})=>{let f=(0,n.useToken)(`colors`,`vechain-kit-modal`),p=(0,n.useToken)(`colors`,`vechain-kit-overlay`),m=(0,r.useRef)(null),h=(0,r.useRef)(null),{tokens:g}=so(),v=g?.effects?.backdropFilter?.overlay,y=g?.colors?.border?.modal||`none`;return(0,i.jsx)(_.Drawer.Root,{dismissible:c,shouldScaleBackground:!0,repositionInputs:!1,open:e,closeThreshold:d,onOpenChange:e=>{e||t()},children:(0,i.jsxs)(_.Drawer.Portal,{children:[(0,i.jsx)(_.Drawer.Overlay,{style:{zIndex:100,position:`fixed`,top:0,right:0,bottom:0,left:0,backgroundColor:p,backdropFilter:v,WebkitBackdropFilter:v}}),(0,i.jsxs)(_.Drawer.Content,{"aria-description":s,style:{zIndex:101,backgroundColor:f,borderRadius:`24px 24px 0 0`,border:y,position:`fixed`,bottom:0,left:0,right:0,...l&&{minHeight:l},maxHeight:u,display:`flex`,flexDirection:`column`},children:[(0,i.jsx)(_.Drawer.Title,{style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:0},children:o}),(0,i.jsxs)(n.Box,{ref:m,flex:`1`,overflowY:`auto`,children:[(0,i.jsx)(Ke,{scrollableContainerRef:m,observerRef:h}),(0,i.jsx)(`div`,{ref:h,style:{height:`1px`,width:`100%`,visibility:`hidden`,marginTop:`-1px`}}),a]})]})]})})},Je=({isOpen:e,onClose:t,children:r,size:a=`sm`,isCentered:o=!0,motionPreset:s=`slideInBottom`,closeOnOverlayClick:c=!0,blockScrollOnMount:l=!1,allowExternalFocus:u=!1,backdropFilter:d,isCloseable:f=!0,useBottomSheetOnMobile:p,mobileMinHeight:m,mobileMaxHeight:h=`57vh`,desktopMinHeight:g,desktopMaxHeight:_})=>{let[v]=(0,n.useMediaQuery)(`(min-width: 768px)`),{portalRootRef:y,themeConfig:b,tokens:x}=so(),S=p??b?.modal?.useBottomSheetOnMobile??!1,C=(0,n.useToken)(`colors`,`vechain-kit-modal`),w=(0,n.useToken)(`colors`,`vechain-kit-overlay`),T=x?.effects?.backdropFilter?.overlay,E=x?.effects?.backdropFilter?.modal,D=d??T??`blur(3px)`,O=v?{minHeight:g,maxHeight:_}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`,minHeight:m,maxHeight:h},k=(0,i.jsxs)(n.Modal,{motionPreset:s,isOpen:e,onClose:t,isCentered:o,size:a,returnFocusOnClose:!1,blockScrollOnMount:l,closeOnOverlayClick:c&&f,preserveScrollBarGap:!0,portalProps:{containerRef:y},trapFocus:!u,autoFocus:!u,variant:`vechainKitBase`,children:[(0,i.jsx)(n.ModalOverlay,{bg:w,backdropFilter:D}),(0,i.jsx)(n.ModalContent,{role:`dialog`,"aria-modal":!u,bg:C,sx:{backdropFilter:E,WebkitBackdropFilter:E},...O,children:r})]});return(0,i.jsx)(i.Fragment,{children:!v&&S?(0,i.jsx)(n.Modal,{isOpen:e,onClose:t,size:a,blockScrollOnMount:!1,trapFocus:!1,children:(0,i.jsx)(qe,{isOpen:e,onClose:t,ariaTitle:`Dialog`,ariaDescription:`Dialog content area`,isDismissable:f,minHeight:m,maxHeight:h,children:r})}):k})},Ye=async t=>{let n=new URL(`/api/v1/apps/${t}`,e.h),r=await fetch(n,{headers:{"privy-app-id":t}});if(!r.ok)throw Error(`Failed to fetch Privy app info`);return r.json()},Xe=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],Ze=e=>{let n=Array.isArray(e)?e:[e];return(0,p.useQuery)({queryKey:Xe(e),queryFn:async()=>{let e=await Promise.all(n.map(e=>Ye(e)));return Object.fromEntries(e.map((e,r)=>{let i=n[r],a=t.Y.find(e=>e.id===i);return[i,{...e,website:a?.website}]}))},enabled:n.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})},Qe=async()=>{try{let t=new URL(`summary.json`,e.g),n=await fetch(t);if(!n.ok)throw Error(`Failed to fetch Privy status`);return(await n.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},$e=()=>(0,p.useQuery)({queryKey:[`PRIVY_STATUS`],queryFn:Qe,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}),et=e=>[`VECHAIN_KIT_DOMAIN`,e],tt=e=>{let{network:n}=$();return(0,p.useQuery)({queryKey:et(e),queryFn:async()=>{if(!e)throw Error(`Address or domain is required`);if(n.type!==`main`&&n.type!==`test`){let n=t.j(e);return{address:n?e:void 0,domain:void 0,isValidAddressOrDomain:n,isPrimaryDomain:!1}}let r=await(0,v.isValidDomain)(e,{networkUrl:n.nodeUrl}),i=t.j(e);if(!r&&!i)throw Error(`Input must be a valid domain or address`);let a=null,o=null,s=!1;return r?(a=await(0,v.getDomainAddress)(e,{networkUrl:n.nodeUrl}),o=e,a&&(s=await(0,v.isPrimaryDomain)(e,a,{networkUrl:n.nodeUrl}))):(o=await(0,v.getAddressDomain)(e,{networkUrl:n.nodeUrl}),a=e,o&&(s=await(0,v.isPrimaryDomain)(o,e,{networkUrl:n.nodeUrl}))),{address:a||void 0,domain:o||void 0,isValidAddressOrDomain:r||i,isPrimaryDomain:s}},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 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})},nt=async(e,n,r)=>{let i=(0,b.keccak256)((0,b.concat)([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,(0,b.keccak256)((0,b.toBytes)(r))])),a=await e.contracts.load(t.bt(n).vetDomainsContractAddress,y.VetDomainsRegistry__factory.abi).read.recordExists(i);if(!a)throw Error(`Failed to get ENS record exists for ${r}`);return a[0]},rt=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],it=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:rt(e),queryFn:()=>nt(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})},at=(e,t)=>{let n=(0,p.useQueryClient)(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:wt(e??``,r.type)}),n.invalidateQueries({queryKey:Ot(e,r.type)}),n.invalidateQueries({queryKey:Rt(t)})])}}},ot=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:et(t)}),e.invalidateQueries({queryKey:et(n)}),e.invalidateQueries({queryKey:rt(r)}),e.invalidateQueries({queryKey:St(t,`.vet`)}),e.invalidateQueries({queryKey:St(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Ot(n)})]),await Promise.all([e.refetchQueries({queryKey:et(t)}),e.refetchQueries({queryKey:et(n)}),e.refetchQueries({queryKey:St(t,`.vet`)}),e.refetchQueries({queryKey:St(t,`.veworld.vet`)}),e.refetchQueries({queryKey:wt(r+`.`+i,a)}),e.refetchQueries({queryKey:Ot(n)}),e.refetchQueries({queryKey:rt(r)}),e.refetchQueries({queryKey:Rt(t)})])},st=y.VeworldSubdomainClaimer__factory.createInterface(),ct=y.VetDomainsReverseRegistrar__factory.createInterface(),lt=(e,n,r,i,a)=>{let s=[];if(!e)throw Error(`Invalid subdomain`);let c=`${e}.${n}`;if(s.push({to:t.bt(a.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ct.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${t.W(i?.address??``,4,4)}`,abi:ct.getFunction(`setName`)}),r){s.push({to:t.bt(a.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ct.encodeFunctionData(`setName`,[c]),comment:`Setting your VeChain nickname to ${c}`,abi:ct.getFunction(`setName`)});let e=new o.ethers.Interface([`function setAddr(bytes32 node, address addr)`]),n=o.ethers.namehash(c);s.push({to:t.bt(a.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[n,i?.address||``]),comment:`Setting the address for ${c} to ${t.W(i?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(dt(n))s.push({to:t.bt(a.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:st.encodeFunctionData(`claim`,[e,t.bt(a.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${n}`,abi:st.getFunction(`claim`)}),s.push({to:t.bt(a.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ct.encodeFunctionData(`setName`,[e+`.`+n]),comment:`Set ${e}.${n} as the VeChain nickname of the account ${t.W(i?.address??``,4,4)}`,abi:ct.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return s},ut=({subdomain:e,domain:t,onSuccess:n,onError:i,alreadyOwned:a=!1})=>{let o=(0,p.useQueryClient)(),{account:s}=X(),{network:c}=$(),{refresh:l}=at(e+`.`+t,s?.address??``),u=(0,r.useCallback)(()=>lt(e,t,a,s,c),[e,t,a,s,c]),d=(0,r.useCallback)(async()=>{let r=`${e}.${t}`;await ot(o,s?.address??``,r,e,t,c.type),l(),n?.()},[n,e,t,o,s,c.type,l]),f=lr({signerAccountAddress:s?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e}.${t} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:d,onTxFailedOrCancelled:()=>{i?.()}});return{...f,clauses:u,sendTransaction:async()=>f.sendTransaction(u())}},dt=e=>e.endsWith(`veworld.vet`),ft=y.VetDomainsReverseRegistrar__factory.createInterface(),pt=(e,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid domain`);if(n){a.push({to:t.bt(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:ft.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:ft.getFunction(`setName`)});let n=new o.ethers.Interface([`function setAddr(bytes32 node, address addr)`]),s=o.ethers.namehash(e);a.push({to:t.bt(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:n.encodeFunctionData(`setAddr`,[s,r?.address||``]),comment:`Setting the address for ${e} to ${t.W(r?.address??``,4,4)}`,abi:n.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return a},mt=({domain:e,onSuccess:t,onError:n,alreadyOwned:i=!1})=>{let{network:a}=$(),o=(0,p.useQueryClient)(),{account:s}=X(),{refresh:c}=at(e,s?.address??``),l=(0,r.useCallback)(()=>pt(e,i,s,a),[e,i,s,a]),u=(0,r.useCallback)(async()=>{await ot(o,s?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,a.type),c(),t?.()},[t,e,o,s,a.type,c]),d=lr({signerAccountAddress:s?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:u,onTxFailedOrCancelled:n});return{...d,clauses:l,sendTransaction:async()=>d.sendTransaction(l())}},ht=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],gt=s.ABIContract.ofAbi(y.VeworldSubdomainClaimer__factory.abi),_t=async(e,n,r)=>{let i=t.bt(n).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(i,gt.abi).read.isDomainProtected(r))[0]},vt=(e,t=!0)=>{let n=(0,f.useThor)(),{network:r}=$();return(0,p.useQuery)({queryKey:ht(e),queryFn:()=>_t(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})},yt=x.z.object({name:x.z.string()}),bt=x.z.object({domains:x.z.array(yt)}),xt=async(e,n,r)=>{if(!n)throw Error(`Address is required`);let i=t.bt(e).graphQlIndexerUrl,a=`query Registrations {
|
|
122
122
|
domains(
|
|
123
123
|
where: ${r?`{owner: "${n.toLowerCase()}", parent_: {name: "${r}"}}`:`{owner: "${n.toLowerCase()}"}`}
|
|
124
124
|
) {
|
|
@@ -197,7 +197,7 @@ const e=require(`./assets-DNJsQD7_.cjs`),t=require(`./utils-CzaSErgL.cjs`);let n
|
|
|
197
197
|
font-family: ${t} !important;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
`}),io=({children:e,theme:t,bodyFont:a,headingFont:o})=>(0,i.jsxs)(P.CacheProvider,{value:(0,r.useMemo)(()=>no(),[]),children:[(0,i.jsx)(ro,{bodyFont:a,headingFont:o}),(0,i.jsx)(n.ChakraProvider,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),ao=({darkMode:e})=>{try{if(t._t(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return(0,i.jsx)(n.ColorModeScript,{initialColorMode:e?`dark`:`light`})},oo=(0,r.createContext)({portalRootRef:void 0,tokens:void 0,themeConfig:void 0}),so=()=>{let e=(0,r.useContext)(oo);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},co=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:a}=(0,n.useColorMode)();return(0,r.useEffect)(()=>{let n=e?`dark`:`light`;a!==n&&t(n)},[e]),(0,i.jsx)(i.Fragment,{})},lo=({children:e,darkMode:t=!1,theme:a})=>{let o=(0,r.useRef)(null),s=(0,r.useContext)(ml),c=s?s.theme:void 0,l=a??c,u=(0,r.useMemo)(()=>Oe(De(t),ke(l,t)),[t,l]),d=(0,r.useMemo)(()=>({...eo(t,l),config:{...eo(t,l).config,initialColorMode:t?`dark`:`light`}}),[t,l]);return(0,i.jsxs)(oo.Provider,{value:{portalRootRef:o,tokens:u,themeConfig:l},children:[(0,i.jsx)(ao,{darkMode:t}),(0,i.jsxs)(io,{theme:d,bodyFont:u.fonts.body,headingFont:u.fonts.heading,children:[(0,i.jsx)(co,{darkMode:t}),(0,i.jsx)(n.Box,{id:`vechain-kit-root`,ref:o,bg:`transparent`,borderRadius:`12px`,children:e})]}),(0,i.jsx)(to,{})]})},uo=(0,r.createContext)(null),Q=()=>{let e=(0,r.useContext)(uo);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},fo=({children:e})=>{let{darkMode:n,theme:a}=$(),[o,s]=(0,r.useState)(!1),[c,l]=(0,r.useState)(`main`),[u,d]=(0,r.useState)(!1),{setSource:p,connectV2:m}=(0,f.useWallet)(),h=(0,r.useCallback)((e,n)=>{t.mt()&&window.vechain&&window.vechain.isInAppBrowser?(p(`veworld`),m(null)):(l(e??`main`),d(n??!1),s(!0))},[]),g=(0,r.useCallback)(()=>{s(!1),l(`main`),d(!1)},[]),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(`main`),C=(0,r.useCallback)((e,t)=>{S(e??`main`),b(t?.isolatedView??!1),v(!0)},[]),w=(0,r.useCallback)(()=>{v(!1),S(`main`),setTimeout(()=>{b(!1)},300)},[]),[T,E]=(0,r.useState)(!1),D=(0,r.useCallback)(()=>E(!0),[]),O=(0,r.useCallback)(()=>E(!1),[]),[k,A]=(0,r.useState)(!1),j=(0,r.useCallback)(()=>A(!0),[]),M=(0,r.useCallback)(()=>A(!1),[]),[N,P]=(0,r.useState)(!1),[F,I]=(0,r.useState)(void 0),L=(0,r.useCallback)(e=>{I(e),P(!0)},[]),R=(0,r.useCallback)(()=>P(!1),[]);return(0,i.jsxs)(uo.Provider,{value:{openConnectModal:h,closeConnectModal:g,isConnectModalOpen:o,connectModalContent:c,setConnectModalContent:l,connectModalPreventAutoClose:u,setConnectModalPreventAutoClose:d,openAccountModal:C,closeAccountModal:w,isAccountModalOpen:_,setAccountModalContent:S,accountModalContent:x,isolatedView:y,openTransactionModal:D,closeTransactionModal:O,isTransactionModalOpen:T,openTransactionToast:j,closeTransactionToast:M,isTransactionToastOpen:k,openUpgradeSmartAccountModal:L,closeUpgradeSmartAccountModal:R,isUpgradeSmartAccountModalOpen:N},children:[e,(0,i.jsxs)(lo,{darkMode:n,theme:a,children:[(0,i.jsx)(wa,{isOpen:o,onClose:g,initialContent:c,preventAutoClose:u}),(0,i.jsx)(ba,{isOpen:_,onClose:w,initialContent:x}),(0,i.jsx)(Fa,{isOpen:N,onClose:R,style:F})]})]})},po=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=Q(),{open:a,close:o}=(0,f.useWalletModal)();return{open:t?a:e=>n(e),close:t?o:r,isOpen:t?!1:i}},mo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),ho=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:()=>e(),close:t,isOpen:n}},go=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),_o=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=Q();return{open:e,close:t,isOpen:n}},vo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),yo=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=Q();return{open:e,close:t,isOpen:n}},bo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),xo=()=>{let{connection:e}=X(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=Q();return{open:n=>{e.isConnected?i(void 0,n):t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},So=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Co=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},wo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),To=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},Eo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Do=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Oo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),ko=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},Ao=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),jo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Mo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),No=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Po=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Fo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Io=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Lo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Ro=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),zo=()=>{let{privy:e,loginMethods:n}=$(),i=e?.appId===t.at,a=e=>n?Array.isArray(e)?e.some(e=>n.some(t=>t.method===e)):n.some(t=>t.method===e):!0,o=(0,r.useMemo)(()=>n?n.length===0||a(`ecosystem`):!0,[n]),s=(0,r.useMemo)(()=>a(`vechain`),[n]),c=(0,r.useMemo)(()=>a(`dappkit`),[n]),l=(0,r.useMemo)(()=>a(`passkey`),[n]),u=(0,r.useMemo)(()=>a(`email`),[n]),d={showGoogleLogin:(0,r.useMemo)(()=>a(`google`),[n]),showEmailLogin:u,showPasskey:l,showVeChainLogin:s,showDappKit:c,showEcosystem:o,showMoreLogin:(0,r.useMemo)(()=>a(`more`),[n]),showGithubLogin:(0,r.useMemo)(()=>a(`github`),[n]),isOfficialVeChainApp:!1};return e?i?{...d,isOfficialVeChainApp:!0}:{...d}:{...d,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},Bo=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=Q();return{open:()=>t(e),close:n,isOpen:r}},Vo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Ho=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Uo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Wo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`settings`,t)},close:()=>{t()},isOpen:n}},Go=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Ko=()=>{let[e,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(null),[a,o]=(0,r.useState)(null),{connection:s,account:c}=X(),{requestCertificate:l}=(0,f.useWallet)(),u=pl();return{signMessage:(0,r.useCallback)(async e=>{if(!c)throw Error(`Account not found`);t(!0),o(null),i(null);try{let t=null;return t=s.isConnectedWithDappKit?(await l({purpose:`agreement`,payload:{type:`text`,content:e}},{signer:c.address})).signature:await u.signMessage(e),i(t),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw o(t),t}finally{t(!1)}},[s,u,c?.address]),isSigningPending:e,signature:n,error:a,reset:(0,r.useCallback)(()=>{t(!1),i(null),o(null)},[])}},qo=()=>{let[e,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(null),[a,o]=(0,r.useState)(null),{signer:s}=(0,f.useWallet)(),{connection:c}=X(),l=pl();return{signTypedData:(0,r.useCallback)(async(e,n)=>{t(!0),o(null),i(null);try{let t;if(c.isConnectedWithDappKit){let r={...e.domain,salt:e.domain?.salt?Buffer.from(e.domain.salt).toString(`hex`):void 0};t=await s.signTypedData(r,e.types,e.message,void 0,n)}else t=await l.signTypedData(e);return i(t),t}catch(e){if(e&&typeof e==`object`&&`statusCode`in e&&e.statusCode===4001){let e=Error(`User denied signature request`);throw o(e),e}let t=e instanceof Error?e:Error(typeof e==`object`?JSON.stringify(e):String(e));throw console.error(t),o(t),t}finally{t(!1)}},[c,l]),isSigningPending:e,signature:n,error:a,reset:(0,r.useCallback)(()=>{t(!1),i(null),o(null)},[])}},Jo=()=>{let{loginWithPasskey:e}=(0,u.useLoginWithPasskey)();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Yo=!1;const Xo=()=>{let{createWallet:e}=(0,u.useCreateWallet)(),{initOAuth:t}=(0,u.useLoginWithOAuth)({onComplete:(0,r.useCallback)(async({isNewUser:t})=>{if(t&&!Yo){Yo=!0;try{await e()}catch(e){throw Yo=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},Zo=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:(0,r.useCallback)(n=>{let r={timestamp:Date.now(),ecosystemApp:n};t.yt(e,JSON.stringify(r))},[]),getConnectionCache:(0,r.useCallback)(()=>{let n=t.dt(e);return n?JSON.parse(n):null},[]),clearConnectionCache:(0,r.useCallback)(()=>{t.gt(e)},[])}},Qo=()=>{let{login:n}=Vn(),{setConnectionCache:r}=Zo(),{data:i}=Ze([t.at]);return{login:async()=>{try{await n(t.at),r({name:`VeChain`,logoUrl:i?.[t.at]?.logo_url,appId:t.at,website:e.y})}catch(e){throw Ln({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.`})}}}},$o=`vechain-kit-app-hub-apps`,es=`vechain-kit-app-hub-apps-expiry`,ts=1440*60*1e3,ns=()=>[`VECHAIN_KIT`,`appHub`,`apps`],rs=async()=>{if(typeof window<`u`)try{let e=t.dt($o),n=t.dt(es);if(e&&n){let t=parseInt(n,10);if(Date.now()<t)return JSON.parse(e)}}catch{console.warn(`Invalid app-hub cache, fetching fresh data`)}let n=new URL(`contents/apps`,e.a),r=await fetch(n);if(!r.ok)throw Error(`Failed to fetch app directories`);let i=(await r.json()).map(async t=>{if(t.type!==`dir`)return null;let n=new URL(`master/apps/${t.name}/manifest.json`,e.o),r=await fetch(n);if(!r.ok)return console.warn(`Failed to fetch manifest for ${t.name}`),null;try{let n=await r.json(),i=new URL(`master/apps/${t.name}/logo.png`,e.o);return{id:t.name,name:n.name,description:n.desc,url:n.href,logo:i.toString(),category:n.category,tags:n.tags||[],isVeWorldSupported:n.isVeWorldSupported||!1,repo:n.repo,contracts:n.contracts,veBetterDaoId:n.veBetterDaoId}}catch(e){return console.warn(`Error parsing manifest for ${t.name}:`,e),null}}),a=(await Promise.all(i)).filter(e=>e!==null);if(typeof window<`u`)try{t.yt($o,JSON.stringify(a)),t.yt(es,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return a},is=()=>(0,p.useQuery)({queryKey:ns(),queryFn:async()=>{try{return await rs()}catch(e){let t=localStorage.getItem($o);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),as=({abi:e,address:t,method:n})=>[`callClause`,t,n],os=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?os(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),ss=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?os(r):[]],cs=({address:e,abi:n,method:r,args:i,queryOptions:a})=>{let o=(0,f.useThor)();return(0,p.useQuery)({queryKey:ss({abi:n,address:e,method:r,args:i}),queryFn:async()=>t.n({thor:o,contractAddress:e,abi:n,method:r,args:i}),...a})},ls=({thor:e,calls:n,queryKey:r,enabled:i=!0})=>(0,p.useQuery)({queryKey:r,queryFn:()=>t.r({thor:e,calls:n}),enabled:i}),us=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},ds=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},fs=()=>{let[e,n]=(0,r.useState)(!0),i=`vechain_kit_feature_announcement_closed`;return(0,r.useEffect)(()=>{t.dt(i)&&n(!1)},[]),{isVisible:e,closeAnnouncement:()=>{t.yt(i,`true`),n(!1)}}},ps=()=>{let{network:e}=$();return e.nodeUrl??t.bt(e.type).nodeUrl},ms=()=>{let[e,n]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{if(!t.mt()){n(!1);return}let e=()=>{n(window.matchMedia(`(display-mode: standalone)`).matches||window.standalone||document.referrer.includes(`android-app://`))};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]),e},hs=()=>{(0,r.useEffect)(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},gs=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(s.Address.of(t));return{balance:(0,b.formatEther)(BigInt(n.balance)).toString(),energy:(0,b.formatEther)(BigInt(n.energy)).toString()}},_s=e=>[`VECHAIN_KIT_BALANCE`,e],vs=e=>{let t=(0,f.useThor)();return(0,p.useQuery)({queryKey:_s(e),queryFn:()=>gs(t,e),enabled:!!e&&s.Address.isValid(e),refetchInterval:1e4})},ys=async(e,n,r)=>{if(!r)throw Error(`Network type is required`);if(!n)throw Error(`Version is required`);let i=e.contracts.load(t.bt(r).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi),a;switch(n){case 1:case 2:a=i.read.accountImplementationV1();break;case 3:a=i.read.accountImplementationV3();break;default:throw Error(`Invalid version, must be between 1 and 3`)}let o=await a;if(!o)throw Error(`Failed to get account implementation address`);return o[0].toString()},bs=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],xs=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:bs(e,n.type),queryFn:async()=>ys(t,e,n.type),enabled:!!t&&!!e&&!!n})},Ss=async(e,n)=>{if(!n)throw Error(`Network type is required`);let r=await e.contracts.load(t.bt(n).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.currentAccountImplementationVersion();if(!r)throw Error(`Failed to get current account implementation version`);return parseInt(r[0].toString())},Cs=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],ws=()=>{let e=(0,f.useThor)(),{network:t}=$();return(0,p.useQuery)({queryKey:Cs(t.type),queryFn:async()=>Ss(e,t.type),enabled:!!e&&!!t})},Ts=async(e,n,r)=>{if(!n)throw Error(`Owner address is required`);if(!r)throw Error(`Network type is required`);let i=await e.contracts.load(t.bt(r).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.getAccountAddress(n);if(!i)throw Error(`Failed to get account address of ${n}`);return i[0].toString()},Es=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],Ds=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:Es(e,n.type),queryFn:async()=>Ts(t,e,n.type),enabled:!!t&&!!e&&!!n})},Os=y.SocialLoginSmartAccountFactory__factory.abi,ks=(e,n,r)=>ss({abi:Os,address:t.bt(r).accountFactoryAddress,method:`getAccountVersion`,args:[e,n]}),As=(e,n)=>{let{network:r}=$();return cs({address:t.bt(r.type).accountFactoryAddress,abi:Os,method:`getAccountVersion`,args:[e,n],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]}),enabled:!!e&&!!n}})},js=y.SocialLoginSmartAccountFactory__factory.abi,Ms=`hasLegacyAccount`,Ns=async(e,n,r)=>{if(!n)throw Error(`Owner address is required`);if(!r)throw Error(`Network type is required`);let[i]=await t.n({thor:e,abi:js,contractAddress:t.bt(r).accountFactoryAddress,method:`hasLegacyAccount`,args:[n]});return i},Ps=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Fs=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:Ps(e,n.type),queryFn:async()=>Ns(t,e,n.type),enabled:!!t&&!!e&&!!n})},Is=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(s.Address.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},Ls=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Rs=e=>{let t=ps(),n=L.ThorClient.at(t);return(0,p.useQuery)({queryKey:Ls(e),queryFn:async()=>Is(n,e),enabled:!!n&&!!e})},zs=()=>{let e=(0,p.useQueryClient)(),{connectedWallet:t,smartAccount:n}=X(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:Es(i,r.type)}),e.cancelQueries({queryKey:ks(a,i,r.type)}),e.cancelQueries({queryKey:Ps(i,r.type)}),e.cancelQueries({queryKey:Cs(r.type)}),e.cancelQueries({queryKey:Gs(a,i,3,r.type)}),e.cancelQueries({queryKey:Js(a,3,r.type)}),e.cancelQueries({queryKey:bs(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:Es(i,r.type)}),e.refetchQueries({queryKey:ks(a,i,r.type)}),e.refetchQueries({queryKey:Ps(i,r.type)}),e.refetchQueries({queryKey:Cs(r.type)}),e.refetchQueries({queryKey:Gs(a,i,3,r.type)}),e.refetchQueries({queryKey:Js(a,3,r.type)}),e.refetchQueries({queryKey:bs(3,r.type)})])}}},Bs=()=>{let e=(0,p.useQueryClient)(),{smartAccount:t}=X();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Hs(n)}),e.cancelQueries({queryKey:Ls(n)})]),await Promise.all([e.refetchQueries({queryKey:Hs(n)}),e.refetchQueries({queryKey:Ls(n)})])}}},Vs=async(e,n,r)=>{if(!r)return{address:void 0};let i=await e.contracts.load(t.bt(n).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.getAccountAddress(r);if(!i)throw Error(`Failed to get account address of ${r}`);let a=s.Address.of(i[0].toString()),o=await e.accounts.getAccount(a);if(!o)throw Error(`Failed to get account detail of ${a}`);return{address:a.toString(),isDeployed:o.hasCode}},Hs=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Us=e=>{let{network:t}=$(),n=(0,f.useThor)();return(0,p.useQuery)({queryKey:Hs(e),queryFn:()=>Vs(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},Ws=async(e,n,r,i,a)=>{let o=await e.contracts.load(t.bt(a).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.upgradeRequired(n,r,BigInt(i));if(!o)throw Error(`Failed to get upgrade required of contract address ${t.bt(a).accountFactoryAddress}`);return o[0]},Gs=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],Ks=(e,t,n)=>{let r=(0,f.useThor)(),{network:i}=$();return(0,p.useQuery)({queryKey:Gs(e,t,n,i.type),queryFn:async()=>Ws(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},qs=async(e,n,r,i)=>{let a=await e.contracts.load(t.bt(i).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.upgradeRequiredForAccount(n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required for contract address ${n}`);return a[0]},Js=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Ys=(e,t)=>{let n=(0,f.useThor)(),{network:r}=$();return(0,p.useQuery)({queryKey:Js(e,t,r.type),queryFn:async()=>qs(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Xs=y.SocialLoginSmartAccount__factory.createInterface(),Zs=({smartAccountAddress:e,targetVersion:n,onSuccess:i,onError:a})=>{let{refresh:o}=zs(),{refresh:s}=Bs(),{data:c}=xs(n),l=(0,r.useCallback)(async()=>{if(!e||!t.j(e))throw Error(`Invalid smart account address`);if(!c)throw Error(`Unable to fetch implementation address for version ${n}`);return[{to:e,value:`0x0`,data:Xs.encodeFunctionData(`upgradeToAndCall`,[c,`0x`]),comment:`Upgrade account to version ${n}`,abi:Xs.getFunction(`upgradeToAndCall`).format(`json`)}]},[e,c,n]),u=lr({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${t.W(e)} to version ${n}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([o(),s()]),i?.()},onTxFailedOrCancelled:async()=>{a?.()}});return{...u,sendTransaction:async()=>u.sendTransaction(await l())}},Qs=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],$s=10*t.s.SECOND,ec=()=>{let e=(0,f.useThor)();return(0,p.useQuery)({queryKey:Qs(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:$s})},tc=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},nc=()=>[`VECHAIN_KIT_CHAIN_ID`],rc=()=>{let e=(0,f.useThor)();return(0,p.useQuery)({queryKey:nc(),queryFn:()=>tc(e),enabled:!!e})},ic=1e3,ac=async({thor:e,order:t=`asc`,offset:n=0,limit:r=ic,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},oc=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await ac({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:ic,order:n,offset:s});if(o.push(...c),c.length<ic)return o;s+=ic}},sc=y.IERC20__factory.createInterface(),cc=(e,n,r,i)=>{if(!e||!n||!t.j(e))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:r,value:`0x0`,data:sc.encodeFunctionData(`transfer`,[e,(0,b.parseEther)(n)]),comment:`Transfer ${n} ${i} to ${e}`,abi:sc.getFunction(`transfer`)}),a},lc=({fromAddress:e,receiverAddress:n,amount:i,tokenAddress:a,tokenName:o,onSuccess:s,onError:c})=>{let{refresh:l}=Wn(),u=(0,r.useMemo)(()=>cc(n,i,a,o),[n,i,a,o]),d=lr({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${i} ${o} to ${t.W(n)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{l(),s?.()},onTxFailedOrCancelled:async e=>{c?.(e instanceof Error?e.message:String(e))}});return{...d,clauses:u,sendTransaction:async()=>d.sendTransaction(u)}},uc=(e,n)=>{if(!e||!n||!t.j(e))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(n)))throw Error(`Invalid amount`);let r=[];try{r.push({to:e,value:(0,b.parseEther)(n).toString(),data:`0x`,comment:`Transfer ${n} VET to ${e}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return r},dc=({fromAddress:e,receiverAddress:n,amount:i,onSuccess:a,onError:o})=>{let{refresh:s}=Wn(),c=(0,r.useMemo)(()=>uc(n,i),[n,i]),l=lr({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${i} VET to ${t.W(n)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...l,clauses:c,sendTransaction:async()=>l.sendTransaction(c)}},fc=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:i,onFailure:a,suggestedMaxGas:o,gasPadding:s,delegationUrl:c})=>{let{account:l}=X(),u=(0,p.useQueryClient)(),d=(0,r.useCallback)(async()=>{n&&t?.forEach(async e=>{await u.cancelQueries({queryKey:e}),await u.refetchQueries({queryKey:e})}),i?.()},[n,i,u,t]),f=lr({signerAccountAddress:l?.address,onTxConfirmed:d,suggestedMaxGas:o,onTxFailedOrCancelled:a,gasPadding:s,delegationUrl:c}),m=(0,r.useCallback)(async t=>{f.sendTransaction(e(t),c)},[e,f,c]);return{...f,sendTransaction:m}},pc=10*t.s.SECOND,mc=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],hc=(e,t=5)=>{let n=(0,f.useThor)();return(0,p.useQuery)({queryKey:mc(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*pc,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},gc=(e,t)=>{let n=(0,b.decodeEventLog)({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},_c=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],vc=({abi:e,contractAddress:t,eventName:n,filterParams:i,mapResponse:a,nodeUrl:o})=>{let s=(0,f.useThor)();return(0,p.useQuery)({queryFn:(0,r.useCallback)(async()=>{if(!s)return[];let r=s.contracts.load(t,e).getEventAbi(n),c=r.encodeFilterTopicsNoNull(i??{}),l=(await oc({thor:s,nodeUrl:o,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:r}]})).map(t=>gc(t,e));if(l.some(({decodedData:e})=>e.eventName!==n))throw Error(`Unknown event`);return l.map(e=>a({meta:e.meta,decodedData:e.decodedData}))},[s,t,e,n,i,a,o]),queryKey:(0,r.useMemo)(()=>_c({eventName:n,filterParams:i}),[n,i]),enabled:!!s})};function yc({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((0,b.encodeFunctionData)(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:o.ethers.hexlify(o.ethers.randomBytes(32))}}}function bc({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?(0,b.encodeFunctionData)(e.data):e.data)||`0x`}}}function xc(){let{connection:e,connectedWallet:t}=X(),{signTypedData:n}=Vn(),{signTypedData:r}=(0,u.usePrivy)(),{network:i}=$(),{data:a}=rc();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const Sc=()=>{let{connection:e,connectedWallet:n,signTypedDataWithCrossApp:r,signTypedDataPrivy:i,network:a,chainId:o}=xc(),c=async e=>{let{version:t}=e;return t&&t<3?await l(e):await u(e)};async function l(c){let{clauses:l,smartAccount:u,title:d=`Sign Transaction`,description:f,buttonText:p=`Sign`}=c,m=[],h=l.map(e=>bc({clause:e,chainId:o,smartAccount:u})),g=[];for(let t=0;t<h.length;t++){let a=h[t],o=l[t];if(!o)throw Error(`Transaction clause at index ${t} is undefined`);if(e.isConnectedWithCrossApp){let e=await r({...a,address:n?.address,types:Object.fromEntries(Object.entries(a.types).map(([e,t])=>[e,[...t]]))});g.push(e);continue}let s=o.data,c=(await i(a,{uiOptions:{title:d,description:f??(l[t].comment||(typeof s==`object`&&s&&`functionName`in s?s.functionName:` `)),buttonText:p}})).signature;g.push(c)}return u.isDeployed||m.push(s.Clause.callFunction(s.Address.of(t.bt(a.type).accountFactoryAddress),s.ABIContract.ofAbi(y.SocialLoginSmartAccountFactory__factory.abi).getFunction(`createAccount`),[n?.address??``])),h.forEach((e,t)=>{m.push(s.Clause.callFunction(s.Address.of(u.address??``),s.ABIContract.ofAbi(y.SocialLoginSmartAccount__factory.abi).getFunction(`executeWithAuthorization`),[e.message.to,BigInt(e.message.value),e.message.data,BigInt(e.message.validAfter),BigInt(e.message.validBefore),g[t]]))}),m}async function u(c){let{clauses:l,smartAccount:u,title:d,description:f,buttonText:p=`Sign`}=c,m=[],h=yc({clauses:l,chainId:o,verifyingContract:u.address??``}),g;return g=e.isConnectedWithCrossApp?await r({...h,address:n?.address}):(await i(h,{uiOptions:{title:d,description:f,buttonText:p}})).signature,u.isDeployed||m.push(s.Clause.callFunction(s.Address.of(t.bt(a.type).accountFactoryAddress),s.ABIContract.ofAbi(y.SocialLoginSmartAccountFactory__factory.abi).getFunction(`createAccount`),[n?.address??``])),m.push(s.Clause.callFunction(s.Address.of(u.address??``),s.ABIContract.ofAbi(y.SocialLoginSmartAccount__factory.abi).getFunction(`executeBatchWithAuthorization`),[h.message.to,h.message.value?.map(e=>BigInt(e))??0,h.message.data,BigInt(h.message.validAfter),BigInt(h.message.validBefore),h.message.nonce,g])),m}return{buildClausesWithAuth:c}};let Cc=function(e){return e.CUSTOM_TOKENS=`vechain_kit_custom_tokens`,e.ECOSYSTEM_SHORTCUTS=`vechain-kit-ecosystem-shortcuts`,e.CURRENCY=`vechain_kit_currency`,e.NODE_URL=`vechain_kit_node_url`,e.NETWORK=`vechain_kit_network`,e.GAS_TOKEN_PREFERENCES=`vechain_kit_gas_token_preferences`,e.SHOW_ASSETS=`vechain_kit_show_assets`,e}({});const wc=(e,n)=>{let[i,a]=(0,r.useState)(()=>{try{let r=t.dt(e);return r?JSON.parse(r):n}catch(e){return console.error(e),n}});return(0,r.useEffect)(()=>{t.yt(e,JSON.stringify(i))},[e,i]),[i,a]},Tc=`vechain-kit-storage-change`,Ec=(e,t)=>{let[n,i]=(0,r.useState)(()=>{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}}),a=(0,r.useRef)(!1);return(0,r.useEffect)(()=>{if(!(typeof window>`u`)){if(a.current){a.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Tc,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),(0,r.useEffect)(()=>{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)&&(a.current=!0,i(e))}catch(e){console.error(`Error parsing storage value:`,e)}},r=(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)&&(a.current=!0,i(e))}}catch(e){console.error(`Error parsing storage value:`,e)}});return window.addEventListener(`storage`,t),window.addEventListener(Tc,r),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Tc,r)}},[e,n]),[n,i,(0,r.useCallback)(()=>{if(!(typeof window>`u`))try{let r=window.localStorage.getItem(e),a=r?JSON.parse(r):t;JSON.stringify(a)!==JSON.stringify(n)&&i(a)}catch(e){console.error(`Error syncing localStorage:`,e)}},[e,t,n]),(0,r.useCallback)(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},Dc=()=>{let[e,t]=wc(Cc.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)}},Oc=async(e,t,n,r,i)=>{let a=new URL(`estimate/clauses/${r.toLowerCase()}`,t);return a.searchParams.set(`type`,`smartaccount`),a.searchParams.set(`speed`,i),await(await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json()},kc=async e=>{let t=new URL(`deposit/account`,e);return await(await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`}})).json()},Ac=async(e,t,n,r)=>{let i=new URL(`sign/transaction/authorized/${n.toLowerCase()}`,r);return await(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json()},jc=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 Mc(e,t){return s.Transaction.of(e.body,R.concatBytes(e.signature??new Uint8Array,s.HexUInt.of(t.slice(2)).bytes))}function Nc(e,t){return s.Transaction.decode(s.HexUInt.of(e.slice(2)).bytes,t)}const Pc=()=>{let{connectedWallet:e}=X(),{data:n}=Us(e?.address??``),{data:i}=As(n?.address??``,e?.address??``),{preferences:a}=Fc(),o=y.IERC20__factory.createInterface(),{network:c}=$(),{buildClausesWithAuth:l}=Sc(),u=L.ThorClient.at(t.bt(c.type).nodeUrl);return{sendTransactionUsingGenericDelegator:(0,r.useCallback)(async({clauses:e,genericDelegatorUrl:r})=>{try{let c=a.gasTokenToUse,d=await Oc(n?.address??``,r,e,c,`medium`),f=await kc(r),p={to:c===`VET`?f.depositAccount:t.Q[c].address,value:c===`VET`?(0,b.parseEther)(d.transactionCost?.toString()??`0`).toString():`0x0`,data:c===`VET`?`0x`:o.encodeFunctionData(`transfer`,[f.depositAccount,(0,b.parseEther)(d.transactionCost?.toString()??`0`)]),comment:`Transfer ${d.transactionCost} ${c} to ${f.depositAccount}`,abi:c===`VET`?void 0:o.getFunction(`transfer`)},m=await l({clauses:[...e,p],smartAccount:n,version:i?.version??0}),h=await jc(m,u,t.V,!0),g=await s.Transaction.of(h).signAsSender(s.HexUInt.of(t.V.privateKey).bytes),_=await Ac(s.HexUInt.of(g.encoded).toString(),t.V.address,c,r),v=Mc(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:t.V.address??``,gasPayer:_.address}},x=await u.transactions.simulateTransaction(y.clauses,{...y.simulateTransactionOptions});for(let e=0;e<x.length;e++)if(x[e].reverted)throw Error(x[e].vmError);return(await u.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`)},[a,n,i,l,u,t.V])}},Fc=()=>{let[e,n]=Ec(Cc.GAS_TOKEN_PREFERENCES,t.J);return{preferences:e,supportedTokens:t.Q,updatePreferences:(0,r.useCallback)(e=>{n(t=>({...t,...e}))},[n]),reorderTokenPriority:(0,r.useCallback)(e=>{n(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}})},[n]),toggleTokenExclusion:(0,r.useCallback)(e=>{n(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}})},[n])}},Ic=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=X(),{data:s}=Us(a?.address??``),{feeDelegation:c}=$(),{balances:l}=Yt(o?.address??``),{updatePreferences:u}=Fc();return(0,p.useQuery)({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 Oc(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})},Lc=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=X(),{data:i}=Us(r?.address??``),{feeDelegation:a}=$();return(0,p.useQuery)({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 Oc(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})},Rc=({symbol:e,amount:a,currencyValue:o,currentCurrency:s,isDisabled:c,onClick:l,...u})=>{let d=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),f=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),[p]=wc(Cc.SHOW_ASSETS,!0);return(0,i.jsxs)(n.Button,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:c,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:l,"data-testid":`asset-${e}`,...u,children:[(0,i.jsxs)(n.HStack,{children:[t.et[e]?r.default.cloneElement(t.et[e],{boxSize:`24px`,borderRadius:`full`}):(0,i.jsx)(n.Image,{src:t.$[e],alt:`${e} logo`,boxSize:`24px`,borderRadius:`full`,fallback:(0,i.jsx)(n.Box,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:(0,i.jsx)(n.Text,{fontSize:`10px`,fontWeight:`bold`,color:d,children:e.slice(0,3)})})}),(0,i.jsx)(n.Text,{color:d,children:e})]}),(0,i.jsxs)(n.VStack,{align:`flex-end`,spacing:0,children:[(0,i.jsxs)(n.Text,{color:d,children:[p?a.toLocaleString(void 0,{maximumFractionDigits:2}):`*`.repeat(4),` `]}),(0,i.jsx)(n.Text,{fontSize:`sm`,color:f,"data-testid":`${e}-balance`,children:p?rn(o,{currency:s}):`*`.repeat(4)})]})]})},zc=({address:e,domain:a,imageSrc:o,imageAlt:s=`Account`,hideAddress:c=!1,balance:u,tokenAddress:d})=>{let{t:f}=(0,l.useTranslation)(),p=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),m=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),h=(0,n.useToken)(`colors`,`vechain-kit-card`),{isLoading:g}=ln({address:e}),{tokens:_,isLoading:v}=cn({address:e}),y=(0,r.useMemo)(()=>d?_.find(e=>e.address===d):null,[_,d]),b=(0,r.useMemo)(()=>u===void 0?y?Number(y.balance):0:u,[u,y]),x=y?.symbol||``;return g||v?(0,i.jsxs)(n.HStack,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:h,children:[(0,i.jsxs)(n.HStack,{children:[(0,i.jsx)(n.Skeleton,{boxSize:`40px`,borderRadius:`full`}),(0,i.jsxs)(n.VStack,{align:`start`,spacing:0,children:[(0,i.jsx)(n.Skeleton,{height:`16px`,width:`120px`,borderRadius:`md`}),!c&&(0,i.jsx)(n.Skeleton,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),(0,i.jsxs)(n.VStack,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`medium`,color:p,children:f(`Balance`)}),(0,i.jsx)(n.Skeleton,{height:`12px`,width:`80px`,borderRadius:`md`})]})]}):(0,i.jsxs)(n.HStack,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:h,children:[(0,i.jsxs)(n.HStack,{children:[(0,i.jsx)(n.Image,{src:o,alt:s,boxSize:`40px`,borderRadius:`full`,objectFit:`cover`}),(0,i.jsx)(n.VStack,{align:`start`,spacing:0,children:a?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Text,{fontWeight:`medium`,fontSize:`sm`,color:p,children:a}),!c&&(0,i.jsx)(n.Text,{fontSize:`xs`,color:m,children:t.W(e,6,4)})]}):(0,i.jsx)(n.Text,{fontWeight:`medium`,fontSize:`sm`,color:p,children:t.W(e,6,4)})})]}),(0,i.jsxs)(n.VStack,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`medium`,color:p,children:f(`Balance`)}),(0,i.jsxs)(n.Text,{fontSize:`xs`,color:m,children:[b.toLocaleString(void 0,{maximumFractionDigits:2}),x&&` ${x}`]})]})]})},Bc=({onClick:e,...t})=>(0,i.jsx)(n.IconButton,{"aria-label":`FAQ`,icon:(0,i.jsx)(n.Icon,{as:g.LuCircleHelp,fontSize:`17px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,lineHeight:`normal`,left:`10px`,top:`8px`,onClick:e,...t}),Vc=({children:e,...t})=>(hs(),(0,i.jsx)(n.VStack,{...t,children:e})),Hc=({wallet:e,props:t})=>{let a=(0,r.useRef)(e?.image),o=(0,r.useRef)(e?.address);return(0,r.useEffect)(()=>{o.current!==e?.address&&(a.current=e?.image,o.current=e?.address)},[e?.address]),(0,r.useEffect)(()=>{e?.image&&!e.isLoadingMetadata&&(a.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!a.current||e?.isLoadingMetadata?(0,i.jsx)(n.Skeleton,{rounded:`full`,width:t?.width,height:t?.height}):(0,i.jsx)(n.Image,{src:t?.src||e?.image||a.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Uc=({transactionError:e,isSubmitting:a,isTxWaitingConfirmation:o,onConfirm:s,onRetry:c,transactionPendingText:u,txReceipt:d,isSubmitForm:f=!1,buttonText:p,isDisabled:m=!1,style:h,onError:g,gasEstimationError:_,hasEnoughGasBalance:v=!0,isLoadingGasEstimation:y=!1,showGasEstimationError:b=!1,context:x=`transaction`})=>{let{t:S}=(0,l.useTranslation)(),{darkMode:C}=$(),{network:w}=$(),T=(0,r.useMemo)(()=>e?e.reason||S(`Something went wrong. Please try again.`):null,[e,S]);(0,r.useEffect)(()=>{T&&g?.(T)},[T,g]);let E=(0,r.useMemo)(()=>{if(h?.accentColor)return`${h.accentColor} !important`},[h?.accentColor]),D=(0,r.useMemo)(()=>{if(!b||y||!(_||v))return null;if(!v&&!_)return{message:S(`You don't have any gas tokens enabled. Please enable at least one gas token in Gas Token Preferences.`)};if(_){let e=``;switch(x){case`send`:e=S(`Insufficient balance to complete this transfer and cover gas fees.`);break;case`customization`:e=S(`Insufficient balance to update your profile and cover gas fees.`);break;case`domain`:e=S(`Insufficient balance to claim this domain and cover gas fees.`);break;default:e=S(`Insufficient balance to complete this transaction and cover gas fees.`)}return{message:e}}return null},[_,v,y,b,x,S]);return(0,i.jsxs)(n.VStack,{width:`full`,spacing:4,children:[T&&(0,i.jsx)(n.Box,{p:3,borderRadius:`md`,bg:C?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:C?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:(0,i.jsx)(n.Text,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:T})}),D&&!T&&(0,i.jsx)(n.Box,{p:3,borderRadius:`md`,bg:C?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:C?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:(0,i.jsx)(n.Text,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:D.message})}),(0,i.jsx)(n.Button,{px:4,variant:T?`vechainKitSecondary`:`vechainKitPrimary`,bg:E,onClick:()=>T&&c?c():s(),type:f?`submit`:`button`,isLoading:a,isDisabled:m,loadingText:o?S(`Waiting wallet confirmation...`):u,"data-testid":`confirm-button`,children:T?S(`Retry`):p||S(`Confirm`)}),T&&d?.meta.txID&&(0,i.jsx)(n.Link,{isExternal:!0,fontSize:`sm`,color:C?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${t.bt(w.type).explorerUrl}/${d?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:S(`View transaction on the explorer`)})]})},Wc=({onClick:e,hasUnreadNotifications:t,...r})=>(0,i.jsx)(n.IconButton,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:(0,i.jsxs)(n.Box,{position:`relative`,children:[(0,i.jsx)(g.LuBell,{fontSize:`20px`}),t&&(0,i.jsx)(n.Box,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...r}),Gc=({isOpen:e,onClose:a,selectedToken:o,onTokenSelect:s,availableTokens:c,tokenEstimations:u,walletAddress:d})=>{let{t:f}=(0,l.useTranslation)(),{balances:p}=Yt(d),[m,h]=r.default.useState(o),[g,_]=r.default.useState(!1),v=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),y=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),b=(0,n.useToken)(`colors`,`vechain-kit-text-tertiary`),x=(0,n.useToken)(`colors`,`vechain-kit-error`),S=e=>e?b:`transparent`,C=e=>e?v:`transparent`;r.default.useEffect(()=>{e&&(h(o),_(!1))},[e,o]);let w=()=>{s(m,g),a()},T=e=>{let t=p.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},E=e=>{let t=p.find(t=>t.symbol===e),n=u[e];return!t||!n?!1:Number(t.balance)<n.cost};return(0,i.jsxs)(Je,{isOpen:e,onClose:a,size:`sm`,children:[(0,i.jsxs)(n.ModalHeader,{children:[(0,i.jsx)(n.Text,{fontSize:`lg`,fontWeight:`semibold`,color:v,children:f(`Fee token`)}),(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`normal`,color:y,mt:1,children:f(`Select the token to pay the fee with`)})]}),(0,i.jsx)(n.ModalBody,{children:(0,i.jsxs)(n.VStack,{spacing:2,align:`stretch`,children:[c.map(e=>{let a=t.Q[e],o=m===e,s=u[e]||{cost:0,loading:!0},c=E(e);return(0,i.jsx)(n.Box,{cursor:c?`not-allowed`:`pointer`,bg:S(o),border:`1px`,borderColor:C(o),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:c?S(o):y&&`#ffffff12`,borderColor:c?C(o):y},opacity:c?.5:1,onClick:()=>!c&&h(e),children:(0,i.jsxs)(n.HStack,{spacing:3,justify:`space-between`,children:[(0,i.jsxs)(n.HStack,{spacing:3,flex:1,children:[r.default.cloneElement(t.et[e],{boxSize:`36px`,borderRadius:`full`}),(0,i.jsxs)(n.VStack,{align:`start`,spacing:0,children:[(0,i.jsx)(n.Text,{fontWeight:`medium`,color:v,children:a.symbol}),(0,i.jsxs)(n.Text,{fontSize:`xs`,color:y,children:[f(`Balance`),`:`,` `,T(e)]}),c&&(0,i.jsx)(n.Text,{fontSize:`xs`,color:x,children:f(`Insufficient balance`)})]})]}),(0,i.jsx)(n.VStack,{align:`end`,spacing:0,children:s.loading?(0,i.jsx)(n.Skeleton,{height:`16px`,width:`60px`}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`semibold`,color:v,children:t.x(s.cost,2)}),(0,i.jsx)(n.Text,{fontSize:`xs`,color:y,children:a.symbol})]})})]})},e)}),m!==o&&(0,i.jsxs)(n.FormControl,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[(0,i.jsx)(n.FormLabel,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:v,children:f(`Use this token for future transactions`)}),(0,i.jsx)(n.Switch,{id:`remember-choice`,isChecked:g,onChange:e=>_(e.target.checked),color:v})]})]})}),(0,i.jsx)(n.ModalFooter,{children:(0,i.jsxs)(n.VStack,{spacing:3,w:`full`,children:[(0,i.jsx)(n.Button,{variant:`vechainKitPrimary`,onClick:w,isDisabled:E(m),children:f(`Apply`)}),(0,i.jsx)(n.Button,{variant:`ghost`,width:`full`,onClick:a,children:f(`Cancel`)})]})})]})},Kc=({estimation:e,isLoading:a,isLoadingTransaction:o,onTokenChange:s,clauses:c=[],userSelectedToken:u})=>{let{t:d}=(0,l.useTranslation)(),{feeDelegation:f}=$(),{connection:p,account:m}=X(),{preferences:h,reorderTokenPriority:_}=Fc(),{isOpen:v,onOpen:y,onClose:b}=(0,n.useDisclosure)(),x=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),S=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),[C,w]=(0,r.useState)(()=>{let e={};return h.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:T,isLoading:E}=Lc({clauses:c,tokens:h.availableGasTokens,enabled:c.length>0});(0,r.useEffect)(()=>{!E&&T&&w(T)},[T,E]),(0,r.useEffect)(()=>{e&&w(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),(0,r.useEffect)(()=>{E&&w(h.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[E,h.availableGasTokens]);let D=(0,r.useCallback)((t,n)=>{n&&_([t,...h.tokenPriority.filter(e=>e!==t)]),s&&t!==e?.usedToken&&s(t)},[e,s,_,h.tokenPriority]);if(f?.delegatorUrl||p.isConnectedWithDappKit||h.availableGasTokens.length===0)return null;let{balances:O}=Yt(m?.address??``),k=e=>{let t=O.find(t=>t.symbol===e),n=C[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},A=e?.usedToken,j=h.availableGasTokens,M;A?M=A:u&&j.includes(u)?M=u:(M=j.find(e=>C[e]&&!C[e].loading&&!k(e)),M||=j.find(e=>C[e]&&!C[e].loading),M||=j[0]);let N=M?C[M]:void 0,P=A&&e?.transactionCost?e.transactionCost:N?.cost||0,F=M?t.Q[M]:void 0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Divider,{mt:3}),(0,i.jsxs)(n.HStack,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[(0,i.jsxs)(n.VStack,{align:`start`,spacing:0,w:`full`,children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:S,children:d(`Fee`)}),(0,i.jsx)(n.HStack,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:(0,i.jsx)(n.HStack,{justifyContent:`flex-start`,w:`full`,children:a||!A&&(!N||N.loading)||!F?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Skeleton,{height:`16px`,width:`120px`,borderRadius:`md`}),(0,i.jsx)(n.Skeleton,{height:`16px`,width:`60px`,borderRadius:`md`})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.Text,{color:x,fontSize:`sm`,fontWeight:`semibold`,children:[t.x(P,2),` `,F.symbol]}),(0,i.jsxs)(n.Text,{color:S,fontSize:`xs`,children:[`≈`,` $`,(P*.01).toFixed(2)]})]})})})]}),(0,i.jsxs)(n.Button,{onClick:y,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:o,color:S,borderColor:S,_hover:{bg:S},leftIcon:r.default.cloneElement(t.et[M||h.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`semibold`,children:M||h.availableGasTokens[0]}),(0,i.jsx)(n.Icon,{as:g.LuChevronDown,boxSize:5,color:S})]})]}),(0,i.jsx)(Gc,{isOpen:v,onClose:b,selectedToken:M||h.availableGasTokens[0],onTokenSelect:D,availableTokens:h.availableGasTokens,tokenEstimations:C,walletAddress:m?.address??``})]})},qc=P.keyframes`
|
|
200
|
+
`}),io=({children:e,theme:t,bodyFont:a,headingFont:o})=>(0,i.jsxs)(P.CacheProvider,{value:(0,r.useMemo)(()=>no(),[]),children:[(0,i.jsx)(ro,{bodyFont:a,headingFont:o}),(0,i.jsx)(n.ChakraProvider,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),ao=({darkMode:e})=>{try{if(t._t(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return(0,i.jsx)(n.ColorModeScript,{initialColorMode:e?`dark`:`light`})},oo=(0,r.createContext)({portalRootRef:void 0,tokens:void 0,themeConfig:void 0}),so=()=>{let e=(0,r.useContext)(oo);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},co=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:a}=(0,n.useColorMode)();return(0,r.useEffect)(()=>{let n=e?`dark`:`light`;a!==n&&t(n)},[e]),(0,i.jsx)(i.Fragment,{})},lo=({children:e,darkMode:t=!1,theme:a})=>{let o=(0,r.useRef)(null),s=(0,r.useContext)(ml),c=s?s.theme:void 0,l=a??c,u=(0,r.useMemo)(()=>Oe(De(t),ke(l,t)),[t,l]),d=(0,r.useMemo)(()=>({...eo(t,l),config:{...eo(t,l).config,initialColorMode:t?`dark`:`light`}}),[t,l]);return(0,i.jsxs)(oo.Provider,{value:{portalRootRef:o,tokens:u,themeConfig:l},children:[(0,i.jsx)(ao,{darkMode:t}),(0,i.jsxs)(io,{theme:d,bodyFont:u.fonts.body,headingFont:u.fonts.heading,children:[(0,i.jsx)(co,{darkMode:t}),(0,i.jsx)(n.Box,{id:`vechain-kit-root`,ref:o,bg:`transparent`,borderRadius:`12px`,children:e})]}),(0,i.jsx)(to,{})]})},uo=(0,r.createContext)(null),Q=()=>{let e=(0,r.useContext)(uo);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},fo=({children:e})=>{let{darkMode:n,theme:a}=$(),[o,s]=(0,r.useState)(!1),[c,l]=(0,r.useState)(`main`),[u,d]=(0,r.useState)(!1),{setSource:p,connectV2:m}=(0,f.useWallet)(),h=(0,r.useCallback)((e,n)=>{t.mt()&&window.vechain&&window.vechain.isInAppBrowser?(p(`veworld`),m(null)):(l(e??`main`),d(n??!1),s(!0))},[]),g=(0,r.useCallback)(()=>{s(!1),l(`main`),d(!1)},[]),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(`main`),C=(0,r.useCallback)((e,t)=>{S(e??`main`),b(t?.isolatedView??!1),v(!0)},[]),w=(0,r.useCallback)(()=>{v(!1),S(`main`),setTimeout(()=>{b(!1)},300)},[]),[T,E]=(0,r.useState)(!1),D=(0,r.useCallback)(()=>E(!0),[]),O=(0,r.useCallback)(()=>E(!1),[]),[k,A]=(0,r.useState)(!1),j=(0,r.useCallback)(()=>A(!0),[]),M=(0,r.useCallback)(()=>A(!1),[]),[N,P]=(0,r.useState)(!1),[F,I]=(0,r.useState)(void 0),L=(0,r.useCallback)(e=>{I(e),P(!0)},[]),R=(0,r.useCallback)(()=>P(!1),[]);return(0,i.jsxs)(uo.Provider,{value:{openConnectModal:h,closeConnectModal:g,isConnectModalOpen:o,connectModalContent:c,setConnectModalContent:l,connectModalPreventAutoClose:u,setConnectModalPreventAutoClose:d,openAccountModal:C,closeAccountModal:w,isAccountModalOpen:_,setAccountModalContent:S,accountModalContent:x,isolatedView:y,openTransactionModal:D,closeTransactionModal:O,isTransactionModalOpen:T,openTransactionToast:j,closeTransactionToast:M,isTransactionToastOpen:k,openUpgradeSmartAccountModal:L,closeUpgradeSmartAccountModal:R,isUpgradeSmartAccountModalOpen:N},children:[e,(0,i.jsxs)(lo,{darkMode:n,theme:a,children:[(0,i.jsx)(wa,{isOpen:o,onClose:g,initialContent:c,preventAutoClose:u}),(0,i.jsx)(ba,{isOpen:_,onClose:w,initialContent:x}),(0,i.jsx)(Fa,{isOpen:N,onClose:R,style:F})]})]})},po=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=Q(),{open:a,close:o}=(0,f.useWalletModal)();return{open:t?a:e=>n(e),close:t?o:r,isOpen:t?!1:i}},mo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),ho=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:()=>e(),close:t,isOpen:n}},go=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),_o=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=Q();return{open:e,close:t,isOpen:n}},vo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),yo=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=Q();return{open:e,close:t,isOpen:n}},bo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),xo=()=>{let{connection:e}=X(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=Q();return{open:n=>{e.isConnected?i(void 0,n):t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},So=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Co=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},wo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),To=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},Eo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Do=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Oo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),ko=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},Ao=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),jo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Mo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),No=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Po=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Fo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=Q();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Io=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Lo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Ro=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),zo=()=>{let{privy:e,loginMethods:n}=$(),i=e?.appId===t.at,a=e=>n?Array.isArray(e)?e.some(e=>n.some(t=>t.method===e)):n.some(t=>t.method===e):!0,o=(0,r.useMemo)(()=>n?n.length===0||a(`ecosystem`):!0,[n]),s=(0,r.useMemo)(()=>a(`vechain`),[n]),c=(0,r.useMemo)(()=>a(`dappkit`),[n]),l=(0,r.useMemo)(()=>a(`passkey`),[n]),u=(0,r.useMemo)(()=>a(`email`),[n]),d={showGoogleLogin:(0,r.useMemo)(()=>a(`google`),[n]),showEmailLogin:u,showPasskey:l,showVeChainLogin:s,showDappKit:c,showEcosystem:o,showMoreLogin:(0,r.useMemo)(()=>a(`more`),[n]),showGithubLogin:(0,r.useMemo)(()=>a(`github`),[n]),isOfficialVeChainApp:!1};return e?i?{...d,isOfficialVeChainApp:!0}:{...d}:{...d,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},Bo=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=Q();return{open:()=>t(e),close:n,isOpen:r}},Vo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Ho=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Uo=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Wo=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=Q();return{open:t=>{e(`settings`,t)},close:()=>{t()},isOpen:n}},Go=({children:e})=>(0,i.jsx)(i.Fragment,{children:e}),Ko=()=>{let[e,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(null),[a,o]=(0,r.useState)(null),{connection:s,account:c}=X(),{requestCertificate:l}=(0,f.useWallet)(),u=pl();return{signMessage:(0,r.useCallback)(async e=>{if(!c)throw Error(`Account not found`);t(!0),o(null),i(null);try{let t=null;return t=s.isConnectedWithDappKit?(await l({purpose:`agreement`,payload:{type:`text`,content:e}},{signer:c.address})).signature:await u.signMessage(e),i(t),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw o(t),t}finally{t(!1)}},[s,u,c?.address]),isSigningPending:e,signature:n,error:a,reset:(0,r.useCallback)(()=>{t(!1),i(null),o(null)},[])}},qo=()=>{let[e,t]=(0,r.useState)(!1),[n,i]=(0,r.useState)(null),[a,o]=(0,r.useState)(null),{signer:s}=(0,f.useWallet)(),{connection:c}=X(),l=pl();return{signTypedData:(0,r.useCallback)(async(e,n)=>{t(!0),o(null),i(null);try{let t;if(c.isConnectedWithDappKit){let r={...e.domain,salt:e.domain?.salt?Buffer.from(e.domain.salt).toString(`hex`):void 0};t=await s.signTypedData(r,e.types,e.message,void 0,n)}else t=await l.signTypedData(e);return i(t),t}catch(e){if(e&&typeof e==`object`&&`statusCode`in e&&e.statusCode===4001){let e=Error(`User denied signature request`);throw o(e),e}let t=e instanceof Error?e:Error(typeof e==`object`?JSON.stringify(e):String(e));throw console.error(t),o(t),t}finally{t(!1)}},[c,l]),isSigningPending:e,signature:n,error:a,reset:(0,r.useCallback)(()=>{t(!1),i(null),o(null)},[])}},Jo=()=>{let{loginWithPasskey:e}=(0,u.useLoginWithPasskey)();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Yo=!1;const Xo=()=>{let{createWallet:e}=(0,u.useCreateWallet)(),{initOAuth:t}=(0,u.useLoginWithOAuth)({onComplete:(0,r.useCallback)(async({isNewUser:t})=>{if(t&&!Yo){Yo=!0;try{await e()}catch(e){throw Yo=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},Zo=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:(0,r.useCallback)(n=>{let r={timestamp:Date.now(),ecosystemApp:n};t.yt(e,JSON.stringify(r))},[]),getConnectionCache:(0,r.useCallback)(()=>{let n=t.dt(e);return n?JSON.parse(n):null},[]),clearConnectionCache:(0,r.useCallback)(()=>{t.gt(e)},[])}},Qo=()=>{let{login:n}=Vn(),{setConnectionCache:r}=Zo(),{data:i}=Ze([t.at]);return{login:async()=>{try{await n(t.at),r({name:`VeChain`,logoUrl:i?.[t.at]?.logo_url,appId:t.at,website:e.y})}catch(e){throw Ln({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.`})}}}},$o=`vechain-kit-app-hub-apps`,es=`vechain-kit-app-hub-apps-expiry`,ts=1440*60*1e3,ns=()=>[`VECHAIN_KIT`,`appHub`,`apps`],rs=async()=>{if(typeof window<`u`)try{let e=t.dt($o),n=t.dt(es);if(e&&n){let t=parseInt(n,10);if(Date.now()<t)return JSON.parse(e)}}catch{console.warn(`Invalid app-hub cache, fetching fresh data`)}let n=new URL(`contents/apps`,e.a),r=await fetch(n);if(!r.ok)throw Error(`Failed to fetch app directories`);let i=(await r.json()).map(async t=>{if(t.type!==`dir`)return null;let n=new URL(`master/apps/${t.name}/manifest.json`,e.o),r=await fetch(n);if(!r.ok)return console.warn(`Failed to fetch manifest for ${t.name}`),null;try{let n=await r.json(),i=new URL(`master/apps/${t.name}/logo.png`,e.o);return{id:t.name,name:n.name,description:n.desc,url:n.href,logo:i.toString(),category:n.category,tags:n.tags||[],isVeWorldSupported:n.isVeWorldSupported||!1,repo:n.repo,contracts:n.contracts,veBetterDaoId:n.veBetterDaoId}}catch(e){return console.warn(`Error parsing manifest for ${t.name}:`,e),null}}),a=(await Promise.all(i)).filter(e=>e!==null);if(typeof window<`u`)try{t.yt($o,JSON.stringify(a)),t.yt(es,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return a},is=()=>(0,p.useQuery)({queryKey:ns(),queryFn:async()=>{try{return await rs()}catch(e){let t=localStorage.getItem($o);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),as=({abi:e,address:t,method:n})=>[`callClause`,t,n],os=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?os(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),ss=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?os(r):[]],cs=({address:e,abi:n,method:r,args:i,queryOptions:a})=>{let o=(0,f.useThor)();return(0,p.useQuery)({queryKey:ss({abi:n,address:e,method:r,args:i}),queryFn:async()=>t.n({thor:o,contractAddress:e,abi:n,method:r,args:i}),...a})},ls=({thor:e,calls:n,queryKey:r,enabled:i=!0})=>(0,p.useQuery)({queryKey:r,queryFn:()=>t.r({thor:e,calls:n}),enabled:i}),us=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},ds=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},fs=()=>{let[e,n]=(0,r.useState)(!0),i=`vechain_kit_feature_announcement_closed`;return(0,r.useEffect)(()=>{t.dt(i)&&n(!1)},[]),{isVisible:e,closeAnnouncement:()=>{t.yt(i,`true`),n(!1)}}},ps=()=>{let{network:e}=$();return e.nodeUrl??t.bt(e.type).nodeUrl},ms=()=>{let[e,n]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{if(!t.mt()){n(!1);return}let e=()=>{n(window.matchMedia(`(display-mode: standalone)`).matches||window.standalone||document.referrer.includes(`android-app://`))};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]),e},hs=()=>{(0,r.useEffect)(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},gs=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(s.Address.of(t));return{balance:(0,b.formatEther)(BigInt(n.balance)).toString(),energy:(0,b.formatEther)(BigInt(n.energy)).toString()}},_s=e=>[`VECHAIN_KIT_BALANCE`,e],vs=e=>{let t=(0,f.useThor)();return(0,p.useQuery)({queryKey:_s(e),queryFn:()=>gs(t,e),enabled:!!e&&s.Address.isValid(e),refetchInterval:1e4})},ys=async(e,n,r)=>{if(!r)throw Error(`Network type is required`);if(!n)throw Error(`Version is required`);let i=e.contracts.load(t.bt(r).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi),a;switch(n){case 1:case 2:a=i.read.accountImplementationV1();break;case 3:a=i.read.accountImplementationV3();break;default:throw Error(`Invalid version, must be between 1 and 3`)}let o=await a;if(!o)throw Error(`Failed to get account implementation address`);return o[0].toString()},bs=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],xs=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:bs(e,n.type),queryFn:async()=>ys(t,e,n.type),enabled:!!t&&!!e&&!!n})},Ss=async(e,n)=>{if(!n)throw Error(`Network type is required`);let r=await e.contracts.load(t.bt(n).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.currentAccountImplementationVersion();if(!r)throw Error(`Failed to get current account implementation version`);return parseInt(r[0].toString())},Cs=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],ws=()=>{let e=(0,f.useThor)(),{network:t}=$();return(0,p.useQuery)({queryKey:Cs(t.type),queryFn:async()=>Ss(e,t.type),enabled:!!e&&!!t})},Ts=async(e,n,r)=>{if(!n)throw Error(`Owner address is required`);if(!r)throw Error(`Network type is required`);let i=await e.contracts.load(t.bt(r).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.getAccountAddress(n);if(!i)throw Error(`Failed to get account address of ${n}`);return i[0].toString()},Es=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],Ds=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:Es(e,n.type),queryFn:async()=>Ts(t,e,n.type),enabled:!!t&&!!e&&!!n})},Os=y.SocialLoginSmartAccountFactory__factory.abi,ks=(e,n,r)=>ss({abi:Os,address:t.bt(r).accountFactoryAddress,method:`getAccountVersion`,args:[e,n]}),As=(e,n)=>{let{network:r}=$();return cs({address:t.bt(r.type).accountFactoryAddress,abi:Os,method:`getAccountVersion`,args:[e,n],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]}),enabled:!!e&&!!n}})},js=y.SocialLoginSmartAccountFactory__factory.abi,Ms=`hasLegacyAccount`,Ns=async(e,n,r)=>{if(!n)throw Error(`Owner address is required`);if(!r)throw Error(`Network type is required`);let[i]=await t.n({thor:e,abi:js,contractAddress:t.bt(r).accountFactoryAddress,method:`hasLegacyAccount`,args:[n]});return i},Ps=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Fs=e=>{let t=(0,f.useThor)(),{network:n}=$();return(0,p.useQuery)({queryKey:Ps(e,n.type),queryFn:async()=>Ns(t,e,n.type),enabled:!!t&&!!e&&!!n})},Is=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(s.Address.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},Ls=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Rs=e=>{let t=ps(),n=L.ThorClient.at(t);return(0,p.useQuery)({queryKey:Ls(e),queryFn:async()=>Is(n,e),enabled:!!n&&!!e})},zs=()=>{let e=(0,p.useQueryClient)(),{connectedWallet:t,smartAccount:n}=X(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:Es(i,r.type)}),e.cancelQueries({queryKey:ks(a,i,r.type)}),e.cancelQueries({queryKey:Ps(i,r.type)}),e.cancelQueries({queryKey:Cs(r.type)}),e.cancelQueries({queryKey:Gs(a,i,3,r.type)}),e.cancelQueries({queryKey:Js(a,3,r.type)}),e.cancelQueries({queryKey:bs(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:Es(i,r.type)}),e.refetchQueries({queryKey:ks(a,i,r.type)}),e.refetchQueries({queryKey:Ps(i,r.type)}),e.refetchQueries({queryKey:Cs(r.type)}),e.refetchQueries({queryKey:Gs(a,i,3,r.type)}),e.refetchQueries({queryKey:Js(a,3,r.type)}),e.refetchQueries({queryKey:bs(3,r.type)})])}}},Bs=()=>{let e=(0,p.useQueryClient)(),{smartAccount:t}=X();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Hs(n)}),e.cancelQueries({queryKey:Ls(n)})]),await Promise.all([e.refetchQueries({queryKey:Hs(n)}),e.refetchQueries({queryKey:Ls(n)})])}}},Vs=async(e,n,r)=>{if(!r)return{address:void 0};let i=await e.contracts.load(t.bt(n).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.getAccountAddress(r);if(!i)throw Error(`Failed to get account address of ${r}`);let a=s.Address.of(i[0].toString()),o=await e.accounts.getAccount(a);if(!o)throw Error(`Failed to get account detail of ${a}`);return{address:a.toString(),isDeployed:o.hasCode}},Hs=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Us=e=>{let{network:t}=$(),n=(0,f.useThor)();return(0,p.useQuery)({queryKey:Hs(e),queryFn:()=>Vs(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},Ws=async(e,n,r,i,a)=>{let o=await e.contracts.load(t.bt(a).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.upgradeRequired(n,r,BigInt(i));if(!o)throw Error(`Failed to get upgrade required of contract address ${t.bt(a).accountFactoryAddress}`);return o[0]},Gs=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],Ks=(e,t,n)=>{let r=(0,f.useThor)(),{network:i}=$();return(0,p.useQuery)({queryKey:Gs(e,t,n,i.type),queryFn:async()=>Ws(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},qs=async(e,n,r,i)=>{let a=await e.contracts.load(t.bt(i).accountFactoryAddress,y.SocialLoginSmartAccountFactory__factory.abi).read.upgradeRequiredForAccount(n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required for contract address ${n}`);return a[0]},Js=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Ys=(e,t)=>{let n=(0,f.useThor)(),{network:r}=$();return(0,p.useQuery)({queryKey:Js(e,t,r.type),queryFn:async()=>qs(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Xs=y.SocialLoginSmartAccount__factory.createInterface(),Zs=({smartAccountAddress:e,targetVersion:n,onSuccess:i,onError:a})=>{let{refresh:o}=zs(),{refresh:s}=Bs(),{data:c}=xs(n),l=(0,r.useCallback)(async()=>{if(!e||!t.j(e))throw Error(`Invalid smart account address`);if(!c)throw Error(`Unable to fetch implementation address for version ${n}`);return[{to:e,value:`0x0`,data:Xs.encodeFunctionData(`upgradeToAndCall`,[c,`0x`]),comment:`Upgrade account to version ${n}`,abi:Xs.getFunction(`upgradeToAndCall`).format(`json`)}]},[e,c,n]),u=lr({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${t.W(e)} to version ${n}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([o(),s()]),i?.()},onTxFailedOrCancelled:async()=>{a?.()}});return{...u,sendTransaction:async()=>u.sendTransaction(await l())}},Qs=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],$s=10*t.s.SECOND,ec=()=>{let e=(0,f.useThor)();return(0,p.useQuery)({queryKey:Qs(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:$s})},tc=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},nc=()=>[`VECHAIN_KIT_CHAIN_ID`],rc=()=>{let e=(0,f.useThor)();return(0,p.useQuery)({queryKey:nc(),queryFn:()=>tc(e),enabled:!!e})},ic=1e3,ac=async({thor:e,order:t=`asc`,offset:n=0,limit:r=ic,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},oc=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await ac({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:ic,order:n,offset:s});if(o.push(...c),c.length<ic)return o;s+=ic}},sc=y.IERC20__factory.createInterface(),cc=(e,n,r,i)=>{if(!e||!n||!t.j(e))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:r,value:`0x0`,data:sc.encodeFunctionData(`transfer`,[e,(0,b.parseEther)(n)]),comment:`Transfer ${n} ${i} to ${e}`,abi:sc.getFunction(`transfer`)}),a},lc=({fromAddress:e,receiverAddress:n,amount:i,tokenAddress:a,tokenName:o,onSuccess:s,onError:c})=>{let{refresh:l}=Wn(),u=(0,r.useMemo)(()=>cc(n,i,a,o),[n,i,a,o]),d=lr({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${i} ${o} to ${t.W(n)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{l(),s?.()},onTxFailedOrCancelled:async e=>{c?.(e instanceof Error?e.message:String(e))}});return{...d,clauses:u,sendTransaction:async()=>d.sendTransaction(u)}},uc=(e,n)=>{if(!e||!n||!t.j(e))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(n)))throw Error(`Invalid amount`);let r=[];try{r.push({to:e,value:(0,b.parseEther)(n).toString(),data:`0x`,comment:`Transfer ${n} VET to ${e}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return r},dc=({fromAddress:e,receiverAddress:n,amount:i,onSuccess:a,onError:o})=>{let{refresh:s}=Wn(),c=(0,r.useMemo)(()=>uc(n,i),[n,i]),l=lr({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${i} VET to ${t.W(n)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...l,clauses:c,sendTransaction:async()=>l.sendTransaction(c)}},fc=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:i,onFailure:a,suggestedMaxGas:o,gasPadding:s,delegationUrl:c})=>{let{account:l}=X(),u=(0,p.useQueryClient)(),d=(0,r.useCallback)(async()=>{n&&t?.forEach(async e=>{await u.cancelQueries({queryKey:e}),await u.refetchQueries({queryKey:e})}),i?.()},[n,i,u,t]),f=lr({signerAccountAddress:l?.address,onTxConfirmed:d,suggestedMaxGas:o,onTxFailedOrCancelled:a,gasPadding:s,delegationUrl:c}),m=(0,r.useCallback)(async t=>{f.sendTransaction(e(t),c)},[e,f,c]);return{...f,sendTransaction:m}},pc=10*t.s.SECOND,mc=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],hc=(e,t=5)=>{let n=(0,f.useThor)();return(0,p.useQuery)({queryKey:mc(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*pc,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},gc=(e,t)=>{let n=(0,b.decodeEventLog)({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},_c=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],vc=({abi:e,contractAddress:t,eventName:n,filterParams:i,mapResponse:a,nodeUrl:o})=>{let s=(0,f.useThor)();return(0,p.useQuery)({queryFn:(0,r.useCallback)(async()=>{if(!s)return[];let r=s.contracts.load(t,e).getEventAbi(n),c=r.encodeFilterTopicsNoNull(i??{}),l=(await oc({thor:s,nodeUrl:o,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:r}]})).map(t=>gc(t,e));if(l.some(({decodedData:e})=>e.eventName!==n))throw Error(`Unknown event`);return l.map(e=>a({meta:e.meta,decodedData:e.decodedData}))},[s,t,e,n,i,a,o]),queryKey:(0,r.useMemo)(()=>_c({eventName:n,filterParams:i}),[n,i]),enabled:!!s})};function yc({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((0,b.encodeFunctionData)(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:o.ethers.hexlify(o.ethers.randomBytes(32))}}}function bc({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?(0,b.encodeFunctionData)(e.data):e.data)||`0x`}}}function xc(){let{connection:e,connectedWallet:t}=X(),{signTypedData:n}=Vn(),{signTypedData:r}=(0,u.usePrivy)(),{network:i}=$(),{data:a}=rc();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const Sc=()=>{let{connection:e,connectedWallet:n,signTypedDataWithCrossApp:r,signTypedDataPrivy:i,network:a,chainId:o}=xc(),c=async e=>{let{version:t}=e;return t&&t<3?await l(e):await u(e)};async function l(c){let{clauses:l,smartAccount:u,title:d=`Sign Transaction`,description:f,buttonText:p=`Sign`}=c,m=[],h=l.map(e=>bc({clause:e,chainId:o,smartAccount:u})),g=[];for(let t=0;t<h.length;t++){let a=h[t],o=l[t];if(!o)throw Error(`Transaction clause at index ${t} is undefined`);if(e.isConnectedWithCrossApp){let e=await r({...a,address:n?.address,types:Object.fromEntries(Object.entries(a.types).map(([e,t])=>[e,[...t]]))});g.push(e);continue}let s=o.data,c=(await i(a,{uiOptions:{title:d,description:f??(l[t].comment||(typeof s==`object`&&s&&`functionName`in s?s.functionName:` `)),buttonText:p}})).signature;g.push(c)}return u.isDeployed||m.push(s.Clause.callFunction(s.Address.of(t.bt(a.type).accountFactoryAddress),s.ABIContract.ofAbi(y.SocialLoginSmartAccountFactory__factory.abi).getFunction(`createAccount`),[n?.address??``])),h.forEach((e,t)=>{m.push(s.Clause.callFunction(s.Address.of(u.address??``),s.ABIContract.ofAbi(y.SocialLoginSmartAccount__factory.abi).getFunction(`executeWithAuthorization`),[e.message.to,BigInt(e.message.value),e.message.data,BigInt(e.message.validAfter),BigInt(e.message.validBefore),g[t]]))}),m}async function u(c){let{clauses:l,smartAccount:u,title:d,description:f,buttonText:p=`Sign`}=c,m=[],h=yc({clauses:l,chainId:o,verifyingContract:u.address??``}),g;return g=e.isConnectedWithCrossApp?await r({...h,address:n?.address}):(await i(h,{uiOptions:{title:d,description:f,buttonText:p}})).signature,u.isDeployed||m.push(s.Clause.callFunction(s.Address.of(t.bt(a.type).accountFactoryAddress),s.ABIContract.ofAbi(y.SocialLoginSmartAccountFactory__factory.abi).getFunction(`createAccount`),[n?.address??``])),m.push(s.Clause.callFunction(s.Address.of(u.address??``),s.ABIContract.ofAbi(y.SocialLoginSmartAccount__factory.abi).getFunction(`executeBatchWithAuthorization`),[h.message.to,h.message.value?.map(e=>BigInt(e))??0,h.message.data,BigInt(h.message.validAfter),BigInt(h.message.validBefore),h.message.nonce,g])),m}return{buildClausesWithAuth:c}};let Cc=function(e){return e.CUSTOM_TOKENS=`vechain_kit_custom_tokens`,e.ECOSYSTEM_SHORTCUTS=`vechain-kit-ecosystem-shortcuts`,e.CURRENCY=`vechain_kit_currency`,e.NODE_URL=`vechain_kit_node_url`,e.NETWORK=`vechain_kit_network`,e.GAS_TOKEN_PREFERENCES=`vechain_kit_gas_token_preferences`,e.SHOW_ASSETS=`vechain_kit_show_assets`,e}({});const wc=(e,n)=>{let[i,a]=(0,r.useState)(()=>{try{let r=t.dt(e);return r?JSON.parse(r):n}catch(e){return console.error(e),n}});return(0,r.useEffect)(()=>{t.yt(e,JSON.stringify(i))},[e,i]),[i,a]},Tc=`vechain-kit-storage-change`,Ec=(e,t)=>{let[n,i]=(0,r.useState)(()=>{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}}),a=(0,r.useRef)(!1);return(0,r.useEffect)(()=>{if(!(typeof window>`u`)){if(a.current){a.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Tc,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),(0,r.useEffect)(()=>{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)&&(a.current=!0,i(e))}catch(e){console.error(`Error parsing storage value:`,e)}},r=(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)&&(a.current=!0,i(e))}}catch(e){console.error(`Error parsing storage value:`,e)}});return window.addEventListener(`storage`,t),window.addEventListener(Tc,r),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(Tc,r)}},[e,n]),[n,i,(0,r.useCallback)(()=>{if(!(typeof window>`u`))try{let r=window.localStorage.getItem(e),a=r?JSON.parse(r):t;JSON.stringify(a)!==JSON.stringify(n)&&i(a)}catch(e){console.error(`Error syncing localStorage:`,e)}},[e,t,n]),(0,r.useCallback)(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},Dc=()=>{let[e,t]=wc(Cc.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)}},Oc=async(e,t,n,r,i)=>{let a=new URL(`estimate/clauses/${r.toLowerCase()}`,t);return a.searchParams.set(`type`,`smartaccount`),a.searchParams.set(`speed`,i),await(await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json()},kc=async e=>{let t=new URL(`deposit/account`,e);return await(await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`}})).json()},Ac=async(e,t,n,r)=>{let i=new URL(`sign/transaction/authorized/${n.toLowerCase()}`,r);return await(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json()},jc=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``,{gasPadding:1}),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function Mc(e,t){return s.Transaction.of(e.body,R.concatBytes(e.signature??new Uint8Array,s.HexUInt.of(t.slice(2)).bytes))}function Nc(e,t){return s.Transaction.decode(s.HexUInt.of(e.slice(2)).bytes,t)}const Pc=()=>{let{connectedWallet:e}=X(),{data:n}=Us(e?.address??``),{data:i}=As(n?.address??``,e?.address??``),{preferences:a}=Fc(),o=y.IERC20__factory.createInterface(),{network:c}=$(),{buildClausesWithAuth:l}=Sc(),u=L.ThorClient.at(t.bt(c.type).nodeUrl);return{sendTransactionUsingGenericDelegator:(0,r.useCallback)(async({clauses:e,genericDelegatorUrl:r})=>{try{let c=a.gasTokenToUse,d=await Oc(n?.address??``,r,e,c,`medium`),f=await kc(r),p={to:c===`VET`?f.depositAccount:t.Q[c].address,value:c===`VET`?(0,b.parseEther)(d.transactionCost?.toString()??`0`).toString():`0x0`,data:c===`VET`?`0x`:o.encodeFunctionData(`transfer`,[f.depositAccount,(0,b.parseEther)(d.transactionCost?.toString()??`0`)]),comment:`Transfer ${d.transactionCost} ${c} to ${f.depositAccount}`,abi:c===`VET`?void 0:o.getFunction(`transfer`)},m=await l({clauses:[...e,p],smartAccount:n,version:i?.version??0}),h=await jc(m,u,t.V,!0),g=await s.Transaction.of(h).signAsSender(s.HexUInt.of(t.V.privateKey).bytes),_=await Ac(s.HexUInt.of(g.encoded).toString(),t.V.address,c,r),v=Mc(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:t.V.address??``,gasPayer:_.address}},x=await u.transactions.simulateTransaction(y.clauses,{...y.simulateTransactionOptions});for(let e=0;e<x.length;e++)if(x[e].reverted)throw Error(x[e].vmError);return(await u.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`)},[a,n,i,l,u,t.V])}},Fc=()=>{let[e,n]=Ec(Cc.GAS_TOKEN_PREFERENCES,t.J);return{preferences:e,supportedTokens:t.Q,updatePreferences:(0,r.useCallback)(e=>{n(t=>({...t,...e}))},[n]),reorderTokenPriority:(0,r.useCallback)(e=>{n(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}})},[n]),toggleTokenExclusion:(0,r.useCallback)(e=>{n(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}})},[n])}},Ic=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=X(),{data:s}=Us(a?.address??``),{feeDelegation:c}=$(),{balances:l}=Yt(o?.address??``),{updatePreferences:u}=Fc();return(0,p.useQuery)({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 Oc(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})},Lc=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=X(),{data:i}=Us(r?.address??``),{feeDelegation:a}=$();return(0,p.useQuery)({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 Oc(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})},Rc=({symbol:e,amount:a,currencyValue:o,currentCurrency:s,isDisabled:c,onClick:l,...u})=>{let d=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),f=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),[p]=wc(Cc.SHOW_ASSETS,!0);return(0,i.jsxs)(n.Button,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:c,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:l,"data-testid":`asset-${e}`,...u,children:[(0,i.jsxs)(n.HStack,{children:[t.et[e]?r.default.cloneElement(t.et[e],{boxSize:`24px`,borderRadius:`full`}):(0,i.jsx)(n.Image,{src:t.$[e],alt:`${e} logo`,boxSize:`24px`,borderRadius:`full`,fallback:(0,i.jsx)(n.Box,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:(0,i.jsx)(n.Text,{fontSize:`10px`,fontWeight:`bold`,color:d,children:e.slice(0,3)})})}),(0,i.jsx)(n.Text,{color:d,children:e})]}),(0,i.jsxs)(n.VStack,{align:`flex-end`,spacing:0,children:[(0,i.jsxs)(n.Text,{color:d,children:[p?a.toLocaleString(void 0,{maximumFractionDigits:2}):`*`.repeat(4),` `]}),(0,i.jsx)(n.Text,{fontSize:`sm`,color:f,"data-testid":`${e}-balance`,children:p?rn(o,{currency:s}):`*`.repeat(4)})]})]})},zc=({address:e,domain:a,imageSrc:o,imageAlt:s=`Account`,hideAddress:c=!1,balance:u,tokenAddress:d})=>{let{t:f}=(0,l.useTranslation)(),p=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),m=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),h=(0,n.useToken)(`colors`,`vechain-kit-card`),{isLoading:g}=ln({address:e}),{tokens:_,isLoading:v}=cn({address:e}),y=(0,r.useMemo)(()=>d?_.find(e=>e.address===d):null,[_,d]),b=(0,r.useMemo)(()=>u===void 0?y?Number(y.balance):0:u,[u,y]),x=y?.symbol||``;return g||v?(0,i.jsxs)(n.HStack,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:h,children:[(0,i.jsxs)(n.HStack,{children:[(0,i.jsx)(n.Skeleton,{boxSize:`40px`,borderRadius:`full`}),(0,i.jsxs)(n.VStack,{align:`start`,spacing:0,children:[(0,i.jsx)(n.Skeleton,{height:`16px`,width:`120px`,borderRadius:`md`}),!c&&(0,i.jsx)(n.Skeleton,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),(0,i.jsxs)(n.VStack,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`medium`,color:p,children:f(`Balance`)}),(0,i.jsx)(n.Skeleton,{height:`12px`,width:`80px`,borderRadius:`md`})]})]}):(0,i.jsxs)(n.HStack,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:h,children:[(0,i.jsxs)(n.HStack,{children:[(0,i.jsx)(n.Image,{src:o,alt:s,boxSize:`40px`,borderRadius:`full`,objectFit:`cover`}),(0,i.jsx)(n.VStack,{align:`start`,spacing:0,children:a?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Text,{fontWeight:`medium`,fontSize:`sm`,color:p,children:a}),!c&&(0,i.jsx)(n.Text,{fontSize:`xs`,color:m,children:t.W(e,6,4)})]}):(0,i.jsx)(n.Text,{fontWeight:`medium`,fontSize:`sm`,color:p,children:t.W(e,6,4)})})]}),(0,i.jsxs)(n.VStack,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`medium`,color:p,children:f(`Balance`)}),(0,i.jsxs)(n.Text,{fontSize:`xs`,color:m,children:[b.toLocaleString(void 0,{maximumFractionDigits:2}),x&&` ${x}`]})]})]})},Bc=({onClick:e,...t})=>(0,i.jsx)(n.IconButton,{"aria-label":`FAQ`,icon:(0,i.jsx)(n.Icon,{as:g.LuCircleHelp,fontSize:`17px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,lineHeight:`normal`,left:`10px`,top:`8px`,onClick:e,...t}),Vc=({children:e,...t})=>(hs(),(0,i.jsx)(n.VStack,{...t,children:e})),Hc=({wallet:e,props:t})=>{let a=(0,r.useRef)(e?.image),o=(0,r.useRef)(e?.address);return(0,r.useEffect)(()=>{o.current!==e?.address&&(a.current=e?.image,o.current=e?.address)},[e?.address]),(0,r.useEffect)(()=>{e?.image&&!e.isLoadingMetadata&&(a.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!a.current||e?.isLoadingMetadata?(0,i.jsx)(n.Skeleton,{rounded:`full`,width:t?.width,height:t?.height}):(0,i.jsx)(n.Image,{src:t?.src||e?.image||a.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Uc=({transactionError:e,isSubmitting:a,isTxWaitingConfirmation:o,onConfirm:s,onRetry:c,transactionPendingText:u,txReceipt:d,isSubmitForm:f=!1,buttonText:p,isDisabled:m=!1,style:h,onError:g,gasEstimationError:_,hasEnoughGasBalance:v=!0,isLoadingGasEstimation:y=!1,showGasEstimationError:b=!1,context:x=`transaction`})=>{let{t:S}=(0,l.useTranslation)(),{darkMode:C}=$(),{network:w}=$(),T=(0,r.useMemo)(()=>e?e.reason||S(`Something went wrong. Please try again.`):null,[e,S]);(0,r.useEffect)(()=>{T&&g?.(T)},[T,g]);let E=(0,r.useMemo)(()=>{if(h?.accentColor)return`${h.accentColor} !important`},[h?.accentColor]),D=(0,r.useMemo)(()=>{if(!b||y||!(_||v))return null;if(!v&&!_)return{message:S(`You don't have any gas tokens enabled. Please enable at least one gas token in Gas Token Preferences.`)};if(_){let e=``;switch(x){case`send`:e=S(`Insufficient balance to complete this transfer and cover gas fees.`);break;case`customization`:e=S(`Insufficient balance to update your profile and cover gas fees.`);break;case`domain`:e=S(`Insufficient balance to claim this domain and cover gas fees.`);break;default:e=S(`Insufficient balance to complete this transaction and cover gas fees.`)}return{message:e}}return null},[_,v,y,b,x,S]);return(0,i.jsxs)(n.VStack,{width:`full`,spacing:4,children:[T&&(0,i.jsx)(n.Box,{p:3,borderRadius:`md`,bg:C?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:C?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:(0,i.jsx)(n.Text,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:T})}),D&&!T&&(0,i.jsx)(n.Box,{p:3,borderRadius:`md`,bg:C?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:C?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:(0,i.jsx)(n.Text,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:D.message})}),(0,i.jsx)(n.Button,{px:4,variant:T?`vechainKitSecondary`:`vechainKitPrimary`,bg:E,onClick:()=>T&&c?c():s(),type:f?`submit`:`button`,isLoading:a,isDisabled:m,loadingText:o?S(`Waiting wallet confirmation...`):u,"data-testid":`confirm-button`,children:T?S(`Retry`):p||S(`Confirm`)}),T&&d?.meta.txID&&(0,i.jsx)(n.Link,{isExternal:!0,fontSize:`sm`,color:C?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${t.bt(w.type).explorerUrl}/${d?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:S(`View transaction on the explorer`)})]})},Wc=({onClick:e,hasUnreadNotifications:t,...r})=>(0,i.jsx)(n.IconButton,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:(0,i.jsxs)(n.Box,{position:`relative`,children:[(0,i.jsx)(g.LuBell,{fontSize:`20px`}),t&&(0,i.jsx)(n.Box,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...r}),Gc=({isOpen:e,onClose:a,selectedToken:o,onTokenSelect:s,availableTokens:c,tokenEstimations:u,walletAddress:d})=>{let{t:f}=(0,l.useTranslation)(),{balances:p}=Yt(d),[m,h]=r.default.useState(o),[g,_]=r.default.useState(!1),v=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),y=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),b=(0,n.useToken)(`colors`,`vechain-kit-text-tertiary`),x=(0,n.useToken)(`colors`,`vechain-kit-error`),S=e=>e?b:`transparent`,C=e=>e?v:`transparent`;r.default.useEffect(()=>{e&&(h(o),_(!1))},[e,o]);let w=()=>{s(m,g),a()},T=e=>{let t=p.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},E=e=>{let t=p.find(t=>t.symbol===e),n=u[e];return!t||!n?!1:Number(t.balance)<n.cost};return(0,i.jsxs)(Je,{isOpen:e,onClose:a,size:`sm`,children:[(0,i.jsxs)(n.ModalHeader,{children:[(0,i.jsx)(n.Text,{fontSize:`lg`,fontWeight:`semibold`,color:v,children:f(`Fee token`)}),(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`normal`,color:y,mt:1,children:f(`Select the token to pay the fee with`)})]}),(0,i.jsx)(n.ModalBody,{children:(0,i.jsxs)(n.VStack,{spacing:2,align:`stretch`,children:[c.map(e=>{let a=t.Q[e],o=m===e,s=u[e]||{cost:0,loading:!0},c=E(e);return(0,i.jsx)(n.Box,{cursor:c?`not-allowed`:`pointer`,bg:S(o),border:`1px`,borderColor:C(o),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:c?S(o):y&&`#ffffff12`,borderColor:c?C(o):y},opacity:c?.5:1,onClick:()=>!c&&h(e),children:(0,i.jsxs)(n.HStack,{spacing:3,justify:`space-between`,children:[(0,i.jsxs)(n.HStack,{spacing:3,flex:1,children:[r.default.cloneElement(t.et[e],{boxSize:`36px`,borderRadius:`full`}),(0,i.jsxs)(n.VStack,{align:`start`,spacing:0,children:[(0,i.jsx)(n.Text,{fontWeight:`medium`,color:v,children:a.symbol}),(0,i.jsxs)(n.Text,{fontSize:`xs`,color:y,children:[f(`Balance`),`:`,` `,T(e)]}),c&&(0,i.jsx)(n.Text,{fontSize:`xs`,color:x,children:f(`Insufficient balance`)})]})]}),(0,i.jsx)(n.VStack,{align:`end`,spacing:0,children:s.loading?(0,i.jsx)(n.Skeleton,{height:`16px`,width:`60px`}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`semibold`,color:v,children:t.x(s.cost,2)}),(0,i.jsx)(n.Text,{fontSize:`xs`,color:y,children:a.symbol})]})})]})},e)}),m!==o&&(0,i.jsxs)(n.FormControl,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[(0,i.jsx)(n.FormLabel,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:v,children:f(`Use this token for future transactions`)}),(0,i.jsx)(n.Switch,{id:`remember-choice`,isChecked:g,onChange:e=>_(e.target.checked),color:v})]})]})}),(0,i.jsx)(n.ModalFooter,{children:(0,i.jsxs)(n.VStack,{spacing:3,w:`full`,children:[(0,i.jsx)(n.Button,{variant:`vechainKitPrimary`,onClick:w,isDisabled:E(m),children:f(`Apply`)}),(0,i.jsx)(n.Button,{variant:`ghost`,width:`full`,onClick:a,children:f(`Cancel`)})]})})]})},Kc=({estimation:e,isLoading:a,isLoadingTransaction:o,onTokenChange:s,clauses:c=[],userSelectedToken:u})=>{let{t:d}=(0,l.useTranslation)(),{feeDelegation:f}=$(),{connection:p,account:m}=X(),{preferences:h,reorderTokenPriority:_}=Fc(),{isOpen:v,onOpen:y,onClose:b}=(0,n.useDisclosure)(),x=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),S=(0,n.useToken)(`colors`,`vechain-kit-text-secondary`),[C,w]=(0,r.useState)(()=>{let e={};return h.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:T,isLoading:E}=Lc({clauses:c,tokens:h.availableGasTokens,enabled:c.length>0});(0,r.useEffect)(()=>{!E&&T&&w(T)},[T,E]),(0,r.useEffect)(()=>{e&&w(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),(0,r.useEffect)(()=>{E&&w(h.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[E,h.availableGasTokens]);let D=(0,r.useCallback)((t,n)=>{n&&_([t,...h.tokenPriority.filter(e=>e!==t)]),s&&t!==e?.usedToken&&s(t)},[e,s,_,h.tokenPriority]);if(f?.delegatorUrl||p.isConnectedWithDappKit||h.availableGasTokens.length===0)return null;let{balances:O}=Yt(m?.address??``),k=e=>{let t=O.find(t=>t.symbol===e),n=C[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},A=e?.usedToken,j=h.availableGasTokens,M;A?M=A:u&&j.includes(u)?M=u:(M=j.find(e=>C[e]&&!C[e].loading&&!k(e)),M||=j.find(e=>C[e]&&!C[e].loading),M||=j[0]);let N=M?C[M]:void 0,P=A&&e?.transactionCost?e.transactionCost:N?.cost||0,F=M?t.Q[M]:void 0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Divider,{mt:3}),(0,i.jsxs)(n.HStack,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[(0,i.jsxs)(n.VStack,{align:`start`,spacing:0,w:`full`,children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:S,children:d(`Fee`)}),(0,i.jsx)(n.HStack,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:(0,i.jsx)(n.HStack,{justifyContent:`flex-start`,w:`full`,children:a||!A&&(!N||N.loading)||!F?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Skeleton,{height:`16px`,width:`120px`,borderRadius:`md`}),(0,i.jsx)(n.Skeleton,{height:`16px`,width:`60px`,borderRadius:`md`})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.Text,{color:x,fontSize:`sm`,fontWeight:`semibold`,children:[t.x(P,2),` `,F.symbol]}),(0,i.jsxs)(n.Text,{color:S,fontSize:`xs`,children:[`≈`,` $`,(P*.01).toFixed(2)]})]})})})]}),(0,i.jsxs)(n.Button,{onClick:y,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:o,color:S,borderColor:S,_hover:{bg:S},leftIcon:r.default.cloneElement(t.et[M||h.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`semibold`,children:M||h.availableGasTokens[0]}),(0,i.jsx)(n.Icon,{as:g.LuChevronDown,boxSize:5,color:S})]})]}),(0,i.jsx)(Gc,{isOpen:v,onClose:b,selectedToken:M||h.availableGasTokens[0],onTokenSelect:D,availableTokens:h.availableGasTokens,tokenEstimations:C,walletAddress:m?.address??``})]})},qc=P.keyframes`
|
|
201
201
|
from {
|
|
202
202
|
transform: translateY(-100%);
|
|
203
203
|
opacity: 0;
|
|
@@ -215,7 +215,7 @@ const e=require(`./assets-DNJsQD7_.cjs`),t=require(`./utils-CzaSErgL.cjs`);let n
|
|
|
215
215
|
transform: translateY(-100%);
|
|
216
216
|
opacity: 0;
|
|
217
217
|
}
|
|
218
|
-
`,Yc=({message:e,duration:t=2e3,onClose:a})=>{let[o,s]=(0,r.useState)(!0),c=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),l=(0,n.useColorModeValue)(`#f0f9ff`,`#0000009e`),u=(0,n.useColorModeValue)(`#bfdbfe`,`#3b3b3b`),d=(0,n.useToken)(`colors`,`vechain-kit-primary`);return(0,r.useEffect)(()=>{let e=setTimeout(()=>{s(!1),setTimeout(()=>{a?.()},300)},t);return()=>clearTimeout(e)},[t,a]),(0,i.jsx)(n.Box,{position:`absolute`,w:`fit-content`,margin:`auto`,animation:`${o?qc:Jc} 0.3s ease-in-out`,zIndex:10,children:(0,i.jsx)(n.Box,{bg:l,borderWidth:1,borderColor:u,borderRadius:`md`,px:4,py:3,mx:4,mt:2,children:(0,i.jsxs)(n.HStack,{spacing:3,align:`center`,children:[(0,i.jsx)(n.Icon,{as:g.LuCheck,boxSize:5,color:d,flexShrink:0}),(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`500`,color:c,flex:1,children:e})]})})})},Xc=({showFeedback:e=!1})=>{let{t}=(0,l.useTranslation)(),[n,a]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{a(!!e)},[e]),n?(0,i.jsx)(Yc,{message:t(`Account Changed`),duration:2e3,onClose:()=>{a(!1)}}):null},Zc=({isOpen:e,onClose:t,steps:r,activeStep:a,goToPrevious:o,setActiveStep:s,disableBackButton:c,disableCloseButton:l,closeOnOverlayClick:u=!0,isCloseable:d=!0})=>{let f=()=>{s(0),t()},[p]=(0,n.useMediaQuery)(`(min-width: 1060px)`),m=r[a],g=a===0,_=!g&&!c||m?.title||p&&!l;return m?(0,i.jsx)(Je,{closeOnOverlayClick:u,isOpen:e,onClose:f,isCloseable:d,blockScrollOnMount:!0,children:(0,i.jsx)(n.Card,{p:0,bg:`none`,children:(0,i.jsxs)(n.CardBody,{p:0,children:[_?(0,i.jsxs)(Y,{children:[m?.title?(0,i.jsx)(n.ModalHeader,{children:m.title}):null,!g&&!c?(0,i.jsx)(J,{onClick:o}):null,p&&!l?(0,i.jsx)(n.ModalCloseButton,{onClick:t}):null]}):null,m?.description?(0,i.jsx)(n.Text,{fontSize:{base:14,md:16},fontWeight:400,px:4,children:m?.description}):null,(0,i.jsx)(h.motion.div,{initial:`hidden`,animate:`visible`,style:{width:`100%`},children:m.content},m.key)]})})}):null},Qc=({document:e,register:t,isText:r=!1})=>{let{t:a}=(0,l.useTranslation)(),{darkMode:o}=$(),s=e.displayName??a(`Policy`),c=o?`whiteAlpha.400`:`blackAlpha.400`,u=o?`blue.300`:`blue.500`,d=o?`blue.200`:`blue.700`,f=(()=>{if(!e.documentType)return s;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 r?(0,i.jsxs)(n.Link,{href:e.url,isExternal:!0,color:`blue.500`,textDecoration:`underline`,_hover:{color:`blue.300`,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[(0,i.jsx)(n.Input,{...t(e.id,{required:e.required}),type:`checkbox`,hidden:!0}),f,(0,i.jsx)(n.Icon,{as:g.LuExternalLink,ml:1,boxSize:3})]},e.id):(0,i.jsx)(n.HStack,{width:`full`,borderRadius:`md`,transition:`all 0.2s`,children:(0,i.jsxs)(n.HStack,{align:`flex-start`,spacing:3,width:`full`,children:[(0,i.jsx)(n.Checkbox,{mt:`2px`,size:`md`,colorScheme:`blue`,borderColor:c,...t(e.id,{required:e.required}),"data-testid":`tnc-checkbox`}),(0,i.jsxs)(n.Text,{fontSize:`xs`,children:[a(`I have read and agree to `),(0,i.jsxs)(n.Link,{href:e.url,isExternal:!0,color:u,textDecoration:`underline`,_hover:{color:d,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[f,(0,i.jsx)(n.Icon,{as:g.LuExternalLink,ml:1})]}),e.required&&(0,i.jsx)(n.Text,{as:`span`,color:`red.500`,fontWeight:`bold`,children:`*`})]})]})},e.id)},$c=({onAgree:e,onReject:t,onlyOptionalDocuments:a=!1})=>{let{t:o}=(0,l.useTranslation)(),{darkMode:s}=$(),{documentsNotAgreed:c}=ll(),{requiredDocuments:u,optionalDocuments:d}=(0,r.useMemo)(()=>c.reduce((e,t)=>(t.required?e.requiredDocuments.push(t):e.optionalDocuments.push(t),e),{requiredDocuments:[],optionalDocuments:[]}),[c]),{handleSubmit:f,register:p,formState:{isValid:m},watch:h}=(0,D.useForm)({defaultValues:(0,r.useMemo)(()=>c.reduce((e,t)=>(e[t.id]=t.required,e),{}),[c])}),g=h(),_=(0,r.useMemo)(()=>c.filter(e=>g[e.id]),[c,g]),v=c?.length===_.length,y=(0,r.useCallback)(t=>{let n=new Set(Object.entries(t).filter(([e,t])=>t).map(([e])=>e));return e(c.filter(e=>n.has(e.id)))},[c,e]),b=s?`#3a3a3a`:`#eaeaea`,x=s?`#2a2a2a`:`#f5f5f5`,S=s?`gray.300`:`gray.600`,C=s?`0 2px 8px rgba(0, 0, 0, 0.2)`:`0 2px 8px rgba(0, 0, 0, 0.05)`,w=u.length>0,T=d.length>0,E=(0,r.useMemo)(()=>{let e=d.filter(e=>g[e.id]).length;return o(v?`Accept all`:a&&e===0?`Ignore and continue`:w&&!T||w&&e===0?`Accept`:`Accept selected`)},[a,v,d,g]),O=e=>e===u.length-2&&u.length>1?o(` and `):`, `;return(0,i.jsx)(n.Stack,{width:`full`,children:(0,i.jsxs)(`form`,{onSubmit:f(y),children:[(0,i.jsx)(Y,{children:(0,i.jsx)(n.ModalHeader,{children:o(`Terms and Policies`)})}),(0,i.jsx)(n.ModalBody,{children:(0,i.jsxs)(n.VStack,{align:`stretch`,spacing:5,width:`full`,children:[w&&(0,i.jsxs)(n.Text,{as:`span`,fontSize:`sm`,children:[o(`By continuing, you agree to`),` `,u.map((e,t)=>(0,i.jsxs)(r.Fragment,{children:[(0,i.jsx)(Qc,{document:e,register:p,isText:!0},e.id),t<u.length-1?O(t):null]},e.id)),`.`,` `,o(`Please take a moment to review all the policies, with acceptance being mandatory to continue.`)]}),a&&(0,i.jsx)(n.Text,{fontSize:`sm`,color:S,mb:3,children:(0,i.jsx)(l.Trans,{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:(0,i.jsx)(n.Text,{as:`span`,fontWeight:`semibold`,color:S})}})}),T&&(0,i.jsxs)(n.Stack,{p:4,borderRadius:`xl`,bg:x,borderWidth:`1px`,borderColor:b,boxShadow:C,spacing:5,children:[(0,i.jsx)(n.Text,{fontSize:`md`,fontWeight:`bold`,color:S,children:o(`Optional`)}),(0,i.jsx)(n.VStack,{align:`stretch`,spacing:4,children:d.map(e=>(0,i.jsx)(Qc,{document:e,register:p},e.id))})]})]})}),(0,i.jsx)(n.ModalFooter,{children:(0,i.jsxs)(n.VStack,{width:`full`,spacing:3,children:[(0,i.jsx)(n.Button,{variant:`vechainKitPrimary`,width:`full`,type:`submit`,isDisabled:!m,"data-testid":`accept-tnc-button`,children:E}),!a&&(0,i.jsx)(n.Button,{variant:`ghost`,width:`full`,onClick:t,"data-testid":`reject-tnc-button`,colorScheme:`red`,children:o(`Reject and logout`)})]})})]})})};var el=function(e){return e.REVIEW_DOCUMENTS=`REVIEW_DOCUMENTS`,e.REJECT_DOCUMENTS=`REJECT_DOCUMENTS`,e}(el||{});const tl=({isOpen:e,onAgree:t,handleLogout:a,onlyOptionalDocuments:o})=>{let{t:s}=(0,l.useTranslation)(),{activeStep:c,goToPrevious:u,setActiveStep:d,goToNext:f}=(0,n.useSteps)({index:0,count:Object.keys(el).length}),p=()=>{d(0)},m=()=>{f()},h=()=>{a(),p()};return(0,i.jsx)(Zc,{isOpen:e,onClose:()=>{},goToPrevious:u,goToNext:f,setActiveStep:d,steps:(0,r.useMemo)(()=>[{key:el.REVIEW_DOCUMENTS,content:(0,i.jsx)($c,{onAgree:t,onReject:m,onlyOptionalDocuments:o})},{key:el.REJECT_DOCUMENTS,content:(0,i.jsx)(zi,{onDisconnect:h,onBack:u,onClose:u,text:s(`Are you sure you want to reject the policies and disconnect?`),showCloseButton:!1})}],[$c,zi,t,h]),disableCloseButton:!0,disableBackButton:!0,isCloseable:!1,closeOnOverlayClick:!1,activeStep:c})},nl=`vechain-kit-legal-documents`,rl=`vechain-kit-legal-documents-optional-reject`,il=e=>`${e.documentType}-${e.url.replace(/[^\w-]+/g,`-`)}-v${e.version}`,al=e=>e.map(e=>({...e,id:il(e)})),ol=e=>e.filter(e=>!e.required),sl=(e,t)=>{let n=Date.now();return e.map(e=>({...e,walletAddress:t,timestamp:n}))},cl=(0,r.createContext)(void 0),ll=()=>(0,r.useContext)(cl)||{hasAgreedToRequiredDocuments:!0,agreements:[],walletAddress:void 0,documents:[],documentsNotAgreed:[]},ul=({children:e})=>{let{connection:n,account:a,disconnect:o}=X(),{darkMode:s,legalDocuments:c,theme:l}=$(),[u,d]=Ec(`vechain-kit-legal-documents`,[]),[f,p]=Ec(`vechain-kit-legal-documents-optional-reject`,[]),[m,h]=(0,r.useState)(!1),g=(0,r.useCallback)((e,n)=>f.some(r=>t.k(r.walletAddress,n)&&r.id===e.id),[f]),[_,v]=(0,r.useMemo)(()=>{let e=al([{items:c?.cookiePolicy||[],type:t.y.COOKIES,source:t.v.APPLICATION},{items:c?.privacyPolicy||[],type:t.y.PRIVACY,source:t.v.APPLICATION},{items:c?.termsAndConditions||[],type:t.y.TERMS,source:t.v.APPLICATION}].flatMap(e=>e.items.map(t=>({...t,documentType:e.type,documentSource:e.source}))));return[e,e.filter(e=>e.required)]},[c]),y=(0,r.useMemo)(()=>a?.address?_.filter(e=>u.some(n=>t.k(n.walletAddress,a.address)&&n.id===e.id)?!1:!f.some(n=>t.k(n.walletAddress,a.address)&&n.id===e.id)):[],[_,a?.address,u,f]),b=(0,r.useMemo)(()=>!v.length||!a?.address?!0:v.every(e=>u.some(n=>t.k(n.walletAddress,a.address)&&n.id===e.id)),[v,u,a?.address]),x=(0,r.useMemo)(()=>{if(!a?.address||!y?.length)return!1;let e=ol(y);return e.length===0?!1:e.some(e=>!g(e,a.address))},[y,a?.address,ol,g]),S=(0,r.useMemo)(()=>b&&x,[b,x]);(0,r.useMemo)(()=>{let e=new Set(u.map(e=>e.id));return _.some(t=>e.has(t.id))},[_,u]),(0,r.useEffect)(()=>{n.isConnected&&a?.address?h(!b||x):h(!1)},[n.isConnected,a?.address,b,x]);let C=(0,r.useCallback)((e,n)=>{let r=Array.isArray(e)?e:[e];if(!r.length)return;let i=sl(r,n);d([...u.filter(e=>!t.k(e.walletAddress,n)||!r.some(t=>t.id===e.id)),...i])},[u,sl]),w=(0,r.useCallback)(e=>{if(!a?.address)return;let t=ol(y);if(t.length===0)return;let n=e.map(e=>e.id),r=t.filter(e=>!n.includes(e.id));if(!r?.length)return;let i=sl(r,a.address);p(e=>[...e,...i])},[a?.address,y,ol,sl]),T=(0,r.useCallback)(e=>{if(!a?.address)return;let t=Array.isArray(e)?e:[e];t.length>0&&C(t,a.address),w(t),h(!1)},[a?.address,C,w]);return(0,i.jsxs)(cl.Provider,{value:{hasAgreedToRequiredDocuments:b,agreements:u,walletAddress:a?.address,documents:_,documentsNotAgreed:y},children:[e,(0,i.jsx)(lo,{darkMode:s,theme:l,children:(0,i.jsx)(tl,{isOpen:m,onAgree:T,handleLogout:S?()=>{}:()=>{o(),h(!1)},onlyOptionalDocuments:S})})]})},dl=(0,r.createContext)(null),fl=({children:e,nodeUrl:n,delegatorUrl:a=t.st(),delegateAllTransactions:o,genericDelegator:s})=>{let{signTypedData:c,exportWallet:l,signMessage:d}=(0,u.usePrivy)(),{signTypedData:f,signMessage:p}=Vn(),{connection:m,connectedWallet:h}=X(),{network:g}=$(),{data:_}=Us(h?.address??``),{data:v}=As(_?.address??``,h?.address??``),{data:y}=Fs(h?.address??``),{buildClausesWithAuth:b}=Sc(),{sendTransactionUsingGenericDelegator:x}=Pc(),S=L.ThorClient.at(n),C=async(e,r,i,o)=>{if(!_?.address)throw Error(`Smart account address is not set`);let s=new L.VeChainProvider(S,i??new L.ProviderInternalBaseWallet([{privateKey:Buffer.from(t.V.privateKey.slice(2),`hex`),address:t.V.address}],{gasPayer:{gasPayerServiceUrl:r??a}}),!0),c=o??await s.getSigner(t.V.address),l=L.signerUtils.transactionBodyToTransactionRequestInput(e,t.V.address),u=await c.signTransaction(l),d=new URL(`transactions`,n),{id:f}=await fetch(d,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({raw:u})}).then(e=>e.json());return f},w=(0,r.useCallback)(async({txClauses:e=[],title:n=`Sign Transaction`,description:r,buttonText:i=`Sign`,delegationUrl:o})=>{if(!_||_&&!_.address||!h||h&&!h.address)throw Error(`Address or embedded wallet is missing`);if(s&&!o)return await x({clauses:e,genericDelegatorUrl:a??``});let c=await b({clauses:e,smartAccount:_,version:y?1:v?.version??3,title:n,description:r,buttonText:i}),l={clauses:c,simulateTransactionOptions:{caller:t.V.address}},u=await S.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 C(await jc(c,S,t.V,!0),o)},[x,s,_,h,a,b,y,v,S]);return(0,i.jsx)(dl.Provider,{value:{accountFactory:t.bt(g.type).accountFactoryAddress,sendTransaction:w,signMessage:async e=>m.isConnectedWithCrossApp?await p(e):(await d({message:e})).signature,signTypedData:async e=>m.isConnectedWithCrossApp?await f({...e,address:h?.address,types:Object.fromEntries(Object.entries(e.types).map(([e,t])=>[e,[...t]]))}):(await c(e)).signature,exportWallet:l,delegateAllTransactions:o},children:e})},pl=()=>{let e=(0,r.useContext)(dl);if(!e)throw Error(`usePrivyWalletProvider must be used within a PrivyWalletProvider`);return e},ml=(0,r.createContext)(null),$=()=>{let e=(0,r.useContext)(ml);if(!e)throw Error(`useVeChainKitConfig must be used within VeChainKit`);return e},hl=e=>{let n=[],r={...e};if(r.dappKit||={allowedWallets:[`veworld`]},(r.privy!==void 0||r.loginMethods?.some(e=>e.method===`vechain`||e.method===`ecosystem`))&&(r.feeDelegation?!r.feeDelegation.delegatorUrl&&!r.feeDelegation.genericDelegatorUrl&&(r.feeDelegation.genericDelegatorUrl=t.st()):r.feeDelegation={genericDelegatorUrl:t.st()}),!r.network||!r.network.type)r.network={type:`main`};else{let e=r.network.type;[`main`,`test`,`solo`].includes(e)||n.push(`network.type must be either "main", "test" or "solo"`)}if(r.loginMethods||=[{method:`vechain`,gridColumn:4},{method:`ecosystem`,gridColumn:4},{method:`dappkit`,gridColumn:4}],r.loginMethods&&!r.privy){let e=r.loginMethods.filter(e=>[`email`,`google`,`passkey`,`more`].includes(e.method));e.length>0&&n.push(`Login methods ${e.map(e=>`"${e.method}"`).join(`, `)} require Privy configuration. Please either remove these methods or configure the privy prop.`)}if(r?.legalDocuments&&(r.legalDocuments.termsAndConditions&&r.legalDocuments.termsAndConditions.forEach(e=>{t.i(e.url)||n.push(`legalDocuments.termsAndConditions.url is invalid: ${e.url}`)}),r.legalDocuments.privacyPolicy&&r.legalDocuments.privacyPolicy.forEach(e=>{t.i(e.url)||n.push(`legalDocuments.privacyPolicy.url is invalid: ${e.url}`)}),r.legalDocuments.cookiePolicy&&r.legalDocuments.cookiePolicy.forEach(e=>{t.i(e.url)||n.push(`legalDocuments.cookiePolicy.url is invalid: ${e.url}`)})),n.length>0)throw Error(`VeChainKit Configuration Error:
|
|
218
|
+
`,Yc=({message:e,duration:t=2e3,onClose:a})=>{let[o,s]=(0,r.useState)(!0),c=(0,n.useToken)(`colors`,`vechain-kit-text-primary`),l=(0,n.useColorModeValue)(`#f0f9ff`,`#0000009e`),u=(0,n.useColorModeValue)(`#bfdbfe`,`#3b3b3b`),d=(0,n.useToken)(`colors`,`vechain-kit-primary`);return(0,r.useEffect)(()=>{let e=setTimeout(()=>{s(!1),setTimeout(()=>{a?.()},300)},t);return()=>clearTimeout(e)},[t,a]),(0,i.jsx)(n.Box,{position:`absolute`,w:`fit-content`,margin:`auto`,animation:`${o?qc:Jc} 0.3s ease-in-out`,zIndex:10,children:(0,i.jsx)(n.Box,{bg:l,borderWidth:1,borderColor:u,borderRadius:`md`,px:4,py:3,mx:4,mt:2,children:(0,i.jsxs)(n.HStack,{spacing:3,align:`center`,children:[(0,i.jsx)(n.Icon,{as:g.LuCheck,boxSize:5,color:d,flexShrink:0}),(0,i.jsx)(n.Text,{fontSize:`sm`,fontWeight:`500`,color:c,flex:1,children:e})]})})})},Xc=({showFeedback:e=!1})=>{let{t}=(0,l.useTranslation)(),[n,a]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{a(!!e)},[e]),n?(0,i.jsx)(Yc,{message:t(`Account Changed`),duration:2e3,onClose:()=>{a(!1)}}):null},Zc=({isOpen:e,onClose:t,steps:r,activeStep:a,goToPrevious:o,setActiveStep:s,disableBackButton:c,disableCloseButton:l,closeOnOverlayClick:u=!0,isCloseable:d=!0})=>{let f=()=>{s(0),t()},[p]=(0,n.useMediaQuery)(`(min-width: 1060px)`),m=r[a],g=a===0,_=!g&&!c||m?.title||p&&!l;return m?(0,i.jsx)(Je,{closeOnOverlayClick:u,isOpen:e,onClose:f,isCloseable:d,blockScrollOnMount:!0,children:(0,i.jsx)(n.Card,{p:0,bg:`none`,children:(0,i.jsxs)(n.CardBody,{p:0,children:[_?(0,i.jsxs)(Y,{children:[m?.title?(0,i.jsx)(n.ModalHeader,{children:m.title}):null,!g&&!c?(0,i.jsx)(J,{onClick:o}):null,p&&!l?(0,i.jsx)(n.ModalCloseButton,{onClick:t}):null]}):null,m?.description?(0,i.jsx)(n.Text,{fontSize:{base:14,md:16},fontWeight:400,px:4,children:m?.description}):null,(0,i.jsx)(h.motion.div,{initial:`hidden`,animate:`visible`,style:{width:`100%`},children:m.content},m.key)]})})}):null},Qc=({document:e,register:t,isText:r=!1})=>{let{t:a}=(0,l.useTranslation)(),{darkMode:o}=$(),s=e.displayName??a(`Policy`),c=o?`whiteAlpha.400`:`blackAlpha.400`,u=o?`blue.300`:`blue.500`,d=o?`blue.200`:`blue.700`,f=(()=>{if(!e.documentType)return s;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 r?(0,i.jsxs)(n.Link,{href:e.url,isExternal:!0,color:`blue.500`,textDecoration:`underline`,_hover:{color:`blue.300`,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[(0,i.jsx)(n.Input,{...t(e.id,{required:e.required}),type:`checkbox`,hidden:!0}),f,(0,i.jsx)(n.Icon,{as:g.LuExternalLink,ml:1,boxSize:3})]},e.id):(0,i.jsx)(n.HStack,{width:`full`,borderRadius:`md`,transition:`all 0.2s`,children:(0,i.jsxs)(n.HStack,{align:`flex-start`,spacing:3,width:`full`,children:[(0,i.jsx)(n.Checkbox,{mt:`2px`,size:`md`,colorScheme:`blue`,borderColor:c,...t(e.id,{required:e.required}),"data-testid":`tnc-checkbox`}),(0,i.jsxs)(n.Text,{fontSize:`xs`,children:[a(`I have read and agree to `),(0,i.jsxs)(n.Link,{href:e.url,isExternal:!0,color:u,textDecoration:`underline`,_hover:{color:d,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[f,(0,i.jsx)(n.Icon,{as:g.LuExternalLink,ml:1})]}),e.required&&(0,i.jsx)(n.Text,{as:`span`,color:`red.500`,fontWeight:`bold`,children:`*`})]})]})},e.id)},$c=({onAgree:e,onReject:t,onlyOptionalDocuments:a=!1})=>{let{t:o}=(0,l.useTranslation)(),{darkMode:s}=$(),{documentsNotAgreed:c}=ll(),{requiredDocuments:u,optionalDocuments:d}=(0,r.useMemo)(()=>c.reduce((e,t)=>(t.required?e.requiredDocuments.push(t):e.optionalDocuments.push(t),e),{requiredDocuments:[],optionalDocuments:[]}),[c]),{handleSubmit:f,register:p,formState:{isValid:m},watch:h}=(0,D.useForm)({defaultValues:(0,r.useMemo)(()=>c.reduce((e,t)=>(e[t.id]=t.required,e),{}),[c])}),g=h(),_=(0,r.useMemo)(()=>c.filter(e=>g[e.id]),[c,g]),v=c?.length===_.length,y=(0,r.useCallback)(t=>{let n=new Set(Object.entries(t).filter(([e,t])=>t).map(([e])=>e));return e(c.filter(e=>n.has(e.id)))},[c,e]),b=s?`#3a3a3a`:`#eaeaea`,x=s?`#2a2a2a`:`#f5f5f5`,S=s?`gray.300`:`gray.600`,C=s?`0 2px 8px rgba(0, 0, 0, 0.2)`:`0 2px 8px rgba(0, 0, 0, 0.05)`,w=u.length>0,T=d.length>0,E=(0,r.useMemo)(()=>{let e=d.filter(e=>g[e.id]).length;return o(v?`Accept all`:a&&e===0?`Ignore and continue`:w&&!T||w&&e===0?`Accept`:`Accept selected`)},[a,v,d,g]),O=e=>e===u.length-2&&u.length>1?o(` and `):`, `;return(0,i.jsx)(n.Stack,{width:`full`,children:(0,i.jsxs)(`form`,{onSubmit:f(y),children:[(0,i.jsx)(Y,{children:(0,i.jsx)(n.ModalHeader,{children:o(`Terms and Policies`)})}),(0,i.jsx)(n.ModalBody,{children:(0,i.jsxs)(n.VStack,{align:`stretch`,spacing:5,width:`full`,children:[w&&(0,i.jsxs)(n.Text,{as:`span`,fontSize:`sm`,children:[o(`By continuing, you agree to`),` `,u.map((e,t)=>(0,i.jsxs)(r.Fragment,{children:[(0,i.jsx)(Qc,{document:e,register:p,isText:!0},e.id),t<u.length-1?O(t):null]},e.id)),`.`,` `,o(`Please take a moment to review all the policies, with acceptance being mandatory to continue.`)]}),a&&(0,i.jsx)(n.Text,{fontSize:`sm`,color:S,mb:3,children:(0,i.jsx)(l.Trans,{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:(0,i.jsx)(n.Text,{as:`span`,fontWeight:`semibold`,color:S})}})}),T&&(0,i.jsxs)(n.Stack,{p:4,borderRadius:`xl`,bg:x,borderWidth:`1px`,borderColor:b,boxShadow:C,spacing:5,children:[(0,i.jsx)(n.Text,{fontSize:`md`,fontWeight:`bold`,color:S,children:o(`Optional`)}),(0,i.jsx)(n.VStack,{align:`stretch`,spacing:4,children:d.map(e=>(0,i.jsx)(Qc,{document:e,register:p},e.id))})]})]})}),(0,i.jsx)(n.ModalFooter,{children:(0,i.jsxs)(n.VStack,{width:`full`,spacing:3,children:[(0,i.jsx)(n.Button,{variant:`vechainKitPrimary`,width:`full`,type:`submit`,isDisabled:!m,"data-testid":`accept-tnc-button`,children:E}),!a&&(0,i.jsx)(n.Button,{variant:`ghost`,width:`full`,onClick:t,"data-testid":`reject-tnc-button`,colorScheme:`red`,children:o(`Reject and logout`)})]})})]})})};var el=function(e){return e.REVIEW_DOCUMENTS=`REVIEW_DOCUMENTS`,e.REJECT_DOCUMENTS=`REJECT_DOCUMENTS`,e}(el||{});const tl=({isOpen:e,onAgree:t,handleLogout:a,onlyOptionalDocuments:o})=>{let{t:s}=(0,l.useTranslation)(),{activeStep:c,goToPrevious:u,setActiveStep:d,goToNext:f}=(0,n.useSteps)({index:0,count:Object.keys(el).length}),p=()=>{d(0)},m=()=>{f()},h=()=>{a(),p()};return(0,i.jsx)(Zc,{isOpen:e,onClose:()=>{},goToPrevious:u,goToNext:f,setActiveStep:d,steps:(0,r.useMemo)(()=>[{key:el.REVIEW_DOCUMENTS,content:(0,i.jsx)($c,{onAgree:t,onReject:m,onlyOptionalDocuments:o})},{key:el.REJECT_DOCUMENTS,content:(0,i.jsx)(zi,{onDisconnect:h,onBack:u,onClose:u,text:s(`Are you sure you want to reject the policies and disconnect?`),showCloseButton:!1})}],[$c,zi,t,h]),disableCloseButton:!0,disableBackButton:!0,isCloseable:!1,closeOnOverlayClick:!1,activeStep:c})},nl=`vechain-kit-legal-documents`,rl=`vechain-kit-legal-documents-optional-reject`,il=e=>`${e.documentType}-${e.url.replace(/[^\w-]+/g,`-`)}-v${e.version}`,al=e=>e.map(e=>({...e,id:il(e)})),ol=e=>e.filter(e=>!e.required),sl=(e,t)=>{let n=Date.now();return e.map(e=>({...e,walletAddress:t,timestamp:n}))},cl=(0,r.createContext)(void 0),ll=()=>(0,r.useContext)(cl)||{hasAgreedToRequiredDocuments:!0,agreements:[],walletAddress:void 0,documents:[],documentsNotAgreed:[]},ul=({children:e})=>{let{connection:n,account:a,disconnect:o}=X(),{darkMode:s,legalDocuments:c,theme:l}=$(),[u,d]=Ec(`vechain-kit-legal-documents`,[]),[f,p]=Ec(`vechain-kit-legal-documents-optional-reject`,[]),[m,h]=(0,r.useState)(!1),g=(0,r.useCallback)((e,n)=>f.some(r=>t.k(r.walletAddress,n)&&r.id===e.id),[f]),[_,v]=(0,r.useMemo)(()=>{let e=al([{items:c?.cookiePolicy||[],type:t.y.COOKIES,source:t.v.APPLICATION},{items:c?.privacyPolicy||[],type:t.y.PRIVACY,source:t.v.APPLICATION},{items:c?.termsAndConditions||[],type:t.y.TERMS,source:t.v.APPLICATION}].flatMap(e=>e.items.map(t=>({...t,documentType:e.type,documentSource:e.source}))));return[e,e.filter(e=>e.required)]},[c]),y=(0,r.useMemo)(()=>a?.address?_.filter(e=>u.some(n=>t.k(n.walletAddress,a.address)&&n.id===e.id)?!1:!f.some(n=>t.k(n.walletAddress,a.address)&&n.id===e.id)):[],[_,a?.address,u,f]),b=(0,r.useMemo)(()=>!v.length||!a?.address?!0:v.every(e=>u.some(n=>t.k(n.walletAddress,a.address)&&n.id===e.id)),[v,u,a?.address]),x=(0,r.useMemo)(()=>{if(!a?.address||!y?.length)return!1;let e=ol(y);return e.length===0?!1:e.some(e=>!g(e,a.address))},[y,a?.address,ol,g]),S=(0,r.useMemo)(()=>b&&x,[b,x]);(0,r.useMemo)(()=>{let e=new Set(u.map(e=>e.id));return _.some(t=>e.has(t.id))},[_,u]),(0,r.useEffect)(()=>{n.isConnected&&a?.address?h(!b||x):h(!1)},[n.isConnected,a?.address,b,x]);let C=(0,r.useCallback)((e,n)=>{let r=Array.isArray(e)?e:[e];if(!r.length)return;let i=sl(r,n);d([...u.filter(e=>!t.k(e.walletAddress,n)||!r.some(t=>t.id===e.id)),...i])},[u,sl]),w=(0,r.useCallback)(e=>{if(!a?.address)return;let t=ol(y);if(t.length===0)return;let n=e.map(e=>e.id),r=t.filter(e=>!n.includes(e.id));if(!r?.length)return;let i=sl(r,a.address);p(e=>[...e,...i])},[a?.address,y,ol,sl]),T=(0,r.useCallback)(e=>{if(!a?.address)return;let t=Array.isArray(e)?e:[e];t.length>0&&C(t,a.address),w(t),h(!1)},[a?.address,C,w]);return(0,i.jsxs)(cl.Provider,{value:{hasAgreedToRequiredDocuments:b,agreements:u,walletAddress:a?.address,documents:_,documentsNotAgreed:y},children:[e,(0,i.jsx)(lo,{darkMode:s,theme:l,children:(0,i.jsx)(tl,{isOpen:m,onAgree:T,handleLogout:S?()=>{}:()=>{o(),h(!1)},onlyOptionalDocuments:S})})]})},dl=(0,r.createContext)(null),fl=({children:e,nodeUrl:n,delegatorUrl:a=t.st(),delegateAllTransactions:o,genericDelegator:s})=>{let{signTypedData:c,exportWallet:l,signMessage:d}=(0,u.usePrivy)(),{signTypedData:f,signMessage:p}=Vn(),{connection:m,connectedWallet:h}=X(),{network:g}=$(),{data:_}=Us(h?.address??``),{data:v}=As(_?.address??``,h?.address??``),{data:y}=Fs(h?.address??``),{buildClausesWithAuth:b}=Sc(),{sendTransactionUsingGenericDelegator:x}=Pc(),S=L.ThorClient.at(n),C=async(e,r,i,o)=>{if(!_?.address)throw Error(`Smart account address is not set`);let s=new L.VeChainProvider(S,i??new L.ProviderInternalBaseWallet([{privateKey:Buffer.from(t.V.privateKey.slice(2),`hex`),address:t.V.address}],{gasPayer:{gasPayerServiceUrl:r??a}}),!0),c=o??await s.getSigner(t.V.address),l=L.signerUtils.transactionBodyToTransactionRequestInput(e,t.V.address),u=await c.signTransaction(l),d=new URL(`transactions`,n),{id:f}=await fetch(d,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({raw:u})}).then(e=>e.json());return f},w=(0,r.useCallback)(async({txClauses:e=[],title:n=`Sign Transaction`,description:r,buttonText:i=`Sign`,delegationUrl:o})=>{if(!_||_&&!_.address||!h||h&&!h.address)throw Error(`Address or embedded wallet is missing`);if(s&&!o)return await x({clauses:e,genericDelegatorUrl:a??``});let c=await b({clauses:e,smartAccount:_,version:v?.version??(y?1:3),title:n,description:r,buttonText:i}),l={clauses:c,simulateTransactionOptions:{caller:t.V.address}},u=await S.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 C(await jc(c,S,t.V,!0),o)},[x,s,_,h,a,b,y,v,S]);return(0,i.jsx)(dl.Provider,{value:{accountFactory:t.bt(g.type).accountFactoryAddress,sendTransaction:w,signMessage:async e=>m.isConnectedWithCrossApp?await p(e):(await d({message:e})).signature,signTypedData:async e=>m.isConnectedWithCrossApp?await f({...e,address:h?.address,types:Object.fromEntries(Object.entries(e.types).map(([e,t])=>[e,[...t]]))}):(await c(e)).signature,exportWallet:l,delegateAllTransactions:o},children:e})},pl=()=>{let e=(0,r.useContext)(dl);if(!e)throw Error(`usePrivyWalletProvider must be used within a PrivyWalletProvider`);return e},ml=(0,r.createContext)(null),$=()=>{let e=(0,r.useContext)(ml);if(!e)throw Error(`useVeChainKitConfig must be used within VeChainKit`);return e},hl=e=>{let n=[],r={...e};if(r.dappKit||={allowedWallets:[`veworld`]},(r.privy!==void 0||r.loginMethods?.some(e=>e.method===`vechain`||e.method===`ecosystem`))&&(r.feeDelegation?!r.feeDelegation.delegatorUrl&&!r.feeDelegation.genericDelegatorUrl&&(r.feeDelegation.genericDelegatorUrl=t.st()):r.feeDelegation={genericDelegatorUrl:t.st()}),!r.network||!r.network.type)r.network={type:`main`};else{let e=r.network.type;[`main`,`test`,`solo`].includes(e)||n.push(`network.type must be either "main", "test" or "solo"`)}if(r.loginMethods||=[{method:`vechain`,gridColumn:4},{method:`ecosystem`,gridColumn:4},{method:`dappkit`,gridColumn:4}],r.loginMethods&&!r.privy){let e=r.loginMethods.filter(e=>[`email`,`google`,`passkey`,`more`].includes(e.method));e.length>0&&n.push(`Login methods ${e.map(e=>`"${e.method}"`).join(`, `)} require Privy configuration. Please either remove these methods or configure the privy prop.`)}if(r?.legalDocuments&&(r.legalDocuments.termsAndConditions&&r.legalDocuments.termsAndConditions.forEach(e=>{t.i(e.url)||n.push(`legalDocuments.termsAndConditions.url is invalid: ${e.url}`)}),r.legalDocuments.privacyPolicy&&r.legalDocuments.privacyPolicy.forEach(e=>{t.i(e.url)||n.push(`legalDocuments.privacyPolicy.url is invalid: ${e.url}`)}),r.legalDocuments.cookiePolicy&&r.legalDocuments.cookiePolicy.forEach(e=>{t.i(e.url)||n.push(`legalDocuments.cookiePolicy.url is invalid: ${e.url}`)})),n.length>0)throw Error(`VeChainKit Configuration Error:
|
|
219
219
|
`+n.join(`
|
|
220
220
|
`));return r},gl=`vechain_kit_currency`,_l=e=>{let{children:n,privy:a,feeDelegation:o,dappKit:s,loginModalUI:c,loginMethods:l,darkMode:p=!1,i18n:m,language:h=`en`,network:g,allowCustomTokens:_,allowCommunityTokens:v=!1,legalDocuments:y,defaultCurrency:b=`usd`,theme:x,onLanguageChange:S,onCurrencyChange:C}=hl(e),w=g?.type??`main`,T=g?.nodeUrl??t.bt(w).nodeUrl,E={...g,type:w,nodeUrl:T},D=s??{allowedWallets:[`veworld`]},[O,k]=(0,r.useState)(()=>typeof window<`u`&&t.dt(`i18nextLng`)||h),[A,j]=(0,r.useState)(()=>{try{return t.dt(gl)||b}catch{return b}}),M=(0,r.useRef)(!1),N=(0,r.useRef)(!1),P=l,F=(0,r.useMemo)(()=>P?.find(e=>e.method===`ecosystem`)?.allowedApps??t.Y.map(e=>e.id),[P]),I,L;a?(I=a.appId,L=a.clientId):(I=`clzdb5k0b02b9qvzjm6jpknsc`,L=`client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF`),(0,r.useEffect)(()=>{me(pe),m&&Object.keys(m).forEach(e=>{pe.addResourceBundle(e,`translation`,m[e],!0,!0)});let e=(typeof window<`u`?t.dt(`i18nextLng`):null)||O;e&&pe.language!==e&&(M.current=!0,pe.changeLanguage(e),e!==O&&k(e),M.current=!1)},[]),(0,r.useEffect)(()=>{let e=typeof window<`u`?t.dt(`i18nextLng`):null;h&&!e&&h!==O&&(M.current=!0,pe.changeLanguage(h),k(h),M.current=!1)},[h,O]),(0,r.useEffect)(()=>{let e=e=>{!M.current&&e!==O&&(k(e),S?.(e))};return pe.on(`languageChanged`,e),()=>{pe.off(`languageChanged`,e)}},[O,S]),(0,r.useEffect)(()=>{let e=t.dt(gl);b&&!e&&b!==A&&(N.current=!0,j(b),t.yt(gl,b),N.current=!1)},[b,A]),(0,r.useEffect)(()=>{let e=()=>{try{let e=t.dt(gl);if(e&&e!==A&&!N.current){let t=e;j(t),C?.(t)}}catch{}};e();let n=t=>{t.key===gl&&t.newValue&&e()};window.addEventListener(`storage`,n);let r=setInterval(e,500);return()=>{window.removeEventListener(`storage`,n),clearInterval(r)}},[A,C]);let R=e=>{M.current=!0,pe.changeLanguage(e),k(e),M.current=!1},z=e=>{N.current=!0,j(e),t.yt(gl,e),N.current=!1};(0,r.useEffect)(()=>{t.yt(t.rt.NETWORK,w)},[w]);let B=(0,r.useMemo)(()=>Oe(De(p),ke(x,p)),[x,p]),ee=(0,r.useMemo)(()=>je(B,p),[B,p]),V=(0,r.useMemo)(()=>Me(B,p),[B,p]);return(0,r.useEffect)(()=>{let e=Ae(B.colors.background.card,p),t=Ae(B.colors.background.cardElevated,p),n=p?`transparent`:`#ffffff`,r=p?`transparent`:`#ffffff`,i=p?`transparent`:`#ffffff`;Pe(V,B.effects.backdropFilter.modal,e,t,n,r,i,B.colors.border.default)},[V,B.effects.backdropFilter.modal,B.colors.background.card,B.colors.background.cardElevated,B.colors.border.default,p]),(0,r.useEffect)(()=>{Ne()},[]),(0,i.jsxs)(Le,{children:[(0,i.jsx)(d.ReactQueryDevtools,{initialIsOpen:!1}),(0,i.jsx)(Bn,{privyEcosystemAppIDS:F,children:(0,i.jsx)(ml.Provider,{value:{privy:a,privyEcosystemAppIDS:F,feeDelegation:o,dappKit:D,loginModalUI:c,loginMethods:P,darkMode:p,i18n:m,currentLanguage:O,network:E,allowCustomTokens:_,allowCommunityTokens:v,legalDocuments:y,currentCurrency:A,theme:x,setLanguage:R,setCurrency:z},children:(0,i.jsx)(u.PrivyProvider,{appId:I,clientId:L,config:{loginMethodsAndOrder:{primary:a?.loginMethods.slice(0,4)??[],overflow:a?.loginMethods.slice(4)??[]},externalWallets:{walletConnect:{enabled:!1}},appearance:{theme:p?`dark`:`light`,accentColor:a?.appearance.accentColor??(B.buttons.primaryButton.bg?.startsWith(`#`)?B.buttons.primaryButton.bg:p?`#3182CE`:`#2B6CB0`),loginMessage:a?.appearance.loginMessage,logo:a?.appearance.logo},embeddedWallets:{createOnLogin:a?.embeddedWallets?.createOnLogin??`all-users`},passkeys:{shouldUnlinkOnUnenrollMfa:!1},customOAuthRedirectUrl:a?.customOAuthRedirectUrl},children:(0,i.jsx)(f.DAppKitProvider,{node:E.nodeUrl,alwaysShowConnect:!0,v2Api:{enabled:D.v2Api?.enabled??!0,external:D.v2Api?.external??!1},language:O,logLevel:D.logLevel,modalParent:D.modalParent,onSourceClick:D.onSourceClick,usePersistence:D.usePersistence??!0,allowedWallets:D.allowedWallets,walletConnectOptions:D.walletConnectOptions,themeMode:p?`DARK`:`LIGHT`,themeVariables:D.themeVariables?{...ee,...D.themeVariables}:ee,children:(0,i.jsx)(fl,{nodeUrl:E.nodeUrl,delegatorUrl:o?.delegatorUrl??o?.genericDelegatorUrl,delegateAllTransactions:o?.delegateAllTransactions??!1,genericDelegator:!!(!o?.delegatorUrl&&o?.genericDelegatorUrl),children:(0,i.jsx)(fo,{children:(0,i.jsx)(ul,{children:n})})})})})})})]})};exports.AccountAvatar=Hc,exports.AccountCustomizationModalProvider=Io,exports.AccountDetailsButton=si,exports.AccountMainContent=Ur,exports.AccountModal=ba,exports.AccountModalProvider=go,exports.AccountSelector=ci,exports.ActionButton=Z,exports.AddressDisplay=Re,exports.AddressDisplayCard=zc,exports.AssetButton=Rc,exports.AssetsContent=wi,exports.BalanceSection=ui,exports.BaseModal=Je,exports.BetterSwapLogo=e.n,exports.BridgeContent=Ei,exports.CURRENCY_SYMBOLS=t.C,exports.ChangeCurrencyContent=Di,exports.ChooseNameContent=$r,exports.ChooseNameModalProvider=wo,exports.ChooseNameSearchContent=ri,exports.ChooseNameSummaryContent=ii,exports.ColorModeSync=co,exports.ConnectModal=wa,exports.ConnectModalProvider=mo,exports.ConnectPopover=Ea,exports.ConnectionButton=Ta,exports.CrossAppConnectionSecurityCard=_i,exports.CustomizationContent=vi,exports.CustomizationSummaryContent=yi,Object.defineProperty(exports,`DAppKitWalletButton`,{enumerable:!0,get:function(){return f.WalletButton}}),exports.DappKitButton=Rr,exports.DisconnectConfirmContent=zi,exports.DomainRequiredAlert=gi,exports.ENS_TEXT_RECORDS=t.S,exports.EcosystemButton=Vr,exports.EcosystemContent=Ca,exports.EmailLoginButton=Mr,exports.ErrorContent=Sa,exports.ExchangeWarningAlert=hi,exports.ExploreEcosystemModalProvider=Ao,exports.FAQContent=oi,exports.FAQModalProvider=Po,exports.FeatureAnnouncementCard=mi,exports.GasFeeSummary=Kc,exports.GasFeeTokenSelector=Gc,exports.GasTokenSettingsContent=ji,exports.GitHubLogo=e.X,exports.GoogleLogo=e.Z,exports.InlineFeedback=Yc,exports.LanguageSettingsContent=Oi,exports.LegalDocumentItem=Qc,exports.LegalDocumentSource=t.v,exports.LegalDocumentType=t.y,exports.LegalDocumentsModal=tl,exports.LegalDocumentsProvider=ul,exports.LoadingContent=xa,exports.LocalStorageKey=Cc,exports.LoginWithGithubButton=Pr,exports.LoginWithGoogleButton=Nr,exports.MAX_IMAGE_SIZE=Qn,exports.MainContent=Hr,exports.ManageCustomTokenContent=Ti,exports.ModalBackButton=J,exports.ModalFAQButton=Bc,exports.ModalNotificationButton=Wc,exports.ModalProvider=fo,exports.NFTMediaType=t.w,exports.NotificationsModalProvider=Mo,exports.PRICE_FEED_IDS=Xt,exports.PasskeyLoginButton=Lr,exports.PrivyButton=zr,exports.PrivyLogo=e.i,exports.PrivyWalletProvider=fl,exports.ProfileContent=Si,exports.ProfileModalProvider=Uo,exports.QuickActionsSection=pi,exports.ReceiveModalProvider=Ro,exports.ReceiveTokenContent=Jr,exports.RemoveWalletConfirmContent=Ui,exports.ScrollToTopWrapper=Vc,exports.SelectTokenContent=Wr,exports.SelectWalletContent=Hi,exports.SendTokenContent=Kr,exports.SendTokenModalProvider=Eo,exports.SendTokenSummaryContent=qr,exports.SettingsContent=Mi,exports.SettingsModalProvider=Go,exports.ShareButtons=ha,exports.SocialIcons=Aa,exports.StickyFooterContainer=Ge,exports.StickyHeaderContainer=Y,exports.SwapTokenContent=Qr,exports.SwapTokenModalProvider=Oo,exports.TermsAndPrivacyContent=Ri,Object.defineProperty(exports,`ThorClient`,{enumerable:!0,get:function(){return L.ThorClient}}),exports.TransactionButtonAndStatus=Uc,exports.TransactionModal=_a,exports.TransactionModalContent=ga,exports.TransactionModalProvider=vo,exports.TransactionToast=Ma,exports.TransactionToastProvider=bo,exports.TwitterLogo=e.Y,exports.UpgradeSmartAccountContent=Ci,exports.UpgradeSmartAccountModal=Fa,exports.UpgradeSmartAccountModalProvider=Vo,exports.VETLogo=e.P,exports.VTHOLogo=e.N,exports.VeBetterIcon=e.F,exports.VeBetterIconDark=e.I,exports.VeBetterIconLight=e.L,exports.VeBetterLogo=e.R,exports.VeBetterLogoDark=e.z,exports.VeBetterLogoLight=e.B,exports.VeChainKitContext=ml,exports.VeChainKitProvider=_l,exports.VeChainLoginButton=Ir,exports.VeChainWithPrivyLoginButton=Fr,exports.VePassportUserStatus=t.T,exports.VeTradeLogo=e.t,exports.VeWorldLogoDark=e.j,exports.VeWorldLogoLight=e.M,exports.VechainEnergy=e.r,exports.VechainIcon=e.V,exports.VechainIconDark=e.H,exports.VechainIconLight=e.U,exports.VechainKitThemeProvider=lo,exports.VechainLogo=e.J,exports.VechainLogoDark=e.q,exports.VechainLogoHorizontalDark=e.G,exports.VechainLogoHorizontalLight=e.W,exports.VechainLogoLight=e.K,exports.VersionFooter=He,exports.WalletButton=ka,exports.WalletModalProvider=So,exports.WalletSwitchFeedback=Xc,exports.buildBatchAuthorizationTypedData=yc,exports.buildCallClauses=t.t,exports.buildClauses=jt,exports.buildERC20Clauses=cc,exports.buildSingleAuthorizationTypedData=bc,exports.buildVETClauses=uc,exports.buildVetDomainClauses=pt,exports.calculateTotalCost=t.b,exports.compressImages=ar,exports.currentBlockQueryKey=Qs,exports.decodeEventLog=gc,exports.decodeRawTx=Nc,exports.delegateAuthorized=Ac,exports.estimateAndBuildTxBody=jc,exports.estimateGas=Oc,exports.executeCallClause=t.n,exports.executeMultipleClausesCall=t.r,exports.fetchAppHubApps=rs,exports.fetchPrivyAppInfo=Ye,exports.fetchPrivyStatus=Qe,exports.formatGasCost=t.x,exports.getAccountAddress=Ts,exports.getAccountAddressQueryKey=Es,exports.getAccountBalance=gs,exports.getAccountBalanceQueryKey=_s,exports.getAccountImplementationAddress=ys,exports.getAccountImplementationAddressQueryKey=bs,exports.getAccountVersionQueryKey=ks,exports.getAllEventLogs=oc,exports.getAppHubAppsQueryKey=ns,exports.getAvatarLegacy=Ht,exports.getAvatarLegacyQueryKey=Ut,exports.getAvatarOfAddressQueryKey=Rt,exports.getAvatarQueryKey=wt,exports.getB3trBalanceQueryKey=vn,exports.getCallClauseQueryKey=as,exports.getCallClauseQueryKeyWithArgs=ss,exports.getChainId=tc,exports.getChainIdQueryKey=nc,exports.getConfig=t.bt,exports.getCurrentAccountImplementationVersion=Ss,exports.getCurrentAccountImplementationVersionQueryKey=Cs,exports.getCurrentAllocationsRoundIdQueryKey=fn,exports.getCustomTokenBalanceQueryKey=bn,exports.getCustomTokenInfoQueryKey=hn,exports.getDepositAccount=kc,exports.getDomainsOfAddress=xt,exports.getDomainsOfAddressQueryKey=St,exports.getEnsRecordExistsQueryKey=rt,exports.getErc20BalanceQueryKey=Sn,exports.getEventLogs=ac,exports.getEventsKey=_c,exports.getHasV1SmartAccount=Ns,exports.getHasV1SmartAccountQueryKey=Ps,exports.getIpfsImage=$n,exports.getIpfsImageQueryKey=er,exports.getIpfsMetadata=Yn,exports.getIpfsMetadataQueryKey=Xn,exports.getIsDeployed=Is,exports.getIsDeployedQueryKey=Ls,exports.getIsDomainProtectedQueryKey=ht,exports.getIsPersonQueryKey=En,exports.getPrivyAppInfoQueryKey=Xe,exports.getResolverAddressQueryKey=Nt,exports.getRoundXAppsQueryKey=An,exports.getSmartAccount=Vs,exports.getSmartAccountQueryKey=Hs,exports.getTextRecords=Dt,exports.getTextRecordsQueryKey=Ot,exports.getTokenInfo=mn,exports.getTokenUsdPrice=Zt,exports.getTokenUsdPriceQueryKey=Qt,exports.getUpgradeRequired=Ws,exports.getUpgradeRequiredForAccount=qs,exports.getUpgradeRequiredForAccountQueryKey=Js,exports.getUpgradeRequiredQueryKey=Gs,exports.getVechainDomainQueryKey=et,exports.getVot3BalanceQueryKey=wn,exports.getXAppMetadata=Kn,exports.getXAppsSharesQueryKey=Pn,exports.imageCompressionOptions=ir,exports.signVip191Transaction=Mc,exports.txReceiptQueryKey=mc,exports.useAccountBalance=vs,exports.useAccountCustomizationModal=Fo,exports.useAccountImplementationAddress=xs,exports.useAccountModal=ho,exports.useAccountModalOptions=Gr,exports.useAppHubApps=is,exports.useBuildClauses=Sc,exports.useBuildTransaction=fc,exports.useCallClause=cs,exports.useChooseNameModal=Co,exports.useClaimVeWorldSubdomain=ut,exports.useClaimVetDomain=mt,exports.useConnectModal=po,exports.useCrossAppConnectionCache=Zo,exports.useCurrency=sn,exports.useCurrentAccountImplementationVersion=ws,exports.useCurrentAllocationsRoundId=pn,exports.useCurrentBlock=ec,exports.useCurrentCurrency=ds,exports.useCurrentLanguage=us,exports.useCustomTokens=_n,Object.defineProperty(exports,`useDAppKitWallet`,{enumerable:!0,get:function(){return f.useWallet}}),Object.defineProperty(exports,`useDAppKitWalletModal`,{enumerable:!0,get:function(){return f.useWalletModal}}),exports.useEcosystemShortcuts=Dc,exports.useEnsRecordExists=it,exports.useEstimateAllTokens=Lc,exports.useEvents=vc,exports.useExploreEcosystemModal=ko,exports.useFAQModal=No,exports.useFeatureAnnouncement=fs,exports.useFetchAppInfo=Ze,exports.useFetchPrivyStatus=$e,exports.useGasEstimate=cr,exports.useGasTokenSelection=Fc,exports.useGenericDelegator=Pc,exports.useGenericDelegatorFeeEstimation=Ic,exports.useGetAccountAddress=Ds,exports.useGetAccountVersion=As,exports.useGetAvatar=Tt,exports.useGetAvatarLegacy=Gt,exports.useGetAvatarOfAddress=zt,exports.useGetB3trBalance=yn,exports.useGetChainId=rc,exports.useGetCustomTokenBalances=xn,exports.useGetCustomTokenInfo=gn,exports.useGetDomainsOfAddress=Ct,exports.useGetErc20Balance=Cn,exports.useGetNodeUrl=ps,exports.useGetResolverAddress=Pt,exports.useGetTextRecords=kt,exports.useGetTokenUsdPrice=$t,exports.useGetVot3Balance=Tn,exports.useHasV1SmartAccount=Fs,exports.useIpfsImage=tr,exports.useIpfsImageList=nr,exports.useIpfsMetadata=Zn,exports.useIpfsMetadatas=rr,exports.useIsDomainProtected=vt,exports.useIsPWA=ms,exports.useIsPerson=Dn,exports.useIsSmartAccountDeployed=Rs,exports.useLegalDocuments=ll,exports.useLocalStorage=wc,exports.useLoginModalContent=zo,exports.useLoginWithOAuth=Xo,exports.useLoginWithPasskey=Jo,exports.useLoginWithVeChain=Qo,Object.defineProperty(exports,`useMfaEnrollment`,{enumerable:!0,get:function(){return u.useMfaEnrollment}}),exports.useModal=Q,exports.useMostVotedAppsInRound=In,exports.useMultipleClausesCall=ls,exports.useNotificationAlerts=Qi,exports.useNotifications=$i,exports.useNotificationsModal=jo,Object.defineProperty(exports,`usePrivy`,{enumerable:!0,get:function(){return u.usePrivy}}),exports.usePrivyWalletProvider=pl,exports.useProfileModal=Ho,exports.useReceiveModal=Lo,exports.useRefreshBalances=Wn,exports.useRefreshFactoryQueries=zs,exports.useRefreshMetadata=at,exports.useRefreshSmartAccountQueries=Bs,exports.useRoundXApps=jn,exports.useScrollToTop=hs,exports.useSendTokenModal=To,exports.useSendTransaction=lr,Object.defineProperty(exports,`useSetWalletRecovery`,{enumerable:!0,get:function(){return u.useSetWalletRecovery}}),exports.useSettingsModal=Wo,exports.useSignMessage=Ko,exports.useSignTypedData=qo,exports.useSingleImageUpload=sr,exports.useSmartAccount=Us,exports.useStickyHeaderContext=We,exports.useSwapQuotes=Ar,exports.useSwapTokenModal=Do,exports.useSwapTransaction=ur,exports.useSwitchWallet=Gn,exports.useSyncableLocalStorage=Ec,Object.defineProperty(exports,`useThor`,{enumerable:!0,get:function(){return f.useThor}}),exports.useTokenBalances=Yt,exports.useTokenPrices=en,exports.useTokensWithValues=cn,exports.useTotalBalance=ln,exports.useTransactionModal=_o,exports.useTransactionToast=yo,exports.useTransferERC20=lc,exports.useTransferVET=dc,exports.useTxReceipt=hc,exports.useUnsetDomain=Jt,exports.useUpdateTextRecord=Mt,exports.useUpgradeRequired=Ks,exports.useUpgradeRequiredForAccount=Ys,exports.useUpgradeSmartAccount=Zs,exports.useUpgradeSmartAccountModal=Bo,exports.useUploadImages=or,exports.useVeChainKitConfig=$,exports.useVechainDomain=tt,exports.useVechainKitThemeConfig=so,exports.useWallet=X,exports.useWalletMetadata=Hn,exports.useWalletModal=xo,exports.useWalletStorage=Un,exports.useXAppMetadata=Jn,exports.useXAppsShares=Fn;
|
|
221
221
|
//# sourceMappingURL=index.cjs.map
|