@initia/interwovenkit-react 2.11.1 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +4965 -4902
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@privy-io/cross-app-connect/rainbow-kit`),l=require(`wagmi`),u=require(`@tanstack/react-query`),d=require(`@initia/utils`),f=require(`bignumber.js`);f=s(f);let p=require(`ramda`),m=require(`@lukemorales/query-key-factory`),h=require(`ky`);h=s(h);let g=require(`react`),_=require(`@cosmjs/encoding`),v=require(`@mysten/bcs`),y=require(`react/jsx-runtime`),b=require(`jotai`),x=require(`@amplitude/analytics-browser`);x=s(x);let S=require(`@cosmjs/amino/build/signdoc`),C=require(`@cosmjs/crypto`),w=require(`ethers`),T=require(`@initia/initia.proto/cosmos/authz/v1beta1/tx`),E=require(`@cosmjs/amino`),D=require(`@cosmjs/proto-signing`),ee=require(`cosmjs-types/cosmos/crypto/secp256k1/keys`),O=require(`cosmjs-types/google/protobuf/any`),k=require(`viem`),A=require(`@cosmjs/math`),j=require(`@cosmjs/stargate`),te=require(`@cosmjs/tendermint-rpc`),ne=require(`cosmjs-types/cosmos/tx/signing/v1beta1/signing`),M=require(`cosmjs-types/cosmos/tx/v1beta1/tx`),re=require(`@initia/amino-converter`),ie=require(`cosmjs-types/cosmos/auth/v1beta1/auth`),ae=require(`@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant`),oe=require(`cosmjs-types/cosmos/tx/v1beta1/service`),se=require(`date-fns`),ce=require(`@initia/initia.proto/cosmos/authz/v1beta1/authz`),le=require(`@initia/initia.proto/cosmos/feegrant/v1beta1/tx`),N=require(`radix-ui`),ue=require(`usehooks-ts`),de=require(`react-error-boundary`),P=require(`clsx`);P=s(P);let F=require(`react-hook-form`),fe=require(`@base-ui/react/dialog`),pe=require(`xss`);pe=s(pe);let I=require(`@initia/icons-react`),me=require(`@react-spring/web`),he=require(`change-case`),ge=require(`@base-ui/react/select`),L=require(`@base-ui/react/collapsible`),_e=require(`nanoid`),ve=require(`react-dom`),ye=require(`psl`),be=require(`jotai/utils`),xe=require(`react-merge-refs`),Se=require(`react-number-format`),Ce=require(`react-intersection-observer`),we=require(`@noble/hashes/sha3`),Te=require(`@noble/hashes/utils`),Ee=require(`qr-code-styling`);Ee=s(Ee);let De=require(`@base-ui/react`),Oe=require(`@base-ui/react/tabs`),ke=require(`@base-ui/react/popover`),Ae=require(`cosmjs-types/cosmos/bank/v1beta1/tx`),je=require(`viem/accounts`),Me=require(`viem/chains`),Ne=require(`wagmi/connectors`);var Pe=1.4,Fe=1.05,Ie={defaultChainId:`interwoven-1`,registryUrl:`https://registry.initia.xyz`,routerApiUrl:`https://router-api.initia.xyz`,glyphUrl:`https://glyph.initia.xyz`,usernamesModuleAddress:`0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef`,lockStakeModuleAddress:`0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789`,clammVaultModuleAddress:`0xef13fcd6485529958442e833ceffbd4fcb2c489e2715d8a4c703779ba28577b6`,minityUrl:`https://portfolio-api.minity.xyz`,dexUrl:`https://dex-api.initia.xyz`,vipUrl:`https://vip-api.initia.xyz`,depositApiUrl:`https://deposit-api.initia.xyz`,onramperApiUrl:`https://deposit-api.initia.xyz/v1/onramper`,onramperApiKey:`pk_prod_01K6EJ9DA43P83T691WQ4HQKKC`,theme:`dark`},Le={defaultChainId:`initiation-2`,registryUrl:`https://registry.testnet.initia.xyz`,routerApiUrl:`https://router-api.initiation-2.initia.xyz`,glyphUrl:`https://glyph.initiation-2.initia.xyz`,usernamesModuleAddress:`0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a`,lockStakeModuleAddress:`0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264`,clammVaultModuleAddress:`0x7b7811c87e398995937f35eb7bad9a92f7ac199f025735923e1a95f05f21215a`,minityUrl:`https://portfolio-api.minity.xyz`,dexUrl:`https://dex-api.initiation-2.initia.xyz`,vipUrl:`https://vip-api.testnet.initia.xyz`,depositApiUrl:void 0,onramperApiUrl:void 0,onramperApiKey:void 0,theme:`dark`,disableAnalytics:!0},Re=`cmbq1ozyc006al70lx4uciz0q`,ze={id:Re,name:`Socials`,iconUrl:`https://assets.initia.xyz/images/wallets/Privy.webp`,iconBackground:`#ffffff`},Be=(0,c.toPrivyWalletConnector)(ze),Ve=(0,c.toPrivyWallet)(ze),He=(0,g.createContext)(null);function R(){let e=(0,g.useContext)(He);if(!e)throw Error(`Check if the InterwovenKitProvider is mounted`);return e}var z={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Ue(e){if(e instanceof h.HTTPError){let{response:t}=e;if((0,p.includes)(`application/json`,t.headers.get(`content-type`)??``))try{let e=await t.json();if(e.message)return e.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if((0,p.path)([`code`],e)===4001||(0,p.path)([`code`],e)===`ACTION_REJECTED`)return`User rejected`;let t=(0,p.path)([`error`,`message`],e),n=(0,p.path)([`cause`,`message`],e),r=(0,p.path)([`shortMessage`],e);return t||n||r||e.message}return String(e)}async function We(e){return Error(await Ue(e),{cause:e})}var Ge=(0,m.createQueryKeys)(`interwovenkit:chain`,{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Ke(e){let t=(0,p.path)([0,`address`],e);if(!t)throw Error(`URL not found`);return t}function qe(e){let{chain_id:t,chain_name:n,pretty_name:r,logo_URIs:i,apis:a,metadata:o}=e,s=r||n,c=i?.png??``,{rpc:l,rest:u,"json-rpc":d,indexer:f}=a,p=Ke(l),m=Ke(u),h=Ke(f),g=o?.minitia?.type===`minievm`?Ke(d):void 0;return{...e,chainId:t,name:s,logoUrl:c,rpcUrl:p,restUrl:m,indexerUrl:h,jsonRpcUrl:g}}function Je({chainId:e,chains:t,enabled:n,error:r,isLoading:i}){if(!n)return{chain:void 0,error:null,isLoading:!1};let a=t?.find(t=>t.chain_id===e);return a?{chain:a,error:null,isLoading:!1}:r&&!t?{chain:void 0,error:r instanceof Error?r:Error(`Failed to load chains: ${String(r)}`),isLoading:!1}:i||!t?{chain:void 0,error:null,isLoading:!0}:r?{chain:void 0,error:r instanceof Error?r:Error(`Failed to load chains: ${String(r)}`),isLoading:!1}:{chain:void 0,error:Error(`Chain not found: ${e}`),isLoading:!1}}function Ye({customChain:e,defaultChainId:t,registryUrl:n}){return(0,u.queryOptions)({queryKey:Ge.list(n).queryKey,queryFn:()=>h.default.create({prefixUrl:n}).get(`chains.json`).json(),select:n=>(e?[e,...n.filter(t=>t.chain_id!==e.chain_id)]:n).map(qe).sort((0,p.descend)(e=>e.chainId===t)),staleTime:z.MINUTE})}function Xe(){let{defaultChainId:e,registryUrl:t,customChain:n}=R(),{data:r}=(0,u.useSuspenseQuery)(Ye({customChain:n,defaultChainId:e,registryUrl:t}));return r}function Ze(e){let{defaultChainId:t,registryUrl:n,customChain:r}=R();return(0,u.useQuery)({...Ye({customChain:r,defaultChainId:t,registryUrl:n}),enabled:e})}function Qe(){let{registryUrl:e}=R(),{data:t}=(0,u.useSuspenseQuery)({queryKey:Ge.profiles(e).queryKey,queryFn:()=>h.default.create({prefixUrl:e}).get(`profiles.json`).json(),staleTime:z.MINUTE});return t}function $e(){let e=B(),t=Xe(),n=Qe();return r=>{let i=t.find(e=>e.chain_id===r);if(i)return i;let a=n.find(e=>e.chain_id===r);if(!a)throw Error(`Chain not found: ${r}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,network_type:e.network_type,bech32_prefix:`init`,fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:r,name:a.pretty_name,logoUrl:a.logo,rpcUrl:``,restUrl:``,indexerUrl:``,jsonRpcUrl:``}}}function et(e){return $e()(e)}function tt(e,t){let n=Ze(t);return Je({chainId:e,chains:n.data,enabled:t,error:n.error,isLoading:n.isLoading})}function nt(){let{defaultChainId:e}=R();return et(e)}function B(){let e=Xe().find(e=>e.metadata?.is_l1);if(!e)throw Error(`Layer 1 not found`);return e}function rt(){return({chainId:e})=>(0,u.queryOptions)({queryKey:Ge.prices(e).queryKey,queryFn:()=>h.default.create({prefixUrl:`https://indexer.initia.xyz`}).get(`initia/${e}/assets`,{searchParams:{quote:`USD`,with_prices:!0}}).json(),staleTime:z.SECOND})}function it(e){return(0,u.useQuery)(rt()(e))}function at(){let e=Xe(),t=rt();return(0,u.useQueries)({queries:e.map(e=>t(e)),combine:e=>e.map(({data:e,isLoading:t,refetch:n})=>({data:e,isLoading:t,refetch:n}))})}var ot=`data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2060%2060%22%3E%0A%20%20%3Ccircle%20fill%3D%22%232F3337%22%20cx%3D%2230%22%20cy%3D%2230%22%20r%3D%2230%22%2F%3E%0A%20%20%3Cpath%20fill%3D%22%23757C82%22%20d%3D%22M26.328%2034.288v-.48c0-2.048%201.024-2.816%204.128-4.16%203.104-1.28%203.712-1.952%203.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816%200-4.416.736-4.768%203.296h-5.248c.416-5.536%204.416-7.584%209.888-7.584h.352c6.208%200%209.28%202.496%209.28%206.24v.352c0%203.392-1.28%204.96-5.376%206.592-1.504.64-2.048%201.024-2.208%201.824h-5.536ZM26.168%2042v-5.152h5.792V42h-5.792Z%22%2F%3E%0A%3C%2Fsvg%3E`,st=(0,m.createQueryKeys)(`interwovenkit:asset`,{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function ct(e){let{base:t,symbol:n,denom_units:r=[],display:i,logo_URIs:a,name:o,address:s,traces:c}=e;return{denom:t,symbol:n,decimals:r.find(e=>e.denom===i)?.exponent??r.find(e=>e.denom===t)?.exponent??(0,p.head)(r)?.exponent??0,logoUrl:a?.png??``,name:o,address:s,traces:c}}function lt(){let e=(0,u.useQueryClient)();return t=>{let n=t?.metadata?.assetlist;return(0,u.queryOptions)({queryKey:st.list(n).queryKey,queryFn:async()=>n?h.default.get(n).json():{assets:[]},select:({assets:n})=>{if(!t)return[];let r=n.map(ct);for(let n of r)e.setQueryData(st.item(t.chainId,n.denom).queryKey,n);return r},staleTime:z.MINUTE})}}function ut(e){let{data:t}=(0,u.useSuspenseQuery)(lt()(e));return t}function dt(){let e=Xe(),t=lt();return(0,u.useQueries)({queries:e.map(e=>t(e)),combine:e=>e.map(({data:e,isLoading:t,refetch:n})=>({data:e,isLoading:t,refetch:n}))})}function ft(e){let t=ut(e),n=ut(B()),r=mt(e);return e=>{let i=t.find(t=>t.denom===e);if(i)return i;let a=n.find(t=>t.denom===r(e));return a?{...a,denom:e}:{denom:e,symbol:``,decimals:0,logoUrl:ot}}}function pt(e,t){let n=ft(t);return(0,u.useQueryClient)().getQueryData(st.item(t.chainId,e).queryKey)||n(e)}function mt(e){let t=B(),n=ut(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith(`l2/`)||r.startsWith(`ibc/`)){let e=n.find(e=>e.denom===r)??n.find(e=>e.traces?.some(e=>e.counterparty.base_denom===r));if(e?.traces){for(let n of e.traces)if(n.counterparty.chain_name===t.chain_name)return n.counterparty.base_denom}}let i=t.metadata?.ibc_channels?.find(({chain_id:t,version:n})=>t===e.chain_id&&n===`ics20-1`)?.channel_id;return i?(0,d.getIbcDenom)(i,r):``}}function ht(e,t){let n=B(),r=h.default.create({prefixUrl:n.restUrl}),i=t?.failSoft??!1,a=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryFn:async()=>{try{return await r.get(`initia/move/v1/denom`,{searchParams:{metadata:e}}).json()}catch(e){if(i)return{denom:``};throw e}},queryKey:[...st.denom(n.restUrl,e).queryKey,i],select:t=>[e,t.denom],staleTime:z.INFINITY}))});return new Map(a.map(({data:e})=>e))}function gt(e){return e.pagination?.next_key??null}async function _t(e,t,n){let r=h.default.create(t),i=async(t,a)=>{let o=await r.extend(a?{searchParams:{"pagination.key":a}}:{}).get(e).json(),s=o[n]??[],c=gt(o),l=[...t,...s];return c?i(l,c):l};return i([],null)}var vt=`interwovenkit`,yt=`INIT`,bt=`iUSD`,xt=`omniINIT`,St=`strat`,Ct=`https://app.initia.xyz`,wt=`${Ct}/liquidity/my`,Tt=`${Ct}/vip/my`,Et=60*1e3,Dt=60*Et,Ot=24*Dt,V={PUBLIC_KEY:`${vt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${vt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${vt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${vt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${vt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${vt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${vt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${vt}:bridge:route-type`,BRIDGE_HISTORY:`${vt}:bridge:history`,ONRAMP_PAYMENT_TYPE_ID:`${vt}:onramp:payment-type-id`,ONRAMP_FIAT_ID:`${vt}:onramp:fiat-id`,OP_REMINDER:`${vt}:op:reminder`},kt=[yt,bt];function At(e){let t=kt.indexOf(e);return t===-1?1/0:t}var jt=`usernames`;function Mt({restUrl:e,moduleAddress:t}){let{viewFunction:n}=(0,d.createMoveClient)(e);async function r(e){if(!d.InitiaAddress.validate(e))return null;let r=await n({moduleAddress:t,moduleName:jt,functionName:`get_name_from_address`,typeArgs:[],args:[(0,_.toBase64)((0,d.InitiaAddress)(e,32).bytes)]});return r?r+`.init`:null}function i(e){return/^[A-Za-z0-9-]{3,64}\.init$/.test(e)}async function a(e){if(!i(e))return null;let r=await n({moduleAddress:t,moduleName:jt,functionName:`get_address_from_name`,typeArgs:[],args:[v.bcs.string().serialize(e.toLowerCase().replace(`.init`,``)).toBase64()]});return r?(0,d.InitiaAddress)(r).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:i}}function Nt(e,{isFeeToken:t,isListed:n}){return(0,p.sortWith)([(0,p.ascend)(({symbol:e})=>At(e)),(0,p.descend)(({denom:e})=>t(e)),(0,p.descend)(({value:e})=>e),(0,p.descend)(({denom:e})=>n(e)),({balance:e},{balance:t})=>(0,f.default)(t||0).comparedTo(e||0)??0,(0,p.ascend)(({symbol:e})=>e.toLowerCase())],e)}var Pt=(0,m.createQueryKeys)(`interwovenkit:account`,{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function Ft(){let{restUrl:e}=B(),{usernamesModuleAddress:t}=R();return Mt({restUrl:e,moduleAddress:t})}function It(){let e=U();return t=>(0,u.queryOptions)({queryKey:Pt.balances(t.restUrl,e||``).queryKey,queryFn:()=>e?_t(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},`balances`):[],staleTime:z.SECOND})}function Lt(e){let{data:t}=(0,u.useSuspenseQuery)(It()(e));return t}function Rt(){let e=Xe(),t=It();return(0,u.useQueries)({queries:e.map(e=>t(e))})}function zt(e){let t=Lt(e),n=ut(e),r=ft(e),{data:i}=it(e);return Nt(t.filter(({amount:e})=>!(0,f.default)(e||0).isZero()).map(({amount:e,denom:t})=>{let n=r(t),a=i?.find(({id:e})=>e===n?.denom)?.price??0,o=(0,f.default)(e||0).times(a).div((0,f.default)(10).pow(n.decimals)).toNumber();return{...n,balance:e,price:a,value:o}}),{isFeeToken:t=>e.fees.fee_tokens.some(e=>e.denom===t),isListed:e=>n.some(t=>t.denom===e)})}var Bt=(0,m.createQueryKeys)(`interwovenkit:deposit`,{assets:null,depositAddress:(e,t,n)=>[e,t,n],deposit:e=>[e],newDeposits:(e,t)=>[e,t],activeDeposits:e=>[e],onramperSupported:null,onramperOnramps:null,onramperGeoDefaults:null,onramperPaymentTypes:(e,t)=>[e,t],onramperQuotes:(e,t,n,r)=>[e,t,n,r],minReceived:(e,t,n,r,i)=>[e,t,n,r,i]});function Vt(){let{depositApiUrl:e}=R();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e}),[e])}function Ht(){let{onramperApiUrl:e,onramperApiKey:t}=R();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e,headers:t?{Authorization:t}:void 0}),[e,t])}function Ut(){let{onramperApiUrl:e,onramperApiKey:t}=R();return!!e&&!!t}var Wt=(0,g.createContext)(null);function Gt(){return(0,g.useContext)(Wt)}function Kt(){let{location:e}=Gt();return e}function qt(){let{path:e}=Kt();return e}function Jt(){let{state:e={}}=Kt();return e}function Yt(){let{history:e}=Gt();return e}function Xt(){let{navigate:e}=Gt();return e}function Zt(){let{reset:e}=Gt();return e}var Qt=({to:e,state:t,shouldReset:n,children:r,onClick:i,...a})=>{let o=Xt(),s=Zt(),c=r=>{r.preventDefault(),i?.(r),n?s(e,t):o(e,t)};return(0,y.jsx)(`button`,{type:`button`,...a,onClick:c,children:r})},$t=({children:e,initialEntry:t})=>{let[n,r]=(0,g.useState)([t??{path:`/`}]),i=n[n.length-1],a=(0,g.useCallback)((e,t)=>{r(n=>{if(typeof e==`string`)return[...n,{path:e,state:t}];let r=n.length+e;if(r<1)return n;let i=(0,p.take)(r,n);return t===void 0?i:(0,p.adjust)(r-1,e=>({...e,state:t}),i)})},[]),o=(0,g.useCallback)((e,t)=>{r([{path:e,state:t}])},[]);return(0,y.jsx)(Wt.Provider,{value:{location:i,history:n,navigate:a,reset:o},children:e})},en=e=>{if(!e)return null;try{let t=(0,f.default)(e);return t.isFinite()?t:null}catch{return null}},tn=({quantity:e,balance:t,decimals:n})=>{if(!e||t===void 0||n===void 0)return!1;let r=(0,d.toBaseUnit)(e,{decimals:n});return!r||(0,f.default)(r).isZero()?!1:(0,f.default)(r).gt(t||0)},nn=(0,m.createQueryKeys)(`interwovenkit:skip`,{chains:null,allAssets:()=>[`allAssets`],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:en(e.quantity)?.toString()??`0`},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function rn(){let{routerApiUrl:e}=R();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e,headers:{"InterwovenKit-Version":`2.11.1`}}),[e])}function H(e){return e.startsWith(`0x`)?e.toLowerCase():e}function an(){let{localOptions:e=[]}=Jt(),t=(0,u.useQueryClient)(),n=rn(),{data:r,isLoading:i,error:a}=(0,u.useQuery)({queryKey:nn.allAssets().queryKey,queryFn:()=>n.get(`v2/fungible/assets`).json(),staleTime:z.MINUTE});return{data:(0,g.useMemo)(()=>{if(r){let t=Object.values(r.chain_to_assets_map).flatMap(e=>e?.assets??[]),n=new Map(t.map(e=>[`${e.chain_id}:${H(e.denom)}`,e]));return e.map(({denom:e,chainId:t})=>{let r=n.get(`${t}:${H(e)}`);return{denom:e,chain_id:t,symbol:r?.symbol??``,logo_uri:r?.logo_uri??``}})}return e.map(({denom:e,chainId:n})=>{let r=t.getQueryData(st.item(n,e).queryKey);return{denom:e,chain_id:n,symbol:r?.symbol??``,logo_uri:r?.logoUrl??``}})},[e,r,t]),isLoading:i,error:a}}function on(e){return e.endsWith(`-native`)?e.replace(/-native$/,``).toUpperCase():e.startsWith(`0x`)?`${e.slice(0,6)}…${e.slice(-4)}`:e}function sn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function cn(e,t,n){return`${(0,f.default)((0,d.fromBaseUnit)(e,{decimals:t,roundingMode:f.default.ROUND_CEIL})||0).toFormat()} ${n}`}function ln(e){return`${(0,f.default)(e||0).toFormat()}%`}function un(e){return e<60?`< 1 min`:`~${Math.ceil(e/60)} min`}function dn(e,t,n){return e.dst_networks.find(e=>e.chain_id===t&&H(e.denom)===H(n))}var fn=[`move`,`evm`,`wasm`];function pn(e){return fn.includes(e)}var mn=[`waiting`,`processing`],hn=[`completed`,`failed`,`below_minimum`],gn=[...mn,...hn],_n=5e3,vn=7;function yn(e){return e.some(e=>e.dst_networks.some(e=>e.processing_time_seconds===void 0))}function bn(e){for(let t of e){if(!/^\d+$/.test(t.min_deposit_amount))throw Error(`Invalid min_deposit_amount "${t.min_deposit_amount}" for route ${t.src_chain_id}:${t.src_denom}`);if(!Number.isInteger(t.src_decimals)||t.src_decimals<0)throw Error(`Invalid src_decimals "${t.src_decimals}" for route ${t.src_chain_id}:${t.src_denom}`)}return e}function xn(e){return(0,u.queryOptions)({queryKey:Bt.assets.queryKey,queryFn:async()=>{try{let{assets:t}=await e.get(`v1/config/assets`).json();return bn(t)}catch(e){throw await We(e)}},staleTime:z.INFINITY,gcTime:z.INFINITY,retry:3,refetchInterval:e=>e.state.data&&yn(e.state.data)&&e.state.dataUpdateCount<vn?_n:!1})}function Sn(){return(0,u.useSuspenseQuery)(xn(Vt()))}function Cn(){let{depositApiUrl:e}=R(),t=Vt(),n=(0,u.useQueryClient)();return(0,g.useCallback)(()=>{e&&n.prefetchQuery(xn(t))},[e,t,n])}function wn(e,t,n){Sn();let r=(0,u.useQueryClient)().getQueryState(Bt.assets.queryKey)?.dataUpdateCount??0,i=e?dn(e,t,n)?.processing_time_seconds:void 0,a=`${e?.src_chain_id??``}:${e?.src_denom??``}:${t}:${n}`,[o,s]=(0,g.useState)({selectionKey:a,passed:!1});(o.selectionKey!==a||i!==void 0&&o.passed)&&s({selectionKey:a,passed:!1});let c=o.selectionKey===a&&o.passed;return(0,g.useEffect)(()=>{if(i!==void 0)return;let e=Math.max(0,vn-r),t=setTimeout(()=>s({selectionKey:a,passed:!0}),e*_n);return()=>clearTimeout(t)},[a,i,r]),i===void 0?c||r>=vn?{status:`unavailable`}:{status:`estimating`}:{status:`ready`,seconds:i}}function Tn(){let{registryUrl:e,defaultChainId:t}=R(),{data:n}=Sn(),r=Xe();return(0,g.useMemo)(()=>{let i=e=>r.find(t=>t.chain_id===e),a=n.flatMap(t=>t.dst_networks.filter(e=>pn(e.vm_type)).map(n=>{let r=i(n.chain_id);return{symbol:t.dst_symbol,denom:n.denom,chainId:n.chain_id,chainName:r?.pretty_name||r?.chain_name||n.chain_name,logoUrl:`${e}/images/${t.dst_symbol}.png`,chainLogoUrl:r?.logo_URIs?.png??``}})),o=new Map;for(let e of a){let n=o.get(e.symbol),r=e.chainId===t&&n?.chainId!==t;(!n||r)&&o.set(e.symbol,e)}return{assets:[...o.values()],chainAssets:a}},[n,r,e,t])}function En(e,t){let{data:n}=Sn();return n.find(n=>n.src_chain_id===e&&n.src_denom===t)}function Dn(e,t,n){return e.dst_networks.some(e=>e.chain_id===t&&H(e.denom)===H(n)&&pn(e.vm_type))}function On(e,t){let{data:n}=Sn();return(0,g.useMemo)(()=>n.filter(n=>Dn(n,e,t)),[n,e,t])}function kn({denom:e,chainId:t,symbol:n}){let{chainAssets:r}=Tn();return(0,g.useMemo)(()=>r.find(n=>H(n.denom)===H(e)&&n.chainId===t)??{symbol:n,denom:e,chainId:t,chainName:``,logoUrl:``,chainLogoUrl:``},[r,e,t,n])}var An=`c33b940c24c17e95f7d9d525d508ac61`;function jn(){let{disableAnalytics:e}=R();(0,g.useEffect)(()=>{e||x.init(An,{autocapture:!1})},[e])}function Mn(){let{connector:e}=(0,l.useAccount)(),{defaultChainId:t,disableAnalytics:n}=R();(0,g.useEffect)(()=>{let n=new x.Identify;e?.name&&n.set(`connector`,e.name),t&&n.set(`defaultChainId`,t),x.identify(n)},[t,e?.name,n])}function Nn(){let e=qt();return(0,g.useCallback)((t,n)=>{x.track(t,{path:e,...n})},[e])}function Pn(e){return e.type===`initia/PubKeyEthSecp256k1`}var Fn={...E.pubkeyType,ethsecp256k1:`initia/PubKeyEthSecp256k1`};function In(e){if(Pn(e)){let t=ee.PubKey.fromPartial({key:(0,_.fromBase64)(e.value)});return O.Any.fromPartial({typeUrl:`/initia.crypto.v1beta1.ethsecp256k1.PubKey`,value:Uint8Array.from(ee.PubKey.encode(t).finish())})}return(0,D.encodePubkey)(e)}function Ln(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw Error(`Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03`);return{type:Fn.ethsecp256k1,value:(0,_.toBase64)(e)}}function Rn(e,t){if(t.length!==64)throw Error(`Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.`);return{pub_key:Ln(e),signature:(0,_.toBase64)(t)}}function zn(e){return`Enable Auto-Sign for InterwovenKit
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@privy-io/cross-app-connect/rainbow-kit`),l=require(`wagmi`),u=require(`@tanstack/react-query`),d=require(`@initia/utils`),f=require(`bignumber.js`);f=s(f);let p=require(`ramda`),m=require(`@lukemorales/query-key-factory`),h=require(`ky`);h=s(h);let g=require(`react`),_=require(`@cosmjs/encoding`),v=require(`@mysten/bcs`),y=require(`react/jsx-runtime`),b=require(`jotai`),x=require(`@amplitude/analytics-browser`);x=s(x);let S=require(`@cosmjs/amino/build/signdoc`),C=require(`@cosmjs/crypto`),w=require(`ethers`),T=require(`@initia/initia.proto/cosmos/authz/v1beta1/tx`),E=require(`@cosmjs/amino`),D=require(`@cosmjs/proto-signing`),O=require(`cosmjs-types/cosmos/crypto/secp256k1/keys`),k=require(`cosmjs-types/google/protobuf/any`),A=require(`viem`),j=require(`@cosmjs/math`),M=require(`@cosmjs/stargate`),ee=require(`@cosmjs/tendermint-rpc`),te=require(`cosmjs-types/cosmos/tx/signing/v1beta1/signing`),N=require(`cosmjs-types/cosmos/tx/v1beta1/tx`),ne=require(`@initia/amino-converter`),re=require(`cosmjs-types/cosmos/auth/v1beta1/auth`),ie=require(`@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant`),ae=require(`cosmjs-types/cosmos/tx/v1beta1/service`),oe=require(`date-fns`),se=require(`@initia/initia.proto/cosmos/authz/v1beta1/authz`),ce=require(`@initia/initia.proto/cosmos/feegrant/v1beta1/tx`),P=require(`radix-ui`),le=require(`usehooks-ts`),ue=require(`react-error-boundary`),F=require(`clsx`);F=s(F);let I=require(`react-hook-form`),de=require(`@base-ui/react/dialog`),fe=require(`xss`);fe=s(fe);let L=require(`@initia/icons-react`),pe=require(`@react-spring/web`),me=require(`change-case`),he=require(`@base-ui/react/select`),R=require(`@base-ui/react/collapsible`),ge=require(`nanoid`),_e=require(`react-dom`),ve=require(`psl`),ye=require(`jotai/utils`),be=require(`react-merge-refs`),xe=require(`react-number-format`),Se=require(`react-intersection-observer`),Ce=require(`@noble/hashes/sha3`),we=require(`@noble/hashes/utils`),Te=require(`qr-code-styling`);Te=s(Te);let Ee=require(`@base-ui/react`),De=require(`@base-ui/react/tabs`),Oe=require(`@base-ui/react/popover`),ke=require(`cosmjs-types/cosmos/bank/v1beta1/tx`),Ae=require(`viem/accounts`),je=require(`viem/chains`),Me=require(`wagmi/connectors`);var Ne=1.4,Pe=1.05,Fe={defaultChainId:`interwoven-1`,registryUrl:`https://registry.initia.xyz`,routerApiUrl:`https://router-api.initia.xyz`,glyphUrl:`https://glyph.initia.xyz`,usernamesModuleAddress:`0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef`,lockStakeModuleAddress:`0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789`,clammVaultModuleAddress:`0xef13fcd6485529958442e833ceffbd4fcb2c489e2715d8a4c703779ba28577b6`,minityUrl:`https://portfolio-api.minity.xyz`,dexUrl:`https://dex-api.initia.xyz`,vipUrl:`https://vip-api.initia.xyz`,depositApiUrl:`https://deposit-api.initia.xyz`,onramperApiUrl:`https://deposit-api.initia.xyz/v1/onramper`,onramperApiKey:`pk_prod_01K6EJ9DA43P83T691WQ4HQKKC`,theme:`dark`},Ie={defaultChainId:`initiation-2`,registryUrl:`https://registry.testnet.initia.xyz`,routerApiUrl:`https://router-api.initiation-2.initia.xyz`,glyphUrl:`https://glyph.initiation-2.initia.xyz`,usernamesModuleAddress:`0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a`,lockStakeModuleAddress:`0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264`,clammVaultModuleAddress:`0x7b7811c87e398995937f35eb7bad9a92f7ac199f025735923e1a95f05f21215a`,minityUrl:`https://portfolio-api.minity.xyz`,dexUrl:`https://dex-api.initiation-2.initia.xyz`,vipUrl:`https://vip-api.testnet.initia.xyz`,depositApiUrl:void 0,onramperApiUrl:void 0,onramperApiKey:void 0,theme:`dark`,disableAnalytics:!0},Le=`cmbq1ozyc006al70lx4uciz0q`,Re={id:Le,name:`Socials`,iconUrl:`https://assets.initia.xyz/images/wallets/Privy.webp`,iconBackground:`#ffffff`},ze=(0,c.toPrivyWalletConnector)(Re),Be=(0,c.toPrivyWallet)(Re),Ve=(0,g.createContext)(null);function z(){let e=(0,g.useContext)(Ve);if(!e)throw Error(`Check if the InterwovenKitProvider is mounted`);return e}var B={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function He(e){if(e instanceof h.HTTPError){let{response:t}=e;if((0,p.includes)(`application/json`,t.headers.get(`content-type`)??``))try{let e=await t.json();if(e.message)return e.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if((0,p.path)([`code`],e)===4001||(0,p.path)([`code`],e)===`ACTION_REJECTED`)return`User rejected`;let t=(0,p.path)([`error`,`message`],e),n=(0,p.path)([`cause`,`message`],e),r=(0,p.path)([`shortMessage`],e),i=t||n||r||e.message;return i===Ue?We:i}return String(e)}var Ue=`Failed to initialize request`,We=`The wallet popup was blocked by the browser. Allow pop-ups for this site and try again.`;async function Ge(e){return Error(await He(e),{cause:e})}var Ke=(0,m.createQueryKeys)(`interwovenkit:chain`,{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function qe(e){let t=(0,p.path)([0,`address`],e);if(!t)throw Error(`URL not found`);return t}function Je(e){let{chain_id:t,chain_name:n,pretty_name:r,logo_URIs:i,apis:a,metadata:o}=e,s=r||n,c=i?.png??``,{rpc:l,rest:u,"json-rpc":d,indexer:f}=a,p=qe(l),m=qe(u),h=qe(f),g=o?.minitia?.type===`minievm`?qe(d):void 0;return{...e,chainId:t,name:s,logoUrl:c,rpcUrl:p,restUrl:m,indexerUrl:h,jsonRpcUrl:g}}function Ye({chainId:e,chains:t,enabled:n,error:r,isLoading:i}){if(!n)return{chain:void 0,error:null,isLoading:!1};let a=t?.find(t=>t.chain_id===e);return a?{chain:a,error:null,isLoading:!1}:r&&!t?{chain:void 0,error:r instanceof Error?r:Error(`Failed to load chains: ${String(r)}`),isLoading:!1}:i||!t?{chain:void 0,error:null,isLoading:!0}:r?{chain:void 0,error:r instanceof Error?r:Error(`Failed to load chains: ${String(r)}`),isLoading:!1}:{chain:void 0,error:Error(`Chain not found: ${e}`),isLoading:!1}}function Xe({customChain:e,defaultChainId:t,registryUrl:n}){return(0,u.queryOptions)({queryKey:Ke.list(n).queryKey,queryFn:()=>h.default.create({prefixUrl:n}).get(`chains.json`).json(),select:n=>(e?[e,...n.filter(t=>t.chain_id!==e.chain_id)]:n).map(Je).sort((0,p.descend)(e=>e.chainId===t)),staleTime:B.MINUTE})}function Ze(){let{defaultChainId:e,registryUrl:t,customChain:n}=z(),{data:r}=(0,u.useSuspenseQuery)(Xe({customChain:n,defaultChainId:e,registryUrl:t}));return r}function Qe(e){let{defaultChainId:t,registryUrl:n,customChain:r}=z();return(0,u.useQuery)({...Xe({customChain:r,defaultChainId:t,registryUrl:n}),enabled:e})}function $e(){let{registryUrl:e}=z(),{data:t}=(0,u.useSuspenseQuery)({queryKey:Ke.profiles(e).queryKey,queryFn:()=>h.default.create({prefixUrl:e}).get(`profiles.json`).json(),staleTime:B.MINUTE});return t}function et(){let e=V(),t=Ze(),n=$e();return r=>{let i=t.find(e=>e.chain_id===r);if(i)return i;let a=n.find(e=>e.chain_id===r);if(!a)throw Error(`Chain not found: ${r}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,network_type:e.network_type,bech32_prefix:`init`,fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:r,name:a.pretty_name,logoUrl:a.logo,rpcUrl:``,restUrl:``,indexerUrl:``,jsonRpcUrl:``}}}function tt(e){return et()(e)}function nt(e,t){let n=Qe(t);return Ye({chainId:e,chains:n.data,enabled:t,error:n.error,isLoading:n.isLoading})}function rt(){let{defaultChainId:e}=z();return tt(e)}function V(){let e=Ze().find(e=>e.metadata?.is_l1);if(!e)throw Error(`Layer 1 not found`);return e}function it(){return({chainId:e})=>(0,u.queryOptions)({queryKey:Ke.prices(e).queryKey,queryFn:()=>h.default.create({prefixUrl:`https://indexer.initia.xyz`}).get(`initia/${e}/assets`,{searchParams:{quote:`USD`,with_prices:!0}}).json(),staleTime:B.SECOND})}function at(e){return(0,u.useQuery)(it()(e))}function ot(){let e=Ze(),t=it();return(0,u.useQueries)({queries:e.map(e=>t(e)),combine:e=>e.map(({data:e,isLoading:t,refetch:n})=>({data:e,isLoading:t,refetch:n}))})}var st=`data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2060%2060%22%3E%0A%20%20%3Ccircle%20fill%3D%22%232F3337%22%20cx%3D%2230%22%20cy%3D%2230%22%20r%3D%2230%22%2F%3E%0A%20%20%3Cpath%20fill%3D%22%23757C82%22%20d%3D%22M26.328%2034.288v-.48c0-2.048%201.024-2.816%204.128-4.16%203.104-1.28%203.712-1.952%203.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816%200-4.416.736-4.768%203.296h-5.248c.416-5.536%204.416-7.584%209.888-7.584h.352c6.208%200%209.28%202.496%209.28%206.24v.352c0%203.392-1.28%204.96-5.376%206.592-1.504.64-2.048%201.024-2.208%201.824h-5.536ZM26.168%2042v-5.152h5.792V42h-5.792Z%22%2F%3E%0A%3C%2Fsvg%3E`,ct=(0,m.createQueryKeys)(`interwovenkit:asset`,{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function lt(e){let{base:t,symbol:n,denom_units:r=[],display:i,logo_URIs:a,name:o,address:s,traces:c}=e;return{denom:t,symbol:n,decimals:r.find(e=>e.denom===i)?.exponent??r.find(e=>e.denom===t)?.exponent??(0,p.head)(r)?.exponent??0,logoUrl:a?.png??``,name:o,address:s,traces:c}}function ut(){let e=(0,u.useQueryClient)();return t=>{let n=t?.metadata?.assetlist;return(0,u.queryOptions)({queryKey:ct.list(n).queryKey,queryFn:async()=>n?h.default.get(n).json():{assets:[]},select:({assets:n})=>{if(!t)return[];let r=n.map(lt);for(let n of r)e.setQueryData(ct.item(t.chainId,n.denom).queryKey,n);return r},staleTime:B.MINUTE})}}function dt(e){let{data:t}=(0,u.useSuspenseQuery)(ut()(e));return t}function ft(){let e=Ze(),t=ut();return(0,u.useQueries)({queries:e.map(e=>t(e)),combine:e=>e.map(({data:e,isLoading:t,refetch:n})=>({data:e,isLoading:t,refetch:n}))})}function pt(e){let t=dt(e),n=dt(V()),r=ht(e);return e=>{let i=t.find(t=>t.denom===e);if(i)return i;let a=n.find(t=>t.denom===r(e));return a?{...a,denom:e}:{denom:e,symbol:``,decimals:0,logoUrl:st}}}function mt(e,t){let n=pt(t);return(0,u.useQueryClient)().getQueryData(ct.item(t.chainId,e).queryKey)||n(e)}function ht(e){let t=V(),n=dt(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith(`l2/`)||r.startsWith(`ibc/`)){let e=n.find(e=>e.denom===r)??n.find(e=>e.traces?.some(e=>e.counterparty.base_denom===r));if(e?.traces){for(let n of e.traces)if(n.counterparty.chain_name===t.chain_name)return n.counterparty.base_denom}}let i=t.metadata?.ibc_channels?.find(({chain_id:t,version:n})=>t===e.chain_id&&n===`ics20-1`)?.channel_id;return i?(0,d.getIbcDenom)(i,r):``}}function gt(e,t){let n=V(),r=h.default.create({prefixUrl:n.restUrl}),i=t?.failSoft??!1,a=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryFn:async()=>{try{return await r.get(`initia/move/v1/denom`,{searchParams:{metadata:e}}).json()}catch(e){if(i)return{denom:``};throw e}},queryKey:[...ct.denom(n.restUrl,e).queryKey,i],select:t=>[e,t.denom],staleTime:B.INFINITY}))});return new Map(a.map(({data:e})=>e))}function _t(e){return e.pagination?.next_key??null}async function vt(e,t,n){let r=h.default.create(t),i=async(t,a)=>{let o=await r.extend(a?{searchParams:{"pagination.key":a}}:{}).get(e).json(),s=o[n]??[],c=_t(o),l=[...t,...s];return c?i(l,c):l};return i([],null)}var yt=`interwovenkit`,bt=`INIT`,xt=`iUSD`,St=`omniINIT`,Ct=`strat`,wt=`https://app.initia.xyz`,Tt=`${wt}/liquidity/my`,Et=`${wt}/vip/my`,Dt=60*1e3,Ot=60*Dt,kt=24*Ot,H={PUBLIC_KEY:`${yt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${yt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${yt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${yt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${yt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${yt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${yt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${yt}:bridge:route-type`,BRIDGE_HISTORY:`${yt}:bridge:history`,ONRAMP_PAYMENT_TYPE_ID:`${yt}:onramp:payment-type-id`,ONRAMP_FIAT_ID:`${yt}:onramp:fiat-id`,OP_REMINDER:`${yt}:op:reminder`},At=[bt,xt];function jt(e){let t=At.indexOf(e);return t===-1?1/0:t}var Mt=`usernames`;function Nt({restUrl:e,moduleAddress:t}){let{viewFunction:n}=(0,d.createMoveClient)(e);async function r(e){if(!d.InitiaAddress.validate(e))return null;let r=await n({moduleAddress:t,moduleName:Mt,functionName:`get_name_from_address`,typeArgs:[],args:[(0,_.toBase64)((0,d.InitiaAddress)(e,32).bytes)]});return r?r+`.init`:null}function i(e){return/^[A-Za-z0-9-]{3,64}\.init$/.test(e)}async function a(e){if(!i(e))return null;let r=await n({moduleAddress:t,moduleName:Mt,functionName:`get_address_from_name`,typeArgs:[],args:[v.bcs.string().serialize(e.toLowerCase().replace(`.init`,``)).toBase64()]});return r?(0,d.InitiaAddress)(r).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:i}}function Pt(e,{isFeeToken:t,isListed:n}){return(0,p.sortWith)([(0,p.ascend)(({symbol:e})=>jt(e)),(0,p.descend)(({denom:e})=>t(e)),(0,p.descend)(({value:e})=>e),(0,p.descend)(({denom:e})=>n(e)),({balance:e},{balance:t})=>(0,f.default)(t||0).comparedTo(e||0)??0,(0,p.ascend)(({symbol:e})=>e.toLowerCase())],e)}var Ft=(0,m.createQueryKeys)(`interwovenkit:account`,{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t],sequence:(e,t)=>[e,t]});function It(){let{restUrl:e}=V(),{usernamesModuleAddress:t}=z();return Nt({restUrl:e,moduleAddress:t})}function Lt(){let e=U();return t=>(0,u.queryOptions)({queryKey:Ft.balances(t.restUrl,e||``).queryKey,queryFn:()=>e?vt(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},`balances`):[],staleTime:B.SECOND})}function Rt(e){let{data:t}=(0,u.useSuspenseQuery)(Lt()(e));return t}function zt(){let e=Ze(),t=Lt();return(0,u.useQueries)({queries:e.map(e=>t(e))})}function Bt(e){let t=Rt(e),n=dt(e),r=pt(e),{data:i}=at(e);return Pt(t.filter(({amount:e})=>!(0,f.default)(e||0).isZero()).map(({amount:e,denom:t})=>{let n=r(t),a=i?.find(({id:e})=>e===n?.denom)?.price??0,o=(0,f.default)(e||0).times(a).div((0,f.default)(10).pow(n.decimals)).toNumber();return{...n,balance:e,price:a,value:o}}),{isFeeToken:t=>e.fees.fee_tokens.some(e=>e.denom===t),isListed:e=>n.some(t=>t.denom===e)})}var Vt=(0,m.createQueryKeys)(`interwovenkit:deposit`,{assets:null,depositAddress:(e,t,n)=>[e,t,n],deposit:e=>[e],newDeposits:(e,t)=>[e,t],activeDeposits:e=>[e],onramperSupported:null,onramperOnramps:null,onramperGeoDefaults:null,onramperPaymentTypes:(e,t)=>[e,t],onramperQuotes:(e,t,n,r)=>[e,t,n,r],minReceived:(e,t,n,r,i)=>[e,t,n,r,i]});function Ht(){let{depositApiUrl:e}=z();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e}),[e])}function Ut(){let{onramperApiUrl:e,onramperApiKey:t}=z();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e,headers:t?{Authorization:t}:void 0}),[e,t])}function Wt(){let{onramperApiUrl:e,onramperApiKey:t}=z();return!!e&&!!t}var Gt=(0,g.createContext)(null);function Kt(){return(0,g.useContext)(Gt)}function qt(){let{location:e}=Kt();return e}function Jt(){let{path:e}=qt();return e}function Yt(){let{state:e={}}=qt();return e}function Xt(){let{history:e}=Kt();return e}function Zt(){let{navigate:e}=Kt();return e}function Qt(){let{reset:e}=Kt();return e}var $t=({to:e,state:t,shouldReset:n,children:r,onClick:i,...a})=>{let o=Zt(),s=Qt(),c=r=>{r.preventDefault(),i?.(r),n?s(e,t):o(e,t)};return(0,y.jsx)(`button`,{type:`button`,...a,onClick:c,children:r})},en=({children:e,initialEntry:t})=>{let[n,r]=(0,g.useState)([t??{path:`/`}]),i=n[n.length-1],a=(0,g.useCallback)((e,t)=>{r(n=>{if(typeof e==`string`)return[...n,{path:e,state:t}];let r=n.length+e;if(r<1)return n;let i=(0,p.take)(r,n);return t===void 0?i:(0,p.adjust)(r-1,e=>({...e,state:t}),i)})},[]),o=(0,g.useCallback)((e,t)=>{r([{path:e,state:t}])},[]);return(0,y.jsx)(Gt.Provider,{value:{location:i,history:n,navigate:a,reset:o},children:e})},tn=e=>{if(!e)return null;try{let t=(0,f.default)(e);return t.isFinite()?t:null}catch{return null}},nn=({quantity:e,balance:t,decimals:n})=>{if(!e||t===void 0||n===void 0)return!1;let r=(0,d.toBaseUnit)(e,{decimals:n});return!r||(0,f.default)(r).isZero()?!1:(0,f.default)(r).gt(t||0)},rn=(0,m.createQueryKeys)(`interwovenkit:skip`,{chains:null,allAssets:()=>[`allAssets`],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:tn(e.quantity)?.toString()??`0`},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function an(){let{routerApiUrl:e}=z();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e,headers:{"InterwovenKit-Version":`2.12.1`}}),[e])}function on(e){return e.startsWith(`0x`)?e.toLowerCase():e}function sn(){let{localOptions:e=[]}=Yt(),t=(0,u.useQueryClient)(),n=an(),{data:r,isLoading:i,error:a}=(0,u.useQuery)({queryKey:rn.allAssets().queryKey,queryFn:()=>n.get(`v2/fungible/assets`).json(),staleTime:B.MINUTE});return{data:(0,g.useMemo)(()=>{if(r){let t=Object.values(r.chain_to_assets_map).flatMap(e=>e?.assets??[]),n=new Map(t.map(e=>[`${e.chain_id}:${on(e.denom)}`,e]));return e.map(({denom:e,chainId:t})=>{let r=n.get(`${t}:${on(e)}`);return{denom:e,chain_id:t,symbol:r?.symbol??``,logo_uri:r?.logo_uri??``}})}return e.map(({denom:e,chainId:n})=>{let r=t.getQueryData(ct.item(n,e).queryKey);return{denom:e,chain_id:n,symbol:r?.symbol??``,logo_uri:r?.logoUrl??``}})},[e,r,t]),isLoading:i,error:a}}function cn(e){return e.endsWith(`-native`)?e.replace(/-native$/,``).toUpperCase():e.startsWith(`0x`)?`${e.slice(0,6)}…${e.slice(-4)}`:e}function ln(e){return e.charAt(0).toUpperCase()+e.slice(1)}function un(e,t,n){return`${(0,f.default)((0,d.fromBaseUnit)(e,{decimals:t,roundingMode:f.default.ROUND_CEIL})||0).toFormat()} ${n}`}function dn(e){return`${(0,f.default)(e||0).toFormat()}%`}function fn(e){return e<60?`< 1 min`:`~${Math.ceil(e/60)} min`}function pn(e,t,n){return e.dst_networks.find(e=>e.chain_id===t&&on(e.denom)===on(n))}var mn=[`move`,`evm`,`wasm`];function hn(e){return mn.includes(e)}var gn=[`waiting`,`processing`],_n=[`completed`,`failed`,`below_minimum`],vn=[...gn,..._n],yn=5e3,bn=7;function xn(e){return e.some(e=>e.dst_networks.some(e=>e.processing_time_seconds===void 0))}function Sn(e){for(let t of e){if(!/^\d+$/.test(t.min_deposit_amount))throw Error(`Invalid min_deposit_amount "${t.min_deposit_amount}" for route ${t.src_chain_id}:${t.src_denom}`);if(!Number.isInteger(t.src_decimals)||t.src_decimals<0)throw Error(`Invalid src_decimals "${t.src_decimals}" for route ${t.src_chain_id}:${t.src_denom}`)}return e}function Cn(e){return(0,u.queryOptions)({queryKey:Vt.assets.queryKey,queryFn:async()=>{try{let{assets:t}=await e.get(`v1/config/assets`).json();return Sn(t)}catch(e){throw await Ge(e)}},staleTime:B.INFINITY,gcTime:B.INFINITY,retry:3,refetchInterval:e=>e.state.data&&xn(e.state.data)&&e.state.dataUpdateCount<bn?yn:!1})}function wn(){return(0,u.useSuspenseQuery)(Cn(Ht()))}function Tn(){let{depositApiUrl:e}=z(),t=Ht(),n=(0,u.useQueryClient)();return(0,g.useCallback)(()=>{e&&n.prefetchQuery(Cn(t))},[e,t,n])}function En(e,t,n){wn();let r=(0,u.useQueryClient)().getQueryState(Vt.assets.queryKey)?.dataUpdateCount??0,i=e?pn(e,t,n)?.processing_time_seconds:void 0,a=`${e?.src_chain_id??``}:${e?.src_denom??``}:${t}:${n}`,[o,s]=(0,g.useState)({selectionKey:a,passed:!1});(o.selectionKey!==a||i!==void 0&&o.passed)&&s({selectionKey:a,passed:!1});let c=o.selectionKey===a&&o.passed;return(0,g.useEffect)(()=>{if(i!==void 0)return;let e=Math.max(0,bn-r),t=setTimeout(()=>s({selectionKey:a,passed:!0}),e*yn);return()=>clearTimeout(t)},[a,i,r]),i===void 0?c||r>=bn?{status:`unavailable`}:{status:`estimating`}:{status:`ready`,seconds:i}}function Dn(){let{registryUrl:e,defaultChainId:t}=z(),{data:n}=wn(),r=Ze();return(0,g.useMemo)(()=>{let i=e=>r.find(t=>t.chain_id===e),a=n.flatMap(t=>t.dst_networks.filter(e=>hn(e.vm_type)).map(n=>{let r=i(n.chain_id);return{symbol:t.dst_symbol,denom:n.denom,chainId:n.chain_id,chainName:r?.pretty_name||r?.chain_name||n.chain_name,logoUrl:`${e}/images/${t.dst_symbol}.png`,chainLogoUrl:r?.logo_URIs?.png??``}})),o=new Map;for(let e of a){let n=o.get(e.symbol),r=e.chainId===t&&n?.chainId!==t;(!n||r)&&o.set(e.symbol,e)}return{assets:[...o.values()],chainAssets:a}},[n,r,e,t])}function On(e,t){let{data:n}=wn();return n.find(n=>n.src_chain_id===e&&n.src_denom===t)}function kn(e,t,n){return e.dst_networks.some(e=>e.chain_id===t&&on(e.denom)===on(n)&&hn(e.vm_type))}function An(e,t){let{data:n}=wn();return(0,g.useMemo)(()=>n.filter(n=>kn(n,e,t)),[n,e,t])}function jn({denom:e,chainId:t,symbol:n}){let{chainAssets:r}=Dn();return(0,g.useMemo)(()=>r.find(n=>on(n.denom)===on(e)&&n.chainId===t)??{symbol:n,denom:e,chainId:t,chainName:``,logoUrl:``,chainLogoUrl:``},[r,e,t,n])}var Mn=`c33b940c24c17e95f7d9d525d508ac61`;function Nn(){let{disableAnalytics:e}=z();(0,g.useEffect)(()=>{e||x.init(Mn,{autocapture:!1})},[e])}function Pn(){let{connector:e}=(0,l.useAccount)(),{defaultChainId:t,disableAnalytics:n}=z();(0,g.useEffect)(()=>{let n=new x.Identify;e?.name&&n.set(`connector`,e.name),t&&n.set(`defaultChainId`,t),x.identify(n)},[t,e?.name,n])}function Fn(){let e=Jt();return(0,g.useCallback)((t,n)=>{x.track(t,{path:e,...n})},[e])}function In(e){return e.type===`initia/PubKeyEthSecp256k1`}var Ln={...E.pubkeyType,ethsecp256k1:`initia/PubKeyEthSecp256k1`};function Rn(e){if(In(e)){let t=O.PubKey.fromPartial({key:(0,_.fromBase64)(e.value)});return k.Any.fromPartial({typeUrl:`/initia.crypto.v1beta1.ethsecp256k1.PubKey`,value:Uint8Array.from(O.PubKey.encode(t).finish())})}return(0,D.encodePubkey)(e)}function zn(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw Error(`Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03`);return{type:Ln.ethsecp256k1,value:(0,_.toBase64)(e)}}function Bn(e,t){if(t.length!==64)throw Error(`Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.`);return{pub_key:zn(e),signature:(0,_.toBase64)(t)}}function Vn(e,t){let n=w.ethers.hashMessage(e),r=w.ethers.SigningKey.recoverPublicKey(n,t);return C.Secp256k1.compressPubkey((0,_.fromHex)(r.replace(`0x`,``)))}function Hn(e){return`${H.PUBLIC_KEY}:${e}`}function Un(e){let t=localStorage.getItem(Hn(e));return t?(0,_.fromHex)(t):null}function Wn(e,t){try{localStorage.setItem(Hn(e),(0,_.toHex)(t))}catch{}}function Gn(e){return`Enable Auto-Sign for InterwovenKit
|
|
2
2
|
|
|
3
3
|
Origin: ${e}
|
|
4
4
|
|
|
5
|
-
Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function Bn(e,t){let n=(0,k.hexToBytes)(e);if(n.length!==65)throw Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${n.length}`);let r=(0,k.hexToBytes)((0,k.keccak256)((0,k.bytesToHex)(n.slice(0,64)))),i=C.Bip39.encode(r),a=await C.Bip39.mnemonicToSeed(i),o=(0,C.stringToPath)(`m/44'/60'/0'/0/0`),{privkey:s}=C.Slip10.derivePath(C.Slip10Curve.Secp256k1,a,o),c=await C.Secp256k1.makeKeypair(s);return{privateKey:s,publicKey:C.Secp256k1.compressPubkey(c.pubkey),address:(0,_.toBech32)(t,(0,k.hexToBytes)((0,k.keccak256)((0,k.bytesToHex)(c.pubkey.slice(1)))).slice(-20))}}function Vn(e,t){return`${e}:${t}`}var Hn=(0,b.atom)(null),Un=(0,b.atom)({}),Wn=(0,b.atom)({}),Gn=(0,b.atom)({}),Kn=(0,b.atom)(0),qn=`autosign:`;function Jn(e,t){let n=e.get(Kn)+1;return e.set(Kn,n),`${t}:${n}`}function Yn(e,t){return e.get(Gn)[t]}function Xn(e,t,n){e.set(Gn,e=>({...e,[t]:n}))}function Zn(e,t){e.set(Gn,e=>{let n={...e};return delete n[t],n})}function Qn(e,t,n){let r=Yn(e,t);!r||r.token!==n||Zn(e,t)}function $n(e,t,n){let r=Yn(e,t);return!!r&&r.token===n}function er(e,t){return e.get(Wn)[t]}function tr(e,t,n){e.set(Wn,e=>({...e,[t]:n}))}function nr(e,t){e.set(Wn,e=>{let n={...e};return delete n[t],n})}function rr(e,t,n){e.set(Un,e=>({...e,[t]:n}))}function ir(e,t){e.set(Un,e=>{let n={...e};return delete n[t],n})}function ar(e,t){return`${qn}${e}:${t}`}function or(e,t,n){try{return e.getItem(ar(t,n))}catch{return null}}function sr(e,t,n,r){try{e.setItem(ar(t,n),r)}catch{}}function cr(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function lr(e,t){let n=cr();if(n)return or(n,e,t)}function ur(e,t,n){let r=cr();r&&sr(r,e,t,n)}function dr(e){return{publicKey:e.publicKey,address:e.address}}function fr(e){e&&e.fill(0)}function pr(e){e.set(Gn,{});let t=e.get(Wn);for(let e of Object.values(t))fr(e);e.set(Wn,{}),e.set(Un,{})}function mr(e,t){return e!==``&&e!==t}function hr(){let e=U(),t=(0,b.useStore)(),n=(0,g.useRef)(e);(0,g.useEffect)(()=>{let r=n.current;mr(r,e)&&pr(t),n.current=e},[t,e])}var gr=class{constructor(e,t){this.wallet=e,this.privateKey=t}async getAccounts(){return[{address:this.wallet.address,algo:`ethsecp256k1`,pubkey:this.wallet.publicKey}]}async signAmino(e,t){if(this.wallet.address!==e)throw Error(`Signer address does not match the derived wallet address`);let n=(0,S.escapeCharacters)((0,S.sortedJsonStringify)(t)),r=(0,_.fromHex)(w.ethers.hashMessage(n).replace(`0x`,``)),i=await C.Secp256k1.createSignature(r,this.privateKey),a=new Uint8Array([...i.r(32),...i.s(32)]);return{signed:t,signature:Rn(this.wallet.publicKey,a)}}};function _r(){let e=(0,b.useStore)(),{signMessageAsync:t}=(0,l.useSignMessage)(),n=$e(),r=U();return{deriveWallet:async i=>{if(!r)throw Error(`User address not available`);let a=n(i),o=Vn(r,a.bech32_prefix),s=e.get(Un)[o];if(s&&er(e,o))return s;let c=Yn(e,o);if(c)return c.promise;let l=Jn(e,o),u=(async()=>{try{let n=window.location.origin,r=await Bn(await t({message:zn(n)}),a.bech32_prefix),i=dr(r);if($n(e,o,l))return tr(e,o,r.privateKey),rr(e,o,i),i;throw fr(r.privateKey),Error(`Wallet derivation was cancelled`)}finally{Qn(e,o,l)}})();return Xn(e,o,{promise:u,token:l}),u},getWallet:t=>{if(!r)return;let i=Vn(r,n(t).bech32_prefix);if(er(e,i))return e.get(Un)[i]},getWalletPrivateKey:t=>{if(r)return er(e,Vn(r,n(t).bech32_prefix))},clearWallet:t=>{if(!r)return;let i=Vn(r,n(t).bech32_prefix),a=er(e,i);Yn(e,i)&&Zn(e,i),fr(a),nr(e,i),ir(e,i)},clearAllWallets:()=>{pr(e)}}}function vr({granteeAddress:e,messages:t,encoder:n}){return[{typeUrl:`/cosmos.authz.v1beta1.MsgExec`,value:T.MsgExec.fromPartial({grantee:e,msgs:t.map(e=>({typeUrl:e.typeUrl,value:n.encode(e)}))})}]}async function yr({chainId:e,granterAddress:t,messages:n,fee:r,memo:i,derivedWallet:a,privateKey:o,encoder:s,signWithEthSecp256k1:c}){let l=vr({granteeAddress:a.address,messages:n,encoder:s}),u={...r,granter:t},d=new Uint8Array(o),f=new gr(a,d);try{return await c(e,a.address,l,u,i,{customSigner:f})}finally{fr(d)}}var br=(0,b.atom)(!1),xr=(0,b.atom)(!1);function Sr(){let e=Zt(),[t,n]=(0,b.useAtom)(br),r=(0,b.useSetAtom)(xr),i=Nn();return{isDrawerOpen:t,openDrawer:(t,a)=>{t&&e(t,a),r(!1),n(!0),i(`Widget Opened`)},closeDrawer:()=>{n(!1),i(`Widget Closed`)}}}function Cr(){let e=Zt(),[t,n]=(0,b.useAtom)(xr),r=(0,b.useSetAtom)(br),i=Nn();return{isModalOpen:t,openModal:(t,a)=>{t&&e(t,a),r(!1),n(!0),i(`Widget Opened`)},closeModal:()=>{n(!1),i(`Widget Closed`)}}}function wr(){let e=Xt(),{closeDrawer:t}=Sr(),{closeModal:n}=Cr(),{disconnect:r}=(0,l.useDisconnect)(),{clearAllWallets:i}=_r();return()=>{e(`/blank`),t(),n(),r(),i(),localStorage.removeItem(V.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(V.BRIDGE_SRC_DENOM),localStorage.removeItem(V.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(V.BRIDGE_DST_DENOM),localStorage.removeItem(V.BRIDGE_QUANTITY),localStorage.removeItem(V.BRIDGE_SLIPPAGE_PERCENT)}}function Tr(e){if(typeof e.amount!=`string`||typeof e.currency!=`string`)throw Error(`onramp amount and currency must be strings`);let t=e.amount.trim(),n=e.currency.trim().toLowerCase();if(!/^\d+(?:\.\d{1,2})?$/.test(t))throw Error(`onramp amount must be a non-negative decimal with at most 2 decimal places`);if(!/^[a-z]{3}$/.test(n))throw Error(`onramp currency must be a 3-letter ISO code`);return{amount:t,currency:n}}function Er(){let e=Ca(),t=nt(),{openModal:n}=Cr(),r=Cn();return i=>{if(!e)throw Error(`No wallet connected`);let{denoms:a,chainId:o,srcOptions:s,recipientAddress:c,onramp:l}=i;if(a.length===0)throw Error(`denoms cannot be empty`);let u=l?Tr(l):void 0;r();let d=o??t.chainId;n(`/deposit`,{localOptions:a.map(e=>({denom:e,chainId:d})),remoteOptions:s,recipientAddress:c,onramp:u})}}function Dr(){let e=Ca(),t=nt(),{openModal:n}=Cr();return r=>{if(!e)throw Error(`No wallet connected`);let{denoms:i,chainId:a,dstOptions:o,recipientAddress:s}=r;if(i.length===0)throw Error(`denoms cannot be empty`);let c=a??t.chainId;n(`/withdraw`,{localOptions:i.map(e=>({denom:e,chainId:c})),remoteOptions:o,recipientAddress:s})}}function Or(e){if(e?.typeUrl===`/initia.crypto.v1beta1.ethsecp256k1.PubKey`){let{key:t}=ee.PubKey.decode(e.value);return(0,E.encodeSecp256k1Pubkey)(t)}return(0,D.decodeOptionalPubkey)(e)}function kr({typeUrl:e,value:t}){if(e===`/cosmos.auth.v1beta1.BaseAccount`){let{address:e,pubKey:n,accountNumber:r,sequence:i}=ie.BaseAccount.decode(t);return{address:e,pubkey:Or(n),accountNumber:Number(r),sequence:Number(i)}}return(0,j.accountFromAny)({typeUrl:e,value:t})}var Ar=`/cosmos.feegrant.v1beta1.MsgGrantAllowance`,jr=`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`,Mr=`cosmos-sdk/AllowedMsgAllowance`;function Nr(){let e=re.aminoConverters[Ar];if(!e)throw Error(`Missing base converter for MsgGrantAllowance`);return e}var Pr=Nr();function Fr(e){if(e.typeUrl===jr){let t=ae.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw Error(`AllowedMsgAllowance is missing nested allowance`);return{type:Mr,value:{allowance:Fr(t.allowance),allowed_messages:t.allowedMessages}}}return Pr.toAmino({granter:``,grantee:``,allowance:e}).allowance}function Ir(e){if(e.type===Mr){let t=e.value;if(!t.allowance)throw Error(`AllowedMsgAllowance amino value is missing nested allowance`);let n=Ir(t.allowance);return{typeUrl:jr,value:ae.AllowedMsgAllowance.encode(ae.AllowedMsgAllowance.fromPartial({allowance:n,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Pr.fromAmino({granter:``,grantee:``,allowance:e}).allowance}var Lr={...re.aminoConverters,[Ar]:{...Pr,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Fr(e.allowance)}:Pr.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Ir(e.allowance)})}},Rr=()=>{let e=R();return new D.Registry([...re.protoRegistry,...e.protoTypes??[]])},zr=()=>{let e=R();return{...Lr,...e.aminoConverters}},Br=()=>new j.AminoTypes(zr()),Vr=class{constructor(e,t,n){this.address=e,this.signMessage=t,this.restUrl=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;let e=`${V.PUBLIC_KEY}:${this.address}`,t=localStorage.getItem(e);if(t)return this.cachedPublicKey=(0,_.fromHex)(t),(0,_.fromHex)(t);let n=await this.getPublicKeyFromRestApi();if(n)return this.cachedPublicKey=n,localStorage.setItem(e,(0,_.toHex)(n)),n;let r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(e,(0,_.toHex)(r)),r}async getPublicKeyFromRestApi(){try{let e=(await h.default.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return e?(0,_.fromBase64)(e):null}catch{return null}}async getPublicKey(){let e=`Sign this message to identify your Initia account.`,t=await this.signMessage(e),n=w.ethers.hashMessage(e),r=w.ethers.SigningKey.recoverPublicKey(n,t);return C.Secp256k1.compressPubkey((0,_.fromHex)(r.replace(`0x`,``)))}async getAccounts(){return[{address:this.address,algo:`ethsecp256k1`,pubkey:await this.getCachedPublicKey()}]}async signAmino(e,t){if(this.address!==e)throw Error(`Signer address does not match the provided address`);let n=(0,S.escapeCharacters)((0,S.sortedJsonStringify)(t)),r=(0,_.fromHex)((await this.signMessage(n)).replace(`0x`,``)).subarray(0,-1),i=C.Secp256k1Signature.fromFixedLength(r).toFixedLength();return{signed:t,signature:Rn(await this.getCachedPublicKey(),i)}}};function Hr(){let e=Rr(),t=Br(),n=Gr(),r=Xr();return async function(i,a,o,s,c,l){let u=l?.customSigner??n;if(!u)throw Error(`Signer not initialized`);let d=await r(i),{accountNumber:f,sequence:p}=await Wr({getSequence:e=>d.getSequence(e),signerAddress:a,incrementSequence:l?.incrementSequence??0,allowMissingAccount:!!l?.customSigner}),[m]=await u.getAccounts(),h=In(Ln(m.pubkey)),g=ne.SignMode.SIGN_MODE_EIP_191,v=(0,S.makeSignDoc)(o.map(e=>t.toAmino(e)),s,i,c,f,p),{signature:y,signed:b}=await u.signAmino(a,v),x={typeUrl:`/cosmos.tx.v1beta1.TxBody`,value:{messages:b.msgs.map(e=>t.fromAmino(e)),memo:c}},C=e.encode(x),w=A.Int53.fromString(b.fee.gas).toNumber(),T=(0,D.makeAuthInfoBytes)([{pubkey:h,sequence:A.Int53.fromString(b.sequence).toNumber()}],b.fee.amount,w,b.fee.granter,b.fee.payer,g);return M.TxRaw.fromPartial({bodyBytes:C,authInfoBytes:T,signatures:[(0,_.fromBase64)(y.signature)]})}}function Ur(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Wr({getSequence:e,signerAddress:t,incrementSequence:n,allowMissingAccount:r}){try{let{accountNumber:r,sequence:i}=await e(t);return{accountNumber:r,sequence:i+n}}catch(e){if(r&&Ur(e,t))return{accountNumber:0,sequence:n};throw e}}function Gr(){let e=U(),{signMessageAsync:t}=(0,l.useSignMessage)(),n=B();return(0,g.useMemo)(()=>new Vr(e,e=>t({message:e}),n.restUrl),[e,t,n.restUrl])}var Kr=new Map,qr=new Map;function Jr(e,t){let n=`${e}:${t}`;qr.delete(n)}function Yr(){let e=$e();return async t=>{if(Kr.has(t))return Kr.get(t);let{rpcUrl:n}=e(t),r=await te.Comet38Client.create(new te.HttpClient(n));return Kr.set(t,r),r}}function Xr(){let e=Rr(),t=Br(),n=Gr(),r=U(),i=Yr();return async a=>{let o=`${r}:${a}`;if(qr.has(o))return qr.get(o);if(!n)throw Error(`Signer not initialized`);let s=await i(a),c=await j.SigningStargateClient.createWithSigner(s,n,{registry:e,aminoTypes:t,accountParser:kr,broadcastPollIntervalMs:500});return qr.set(o,c),c}}function Zr(){let{connector:e}=(0,l.useAccount)();return async()=>{if(!e)throw Error(`Wallet not connected`);return new w.BrowserProvider(await e.getProvider())}}var Qr=class extends Error{constructor(e){super(e),this.name=`TimeoutError`}};function $r(e,t,n){let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(new Qr(n)),t)});return Promise.race([e,i]).finally(()=>{clearTimeout(r)})}function ei(e){return e.filter(e=>e.authorization[`@type`].includes(`GenericAuthorization`)).filter(e=>!!e.authorization.msg)}function ti(e){return e[`@type`]===`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`?e.allowance?.expiration:e.expiration}function ni(e){if(e[`@type`]===`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`)return e.allowedMessages??e.allowed_messages??[]}function ri(){let e=U(),t=$e();return{fetchFeegrant:async(n,r)=>{if(!e)return null;let i=t(n),a=h.default.create({prefixUrl:i.restUrl});try{let{allowance:t}=await a.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return t}catch(e){if(e instanceof h.HTTPError&&[404,500].includes(e.response.status))return null;throw e}},fetchGrants:async(n,r)=>{if(!e)return[];let i=t(n),{grants:a}=await h.default.create({prefixUrl:i.restUrl}).get(`cosmos/authz/v1beta1/grants`,{searchParams:{granter:e,grantee:r}}).json();return a},fetchAllGrants:async n=>{let r=t(n),i=e;return i?ei(await _t(`cosmos/authz/v1beta1/grants/granter/${i}`,{prefixUrl:r.restUrl},`grants`)):[]}}}var ii=(0,m.createQueryKeys)(`interwovenkit:autosign`,{expirations:(e,t,n)=>[e,t,n],grants:(e,t)=>[e,t]}),ai=4,oi=4;function si(e){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${[...t].sort().join(`,`)}`).join(`|`)}function ci(){let e=R(),t=nt(),{enableAutoSign:n,defaultChainId:r}=e;if(!n)return{[r]:[]};if(typeof n!=`boolean`)return n;switch(t.metadata?.minitia?.type){case`minievm`:return{[r]:[`/minievm.evm.v1.MsgCall`]};case`miniwasm`:return{[r]:[`/cosmwasm.wasm.v1.MsgExecuteContract`]};default:return{[r]:[`/initia.move.v1.MsgExecute`]}}}function li(){let{data:e}=ui(),t=ci();return(n,r)=>{let i=r.every(e=>{let r=t[n];return r?r.includes(e.typeUrl):!1}),a=e?.isEnabledByChain[n]??!1;return i&&a}}function ui(){let e=U(),t=ci(),n=si(t),{fetchFeegrant:r,fetchAllGrants:i}=ri();return(0,u.useQuery)({queryKey:ii.expirations(e,n,t).queryKey,queryFn:()=>di({initiaAddress:e,messageTypes:t,fetchAllGrants:i,fetchFeegrant:r}),staleTime:z.MINUTE,retry:1})}async function di(e){let{initiaAddress:t,messageTypes:n,fetchAllGrants:r,fetchFeegrant:i}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};let a={},o={},s={},c={},l=[];for(let[e,t]of Object.entries(n))a[e]=null,o[e]=void 0,s[e]=!1,t.length>0&&l.push([e,t]);if(l.length===0)return{expiredAtByChain:a,isEnabledByChain:s,granteeByChain:o};let u=await fi(l,ai,async([e,n])=>{let a=lr(t,e);try{let t=await r(e),o=hi(a===void 0?t:a===null?[]:t.filter(e=>e.grantee===a),n);if(o.length===0)return{chainId:e,expectedAddress:a,expiration:null,grantee:void 0};let s=await mi({chainId:e,candidates:o,fetchFeegrant:i,concurrency:oi});if(!s)return{chainId:e,expectedAddress:a,expiration:null,grantee:void 0};let c=s.grantee.grants.filter(e=>n.includes(e.authorization.msg)).map(e=>e.expiration),l=ti(s.feegrant.allowance),u=vi([...c,l]);return{chainId:e,expectedAddress:a,expiration:u?new Date(u):void 0,grantee:s.grantee.grantee}}catch{return{chainId:e,expectedAddress:a,expiration:null,grantee:void 0}}});for(let e of u)c[e.chainId]=e.expectedAddress,a[e.chainId]=e.expiration,o[e.chainId]=e.grantee;for(let[e]of l)s[e]=gi({expiration:a[e],grantee:o[e],expectedAddress:c[e]});return{expiredAtByChain:a,isEnabledByChain:s,granteeByChain:o}}async function fi(e,t,n){let r=Array(e.length),i=Math.max(1,t),a=0,o=Array.from({length:Math.min(i,e.length)},async()=>{for(;;){let t=a;if(a+=1,t>=e.length)return;r[t]=await n(e[t],t)}});return await Promise.all(o),r}function pi(e){let t=ni(e.allowance);if(!(!t||t.includes(`/cosmos.authz.v1beta1.MsgExec`)))return!1;let n=ti(e.allowance);if(!n)return!0;let r=new Date(n);return!Number.isNaN(r.getTime())&&(0,se.isFuture)(r)}async function mi(e){let{chainId:t,candidates:n,fetchFeegrant:r,concurrency:i=oi}=e,a=await fi(n,i,async e=>{let n=await r(t,e.grantee);return n&&pi(n)?{grantee:e,feegrant:n}:null});for(let e of a)if(e)return e;return null}function hi(e,t){if(t.length===0)return[];let n=new Map;for(let t of e){let e=n.get(t.grantee)||[];e.push({authorization:t.authorization,expiration:t.expiration}),n.set(t.grantee,e)}let r=[];for(let[e,i]of n){let n=i.filter(e=>!e.expiration||(0,se.isFuture)(new Date(e.expiration))),a=n.map(e=>e.authorization.msg);t.every(e=>a.includes(e))&&r.push({grantee:e,grants:n})}return r}function gi(e){let{expiration:t,grantee:n,expectedAddress:r}=e,i=r===void 0?!!n:!!n&&r===n;switch(t){case null:return!1;case void 0:return i;default:return i&&(0,se.isFuture)(t)}}function _i(){let{data:e,refetch:t}=ui();(0,g.useEffect)(()=>{if(!e)return;let n=new Date,r=Object.values(e.expiredAtByChain).filter(e=>e instanceof Date&&(0,se.isFuture)(e));if(r.length===0)return;let i=vi(r);if(!i)return;let a=i.getTime()-n.getTime();if(a<=0)return;let o=setTimeout(()=>{t()},a+100);return()=>clearTimeout(o)},[e,t])}function vi(e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return[...t].sort((e,t)=>new Date(e).getTime()-new Date(t).getTime())[0]}var yi=(0,g.createContext)(null),bi=()=>(0,g.useContext)(yi),xi=class extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(e,t,n,r,i,a,o){super(e),this.name=`MoveError`,this.originalError=t,this.moduleAddress=n,this.moduleName=r,this.errorCode=i,this.errorCodeHex=a,this.isFromRegistry=o}},Si=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Ci=new Map;function wi(e){let t=e.match(Si);if(!t)return null;let[,n,r,i]=t;return{moduleAddress:`0x${n.replace(/^0+/,``)||`0`}`,moduleName:r,errorCode:i.replace(/^0+/,``)||`0`}}async function Ti(e,t,n){let r=`${e}:${t}`;if(Ci.has(r))return Ci.get(r);try{let i=`${n}/errors/${t===`0x1`?`0x1.json`:`${e}/${t}.json`}`,{errors:a={}}=await h.default.get(i).json();return Ci.set(r,a),a}catch{return null}}function Ei(e,t,n,r,i,a,o){return new xi(e,t,n,r,i,a,o)}async function Di(e,t,n){if(e instanceof xi)return e;if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!==`minimove`)return await We(e);let r=wi(e.message);if(!r)return await We(e);let i=await Ti(t.chain_name,r.moduleAddress,n),a=`0x${parseInt(r.errorCode,10).toString(16)}`,o=`Failed with code ${a} in module ${r.moduleName} at ${r.moduleAddress}`,s=i?.[r.moduleName]?.[r.errorCode],c=s||o,l=!!s;return Ei(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,l)}var Oi=5e3;function ki(){let e=U();return(t,n)=>(0,u.queryOptions)({queryKey:Pt.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];let{txs:r}=await h.default.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:{"pagination.reverse":!0,"pagination.limit":10}}).json();return r},staleTime:z.SECOND})}function Ai(e,t){return(0,u.useSuspenseQuery)(ki()(e,t))}function ji(e,t){let n=e.flatMap((e,n)=>(t[n]??[]).map(t=>({...t,chain:e})));return(0,p.sortWith)([(0,p.descend)(e=>new Date(e.timestamp).getTime())])(n)}var Mi=()=>{let e=Xe(),t=ki();return(0,u.useQueries)({queries:e.map(e=>({...t(e,{enabled:!0}),refetchInterval:Oi})),combine:t=>({activities:ji(e,t.map((0,p.prop)(`data`))),isLoading:t.some(e=>e.isLoading)})})};function Ni({denom:e,amount:t}){let n=(t||``).trim();if(!n)return null;let r=e===`uinit`?1:Fe;return{amount:(0,f.default)(n).times(r).toFixed(18),denom:e}}async function Pi(e){if(e.metadata?.is_l1){let{restUrl:t}=e,{gas_prices:n}=await h.default.create({prefixUrl:t}).get(`initia/tx/v1/gas_prices`).json(),r=[...n].sort((0,p.descend)(({denom:e})=>e===`uinit`)).flatMap(e=>{let t=Ni(e);return t?[t]:(console.error(`Gas price entry has empty amount for ${e.denom}`),[])});if(r.length===0)throw Error(`Gas prices response is empty or invalid`);return r}return e.fees.fee_tokens.map(({denom:e,fixed_min_gas_price:t})=>{if((0,p.isNil)(t))throw Error(`${e} has no price`);return{amount:String(t),denom:e}})}function Fi(e){let{data:t}=(0,u.useSuspenseQuery)({queryKey:Ge.gasPrices(e).queryKey,queryFn:()=>Pi(e),staleTime:z.SECOND});return t}function Ii(e){let t=U(),{data:n}=Ai(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;let r=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return r;try{return n.find(({tx:e})=>e.auth_info.signer_infos.some(e=>d.InitiaAddress.equals(t,(0,w.computeAddress)(`0x${(0,_.toHex)(C.Secp256k1.uncompressPubkey((0,_.fromBase64)(e.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}var Li=`approve`,Ri=(0,b.atom)(),zi=(0,b.atom)(null),Bi=Pe,Vi=1.5;function Hi({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:n,allowedFeeDenoms:r}){let i=r?.length?e.filter(({denom:e})=>r.includes(e)):e;if(i.length===0)throw Error(`No allowed gas price tokens available for auto-sign`);let a=e=>e?i.find(t=>t.denom===e):void 0;return a(t)??a(n)??i[0]}function Ui({simulatedGas:e,gasPrices:t,preferredFeeDenom:n,fallbackFeeDenom:r,policy:i}){if(!Number.isFinite(e)||e<=0)throw Error(`Auto-sign gas simulation failed`);let{gasMultiplier:a,maxGasMultiplierFromSim:o,allowedFeeDenoms:s}=i;if(a<=0||o<=0||a>o)throw Error(`Invalid auto-sign gas multiplier policy`);let c=Math.ceil(e*a),l=Hi({gasPrices:t,preferredFeeDenom:n,fallbackFeeDenom:r,allowedFeeDenoms:s});return(0,j.calculateFee)(c,j.GasPrice.fromString(`${l.amount}${l.denom}`))}function Wi({derivedAddress:e,messages:t,encoder:n}){return{messages:vr({granteeAddress:e,messages:t,encoder:n})}}function Gi(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase(),n=e.code,r=e.cause?.code,i=t.includes(`user rejected`)||t.includes(`rejected the request`)||t.includes(`user denied`)||t.includes(`denied by user`)||t.includes(`user cancelled`)||t.includes(`user canceled`)||t.includes(`cancelled by user`)||t.includes(`canceled by user`);return n===4001||n===`ACTION_REJECTED`||r===4001||r===`ACTION_REJECTED`||i}async function Ki({queryClient:e,messages:t,memo:n,pubkey:r,sequence:i}){let a=new oe.ServiceClientImpl((0,j.createProtobufRpcClient)(e)),o=M.Tx.fromPartial({authInfo:M.AuthInfo.fromPartial({fee:M.Fee.fromPartial({}),signerInfos:[{publicKey:r,sequence:BigInt(i),modeInfo:{single:{mode:ne.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:M.TxBody.fromPartial({messages:Array.from(t),memo:n}),signatures:[new Uint8Array]});return await a.Simulate(oe.SimulateRequest.fromPartial({txBytes:M.Tx.encode(o).finish()}))}function qi(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e}async function Ji({address:e,chainId:t,messages:n,memo:r,fee:i,preferredFeeDenom:a,client:o,allowAutoSign:s=!0,allowWalletDerivation:c=!1},l){let u=async()=>l.signWithEthSecp256k1(t,e,n,i,r),d=(e,n)=>{l.onAutoSignFallback?.({chainId:t,reason:e,errorMessage:qi(n)})};if(!s)return u();if(!l.validateAutoSign(t,n))return d(`validation_failed`),u();let f=l.getWallet(t),p=!1;if(!f&&c)try{f=await l.deriveWallet(t)}catch(e){if(Gi(e))throw e;d(`derive_wallet_failed`,e),p=!0,f=void 0}if(!f)return p||d(`missing_derived_wallet`),u();let m;try{let e=o??await l.getSigningClient(t);m=await l.computeAutoSignFee({chainId:t,messages:n,memo:r,derivedWallet:f,preferredFeeDenom:a,fallbackFeeDenom:i.amount[0]?.denom,client:e})}catch(e){if(e instanceof Error&&wi(e.message))throw await l.formatError(t,e);return d(`fee_computation_failed`,e),u()}try{return await l.signWithDerivedWallet(t,e,n,m,r,f)}catch(e){return d(`derived_wallet_sign_failed`,e),u()}}function Yi(){let e=U(),{autoSignFeePolicy:t,registryUrl:n}=R(),r=$e(),i=Yr(),a=Xr(),o=Rr(),s=li(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:u}=_r(),d=Hr(),f=Nn(),p=e=>{let n=t?.[e];return{gasMultiplier:n?.gasMultiplier??Bi,maxGasMultiplierFromSim:n?.maxGasMultiplierFromSim??Vi,allowedFeeDenoms:n?.allowedFeeDenoms}},m=async({chainId:e,messages:t,memo:n,derivedWallet:a,preferredFeeDenom:s,fallbackFeeDenom:c,client:l})=>{let u=await Pi(r(e)),d=Wi({derivedAddress:a.address,messages:t,encoder:o}).messages.map(e=>o.encodeAsAny(e)),f=In(Ln(a.publicKey)),{sequence:m}=await Wr({getSequence:e=>l.getSequence(e),signerAddress:a.address,incrementSequence:0,allowMissingAccount:!0}),h=await i(e),{gasInfo:g}=await Ki({queryClient:j.QueryClient.withExtensions(h,j.setupTxExtension),messages:d,memo:n,pubkey:f,sequence:m});return Ui({simulatedGas:g?Number(g.gasUsed.toString()):0,gasPrices:u,preferredFeeDenom:s,fallbackFeeDenom:c,policy:p(e)})},h=async(e,t,n,r,i,a)=>{let s=a??c(e);s||=await l(e);let f=u(e);if(!f)throw Error(`Derived wallet key not initialized`);return await yr({chainId:e,granterAddress:t,messages:n,fee:r,memo:i,derivedWallet:s,privateKey:f,encoder:o,signWithEthSecp256k1:d})};return t=>Ji({...t,address:e},{validateAutoSign:s,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:m,signWithDerivedWallet:h,signWithEthSecp256k1:d,formatError:(e,t)=>Di(t,r(e),n),onAutoSignFallback:({chainId:e,reason:t,errorMessage:n})=>{f(`AutoSign Fallback`,{chainId:e,reason:t,errorMessage:n})}})}function Xi(){let e=(0,b.useAtomValue)(Ri);if(!e)throw Error(`Tx request not found`);return e}function Zi(){let e=Xt(),t=U(),{defaultChainId:n,registryUrl:r}=R(),i=$e(),{openDrawer:a,closeDrawer:o}=Sr(),{openModal:s,closeModal:c}=bi(),l=(0,b.useSetAtom)(Ri),u=(0,b.useSetAtom)(zi),d=Yr(),f=Xr(),p=Gr(),m=Rr(),h=Yi(),g=async({messages:e,memo:a,chainId:o=n})=>{try{return await(await f(o)).simulate(t,e,a)}catch(e){throw await Di(e,i(o),r)}},_=async({messages:e,memo:r,chainId:i=n})=>{let a=await d(i),o=j.QueryClient.withExtensions(a,j.setupTxExtension),s=e.map(e=>m.encodeAsAny(e)),[c]=await p.getAccounts(),l=(0,E.encodeSecp256k1Pubkey)(c.pubkey),{sequence:u}=await(await f(i)).getSequence(t);return o.tx.simulate(s,r,l,u)},v=async({txRequest:t,broadcaster:u})=>{let d={memo:``,chainId:n,gas:t.gas||await g(t),gasAdjustment:Pe,gasPrices:null,spendCoins:[],internal:!1,...t};return new Promise((t,n)=>{l({txRequest:d,resolve:async a=>{try{t(await u(await f(d.chainId),M.TxRaw.encode(a).finish())),typeof d.internal==`string`&&e(d.internal)}catch(e){n(await Di(e,i(d.chainId),r))}finally{p()}},reject:e=>{n(e),p()}}),d.internal?s({path:`/tx`}):a(`/tx`);let p=()=>{if(!d.internal){e(`/blank`),o();return}c()}})},y=async e=>{let t=e.chainId??n;try{let n=await v({txRequest:e,broadcaster:async(e,t)=>await e.broadcastTxSync(t)});return e.internal&&typeof e.internal!=`number`&&(u({txHash:n,chainId:t,status:`loading`}),T({txHash:n,chainId:e.chainId}).then(e=>{u({status:e.code===0?`success`:`error`,chainId:t,txHash:n})}).catch(()=>{u({status:`error`,chainId:t,txHash:n})})),n}catch(n){throw e.internal&&typeof e.internal!=`number`&&u({status:`error`,chainId:t,error:n}),n}},x=(e,t=30*1e3,n=.5*1e3)=>v({txRequest:e,broadcaster:async(e,r)=>{let i=await e.broadcastTx(r,t,n);if(i.code!==0)throw Error(i.rawLog);return i}}),S=async({chainId:e,messages:t,memo:n=``,fee:r,preferredFeeDenom:i})=>{let a=await f(e);return{client:a,signedTx:await h({chainId:e,messages:t,memo:n,fee:r,preferredFeeDenom:i,client:a,allowWalletDerivation:!0})}},C=async e=>{let t=e.chainId??n;try{let{client:n,signedTx:r}=await S({...e,chainId:t});return await n.broadcastTxSync(M.TxRaw.encode(r).finish())}catch(e){throw await Di(e,i(t),r)}},w=async(e,t=30*1e3,a=.5*1e3)=>{let o=e.chainId??n;try{let{client:n,signedTx:r}=await S({...e,chainId:o}),i=await n.broadcastTx(M.TxRaw.encode(r).finish(),t,a);if(i.code!==0)throw Error(i.rawLog);return i}catch(e){throw await Di(e,i(o),r)}},T=async({chainId:e=n,...t})=>{try{let n=await f(e);return await Qi({...t,client:n})}catch(t){throw t instanceof Qr?t:await Di(t,i(e),r)}};return{estimateGas:g,simulateTx:_,requestTxSync:y,requestTxBlock:x,submitTxSync:C,submitTxBlock:w,waitForTxConfirmation:T}}async function Qi({txHash:e,client:t,timeoutMs:n=30*1e3,intervalMs:r=.5*1e3}){let i=Date.now();for(;;){let a=await t.getTx(e);if(a){if(a.code!==0)throw Error(a.rawLog);return a}if(Date.now()-i>=n)throw new Qr(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(e=>setTimeout(e,r))}}var $i=`/cosmos.authz.v1beta1.MsgExec`;function ea(e){if(e.explicitGrantee)return[e.explicitGrantee];let t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(e=>!!e);return[...new Set(t)]}function ta(e){let t=[e.currentGrantee,e.expectedGrantee].filter(e=>!!e);return[...new Set(t)]}function na(e){let{isEnabledOnTargetChain:t,hasEnabledSibling:n,didBroadcast:r,hasExplicitGrantee:i}=e;return n?!1:t===!1?!0:t===void 0&&r&&!i}function ra(e){return[...new Set(e.map(e=>e.authorization.msg))].filter(e=>!!e)}async function ia(e){let t=[ii.expirations._def,ii.grants._def];for(let n of t)await e.invalidateQueries({queryKey:n})}function aa(){let e=U(),{fetchFeegrant:t,fetchGrants:n}=ri();return async r=>{let{chainId:i,grantee:a}=r;if(!e)throw Error(`Granter wallet not initialized`);let o=await t(i,a),s=await n(i,a),c=o?[{typeUrl:`/cosmos.feegrant.v1beta1.MsgRevokeAllowance`,value:le.MsgRevokeAllowance.fromPartial({granter:e,grantee:a})}]:[],l=ra(s).map(t=>({typeUrl:`/cosmos.authz.v1beta1.MsgRevoke`,value:T.MsgRevoke.fromPartial({granter:e,grantee:a,msgTypeUrl:t})}));return[...c,...l]}}function oa(){let e=U(),t=ci(),{requestTxBlock:n}=Zi(),r=(0,u.useQueryClient)(),[i,a]=(0,b.useAtom)(Hn),{closeDrawer:o}=Sr(),s=aa(),{deriveWallet:c}=_r();return(0,u.useMutation)({mutationFn:async r=>{if(!i)throw Error(`No pending request`);let{chainId:a}=i;if(!e)throw Error(`Wallet not connected`);let o=t[a];if(!o||o.length===0)throw Error(`No message types configured for chain ${a}`);let l=await c(a);Jr(e,a);let u=lr(e,a),d=ta({currentGrantee:l.address,expectedGrantee:u}),f=(await Promise.all(d.map(e=>s({chainId:a,grantee:e})))).flat(),p=r===0?void 0:(0,se.addMilliseconds)(new Date,r),m={typeUrl:`/cosmos.feegrant.v1beta1.BasicAllowance`,value:ae.BasicAllowance.encode(ae.BasicAllowance.fromPartial({expiration:p})).finish()},h={typeUrl:`/cosmos.feegrant.v1beta1.MsgGrantAllowance`,value:le.MsgGrantAllowance.fromPartial({granter:e,grantee:l.address,allowance:{typeUrl:`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`,value:ae.AllowedMsgAllowance.encode(ae.AllowedMsgAllowance.fromPartial({allowance:m,allowedMessages:[$i]})).finish()}})},g=o.map(t=>({typeUrl:`/cosmos.authz.v1beta1.MsgGrant`,value:T.MsgGrant.fromPartial({granter:e,grantee:l.address,grant:{authorization:{typeUrl:`/cosmos.authz.v1beta1.GenericAuthorization`,value:ce.GenericAuthorization.encode(ce.GenericAuthorization.fromPartial({msg:t})).finish()},expiration:p}})}));return await n({messages:[...f,h,...g],chainId:a,internal:!0}),{chainId:a,derivedWallet:l}},onSuccess:async({chainId:t,derivedWallet:n})=>{e&&ur(e,t,n.address),await ia(r),i?.resolve()},onError:e=>{i?.reject(e)},onSettled:()=>{a(null),o()}})}function sa(e){let t=R(),n=Xe(),r=$e(),{getWallet:i,clearWallet:a}=_r(),{requestTxBlock:o}=Zi(),s=(0,u.useQueryClient)(),c=aa(),{data:l,refetch:d}=ui();return(0,u.useMutation)({mutationFn:async(n=t.defaultChainId)=>{let r=i(n),a=l?.granteeByChain[n],s;e?.grantee||(s=(await d()).data?.granteeByChain[n]);let u=ea({explicitGrantee:e?.grantee,cachedDerivedAddress:r?.address,statusGrantee:a,refetchedStatusGrantee:s});if(u.length===0)throw Error(`No grantee address available`);let f=(await Promise.all(u.map(e=>c({chainId:n,grantee:e})))).flat();return f.length===0?{chainId:n,didBroadcast:!1}:(await o({messages:f,chainId:n,internal:e?.internal}),{chainId:n,didBroadcast:!0})},onSuccess:async({chainId:t,didBroadcast:i})=>{await ia(s);let o=r(t),c=n.filter(e=>e.bech32_prefix===o.bech32_prefix).map(e=>e.chain_id).filter(e=>e!==t),u;try{u=(await d()).data}catch{u=void 0}let f=u??l,p=!1;c.length>0&&f&&(p=c.some(e=>f?.isEnabledByChain[e])),na({isEnabledOnTargetChain:i?u?.isEnabledByChain[t]:(u??l)?.isEnabledByChain[t],hasEnabledSibling:p,didBroadcast:i,hasExplicitGrantee:!!e?.grantee})&&a(t)}})}var ca=[{value:10*Et,label:`for 10 minutes`},{value:Dt,label:`for 1 hour`},{value:Ot,label:`for 1 day`},{value:7*Ot,label:`for 7 days`},{value:0,label:`until revoked`}],la=ca[0].value;function ua(e){return e===void 0?la:ca.some(t=>t.value===e)?e:la}function da(){let{defaultChainId:e}=R(),{openDrawer:t}=Sr(),n=(0,b.useSetAtom)(Hn),r=sa(),{data:i={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:a}=ui(),o=async(r=e,i)=>new Promise((e,a)=>{n({chainId:r,defaultDuration:ua(i?.defaultDuration),resolve:e,reject:a}),t(`/autosign/enable`)}),s=async(t=e)=>{await r.mutateAsync(t)};return{...i,isLoading:a,enable:o,disable:s}}function fa(e){return e.assets.reduce((e,{value:t})=>e+(t??0),0)}function pa(e){return e.assets.reduce((e,{quantity:t})=>e.plus(t||0),(0,f.default)(0)).toString()}function ma(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??ot}}function ha(e){return(0,p.pick)([`chainId`,`name`,`logoUrl`],e)}function ga(e){return(0,p.sortWith)([(0,p.ascend)(({symbol:e})=>At(e)),(0,p.descend)(fa),(0,p.descend)(({assets:e})=>e.length),(0,p.ascend)(({symbol:e})=>e)])(e)}function _a(e){return(0,p.sortWith)([(0,p.descend)(({value:e})=>e??0),(0,p.descend)(({quantity:e})=>Number(e)),(0,p.ascend)(({chain:e})=>e.name)])(e)}function va(e,t){return(0,p.sortWith)([(0,p.descend)(({chain:e})=>e.chainId===t),(0,p.ascend)(({chain:e})=>e.name),(0,p.ascend)(({denom:e})=>e)])(e)}function ya(e,t){return(0,p.sortWith)([(0,p.descend)(({chainId:e})=>e===t),(0,p.descend)((0,p.prop)(`value`))])(e)}function ba(e,t,n,r,i){let a=e.find(e=>e.metadata?.is_l1)?.chainId,o={};for(let i of e){let e=i.chainId,a=t[e]??[],s=n[e],c=r[e],l=[];for(let{amount:e,denom:t}of a){if(!(0,f.default)(e||0).gt(0))continue;let n=s?.find(e=>e.denom===t),r=c?.find(e=>e.id===t)?.price,a=n?.decimals??0,o=(0,d.fromBaseUnit)(e,{decimals:a}),u=r?(0,f.default)(o||0).times(r).toNumber():void 0;l.push({...ma(t,n),amount:e,denom:t,decimals:a,quantity:o,price:r,value:u,address:n?.address,unlisted:!n,chain:ha(i)})}o[e]=l}let s=new Map;for(let[t,n]of Object.entries(o)){if(n.length===0)continue;let r=e.find(e=>e.chainId===t);if(!r)continue;let i=n.reduce((e,{value:t})=>e+(t??0),0);s.set(t,{...ha(r),value:i})}let c=new Map;for(let e of Object.values(o))for(let t of e)if(!t.unlisted){let{symbol:e}=t,n=c.get(e)??[];c.set(e,[...n,t])}let l=[];for(let[e,t]of c){let n=(0,p.head)(t);if(!n)continue;let r=_a(t),i=r.reduce((e,{value:t})=>e+(t??0),0),a=r.reduce((e,{quantity:t})=>e.plus(t||0),(0,f.default)(0)).toNumber();l.push({symbol:e,logoUrl:n.logoUrl,assets:r,totalValue:i,totalAmount:a})}let u=[];for(let e of Object.values(o))for(let t of e)t.unlisted&&u.push(t);return{chainsByValue:ya(Array.from(s.values()),i),assetGroups:ga(l),unlistedAssets:va(u,a),totalValue:l.reduce((e,t)=>e+t.totalValue,0)}}function xa(){let{defaultChainId:e}=R(),t=Xe(),n=Rt(),r=dt(),i=at(),a=t.map(e=>e.chainId),o=ba(t,(0,p.zipObj)(a,n.map((0,p.prop)(`data`))),(0,p.zipObj)(a,r.map((0,p.prop)(`data`))),(0,p.zipObj)(a,i.map((0,p.prop)(`data`))),e),s=[n,r,i].flat().some(({isLoading:e})=>e),c=()=>{n.forEach(({refetch:e})=>e()),r.forEach(({refetch:e})=>e()),i.forEach(({refetch:e})=>e())};return{...o,isLoading:s,refetch:c}}function U(){let e=Sa();return e?(0,d.InitiaAddress)(e).bech32:``}function Sa(){let{address:e}=(0,l.useAccount)();return e?(0,d.InitiaAddress)(e).hex:``}function Ca(){let e=nt(),t=U(),n=Sa();return e.metadata?.minitia?.type===`minievm`?n:t}function wa(e){let t=Ca(),n=e??t,r=Ft();return(0,u.useQuery)({queryKey:Pt.username(r.restUrl,n).queryKey,queryFn:()=>r.getUsername(n),enabled:!!n,staleTime:z.MINUTE})}function Ta(){let e=Ca(),t=U(),n=Sa(),{data:r}=wa(),i=Gr(),a=wr(),o=da(),{isDrawerOpen:s,openDrawer:c}=Sr(),{isModalOpen:l}=Cr(),u=()=>{c(`/`)},d=()=>{c(`/connect`)},f=e=>{c(`/bridge`,e)},p=Er(),m=Dr(),h=Zi();return{address:e,initiaAddress:t,hexAddress:n,username:r,offlineSigner:i,isConnected:!!e,isOpen:s||l,openConnect:d,openWallet:u,openBridge:f,openDeposit:p,openWithdraw:m,disconnect:a,autoSign:o,...h}}var Ea={status:`_status_tn9m1_1`,error:`_error_tn9m1_9`},Da=({error:e,className:t,children:n})=>(0,y.jsx)(`p`,{className:(0,P.default)(Ea.status,{[Ea.error]:e},t),role:e?`alert`:`status`,children:n}),W=({errorBoundaryProps:e={fallbackRender:({error:e})=>(0,y.jsx)(Da,{error:!0,children:e.message})},suspenseFallback:t=(0,y.jsx)(Da,{children:`Loading...`}),children:n})=>(0,y.jsx)(de.ErrorBoundary,{...e,children:(0,y.jsx)(g.Suspense,{fallback:t,children:n})}),Oa=1n<<64n,ka=1n<<63n,Aa=(1n<<128n)-1n;function ja(e){let t=BigInt(e);return t>=ka?t-Oa:t}var Ma=(1n<<256n)-1n,Na=443636n,Pa=255738958999603826347141n;function Fa(e,t,n){let r=Number(ja(e)),i=Number(ja(t)),a=Math.floor(-Number(Na)/n)*n,o=Math.floor(Number(Na)/n)*n;return r===a&&i===o}function Ia(e){return e>>64n}function La(e){let t=e>>64n;return e%Oa===0n?t:t+1n}function Ra(e){return e}function za(e){if(e<0n||e>Aa)throw Error(`INPUT_OUT_OF_RANGE`);return e}function Ba(e,t){let n=e*t>>64n;if(n>Aa)throw Error(`OVERFLOW`);return n}function Va(e,t){return e>t?[t,e]:[e,t]}function Ha(e,t,n,r){if(e===t)return 0n;let[i,a]=Va(e,t);if(i===0n||a===0n)return 0n;let o=n*Oa*(a-i);if(o===0n)return 0n;let s=i*a;return r?(o-1n)/s+1n:o/s}function Ua(e,t,n,r){if(e===t)return 0n;let[i,a]=Va(e,t),o=(a-i)*n;return r?La(za(o)):Ia(za(o))}function Wa(e,t,n){return Ha(e,t,n<0n?-n:n,n>=0n)}function Ga(e,t,n){return Ua(e,t,n<0n?-n:n,n>=0n)}var Ka=1n<<64n,qa=1n<<65n,Ja=64n;function Ya(e){if(e<=0n)throw Error(`LOG_2_ZERO_UNBOUNDED`);let t=Ra(e),n=0n,r=0n,i=1n<<Ja-1n,a=0n,o=1;for(;t>=qa;)t>>=1n,n+=Ka;for(;t<Ka;)o=0,t<<=1n,r+=Ka;for(;a<62n;){let e=t>>1n;t=e*e>>62n,t>=qa&&(t>>=1n,n+=i),i>>=1n,a+=1n}let s=za(o>0?n:r-n);return[o,s]}function Xa(e){let t=e<0n?-e:e;if(t>443636n)throw Error(`MAX_TICK`);let n=(t&1n)==0n?340282366920938463463374607431768211456n:340265354078544963557816517032075149313n;(t&2n)!=0n&&(n=n*340248342086729790484326174814286782778n>>128n),(t&4n)!=0n&&(n=n*340214320654664324051920982716015181260n>>128n),(t&8n)!=0n&&(n=n*340146287995602323631171512101879684304n>>128n),(t&16n)!=0n&&(n=n*340010263488231146823593991679159461444n>>128n),(t&32n)!=0n&&(n=n*339738377640345403697157401104375502016n>>128n),(t&64n)!=0n&&(n=n*339195258003219555707034227454543997025n>>128n),(t&128n)!=0n&&(n=n*338111622100601834656805679988414885971n>>128n),(t&256n)!=0n&&(n=n*335954724994790223023589805789778977700n>>128n),(t&512n)!=0n&&(n=n*331682121138379247127172139078559817300n>>128n),(t&1024n)!=0n&&(n=n*323299236684853023288211250268160618739n>>128n),(t&2048n)!=0n&&(n=n*307163716377032989948697243942600083929n>>128n),(t&4096n)!=0n&&(n=n*277268403626896220162999269216087595045n>>128n),(t&8192n)!=0n&&(n=n*225923453940442621947126027127485391333n>>128n),(t&16384n)!=0n&&(n=n*149997214084966997727330242082538205943n>>128n),(t&32768n)!=0n&&(n=n*66119101136024775622716233608466517926n>>128n),(t&65536n)!=0n&&(n=n*12847376061809297530290974190478138313n>>128n),(t&131072n)!=0n&&(n=n*485053260817066172746253684029974020n>>128n),(t&262144n)!=0n&&(n=n*691415978906521570653435304214168n>>128n),e>=0n&&(n=Ma/n);let r=n/Oa;return n%Oa===0n?r:r+1n}function Za(e){if(e<4295048017n||e>=79226673515401279992447579062n)throw Error(`INVALID_SQRT_PRICE`);let[,t]=Ya(za(e)),n=Ia(Ba(t,za(Pa))),r,i,a;if(n===0n?(r=-1n,i=0n,a=1n):e<18446744073709551616n?(r=-n-1n,i=-n,a=-n+1n):(r=n-1n,i=n,a=n+1n),r<-443636n&&(r=-Na),a>443636n&&(a=Na),Xa(a)<=e){if(a>=443636n)throw Error(`GTE_MAX_TICK`);if(Xa(a+1n)<=e)throw Error(`NO_SAFE_TICK_FOUND`);return a}if(Xa(i)<=e)return i;if(Xa(r)<=e)return r;throw Error(`NO_SAFE_TICK_FOUND`)}function Qa(e,t,n,r){let[i,a]=Va(t,n);return e<i?[Wa(i,a,r),0n]:e<a?[Wa(e,a,r),Ga(i,e,r)]:[0n,Ga(i,a,r)]}function $a({tickLower:e,tickUpper:t,liquidity:n,sqrtPrice:r}){let i=Xa(ja(e)),a=Xa(ja(t));return Qa(BigInt(r),BigInt(i),BigInt(a),BigInt(n))}var eo=Oa*Oa,to=1e-300,no=BigInt(2**53-1);function ro(e){let t=e*e,n=t/eo,r=t%eo;return n>no?Number(n):Number(n)+Number(r)/Number(eo)}function io(e){if(!Number.isFinite(e)||e<0)throw Error(`calculateTokens: price must be finite and non-negative`);return 1/Math.max(e,to)}function ao({tickLower:e,tickUpper:t,isReversed:n=!1}){let r=Xa(ja(e)),i=Xa(ja(t)),a=ro(r),o=ro(i);return n?{min:io(o),max:io(a)}:{min:a,max:o}}var oo=(0,m.createQueryKeys)(`interwovenkit:initia-liquidity`,{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,n)=>[e,t,n],clammFees:(e,t,n)=>[e,t,n],clammIncentive:(e,t,n,r)=>[e,t,n,r]}),so={lens:`lens`,pool:`pool`,farming:`farming`},co={"interwoven-1":{clammModuleAddress:`0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e`,incentiveModuleAddress:`0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351`},"initiation-2":{clammModuleAddress:`0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d`,incentiveModuleAddress:`0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753`}};function lo(e){return e.startsWith(`0x`)?`0x${e.replace(/^0x/,``).padStart(64,`0`)}`:(0,d.InitiaAddress)(e).hex}function uo(e){return(0,_.toBase64)((0,d.InitiaAddress)(lo(e),32).bytes)}function fo(e,t){return`${e}:${t}`}function po(e){return`clamm:${e}`}function mo(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function ho(e){return e.map(e=>({tokenAddress:e.token_address,lpMetadata:e.lp_metadata,tickLower:e.tick_lower,tickUpper:e.tick_upper,liquidity:e.liquidity,incentives:e.incentives.map(e=>({incentiveAddress:e.incentive_address,rewardMetadata:e.reward_metadata}))}))}function go(e){let{dexUrl:t}=R();return(0,u.useSuspenseQuery)({queryKey:oo.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];let n=[],r;do{let i={"pagination.limit":`100`};r&&(i[`pagination.key`]=r);let a=await h.default.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:i}).json().catch(()=>({positions:[],pagination:{next_key:null,total:`0`}}));n.push(...mo(a.positions)),r=a.pagination.next_key||void 0}while(r);return ho(n)},staleTime:z.MINUTE})}function _o(e){let t=B(),{viewFunction:n}=(0,d.createMoveClient)(t.restUrl),r=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:oo.clammPoolInfo(t.restUrl,t.chainId,e).queryKey,queryFn:async()=>{let r=co[t.chainId];if(!r)return null;try{let t=await n({moduleAddress:r.clammModuleAddress,moduleName:so.lens,functionName:`get_pool_info`,typeArgs:[],args:[uo(e)]});return!t?.sqrt_price||!t?.tick_spacing?null:{sqrtPrice:t.sqrt_price,tickSpacing:t.tick_spacing}}catch{return null}},staleTime:z.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>{t.set(e,r[n]??null)}),t},[e,r])}function vo(e){let t=B(),{viewFunction:n}=(0,d.createMoveClient)(t.restUrl),r=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:oo.clammFees(t.restUrl,t.chainId,e).queryKey,queryFn:async()=>{let r=co[t.chainId];if(!r)return null;try{let t=await n({moduleAddress:r.clammModuleAddress,moduleName:so.pool,functionName:`fees_available`,typeArgs:[],args:[uo(e)]});return Array.isArray(t)?t:null}catch{return null}},staleTime:z.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>{let i=r[n];i&&t.set(e,i)}),t},[e,r])}function yo(e){let t=B(),{viewFunction:n}=(0,d.createMoveClient)(t.restUrl),r=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:oo.clammIncentive(t.restUrl,t.chainId,e.tokenAddress,e.incentiveAddress).queryKey,queryFn:async()=>{let r=co[t.chainId];if(!r)return`0`;try{let t=await n({moduleAddress:r.incentiveModuleAddress,moduleName:so.farming,functionName:`pending_reward_info`,typeArgs:[],args:[uo(e.tokenAddress),uo(e.incentiveAddress)]});return typeof t==`string`?t:Array.isArray(t)&&typeof t[0]==`string`?t[0]:`0`}catch{return`0`}},staleTime:z.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>{t.set(fo(e.tokenAddress,e.incentiveAddress),r[n]||`0`)}),t},[e,r])}function bo(e){let{dexUrl:t}=R(),n=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:oo.poolByMetadata(t,e).queryKey,queryFn:async()=>{try{return(await h.default.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(e)}`).json()).pool}catch{return null}},staleTime:z.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{t.set(e,n[r]??null)}),t},[e,n])}function xo(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(e=>t.get(e.denom)?.logoUrl||``)}function So(e){return bo(e)}function Co(e){let t=ut(B()),n=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.denom,n);return e},[t]),r=(0,g.useMemo)(()=>e.map(e=>(0,d.denomToMetadata)(e)),[e]),i=bo(r);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,a)=>{let o=r[a];if(!o){t.set(e,null);return}let s=i.get(o);if(!s){t.set(e,null);return}if(e===`uoinit`){t.set(e,{...s,symbol:xt});return}let c=s.coins.map(e=>n.get(e.denom)?.symbol||e.denom).join(`-`);t.set(e,{...s,symbol:c})}),t},[e,r,i,n])}var wo=`lock_staking`;function To(e,t){return(0,d.InitiaAddress)((0,d.createObjectAddress)(e,`${t}::lock_staking::StakingAccount`)).bech32}var Eo=(0,m.createQueryKeys)(`interwovenkit:initia-staking`,{delegations:(e,t)=>[e,t],undelegations:(e,t,n)=>[e,t,n],lockStaking:(e,t,n)=>[e,t,n],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,n)=>[e,t,n]});function Do(){let{restUrl:e}=B(),t=U();return(0,u.useSuspenseQuery)({queryKey:Eo.delegations(e,t||``).queryKey,queryFn:async()=>t?(await h.default.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:e=>{let t=new Map;for(let n of e){let e=n.delegation.validator_address;for(let r of n.balance){let n=(0,d.denomToMetadata)(r.denom),i={denom:r.denom,metadata:n,amount:r.amount,validator:e},a=t.get(n)??[];a.push(i),t.set(n,a)}}return t},staleTime:z.MINUTE})}function Oo(){let{restUrl:e}=B(),{lockStakeModuleAddress:t}=R(),n=U(),r=n?To(n,t):``;return(0,u.useSuspenseQuery)({queryKey:Eo.undelegations(e,n||``,r).queryKey,queryFn:async()=>{if(!n)return[];let t=await h.default.get(`${e}/initia/mstaking/v1/delegators/${n}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),i=await h.default.get(`${e}/initia/mstaking/v1/delegators/${r}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...t.unbonding_responses,...i.unbonding_responses]},select:e=>{let t=new Map;for(let n of e){let e=n.validator_address;for(let r of n.entries)for(let n of r.balance){let i=(0,d.denomToMetadata)(n.denom),a={denom:n.denom,metadata:i,amount:n.amount,validator:e,completionTime:r.completion_time},o=t.get(i)??[];o.push(a),t.set(i,o)}}return t},staleTime:z.MINUTE})}function ko(){let{restUrl:e}=B(),{lockStakeModuleAddress:t}=R(),n=U();return(0,u.useSuspenseQuery)({queryKey:Eo.lockStaking(e,n||``,t).queryKey,queryFn:async()=>{if(!n)return[];let{viewFunction:r}=(0,d.createMoveClient)(e);return await r({moduleAddress:t,moduleName:wo,functionName:`get_locked_delegations`,typeArgs:[],args:[(0,_.toBase64)((0,d.InitiaAddress)(n,32).bytes)]})??[]},select:e=>{let t=new Map;for(let n of e){let e={metadata:n.metadata,amount:n.amount,validator:n.validator,releaseTime:n.release_time},r=t.get(n.metadata)??[];r.push(e),t.set(n.metadata,r)}return t},staleTime:z.MINUTE})}function Ao(e){let t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(let n of e.total){if(!n?.denom||!n?.dec_coins)continue;let e=(0,d.denomToMetadata)(n.denom),r=new f.default(0);for(let e of n.dec_coins)e?.amount&&(r=r.plus(e.amount));let i=t.get(e);if(i){let e=new f.default(i.amount);r=r.plus(e)}t.set(e,{denom:n.denom,amount:r.toString()})}return t}function jo(){let{restUrl:e}=B(),t=U();return(0,u.useSuspenseQuery)({queryKey:Eo.stakingRewards(e,t||``).queryKey,queryFn:async()=>t?await h.default.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:Ao,staleTime:z.MINUTE})}function Mo(){let{restUrl:e}=B(),{lockStakeModuleAddress:t}=R(),n=U(),r=n?To(n,t):``;return(0,u.useSuspenseQuery)({queryKey:Eo.lockStakingRewards(e,n??``,r).queryKey,queryFn:async()=>n?await h.default.get(`${e}/initia/distribution/v1/delegators/${r}/rewards`).json():{rewards:[],total:[]},select:Ao,staleTime:z.MINUTE})}function No(){let e=B(),t=ut(e),{data:n,isLoading:r}=it(e),{data:i}=Do(),{data:a}=Oo(),{data:o}=ko(),s=ht((0,g.useMemo)(()=>{let e=new Set;for(let t of i.keys())e.add(t);for(let t of o.keys())e.add(t);for(let t of a.keys())e.add(t);return Array.from(e)},[i,o,a])),c=(0,g.useMemo)(()=>{let e=new Map;if(n)for(let t of n)e.set(t.id,t.price);return e},[n]),l=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.denom,n);return e},[t]),u=(0,g.useMemo)(()=>{let e=[],t=e=>{let t=l.get(e);return t?{symbol:t.symbol,decimals:t.decimals}:null};for(let[n,r]of i){let i=s.get(n)??r[0]?.denom;if(!i)continue;let a=t(i);if(!a)continue;let o=c.get(i)??0;for(let t of r){let{symbol:n,decimals:r}=a,s=Number((0,d.fromBaseUnit)(t.amount,{decimals:r})),c={type:`asset`,denom:i,symbol:n,amount:t.amount,formattedAmount:s,decimals:r,value:s*o};e.push({type:`staking`,validator:t.validator,balance:c})}}for(let[n,r]of o){let i=s.get(n);if(!i)continue;let a=t(i);if(!a)continue;let o=c.get(i)??0;for(let t of r){let{symbol:n,decimals:r}=a,s=Number((0,d.fromBaseUnit)(t.amount,{decimals:r})),c={type:`asset`,denom:i,symbol:n,amount:t.amount,formattedAmount:s,decimals:r,value:s*o},l=Number(t.releaseTime);e.push({type:`lockstaking`,validator:t.validator,releaseTime:Number.isNaN(l)?0:l,balance:c})}}for(let[n,r]of a){let i=s.get(n)??r[0]?.denom;if(!i)continue;let a=t(i);if(!a)continue;let o=c.get(i)??0;for(let t of r){let{symbol:n,decimals:r}=a,s=Number((0,d.fromBaseUnit)(t.amount,{decimals:r})),c={type:`asset`,denom:i,symbol:n,amount:t.amount,formattedAmount:s,decimals:r,value:s*o},l=new Date(t.completionTime).getTime(),u=Number.isNaN(l)?0:Math.floor(l/1e3);e.push({type:`unstaking`,validator:t.validator,completionTime:u,balance:c})}}return e.filter(e=>e.type!==`fungible-position`&&e.type!==`perp-position`&&e.balance.denom===`uinit`)},[i,o,a,s,l,c]);return{positions:u,totalValue:(0,g.useMemo)(()=>u.reduce((e,t)=>t.type===`fungible-position`||t.type===`perp-position`||t.balance.type===`unknown`?e:e+(t.balance.value??0),0),[u]),isLoading:r}}function Po(e){let t=new Map;for(let n of e){let e=(0,d.denomToMetadata)(n.denom),r={...n,metadata:e},i=t.get(e)??[];i.push(r),t.set(e,i)}return t}function Fo(e,t){return e.map(e=>t.get(e)?.symbol||e).join(`/`)}function Io(e){let{dexUrl:t}=R();return(0,u.useSuspenseQuery)({queryKey:oo.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;let n=await h.default.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(n.data))},staleTime:z.MINUTE})}function Lo(){let e=Lt(B()),{data:t}=Io((0,g.useMemo)(()=>e.map(e=>e.denom),[e]));return(0,g.useMemo)(()=>Po(e.filter(e=>t.get(e.denom)===!0)),[e,t])}function Ro(e){let{dexUrl:t}=R();return(0,u.useSuspenseQuery)({queryKey:oo.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;let{prices:n}=await h.default.get(`${t}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(`,`))}`).json();return Array.isArray(n)?new Map(n.map(({denom:e,price:t})=>[e,t])):new Map(Object.entries(n))},staleTime:z.MINUTE})}function zo(e,t,n,r){let i=new Set;for(let t of e.keys())i.add(t);for(let[e,n]of t){let t=n[0]?.denom;t&&t!==`uinit`&&i.add(e)}for(let e of n.keys())i.add(e);for(let[e,t]of r){let n=t[0]?.denom;n&&n!==`uinit`&&i.add(e)}return Array.from(i)}function Bo(e){let t=[];for(let[,n]of e)n&&n!==`uinit`&&t.push(n);return t}function Vo(e,t,n){let r=t.get(e)??null,i=r?.symbol||e,a=xo(r,n),o=a.length>0&&a.some(e=>e),s=o?void 0:n.get(e)?.logoUrl;return{denom:e,symbol:i,totalAmount:0,totalValue:0,decimals:n.get(e)?.decimals??6,poolType:r?.pool_type,logoUrl:s,coinLogos:o?a:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Ho(e,t,n,r,i){for(let[a,o]of e){let e=t.get(a)??o[0]?.denom;if(!e||e===`uinit`)continue;let s=r.get(e);if(s)for(let t of o){let r=s.decimals,a=Number((0,d.fromBaseUnit)(String(t.amount),{decimals:r})),o=a*(n.get(e)??0);s.breakdown[i]+=a,s.totalAmount+=a,s.totalValue+=o}}}function Uo(e,t,n,r,i){for(let[a,o]of e){let e=t.get(a);if(!e||e===`uinit`)continue;let s=r.get(e);if(s)for(let t of o){let r=s.decimals,a=Number((0,d.fromBaseUnit)(String(t.amount),{decimals:r})),o=a*(n.get(e)??0);s.breakdown[i]+=a,s.totalAmount+=a,s.totalValue+=o}}}function Wo(e,t,n,r){for(let[i,a]of e){let e=(0,d.denomToMetadata)(i),o=t?.get(e),s=o?(0,d.fromBaseUnit)(o.amount,{decimals:6}):`0`,c=n?.get(e),l=c?(0,d.fromBaseUnit)(c.amount,{decimals:6}):`0`,u=Number(s)+Number(l);u<=0||(a.claimableInit={staking:s,lockStaking:l,total:String(u),totalValue:u*r})}}function Go(e){return`#${e.replace(/^0x/,``).slice(-6)}`}function Ko(){let e=B(),t=ut(e),n=U(),r=Lo(),{data:i}=Do(),{data:a}=ko(),{data:o}=Oo(),{data:s}=jo(),{data:c}=Mo(),{data:l}=it(e),{data:u}=go(n),f=(0,g.useMemo)(()=>{let e=new Map;for(let t of u){let n=e.get(t.lpMetadata)??[];n.push(t),e.set(t.lpMetadata,n)}return e},[u]),p=(0,g.useMemo)(()=>Array.from(f.keys()),[f]),m=So(p),h=_o(p),_=vo((0,g.useMemo)(()=>u.map(e=>e.tokenAddress),[u])),v=yo((0,g.useMemo)(()=>{let e=[];for(let t of u)for(let n of t.incentives)e.push({tokenAddress:t.tokenAddress,incentiveAddress:n.incentiveAddress});return e},[u])),y=ht((0,g.useMemo)(()=>{let e=new Set;for(let t of u)for(let n of t.incentives)e.add(n.rewardMetadata);return Array.from(e)},[u]),{failSoft:!0}),b=ht((0,g.useMemo)(()=>zo(r,i,a,o),[r,i,a,o])),x=(0,g.useMemo)(()=>Bo(b),[b]),{data:S}=Ro(x),C=Co(x),w=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.denom,n);return e},[t]),T=(0,g.useMemo)(()=>{let e=new Map;for(let t of l??[])e.set(t.id,t.price);return e},[l]),{rows:E,totalValue:D}=(0,g.useMemo)(()=>{let e=l?.find(e=>e.id===`uinit`)?.price??0,t=new Map;for(let e of x)t.set(e,Vo(e,C,w));Ho(r,b,S,t,`deposit`),Ho(i,b,S,t,`staking`),Uo(a,b,S,t,`lockStaking`),Ho(o,b,S,t,`unstaking`),Wo(t,s,c,e);for(let e of p){let n=f.get(e)??[];if(n.length===0)continue;let r=m.get(e),i=h.get(e),a=po(e),o=r?.coins.map(e=>e.denom)??[],s=r?xo(r,w).filter(Boolean):[],c=o.map(e=>w.get(e)?.symbol||e),l=r?.symbol||c.join(`-`)||a,u=Fo(o,w),p=n.map(e=>{let t,n,a,s=!1,c=0,l=0;try{let r=ao({tickLower:e.tickLower,tickUpper:e.tickUpper});t=r.min,n=r.max}catch{t=void 0,n=void 0}if(i){try{let t=Za(BigInt(i.sqrtPrice)),n=ja(e.tickLower),r=ja(e.tickUpper),o=Number(i.tickSpacing);s=Number.isFinite(o)&&o>0?Fa(e.tickLower,e.tickUpper,o):!1,a=s||t>=n&&t<r}catch{a=void 0,s=!1}if(r&&o.length>0)try{$a({sqrtPrice:i.sqrtPrice,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:e.liquidity}).forEach((e,t)=>{let n=r.coins[t];if(!n)return;let i=w.get(n.denom)?.decimals??6,a=T.get(n.denom)??0,o=Number((0,d.fromBaseUnit)(String(e),{decimals:i}));c+=o*a})}catch{c=0}}return r&&((_.get(e.tokenAddress)??[]).forEach((e,t)=>{let n=r.coins[t];if(!n)return;let i=w.get(n.denom)?.decimals??6,a=T.get(n.denom)??0,o=Number((0,d.fromBaseUnit)(e,{decimals:i}));l+=o*a}),e.incentives.forEach(t=>{let n=v.get(fo(e.tokenAddress,t.incentiveAddress))??`0`,r=y.get(t.rewardMetadata);if(!r)return;let i=w.get(r)?.decimals??6,a=T.get(r)??0,o=Number((0,d.fromBaseUnit)(n,{decimals:i}));l+=o*a})),{tokenAddress:e.tokenAddress,positionId:Go(e.tokenAddress),inRange:a,isFullRange:s,minPrice:t,maxPrice:n,pricePairLabel:u,rewardValue:l,value:c}}),g=p.reduce((e,t)=>e+t.value,0),b=p.reduce((e,t)=>e+t.rewardValue,0),x=s.length>0;t.set(a,{denom:a,symbol:l,totalAmount:0,totalValue:g,decimals:6,poolType:`CLAMM`,logoUrl:void 0,coinLogos:x?s:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:e,totalRewardValue:b,positions:p}})}let n=Array.from(t.values()).filter(e=>e.totalAmount>0||e.isClamm).sort((e,t)=>t.totalValue-e.totalValue);return{rows:n,totalValue:n.reduce((e,t)=>e+t.totalValue,0)}},[l,x,C,w,r,i,a,o,b,S,s,c,p,f,m,h,_,v,y,T]);return{totalValue:D,rows:E}}var qo=`vault`,Jo=`vault_staking`,Yo=(0,m.createQueryKeys)(`interwovenkit:initia-vault`,{staked:(e,t,n)=>[e,t,n],info:(e,t,n)=>[e,t,n],shareToAsset:(e,t,n,r)=>[e,t,n,r],claimable:(e,t,n,r)=>[e,t,n,r]}),Xo=e=>d.bcs.object().serialize(e).toBase64(),Zo=e=>d.bcs.address().serialize(e).toBase64();function Qo(e,t,n,r){return(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:Yo.info(t,n,e.metadata).queryKey,queryFn:()=>r({moduleAddress:n,moduleName:qo,functionName:`vault_info`,typeArgs:[],args:[Xo(e.metadata)]}),staleTime:z.MINUTE})),combine:e=>e.map(e=>e.data)})}function $o(e,t,n,r){return(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:Yo.shareToAsset(t,n,e.metadata,e.amount).queryKey,queryFn:()=>r({moduleAddress:n,moduleName:qo,functionName:`vault_share_to_asset`,typeArgs:[],args:[Xo(e.metadata),d.bcs.u64().serialize(e.amount).toBase64()]}),staleTime:z.MINUTE})),combine:e=>e.map(e=>e.data)})}function es(e,t,n,r,i){return(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:Yo.claimable(t,n,e.metadata,r).queryKey,queryFn:()=>i({moduleAddress:n,moduleName:qo,functionName:`user_claimable_rewards`,typeArgs:[],args:[Xo(e.metadata),Zo(r)]}),staleTime:z.MINUTE})),combine:e=>e.map(e=>e.data??[])})}function ts(){let e=U(),t=B(),{restUrl:n}=t,{clammVaultModuleAddress:r}=R(),{viewFunction:i}=(0,d.createMoveClient)(n),{data:a}=it(t),o=ut(t),{data:s}=(0,u.useSuspenseQuery)({queryKey:Yo.staked(n,r,e).queryKey,queryFn:async()=>e?await i({moduleAddress:r,moduleName:Jo,functionName:`user_staked_tokens`,typeArgs:[],args:[Zo(e)]})??[]:[],staleTime:z.MINUTE}),c=Qo(s,n,r,i),l=$o(s,n,r,i),p=es(s,n,r,e,i),m=[...new Set(c.flatMap(e=>e?[e.asset_0,e.asset_1]:[]))],h=[...new Set(p.flatMap(e=>e.map(e=>e.metadata)))],_=ht(m,{failSoft:!0}),v=ht(h,{failSoft:!0});return(0,g.useMemo)(()=>{let e=new Map(o.map(e=>[e.denom,e])),t=e=>a?.find(t=>t.id===e)?.price??0,n=s.map((n,r)=>{let i=c[r],a=l[r];if(!i||!a)return null;let o=(0,f.default)(i.oracle_price_0||0).times(a[0]||0).plus((0,f.default)(i.oracle_price_1||0).times(a[1]||0)).toNumber(),s=e.get(_.get(i.asset_0)??``),u=e.get(_.get(i.asset_1)??``),m=p[r].reduce((n,r)=>{let i=v.get(r.metadata)??``,a=e.get(i),o=(0,d.fromBaseUnit)(r.amount,{decimals:a?.decimals??6});return n.plus((0,f.default)(o||0).times(t(i)))},(0,f.default)(0)).toNumber();return{vaultAddress:n.metadata,symbol:[s?.symbol,u?.symbol].filter(Boolean).join(`-`),coinLogos:[s?.logoUrl??``,u?.logoUrl??``],isActive:i.is_active,curatorAddress:i.curator?(0,d.InitiaAddress)(i.curator).bech32:``,value:o,claimableValue:m}}).filter(e=>e!==null).sort((e,t)=>t.value+t.claimableValue-(e.value+e.claimableValue));return{totalValue:n.reduce((e,t)=>e+t.value+t.claimableValue,0),rows:n}},[s,c,l,p,_,v,o,a])}var ns=(0,m.createQueryKeys)(`interwovenkit:initia-vip`,{allVestingPositions:(e,t)=>[e,t]});function rs(e){return e.filter(e=>e.data.length>0).map(e=>{let t=e.data[0].bridge_id,n=e.data[0].version,r=e.data.reduce((e,t)=>e+t.claimed_reward,0);return{claimableReward:e.total_claimable_reward,claimedReward:r,initialReward:e.total_vesting_reward,lockedReward:e.total_locked_reward,requiredScore:e.required_score,rollup:{bridgeId:t,version:n}}}).filter(e=>e.initialReward>0).sort((e,t)=>t.initialReward-e.initialReward)}function is(){let{vipUrl:e}=R(),t=U();return(0,u.useQuery)({queryKey:ns.allVestingPositions(e,t).queryKey,queryFn:async()=>(await h.default.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:e})=>e>0),staleTime:z.MINUTE,enabled:!!t})}function as(){let e=Xe(),t=Qe();return(0,g.useCallback)(n=>{let r=e.find(({metadata:e})=>e?.op_bridge_id===String(n));if(r)return r;let i=t.find(e=>e.op_bridge_id===String(n));if(i)return{name:i.pretty_name,logoUrl:i.logo}},[e,t])}function os(){let{data:e}=is(),{data:t}=it(B()),n=as(),r=(0,g.useMemo)(()=>t?.find(e=>e.id===`uinit`)?.price??0,[t]),i=(0,g.useMemo)(()=>e?rs(e).map(e=>{let t=n(e.rollup.bridgeId),i=Number((0,d.fromBaseUnit)(String(e.lockedReward),{decimals:6})),a=Number((0,d.fromBaseUnit)(String(e.claimableReward),{decimals:6})),o=(0,f.default)((0,d.fromBaseUnit)(String(e.lockedReward),{decimals:6})||0).times(r).toNumber(),s=(0,f.default)((0,d.fromBaseUnit)(String(e.claimableReward),{decimals:6})||0).times(r).toNumber();return{bridgeId:e.rollup.bridgeId,version:e.rollup.version,name:t?.name||`Bridge #${e.rollup.bridgeId}`,logoUrl:t?.logoUrl||ot,lockedReward:i,lockedRewardValue:o,claimableReward:a,claimableRewardValue:s}}).filter(e=>e.lockedReward+e.claimableReward>0):[],[e,r,n]);return{rows:i,totalValue:(0,g.useMemo)(()=>i.reduce((e,t)=>e+t.lockedRewardValue+t.claimableRewardValue,0),[i])}}function ss(){let{totalValue:e}=Ko(),{totalValue:t}=ts(),{data:n}=Do(),{data:r}=ko(),{data:i}=Oo(),{data:a}=is(),o=ht((0,g.useMemo)(()=>Array.from(r.keys()),[r])),{data:s}=it(B()),c=(0,g.useMemo)(()=>s?.find(e=>e.id===`uinit`)?.price??0,[s]);return(0,g.useMemo)(()=>{let s=0,l=0,u=c??0;for(let[,e]of n)for(let{denom:t,amount:n}of e)t===`uinit`&&(s+=Number((0,d.fromBaseUnit)(n,{decimals:6}))*u);for(let[e,t]of r)if(o.get(e)===`uinit`)for(let{amount:e}of t)l+=Number((0,d.fromBaseUnit)(e,{decimals:6}))*u;for(let[,e]of i)for(let{denom:t,amount:n}of e)t===`uinit`&&(s+=Number((0,d.fromBaseUnit)(n,{decimals:6}))*u);let f=0;if(a)for(let e of a){let t=e.total_locked_reward??0,n=e.total_claimable_reward??0;f+=Number((0,d.fromBaseUnit)(String(t+n),{decimals:6}))*u}return s+l+e+f+t},[n,r,o,i,a,c,e,t])}function cs(){let e=[`initia-wallet-widget:last-connected-wallet`,`initia-wallet-widget:fee-denoms`,`initia-wallet-widget:chain-ids`,`initia-wallet-widget:opened-layers-assets`,`initia-wallet-widget:opened-layers-nft`],t={"initia-wallet-widget:ethereum-public-keys":{prefix:V.PUBLIC_KEY,getSuffix:e=>(0,d.InitiaAddress)(e).bech32}};for(let t of e)localStorage.removeItem(t);for(let[e,{prefix:n,getSuffix:r}]of Object.entries(t)){let t=localStorage.getItem(e);if(t)try{let i=JSON.parse(t);for(let[e,t]of Object.entries(i)){let i=`${n}:${r(e)}`;localStorage.setItem(i,t)}localStorage.removeItem(e)}catch{}}}var ls=(0,m.createQueryKeys)(`interwovenkit:minity`,{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,n)=>[e,t,n],initiaPositions:(e,t)=>[e,`initia`,t],echelonPositions:(e,t)=>[e,`echelon`,t],inertiaPositions:(e,t)=>[e,`inertia`,t],ravePositions:(e,t,n)=>[e,`rave`,t,n],yominetPositions:(e,t)=>[e,`yominet`,t],chainPositions:(e,t,n)=>[e,t,n]});function us(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i++){let a=e[i],o=t[i],s=a.data;if(!(!o||!s)){for(let e of s)if(e.logoUrl&&!e.logoUrl.includes(`undefined`)){let t=`${o.chainId}:${e.denom}`;n.has(t)||n.set(t,e.logoUrl);let i=e.symbol.toUpperCase();r.has(i)||r.set(i,e.logoUrl)}}}return{denomLogos:n,symbolLogos:r}}function ds(e){return e.pnl??null}function fs(e){return e.balance.type===`unknown`?null:e.balance.value??null}function ps(e){return fs(e)==null}function ms(e){if(e==null||!Number.isFinite(e))return`—`;let t=(0,f.default)(e).decimalPlaces(2,f.default.ROUND_HALF_UP);return t.isZero()?`$0.00`:`${t.gt(0)?`+`:`-`}$${(0,d.formatNumber)(t.abs().toNumber(),{dp:2})}`}function hs(e,t){if(e==null||t==null||!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return``;let n=(0,f.default)(e).div(t).times(100).decimalPlaces(2,f.default.ROUND_HALF_UP);return n.isZero()?`(0.00%)`:`(${n.gt(0)?`+`:`-`}${n.abs().toFixed(2)}%)`}function gs(e){return!Number.isFinite(e)||e<1?``:(0,f.default)(e).decimalPlaces(0,f.default.ROUND_DOWN).toString()}function _s(e){if(e.type===`fungible-position`)return e.value??0;if(e.type===`perp-position`){let t=fs(e);if(t==null)return 0;let n=ds(e);return(0,f.default)(t).plus(n??0).toNumber()}if(e.balance.type===`unknown`)return 0;let t=e.balance.value??0;return e.type===`lending`&&e.direction===`borrow`?-t:t}function vs(e){switch(e.type){case`fungible-position`:return null;case`perp-position`:return`perp`;case`staking`:case`unstaking`:case`lockstaking`:return`staking`;case`lending`:return e.direction===`supply`?`lending`:`borrowing`;default:return e}}function ys(e,t={}){let{isInitia:n=!1,chainName:r}=t,i=r?.toLowerCase()===St;switch(e){case`staking`:return i?`Vault`:n?`INIT staking`:`Staking`;case`perp`:return`Perpetuals`;case`borrowing`:return`Borrowing`;case`lending`:return`Lending`;default:return e.charAt(0).toUpperCase()+e.slice(1)}}function bs(e){let t=new Map;for(let n of e){let e=vs(n);if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}let n=new Map,r=new Map;for(let[e,i]of t){let t=i.reduce((e,t)=>e+_s(t),0),a=i.reduce((e,t)=>e+Math.abs(_s(t)),0);n.set(e,t),r.set(e,a)}let i=(r.get(`lending`)??0)+(r.get(`borrowing`)??0),a=[...t.keys()].sort((e,t)=>{let n=e===`lending`||e===`borrowing`?i:r.get(e)??0,a=t===`lending`||t===`borrowing`?i:r.get(t)??0;return(e===`lending`||e===`borrowing`)&&(t===`lending`||t===`borrowing`)?e===`lending`?-1:1:a-n}),o=new Map;for(let e of a)o.set(e,{positions:t.get(e),totalValue:n.get(e)??0});return o}function xs(e){return e.type===`fungible-position`?e.title:e.type===`perp-position`?e.pair:e.balance.denom}function Ss(e){return e.type===`fungible-position`?e.title:e.type===`perp-position`?e.pair:e.balance.type===`unknown`?e.balance.denom:e.balance.symbol}function Cs(e){return e.type===`fungible-position`||e.type===`perp-position`?null:e.balance}function ws(e){switch(e){case`staking`:return`Staking`;case`unstaking`:return`Unstaking`;case`lockstaking`:return`Lock staking`;case`lending`:return`Lending`;case`fungible-position`:return`Position`;case`perp-position`:return`Perpetuals`;default:return``}}function Ts(e){let t=new Map;for(let n of e){let e=t.get(n.type)??[];e.push(n),t.set(n.type,e)}return t}function Es(e,t){let n=At(e.symbol),r=At(t.symbol);return n===r?t.totalValue===e.totalValue?e.symbol.localeCompare(t.symbol,void 0,{sensitivity:`base`}):t.totalValue-e.totalValue:n-r}function Ds(e){let t=new Map;for(let n of e){let e=xs(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.entries()).map(([e,t])=>{let n=Cs(t[0]),r=0;for(let e of t)e.type===`fungible-position`||e.type===`perp-position`||e.balance.type!==`unknown`&&(r+=e.balance.formattedAmount);return{denom:e,symbol:Ss(t[0]),positions:t,totalValue:t.reduce((e,t)=>e+_s(t),0),totalAmount:r,balance:n}}).sort(Es)}function Os(e,t){let n=new Map;return e.forEach((e,r)=>{let i=t[r]?.data;if(i&&i.length>0){let t=new Map(i.map(e=>[e.id,e.price]));n.set(e.chainId,t)}}),n}function ks(e,t){return e.map(e=>({...e,balances:e.balances.map(n=>{if(n.type===`unknown`||n.value!=null&&n.value>0)return n;let r=t.get(e.chainId);if(r){let e=r.get(n.denom)??0;if(e>0)return{...n,value:n.formattedAmount*e}}return n})}))}function As(e,t){let n=At(e.symbol),r=At(t.symbol);return n===r?t.totalValue===e.totalValue?e.symbol.localeCompare(t.symbol,void 0,{sensitivity:`base`}):t.totalValue-e.totalValue:n-r}function js(e,t,n){return e.map(e=>{let r=e.assets.map(e=>{let r=e.symbol.toUpperCase(),i=`${e.chain.chainId}:${e.denom}`,a=t.get(i)??n.get(r)??``;return a===e.logoUrl?e:{...e,logoUrl:a}}),i=``;for(let e of r)if(e.logoUrl){i=e.logoUrl;break}return i||=n.get(e.symbol.toUpperCase())??``,i!==e.logoUrl||r!==e.assets?{...e,logoUrl:i,assets:r}:e})}function Ms(e,t,n){let r=t?e.filter(e=>{let{symbol:n,assets:r}=e,i=t.toLowerCase();return n.toLowerCase().includes(i)||r.some(({denom:e})=>e.toLowerCase().includes(i))}):e,i=n?r.map(e=>{let t=e.assets.filter(({chain:e})=>e.chainId===n);return{...e,assets:t,totalValue:t.reduce((e,t)=>e+(t.value??0),0),totalAmount:t.reduce((e,t)=>e+Number(t.quantity),0)}}).filter(e=>e.assets.length>0):r;return{filteredAssets:i,totalAssetsValue:i.reduce((e,t)=>e+t.assets.reduce((e,t)=>e+(t.value??0),0),0)}}function Ns(e,t,n){let r=t?e.filter(({denom:e,address:n})=>{let r=t.toLowerCase();return e.toLowerCase().includes(r)||n?.toLowerCase().includes(r)}):e;return n?r.filter(({chain:e})=>e.chainId===n):r}function Ps(e,t,n,r){let{filteredAssets:i,totalAssetsValue:a}=Ms(e,n,r);return{filteredAssets:i,totalAssetsValue:a,filteredUnlistedAssets:Ns(t,n,r)}}function Fs(e,t,n,r){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};let i=new Map,a=[];for(let r of e){let{chainName:e,chainId:o,balances:s}=r;if(!Array.isArray(s))continue;let c=t.get(e.toLowerCase()),l=c?.chainId??o??e,u=c?.prettyName??e,d=c?.logoUrl??``,f=n.get(l);for(let e of s){if(e.type===`unknown`){if(!e.amount||e.amount===`0`)continue;a.push({symbol:e.denom,logoUrl:``,denom:e.denom,amount:e.amount,decimals:0,quantity:e.amount,value:void 0,unlisted:!0,chain:{chainId:l,name:u,logoUrl:d}});continue}if(e.type===`lp`||(e.value??0)<=0&&(e.formattedAmount??0)<=0)continue;let t=e.value;if((t==null||t<=0)&&f){let n=f.get(e.denom)??0;n>0&&(t=e.formattedAmount*n)}let n={symbol:e.symbol,logoUrl:``,denom:e.denom,amount:e.amount,decimals:e.decimals,quantity:String(e.formattedAmount),value:t,chain:{chainId:l,name:u,logoUrl:d}},r=i.get(e.symbol);r?r.push(n):i.set(e.symbol,[n])}}a.sort((e,t)=>{let n=e.chain.chainId===r,i=t.chain.chainId===r;if(n&&!i)return-1;if(!n&&i)return 1;let a=e.chain.name.localeCompare(t.chain.name);if(a!==0)return a;try{let n=BigInt(e.amount),r=BigInt(t.amount);if(n>r)return-1;if(n<r)return 1}catch{let n=e.amount.localeCompare(t.amount);if(n!==0)return-n}return e.denom.localeCompare(t.denom)});let o=[];for(let[e,t]of i){t.sort((e,t)=>(t.value??0)-(e.value??0));let n=0,r=0;for(let e of t)n+=e.value??0,r+=Number(e.quantity);o.push({symbol:e,logoUrl:``,assets:t,totalValue:n,totalAmount:r})}return o.sort(As),{listedGroups:o,unlistedAssets:a}}function Is(){return B().network_type===`testnet`}function Ls(){return(0,F.useFormContext)()}function Rs(e){let t=en(e);return t&&t.gt(0)?e:null}function zs(){let e=Jt(),t=Is(),n={quantity:``,slippagePercent:`0.5`,sender:``,cosmosWalletName:``,recipient:``},r={...n,srcChainId:`initiation-2`,srcDenom:`uusdc`,dstChainId:`initiation-2`,dstDenom:`uinit`},i={...n,srcChainId:`interwoven-1`,srcDenom:`ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4`,dstChainId:`interwoven-1`,dstDenom:`uinit`},a=(0,p.pickBy)(e=>e!==null,{srcChainId:localStorage.getItem(V.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(V.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(V.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(V.BRIDGE_DST_DENOM),quantity:localStorage.getItem(V.BRIDGE_QUANTITY),slippagePercent:Rs(localStorage.getItem(V.BRIDGE_SLIPPAGE_PERCENT))});return{...t?r:i,...a,...e}}var Bs={balances:[],positions:[],isLoading:!0,isComplete:!1},Vs=(0,b.atom)(0),Hs=1e3,Us=0;function Ws(){let e=(0,b.useSetAtom)(Vs);return(0,g.useCallback)(t=>{let n=Date.now();(t?.force||n-Us>=Hs)&&(Us=n,e(e=>e+1))},[e])}function Gs(){let e=(0,u.useQueryClient)(),t=U(),{minityUrl:n}=R(),r=Is(),i=(0,b.useAtomValue)(Vs),a=(0,g.useEffectEvent)((e,t)=>{let n=Array.isArray(e.balances)?e.balances:[];t.set(e.chain,{chainName:e.chain,chainId:e.chainId,balances:n})}),o=(0,g.useEffectEvent)((e,t)=>{let n=Array.isArray(e.positions)?e.positions:[];t.set(e.chain,{chainName:e.chain,chainId:e.chainId,positions:n})}),s=(0,g.useEffectEvent)((r,i)=>{let a=ls.ssePortfolio(t??``,n).queryKey,o=e.getQueryData(a)??Bs,s=r.size>0||i.size>0;e.setQueryData(a,{...o,balances:Array.from(r.values()),positions:Array.from(i.values()),isLoading:s?!1:o.isLoading,isComplete:!1})});(0,g.useEffect)(()=>{if(!t||r)return;let i=ls.ssePortfolio(t,n).queryKey,c=e.getQueryData(i),l=new Map,u=new Map;for(let e of c?.balances??[])l.set(e.chainName,e);for(let e of c?.positions??[])u.set(e.chainName,e);let d=`${n}/v1/chain/all/${encodeURIComponent(t)}`,f=null,p=!1;return e.setQueryData(i,{balances:c?.balances??[],positions:c?.positions??[],isLoading:!0,isComplete:!1}),f=new EventSource(d),f.onmessage=e=>{if(!p)try{let t=JSON.parse(e.data);t.type===`balances`?a(t,l):t.type===`positions`&&o(t,u),s(l,u)}catch{}},f.onerror=()=>{f?.close()},()=>{p=!0,f?.close()}},[t,r,i])}var Ks={balances:[],positions:[],isLoading:!0,isComplete:!1};function qs(){let e=U(),{minityUrl:t}=R(),n=ls.ssePortfolio(e??``,t).queryKey,{data:r}=(0,u.useQuery)({queryKey:n,queryFn:()=>Ks,enabled:!!e,staleTime:z.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return r??Ks}function Js(){let e=Xe();return(0,g.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.chain_name.toLowerCase();t.set(e,{chainId:n.chainId,chainName:n.chain_name,prettyName:n.name||n.chain_name,logoUrl:n.logoUrl||``})}return t},[e])}function Ys(){let{balances:e,positions:t}=qs(),n=Xe(),r=(0,g.useMemo)(()=>{let e=new Map;for(let t of n)e.set(t.chain_name.toLowerCase(),t);return e},[n]);return(0,g.useMemo)(()=>{let n=e=>e.type===`unknown`?0:e.value??0,i=e=>e.positions.reduce((e,t)=>e+_s(t),0),a=new Map,o=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[];for(let{chainName:e,balances:t}of o){if(!Array.isArray(t))continue;let r=t.reduce((e,t)=>e+n(t),0);a.set(e,(a.get(e)||0)+r)}for(let{chainName:e,positions:t}of s){if(!Array.isArray(t))continue;let n=t.reduce((e,t)=>e+i(t),0);a.set(e,(a.get(e)||0)+n)}let c=Array.from(a.values()).reduce((e,t)=>e+t,0),l=Array.from(a.entries()).filter(([,e])=>e>0).map(([e,t])=>{let n=r.get(e.toLowerCase());return{chainId:n?.chainId||``,chainName:n?.name||e,logoUrl:n?.logoUrl||``,totalBalance:t,percentage:c>0?t/c:0}}).filter(e=>e.chainId!==``);return(0,p.sortWith)([(0,p.descend)(e=>e.chainName.toLowerCase()===`initia`),(0,p.descend)((0,p.prop)(`totalBalance`))],l)},[e,t,r])}function Xs(){let{balances:e}=qs(),t=Xe(),n=at(),r=(0,g.useMemo)(()=>Os(t,n),[t,n]);return(0,g.useMemo)(()=>{let t=e=>e.type===`unknown`?0:e.value??0,n=0,i=ks(Array.isArray(e)?e:[],r);for(let{balances:e}of i)if(Array.isArray(e))for(let r of e)r.type!==`lp`&&(n+=t(r));return n},[e,r])}function Zs(){let{positions:e}=qs();return(0,g.useMemo)(()=>{let t=e=>e.positions.reduce((e,t)=>e+_s(t),0),n=[`initia`,`civitia`,`yominet`],r=0,i=Array.isArray(e)?e:[];for(let{chainName:e,positions:a}of i){let i=e.toLowerCase();n.includes(i)||Array.isArray(a)&&(r+=a.reduce((e,n)=>e+t(n),0))}return r},[e])}function Qs(){let e=rn();(0,u.usePrefetchQuery)({queryKey:nn.chains.queryKey,queryFn:()=>e.get(`v2/info/chains`).json(),staleTime:z.MINUTE}),(0,u.usePrefetchQuery)({queryKey:nn.allAssets().queryKey,queryFn:()=>e.get(`v2/fungible/assets`).json(),staleTime:z.MINUTE})}var $s=()=>(jn(),Mn(),null),ec={loader:`_loader_1vxch_1`,spin:`_spin_1vxch_1`},tc=({size:e=24,color:t=`currentColor`,border:n=2})=>{let r={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${n}px`};return(0,y.jsx)(`div`,{className:ec.loader,style:r,role:`status`,"aria-label":`Loading`})},nc={button:`_button_1q027_1`,outline:`_outline_1q027_28`,sm:`_sm_1q027_46`,full:`_full_1q027_53`,small:`_small_1q027_57`,span:`_span_1q027_76`,unpadded:`_unpadded_1q027_88`},rc=e=>{let{sm:t,fullWidth:n,loading:r,className:i,children:a,disabled:o,...s}=e;return(0,y.jsx)(`button`,{...s,className:(0,P.default)(nc.button,{[nc.sm]:t,[nc.full]:n},i),disabled:!!r||o,"aria-busy":!!r,children:r?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(tc,{color:`currentColor`,size:16}),typeof r==`string`&&(0,y.jsx)(`span`,{className:nc.loading,children:r})]}):a})},G={White:rc,Outline:({className:e,...t})=>(0,y.jsx)(rc,{...t,className:(0,P.default)(nc.outline,e)}),Small:({className:e,unpadded:t,...n})=>(0,y.jsx)(`button`,{...n,className:(0,P.default)(nc.small,{[nc.unpadded]:t},e)})},ic={footer:`_footer_1vp4h_1`,actions:`_actions_1vp4h_10`},ac=({extra:e,className:t,children:n})=>(0,y.jsxs)(`footer`,{className:(0,P.default)(ic.footer,t),children:[e,(0,y.jsx)(`div`,{className:ic.actions,children:n})]}),oc={scrollable:`_scrollable_13su7_1`},sc=({className:e,children:t,ref:n})=>(0,y.jsx)(`div`,{ref:n,className:(0,P.default)(oc.scrollable,e),children:t}),cc=`interwovenkit:`;function lc(e){let[t]=e;return typeof t==`string`&&t.startsWith(cc)}function uc(e){e.removeQueries({predicate:e=>lc(e.queryKey)})}function dc(){return(0,ue.useMediaQuery)(`(max-width: 576px)`)}var fc=`interwoven-kit`;function pc(){let e=document.querySelector(fc)||document.body.appendChild(document.createElement(fc));return e.shadowRoot||e.attachShadow({mode:`open`})}function mc(){let{theme:e,container:t}=R();return(0,g.useEffect)(()=>{document.querySelector(fc)?.setAttribute(`data-theme`,e)},[e]),t??pc()}function hc(e){let t=pc(),n=document.createElement(`style`);n.textContent=e,t.appendChild(n)}var gc=(0,g.createContext)(null);function _c(){let{container:e}=(0,g.useContext)(gc);return e}function vc(e){let t=_c();return t?getComputedStyle(t).getPropertyValue(e):``}function yc(){return(0,ue.useScrollLock)(),null}function bc(e){return/^[A-F0-9]{64}$/i.test(e)}function xc(e,t){let{txHash:n,accountAddress:r,pathSuffix:i}=t;if(n)return bc(n)?(0,p.path)([`explorers`,0,`tx_page`],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!d.InitiaAddress.validate(r))return;let t=(0,p.path)([`explorers`,0,`account_page`],e)?.replace(/\$\{accountAddress\}/g,r);return t&&i?t+i:t}}function Sc(e){try{let t=new URL(e,window.location.href);if(![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid protocol`);return t.toString()}catch{return`#`}}var Cc={link:`_link_j1lkz_1`},wc=({chainId:e,txHash:t,accountAddress:n,pathSuffix:r,...i})=>{let{showIcon:a,className:o,children:s,onClick:c,...l}=i,u=xc(et(e),{txHash:t,accountAddress:n,pathSuffix:r}),f=t?(0,d.truncate)(t):n?(0,d.truncate)(n):``,p=s??f;return u?(0,y.jsxs)(`a`,{...l,href:(0,pe.default)(Sc(u)),className:(0,P.default)(Cc.link,o),onClick:c,target:`_blank`,rel:`noopener noreferrer`,children:[p,a&&(0,y.jsx)(I.IconExternalLink,{size:12,"aria-hidden":`true`})]}):(0,y.jsx)(`span`,{...l,className:(0,P.default)(Cc.link,o),children:p})},Tc=(0,g.createContext)(null),Ec=()=>(0,g.useContext)(Tc),Dc=()=>{let[e,t]=(0,b.useAtom)(zi),{showNotification:n,updateNotification:r,hideNotification:i}=Ec(),a=(0,u.useQueryClient)(),o=Ws();return(0,g.useEffect)(()=>{if(!e)return;let{status:s,chainId:c,txHash:l,error:u}=e,d=u?u.message:l?(0,y.jsx)(wc,{txHash:l,chainId:c,onClick:i,showIcon:!0,children:`View on Initia Scan`}):null,f=()=>{a.invalidateQueries({queryKey:Pt.balances._def}),o({force:!0}),t(null)};switch(s){case`loading`:n({type:`loading`,title:`Transaction is pending...`});break;case`error`:r({type:`error`,title:`Transaction failed`,description:d}),f();break;case`success`:r({type:`success`,title:`Transaction is successful!`,description:d,autoHide:!0}),f();break}},[e,t,n,r,i,a,o]),null},Oc=({value:e,children:t})=>{let[n,r]=(0,g.useState)(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},kc={placeholder:`_placeholder_wrm07_1`,logo:`_logo_wrm07_8`},K=({src:e,alt:t,placeholder:n,classNames:r,style:i,logo:a,...o})=>{let[s,c]=(0,g.useState)(void 0),{width:l,height:u}=o,d=n??(0,y.jsx)(`span`,{className:(0,P.default)(kc.placeholder,r?.placeholder),style:{width:l,height:u,...i},"aria-hidden":`true`});return!e||s===e?d:(0,y.jsx)(`img`,{...o,className:(0,P.default)(o.className,{[kc.logo]:a}),style:{width:l,height:u,...i},src:e,alt:t??``,loading:`lazy`,onError:()=>c(e)})};function Ac(){let{connector:e}=(0,l.useAccount)();if(e)return e.id===`io.privy.wallet`?`https://assets.initia.xyz/images/wallets/Privy.webp`:e.icon}var jc={header:`_header_1q8ju_1`,account:`_account_1q8ju_17`,name:`_name_1q8ju_28`,address:`_address_1q8ju_32`,icon:`_icon_1q8ju_36`,copied:`_copied_1q8ju_43`,button:`_button_1q8ju_58`,settings:`_settings_1q8ju_69`,disconnect:`_disconnect_1q8ju_73`,label:`_label_1q8ju_83`,expanded:`_expanded_1q8ju_91`},Mc=()=>{let e=wr(),{address:t,username:n}=Ta(),r=Ac(),i=n??t,[a,o]=(0,g.useState)(!1),s=(0,g.useRef)(null),c=(0,me.useSpring)({width:a?140:52,config:{tension:500,friction:30,clamp:!0}}),l=()=>{a?e():o(!0)},u=()=>{a&&(s.current=setTimeout(()=>{o(!1)},500))},f=()=>{s.current&&=(clearTimeout(s.current),null)};return(0,g.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),t?(0,y.jsxs)(`header`,{className:jc.header,children:[(0,y.jsx)(Oc,{value:t,children:({copy:e,copied:n})=>(0,y.jsxs)(`button`,{className:(0,P.default)(jc.account,{[jc.copied]:n}),onClick:e,"aria-label":n?`Copied`:`Copy address`,children:[(0,y.jsx)(K,{src:r,width:18,height:18}),(0,y.jsx)(`div`,{className:jc.address,children:(0,d.truncate)(t)}),(0,y.jsx)(`div`,{className:jc.name,children:(0,d.truncate)(i)}),(0,y.jsx)(I.IconCopy,{className:jc.icon,size:12,"aria-hidden":`true`}),n?`Copied!`:``]})}),(0,y.jsx)(Qt,{to:`/settings`,className:(0,P.default)(jc.button,jc.settings),"aria-label":`Open settings`,children:(0,y.jsx)(I.IconSettingFilled,{size:16,"aria-hidden":`true`})}),(0,y.jsxs)(me.animated.button,{className:(0,P.default)(jc.button,jc.disconnect,{[jc.expanded]:a}),style:c,onClick:l,onMouseLeave:u,onMouseEnter:f,"aria-label":`Disconnect wallet`,children:[(0,y.jsx)(I.IconSignOut,{size:16,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:jc.label,children:`Disconnect`})]})]}):null},Nc={overlay:`_overlay_jij9g_1`,content:`_content_jij9g_28`,inner:`_inner_jij9g_60`},Pc=({children:e})=>{let{isDrawerOpen:t,closeDrawer:n}=Sr(),{setContainer:r}=(0,g.useContext)(gc),i=(0,g.useCallback)(e=>{e&&r(e)},[r]),a=dc(),o=mc(),s=(0,b.useAtomValue)(Ri),c=(0,b.useAtomValue)(Hn),l=(0,u.useIsMutating)({mutationKey:[Li]}),d=()=>{let e=l?`User exited before response arrived. Transaction may succeed or fail.`:`User rejected`;n(),s?.reject(Error(e)),c?.reject(Error(`User rejected`))},f=qt(),p=Xt(),m=(0,u.useQueryClient)();return(0,y.jsx)(fe.Dialog.Root,{open:t,onOpenChange:e=>!e&&d(),modal:!1,children:(0,y.jsxs)(fe.Dialog.Portal,{container:o,children:[a&&(0,y.jsx)(fe.Dialog.Backdrop,{className:Nc.overlay,onClick:d,children:(0,y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z`}),(0,y.jsx)(`path`,{d:`M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z`})]})}),(0,y.jsx)(fe.Dialog.Popup,{className:Nc.content,"aria-label":`Initia wallet`,children:(0,y.jsxs)(`div`,{className:(0,P.default)(Nc.inner,`body`),ref:i,children:[a&&(0,y.jsx)(yc,{}),(0,y.jsx)(Dc,{}),(0,y.jsx)(Mc,{}),(0,y.jsx)(W,{errorBoundaryProps:{fallbackRender:({error:e,resetErrorBoundary:t})=>(0,y.jsxs)(sc,{children:[(0,y.jsx)(Da,{error:!0,children:e.message}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{onClick:()=>{f===`/bridge`&&(localStorage.removeItem(V.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(V.BRIDGE_SRC_DENOM),localStorage.removeItem(V.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(V.BRIDGE_DST_DENOM)),p(`/`),uc(m),t()},children:`Retry`})})]})},children:e})]})})]})})},Fc={backdrop:`_backdrop_1polz_1`,modal:`_modal_1polz_12`,content:`_content_1polz_18`,closeButton:`_closeButton_1polz_59`},Ic=({children:e})=>{let{isModalOpen:t,closeModal:n}=Cr(),{setContainer:r}=(0,g.useContext)(gc),i=(0,g.useCallback)(e=>{e&&r(e)},[r]),a=mc();return(0,y.jsx)(fe.Dialog.Root,{open:t,onOpenChange:e=>!e&&n(),children:(0,y.jsxs)(fe.Dialog.Portal,{container:a,children:[(0,y.jsx)(fe.Dialog.Backdrop,{className:Fc.backdrop,onClick:n}),(0,y.jsxs)(fe.Dialog.Popup,{className:Fc.modal,ref:i,"aria-label":`Initia wallet`,children:[(0,y.jsx)(`button`,{className:Fc.closeButton,onClick:n,"aria-label":`Close`,children:(0,y.jsx)(I.IconClose,{size:20})}),(0,y.jsx)(`div`,{className:Fc.content,children:(0,y.jsx)(W,{children:e})})]})]})})},Lc=(0,g.createContext)(!1),Rc={overlay:`_overlay_1iyfl_1`,fullscreen:`_fullscreen_1iyfl_15`,content:`_content_1iyfl_19`,header:`_header_1iyfl_56`,title:`_title_1iyfl_65`,close:`_close_1iyfl_70`},zc=({title:e,children:t,trigger:n,className:r,open:i,onOpenChange:a})=>{let o=_c(),s=(0,g.useContext)(Lc);return o?(0,y.jsxs)(fe.Dialog.Root,{open:i,onOpenChange:a,modal:!1,children:[n&&(0,y.jsx)(fe.Dialog.Trigger,{className:r,children:n}),(0,y.jsxs)(fe.Dialog.Portal,{container:o,children:[(0,y.jsx)(fe.Dialog.Backdrop,{className:(0,P.default)(Rc.overlay,{[Rc.fullscreen]:s}),onClick:()=>a(!1),forceRender:!0}),(0,y.jsxs)(fe.Dialog.Popup,{className:(0,P.default)(Rc.content,{[Rc.fullscreen]:s}),children:[e&&(0,y.jsxs)(`header`,{className:Rc.header,children:[(0,y.jsx)(fe.Dialog.Title,{className:Rc.title,children:e}),(0,y.jsx)(fe.Dialog.Close,{className:Rc.close,"aria-label":`Close`,children:(0,y.jsx)(I.IconClose,{size:20,"aria-hidden":`true`})})]}),t]})]})]}):null},Bc=({children:e})=>{let t=(0,g.useRef)(null),[n,r]=(0,g.useState)(0),[i,a]=(0,g.useState)(!1),o=(0,me.useSpring)({height:n,config:{tension:500,friction:30,clamp:!0},immediate:!i});return(0,g.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let{height:t}=e.getBoundingClientRect();r(t),a(!0)};n();let i=new ResizeObserver(n);return i.observe(e),()=>i.disconnect()},[e]),e?(0,y.jsx)(me.animated.div,{style:{overflow:`hidden`,...o},children:(0,y.jsx)(`div`,{ref:t,children:e})}):null},Vc={help:`_help_qcmtq_1`,icon:`_icon_qcmtq_10`,info:`_info_qcmtq_19`,warning:`_warning_qcmtq_23`,error:`_error_qcmtq_27`,success:`_success_qcmtq_33`},Hc=({level:e,className:t,mt:n=8,children:r})=>r?(0,y.jsxs)(`div`,{className:(0,P.default)(Vc.help,e&&Vc[e],t),style:{marginTop:n},role:e===`error`?`alert`:`status`,children:[(0,y.jsx)(`div`,{className:Vc.icon,"aria-hidden":`true`,children:(()=>{switch(e){case`loading`:return(0,y.jsx)(tc,{size:12});case`info`:return(0,y.jsx)(I.IconInfoFilled,{size:12});case`warning`:case`error`:return(0,y.jsx)(I.IconWarningFilled,{size:12});default:return(0,y.jsx)(I.IconCheckCircleFilled,{size:12})}})()}),r]}):null,Uc={stack:`_stack_a6m7u_1`,help:`_help_a6m7u_6`,info:`_info_a6m7u_14`,warning:`_warning_a6m7u_19`,error:`_error_a6m7u_24`,success:`_success_a6m7u_29`},Wc=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:(0,y.jsx)(Bc,{children:(0,y.jsx)(`div`,{className:Uc.stack,children:e})}),Gc=({mt:e=0,...t})=>(0,y.jsx)(Hc,{...t,className:(0,P.default)(Uc.help,Uc[t.level]),mt:e});Gc.Stack=Wc;var Kc={root:`_root_16p5j_1`,item:`_item_16p5j_10`,chevron:`_chevron_16p5j_14`,trigger:`_trigger_16p5j_19`,content:`_content_16p5j_39`,slideDown:`_slideDown_16p5j_1`,slideUp:`_slideUp_16p5j_1`};function qc(e){let{list:t,getKey:n,renderHeader:r,renderContent:i,footer:a,...o}=e;return(0,y.jsxs)(N.Accordion.Root,{className:Kc.root,type:`multiple`,...o,children:[t.map((e,t)=>(0,y.jsxs)(N.Accordion.Item,{className:Kc.item,value:n?.(e)??String(t),children:[(0,y.jsx)(N.Accordion.Header,{children:(0,y.jsxs)(N.Accordion.Trigger,{className:Kc.trigger,children:[r(e),(0,y.jsx)(I.IconChevronDown,{className:Kc.chevron,size:16,"aria-hidden":`true`})]})}),(0,y.jsx)(N.Accordion.Content,{className:Kc.content,children:i(e)})]},n?.(e)??t)),a]})}var Jc={trigger:`_trigger_u613p_1`,icon:`_icon_u613p_18`,content:`_content_u613p_27`,item:`_item_u613p_36`,itemText:`_itemText_u613p_52`,itemIndicator:`_itemIndicator_u613p_57`,active:`_active_u613p_60`};function Yc({options:e,value:t,onChange:n,classNames:r}){let i=_c(),a=e.find(e=>e.value===t);if(!a)throw Error(`Selected option not found`);return(0,y.jsxs)(ge.Select.Root,{value:String(t),onValueChange:t=>{let r=e.find(e=>String(e.value)===t);if(!r)throw Error(`Option not found: ${t}`);n(r.value)},modal:!1,children:[(0,y.jsxs)(ge.Select.Trigger,{className:(0,P.default)(Jc.trigger,r?.trigger),children:[(0,y.jsx)(ge.Select.Value,{children:a.triggerLabel||a.label}),(0,y.jsx)(ge.Select.Icon,{className:Jc.icon,children:(0,y.jsx)(I.IconChevronDown,{size:12,"aria-hidden":`true`})})]}),(0,y.jsx)(ge.Select.Portal,{container:i,children:(0,y.jsx)(ge.Select.Positioner,{className:Jc.content,alignItemWithTrigger:!1,sideOffset:6,align:`end`,children:(0,y.jsx)(ge.Select.Popup,{className:Jc.popup,children:e.map(e=>(0,y.jsxs)(ge.Select.Item,{className:(0,P.default)(Jc.item,r?.item),value:String(e.value),children:[(0,y.jsx)(ge.Select.ItemText,{className:(0,P.default)(Jc.itemText,r?.itemText),children:e.label}),(0,y.jsx)(I.IconCheck,{size:12,className:(0,P.default)(Jc.itemIndicator,{[Jc.active]:e.value===t}),"aria-hidden":`true`})]},String(e.value)))})})})]})}var Xc={root:`_root_1t37n_1`,trigger:`_trigger_1t37n_7`,item:`_item_1t37n_11`,itemText:`_itemText_1t37n_17`},Zc=({options:e,value:t,onChange:n})=>{let{txRequest:r}=Xi(),i=ft(et(r.chainId)),a=(e,t)=>{if((0,d.formatAmount)(e,{decimals:t})===`0.000000`)return 8},o=({amount:[{amount:e,denom:t}]})=>{if((0,f.default)(e||0).isZero())return`0`;let{symbol:n,decimals:r}=i(t);return`${(0,d.formatAmount)(e,{decimals:r,dp:a(e,r)})} ${n}`},s=e.map(e=>{let[{denom:t}]=e.amount,{symbol:n}=i(t);return{value:t,label:o(e),triggerLabel:n}});if(e.length===1)return(0,y.jsx)(`span`,{className:`monospace`,children:o(e[0])});let c=e.find(e=>e.amount[0].denom===t);if(!c)throw Error(`Fee option not found`);let[{amount:l,denom:u}]=c.amount,{decimals:p}=i(u),m=a(l,p);return(0,y.jsxs)(`div`,{className:Xc.root,children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.formatAmount)(l,{decimals:p,dp:m})}),(0,y.jsx)(Yc,{options:s,value:t,onChange:n,classNames:Xc})]})},Qc={root:`_root_16nr2_1`,trigger:`_trigger_16nr2_5`,chevron:`_chevron_16nr2_13`,panel:`_panel_16nr2_27`,details:`_details_16nr2_39`,row:`_row_16nr2_48`},$c=({spend:e,fee:t,total:n,balance:r,symbol:i,decimals:a})=>{let o=[e&&{label:`Spend`,value:e},{label:`Fee`,value:t},e&&{label:`Required (spend + fee)`,value:n},{label:`Balance`,value:r}].filter(Boolean),s=a===6?void 0:8;return(0,y.jsxs)(L.Collapsible.Root,{className:Qc.root,children:[(0,y.jsxs)(L.Collapsible.Trigger,{className:Qc.trigger,children:[(0,y.jsx)(`span`,{children:`Insufficient balance for fee`}),(0,y.jsx)(I.IconChevronDown,{className:Qc.chevron,size:16})]}),(0,y.jsx)(L.Collapsible.Panel,{className:Qc.panel,children:(0,y.jsx)(`div`,{className:Qc.details,children:o.map(({label:e,value:t})=>(0,y.jsxs)(`div`,{className:Qc.row,children:[(0,y.jsx)(`span`,{children:e}),(0,y.jsxs)(`span`,{children:[(0,d.formatAmount)(t,{decimals:a,dp:s}),` `,i]})]},e))})})]})};function el(e){switch(typeof e){case`string`:return e;case`number`:case`bigint`:return e.toString();case`boolean`:return e?`true`:`false`;case`object`:return e===null?`null`:e instanceof Uint8Array?(0,_.toBase64)(e):Array.isArray(e)?`[${e.map(el).join(`,`)}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t);default:return`unknown`}}var tl={container:`_container_1xzyq_1`,toggle:`_toggle_1xzyq_5`,list:`_list_1xzyq_11`,arg:`_arg_1xzyq_16`,type:`_type_1xzyq_21`},nl=(0,m.createQueryKeys)(`interwovenkit:move`,{abi:(e,t,n,r)=>[e,t,n,r]}),rl=({type:e,arg:t})=>el((0,d.resolveBcsType)(e).parse(t)),il=({msg:e,chainId:t,fallback:n})=>{let[r,i]=(0,ue.useToggle)(!1),{restUrl:a}=et(t),{moduleAddress:o,moduleName:s,functionName:c,args:l}=e,{data:d}=(0,u.useQuery)({queryKey:nl.abi(a,o,s,c).queryKey,queryFn:async()=>{let e=await h.default.create({prefixUrl:a}).get(`initia/move/v1/accounts/${o}/modules/${s}`).json(),t=JSON.parse(e.module.abi).exposed_functions.find(({name:e})=>e===c);if(!t)throw Error(`Function ${c} not found in module ${s}`);return t.params.filter(e=>!e.startsWith(`&`))},staleTime:z.INFINITY});return d?(0,y.jsxs)(`div`,{className:tl.container,children:[(0,y.jsx)(G.Small,{className:tl.toggle,onClick:i,disabled:!d,children:r?`Encode`:`Decode`}),r?(0,y.jsx)(`div`,{className:tl.list,children:l.map((e,t)=>{let n=d[t];return(0,y.jsxs)(`div`,{className:tl.arg,children:[(0,y.jsx)(`div`,{className:tl.type,children:n}),(0,y.jsx)(de.ErrorBoundary,{fallback:(0,y.jsx)(`div`,{className:`error`,children:`Error decoding argument`}),children:(0,y.jsx)(rl,{type:n,arg:e})})]},t)})}):n]}):n},al={list:`_list_oip9m_1`,key:`_key_oip9m_9`,value:`_value_oip9m_14`},ol=({message:e,chainId:t})=>{let{typeUrl:n,value:r}=e;return(0,y.jsx)(`div`,{className:al.list,children:Object.entries(r).map(([e,i])=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:al.key,children:e}),(0,y.jsx)(`div`,{className:al.value,children:n===`/initia.move.v1.MsgExecute`&&e===`args`?(0,y.jsx)(il,{msg:r,chainId:t,fallback:el(i)}):el(i)})]},e))})},sl={item:`_item_1n572_1`,title:`_title_1n572_10`,content:`_content_1n572_14`},cl=({title:e,content:t})=>(0,y.jsxs)(`div`,{className:sl.item,children:[(0,y.jsx)(`div`,{className:sl.title,children:e}),(0,y.jsx)(`div`,{className:sl.content,children:t})]});function q(e){let t=e?(0,f.default)(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return`< $0.01`;let n=e&&(0,f.default)(e).lt(0),r=(0,d.formatNumber)(t?.toString()??e,{dp:2});return r?n?`-$${r}`:`$${r}`:``}function ll(e,t){return t==null?`$-`:q(e??0)}function ul(e,t){let n={};for(let r of e)if(r.attributes.some(e=>e.key===`msg_index`)){if(r.type===`coin_spent`){let e=r.attributes.find(e=>e.key===`spender`)?.value,i=r.attributes.find(e=>e.key===`amount`)?.value;if(e===t&&i){let[e,t]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];e&&t&&(n[t]=(n[t]||BigInt(0))-BigInt(e))}}if(r.type===`coin_received`){let e=r.attributes.find(e=>e.key===`receiver`)?.value,i=r.attributes.find(e=>e.key===`amount`)?.value;if(e===t&&i){let[e,t]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];e&&t&&(n[t]=(n[t]||BigInt(0))+BigInt(e))}}}return Object.entries(n).filter(([,e])=>e!==BigInt(0)).map(([e,t])=>({amount:t.toString(),denom:e}))}function dl(e,t){let n={};for(let r of e)if(r.attributes.some(e=>e.key===`msg_index`)&&r.type===`move`){let e=r.attributes.find(e=>e.key===`type_tag`)?.value,i=r.attributes.find(e=>e.key===`data`)?.value;if(!e||!i)continue;let a;try{a=JSON.parse(i)}catch{continue}if(e===`0x1::fungible_asset::WithdrawEvent`){let e=a.store_addr,r=a.amount,i=a.metadata_addr;e&&r&&i&&(0,d.createUserDerivedObjectAddress)(t,i)===e&&(n[i]=(n[i]||BigInt(0))-BigInt(r))}if(e===`0x1::fungible_asset::DepositEvent`){let e=a.store_addr,r=a.amount,i=a.metadata_addr;e&&r&&i&&(0,d.createUserDerivedObjectAddress)(t,i)===e&&(n[i]=(n[i]||BigInt(0))+BigInt(r))}}return Object.entries(n).filter(([,e])=>e!==BigInt(0)).map(([e,t])=>({amount:t.toString(),metadata:e}))}var fl=({metadata:e,chain:t,children:n})=>{let{restUrl:r}=t,{data:i}=(0,u.useSuspenseQuery)({queryKey:st.denom(r,e).queryKey,queryFn:()=>h.default.create({prefixUrl:r}).get(`initia/move/v1/denom`,{searchParams:{metadata:e}}).json(),select:({denom:e})=>e,staleTime:z.INFINITY});return n(i)},pl={root:`_root_1p8a4_1`,title:`_title_1p8a4_8`,changes:`_changes_1p8a4_14`,change:`_change_1p8a4_14`,amount:`_amount_1p8a4_35`,text:`_text_1p8a4_42`,value:`_value_1p8a4_49`},ml=({amount:e,asset:t,price:n})=>{let{denom:r,symbol:i,decimals:a,logoUrl:o}=t,s=(0,d.formatAmount)(e,{decimals:a}),c=n&&(0,f.default)((0,d.fromBaseUnit)(e,{decimals:a})||0).times(n).abs();return(0,y.jsxs)(`div`,{className:pl.change,children:[(0,y.jsxs)(`div`,{className:pl.amount,children:[(0,y.jsx)(K,{src:o,width:14,height:14,logo:!0}),(0,y.jsxs)(`span`,{className:pl.text,children:[s,` `,i||r]})]}),c&&(0,y.jsx)(`div`,{className:pl.value,children:q(c)})]})},hl=({changes:e,chain:t})=>{let n=ft(t),{data:r}=it(t);return e.map(({amount:e,denom:t},i)=>{let a=n(t),o=r?.find(({id:e})=>e===t)?.price;return(0,y.jsx)(ml,{amount:e,asset:a,price:o},i)})},gl=({changes:e,chain:t})=>{let n=ft(t),{data:r}=it(t);return e.map(({amount:e,metadata:i},a)=>(0,y.jsx)(fl,{metadata:i,chain:t,children:t=>{let i=r?.find(({id:e})=>e===t)?.price;return(0,y.jsx)(ml,{amount:e,asset:n(t),price:i})}},a))};function _l(e,t){return typeof t==`bigint`?t.toString():t}var vl=(0,m.createQueryKeys)(`interwovenkit:tx`,{simulate:e=>[JSON.stringify(e,_l)]}),yl=({messages:e,memo:t,chainId:n})=>{let{initiaAddress:r,hexAddress:i}=Ta(),a=et(n),{simulateTx:o}=Zi(),{data:s}=(0,u.useSuspenseQuery)({queryKey:vl.simulate({messages:e,memo:t,chainId:n}).queryKey,queryFn:()=>o({messages:e,memo:t,chainId:n}),staleTime:z.SECOND}),c=e=>(0,y.jsxs)(`div`,{className:pl.root,children:[(0,y.jsx)(`h2`,{className:pl.title,children:`Estimated changes`}),(0,y.jsx)(`div`,{className:pl.changes,children:e})]});if(!s)return null;let l=s.result?.events??[];if(l.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type===`minimove`){let[e]=bl(dl(l,i));return e.length===0?null:c((0,y.jsx)(gl,{changes:e,chain:a}))}let[d]=bl(ul(l,r));return d.length===0?null:c((0,y.jsx)(hl,{changes:d,chain:a}))};function bl(e){return(0,p.partition)(e=>(0,f.default)(e.amount||0).isNegative(),e)}var xl={title:`_title_1d032_1`,meta:`_meta_1d032_7`,footer:`_footer_1d032_14`,rejectButton:`_rejectButton_1d032_19`},Sl=()=>{let{txRequest:e,resolve:t,reject:n}=Xi(),{messages:r,memo:i,chainId:a,gas:o,gasAdjustment:s,spendCoins:c}=e,l=et(a),d=Lt(l),p=Fi(l),m=Ii(l),h=ft(l),_=Yi(),v=(e.gasPrices??p).map(({amount:e,denom:t})=>(0,j.calculateFee)(Math.ceil(o*s),j.GasPrice.fromString(e+t))),b=v.map(e=>e.amount[0]),x=e=>{let t=d.find(t=>t.denom===e)?.amount||`0`,n=b.find(t=>t.denom===e)?.amount||`0`,r=c.filter(t=>t.denom===e).reduce((e,t)=>e.plus(t.amount||0),(0,f.default)(0)),i=(0,f.default)(n).plus(r),a=(0,f.default)(t).gte(i),{symbol:o,decimals:s}=h(e);return{symbol:o,decimals:s,spend:r.gt(0)?r.toFixed():null,fee:n,total:i.toFixed(),balance:t,isSufficient:a}},[S,C]=(0,g.useState)(()=>{if(m&&x(m).isSufficient)return m;for(let{denom:e}of b)if(x(e).isSufficient)return e;return b[0]?.denom}),{mutate:w,isPending:T}=(0,u.useMutation)({mutationKey:[Li],mutationFn:async()=>{let n=v.find(e=>e.amount[0].denom===S);if(!n)throw Error(`Fee not found`);await t(await _({chainId:a,messages:r,memo:i||``,fee:n,preferredFeeDenom:S,allowAutoSign:!e.internal,allowWalletDerivation:!0}))},onError:async e=>{n(e)}}),E=x(S),D=!E.isSufficient;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(sc,{children:[(0,y.jsx)(`h1`,{className:xl.title,children:`Confirm tx`}),(0,y.jsxs)(`section`,{className:xl.meta,"aria-label":`Transaction metadata`,children:[(0,y.jsx)(cl,{title:`Chain`,content:a}),(0,y.jsx)(cl,{title:`Tx fee`,content:(0,y.jsx)(Zc,{options:v,value:S,onChange:C})}),i&&(0,y.jsx)(cl,{title:`Memo`,content:i}),D&&(0,y.jsx)(Gc,{level:`error`,children:(0,y.jsx)($c,{...E})})]}),(0,y.jsx)(yl,{messages:r,memo:i,chainId:a}),(0,y.jsx)(qc,{list:r,renderHeader:({typeUrl:e})=>(0,he.sentenceCase)(e.split(`.`).pop().replace(/^Msg/,``)),renderContent:e=>(0,y.jsx)(ol,{message:e,chainId:a})})]}),(0,y.jsxs)(ac,{className:xl.footer,children:[(0,y.jsx)(G.Outline,{onClick:()=>n(Error(`User rejected`)),disabled:T,className:xl.rejectButton,"aria-label":`Reject`,children:(0,y.jsx)(I.IconClose,{size:16})}),(0,y.jsx)(G.White,{onClick:()=>w(),disabled:D,loading:T,children:`Approve`})]})]})},Cl=({children:e})=>{let[{title:t,content:n,path:r},i]=(0,g.useState)({}),[a,o]=(0,g.useState)(!1),s=(0,b.useAtomValue)(Ri),c=(0,g.useCallback)(e=>{i(e),o(!0)},[]),l=(0,g.useCallback)(()=>{i({}),o(!1)},[]),u=(0,g.useCallback)(e=>{e||(s?.reject(Error(`User rejected`)),i({})),o(e)},[s]);return(0,y.jsxs)(yi.Provider,{value:{openModal:c,closeModal:l},children:[e,(0,y.jsx)(zc,{title:t,open:a,onOpenChange:u,children:(0,y.jsx)(W,{children:r===`/tx`?(0,y.jsx)(Sl,{}):n})})]})},wl={container:`_container_1w1hx_1`,toast:`_toast_1w1hx_11`,info:`_info_1w1hx_24`,success:`_success_1w1hx_28`,error:`_error_1w1hx_32`,icon:`_icon_1w1hx_37`,content:`_content_1w1hx_45`,title:`_title_1w1hx_48`,description:`_description_1w1hx_53`,close:`_close_1w1hx_75`},Tl=({notification:e,onClose:t,...n})=>{let r=(0,me.useTransition)(e,{keys:e=>e?.id||`empty`,from:{transform:`translateY(-52px)`,opacity:0},enter:{transform:`translateY(0px)`,opacity:1},leave:{transform:`translateY(-52px)`,opacity:0},config:{tension:500,friction:30,clamp:!0}}),i=e=>{switch(e){case`loading`:return(0,y.jsx)(tc,{size:16});case`info`:case`success`:return(0,y.jsx)(I.IconCheckCircleFilled,{size:16});case`error`:return(0,y.jsx)(I.IconCloseCircleFilled,{size:16});default:return null}};return r((e,r)=>{if(!r)return null;let{type:a,title:o,description:s}=r,c=i(a);return(0,y.jsx)(me.animated.div,{style:e,className:wl.container,children:(0,y.jsxs)(`div`,{className:(0,P.default)(wl.toast,a&&wl[a]),role:`alert`,...n,children:[c&&(0,y.jsx)(`div`,{className:wl.icon,"aria-hidden":`true`,children:c}),(0,y.jsxs)(`div`,{className:wl.content,children:[(0,y.jsx)(`p`,{className:wl.title,children:o}),s&&(0,y.jsx)(`div`,{className:wl.description,children:s})]}),(0,y.jsx)(`button`,{className:wl.close,onClick:t,"aria-label":`Dismiss notification`,children:(0,y.jsx)(I.IconClose,{size:14,"aria-hidden":`true`})})]})})})},El=5e3,Dl=({children:e})=>{let t=_c(),[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(!1),o=()=>{i.current&&=(clearTimeout(i.current),null)},s=(0,g.useCallback)(()=>{o(),r(null)},[]),c=(0,g.useCallback)(e=>{o(),r({...e,id:(0,_e.nanoid)()}),e.autoHide&&!a.current&&(i.current=setTimeout(()=>s(),El))},[s]),l=(0,g.useCallback)(e=>{o(),r(t=>t?{...t,...e}:{...e,id:(0,_e.nanoid)()}),e.autoHide&&!a.current&&(i.current=setTimeout(()=>s(),El))},[s]);return(0,g.useEffect)(()=>()=>o(),[]),(0,y.jsxs)(Tc.Provider,{value:{showNotification:c,updateNotification:l,hideNotification:s},children:[e,t&&(0,ve.createPortal)((0,y.jsx)(Tl,{notification:n,onClose:s,onMouseEnter:()=>{o(),a.current=!0},onMouseLeave:()=>{o(),a.current=!1,n?.autoHide&&(i.current=setTimeout(()=>s(),El))}}),t)]})},Ol=({children:e})=>{let[t,n]=(0,g.useState)(null);return(0,y.jsx)(gc.Provider,{value:{container:t,setContainer:n},children:e})};function kl(e){let t=e.split(`.`);return t.length===4?t.every(e=>{if(!/^\d+$/.test(e))return!1;let t=Number(e);return t>=0&&t<=255}):!1}function Al(e){return kl(e)||e.includes(`:`)}function jl(e){let t=(0,ye.parse)(e);return`error`in t?null:t.domain}function Ml(e,t){return e===t||e===`www.${t}`}function Nl(e){if(e.protocol!==`https:`)return!1;let t=e.hostname.toLowerCase();return!t||!t.includes(`.`)||t===`localhost`||Al(t)?!1:jl(t)!==null}function Pl(e,t){try{let n=new URL(e);if(!Nl(n))return!1;let r=n.hostname.toLowerCase(),i=t.toLowerCase();if(!r||!i||Al(i)||i===`localhost`)return!1;let a=jl(r);if(!a)return!1;let o=jl(i);return!o||o!==a?!1:Ml(r,a)?i===a||i.endsWith(`.${a}`):i===r||i.endsWith(`.${r}`)}catch{return!1}}var J={container:`_container_1422v_1`,title:`_title_1422v_7`,description:`_description_1422v_14`,sectionTitle:`_sectionTitle_1422v_20`,websiteInfo:`_websiteInfo_1422v_27`,favicon:`_favicon_1422v_37`,websiteTitle:`_websiteTitle_1422v_42`,websiteHost:`_websiteHost_1422v_48`,warningContent:`_warningContent_1422v_54`,ignoreButton:`_ignoreButton_1422v_61`,infoList:`_infoList_1422v_65`,infoItem:`_infoItem_1422v_75`,label:`_label_1422v_84`,value:`_value_1422v_90`,infoValue:`_infoValue_1422v_94`,durationTrigger:`_durationTrigger_1422v_100`,durationItem:`_durationItem_1422v_101`,featureList:`_featureList_1422v_105`,featureItem:`_featureItem_1422v_113`,checkIcon:`_checkIcon_1422v_123`,learnMoreLink:`_learnMoreLink_1422v_127`,feedbackContainer:`_feedbackContainer_1422v_140`,footer:`_footer_1422v_146`};function Fl(e){return e instanceof h.HTTPError&&e.response.status===404}var Il=(0,m.createQueryKeys)(`interwovenkit:account`,{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{let n=h.default.create({prefixUrl:e}),r=`cosmos/auth/v1beta1/account_info/${t}`;try{return await n.get(r).json(),!0}catch(e){if(Fl(e))return!1;throw e}}})}),Ll=()=>{let[e,t]=(0,b.useAtom)(Hn),[n,r]=(0,g.useState)(()=>e?.defaultDuration??la),[i,a]=(0,g.useState)(!1),o=$e(),s=Xe(),{address:c,initiaAddress:l,username:f}=Ta(),{mutate:p,isPending:m}=oa(),{closeDrawer:h}=Sr();if(!e)throw Error(`Pending request not found`);let{logoUrl:_,name:v,restUrl:x}=o(e.chainId),{data:S,isLoading:C,isError:w}=(0,u.useQuery)(Il.info(x,l)),T={favicon:document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)||``,title:document.title,hostname:window.location.hostname},E=s.find(t=>t.chainId===e.chainId),D=E?.website?Pl(E.website,window.location.hostname):!1,ee=()=>{p(n)},O=()=>{e?.reject(Error(`User cancelled`)),t(null),h()},k=!D&&!i,A=!C&&!w&&S===!1,j=!C&&w,te=k||C||w||S===!1;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(sc,{className:J.container,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`h1`,{className:J.title,children:`Enable auto-signing`}),(0,y.jsx)(`p`,{className:J.description,children:`An application is requesting to enable auto-signing`})]}),(0,y.jsxs)(`section`,{children:[(0,y.jsx)(`h2`,{className:J.sectionTitle,children:`Requested by`}),(0,y.jsxs)(`div`,{className:J.websiteInfo,children:[(0,y.jsx)(`img`,{src:T.favicon,alt:``,className:J.favicon}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:J.websiteTitle,children:T.title}),(0,y.jsx)(`div`,{className:J.websiteHost,children:T.hostname})]})]})]}),(0,y.jsxs)(`section`,{children:[(0,y.jsx)(`h2`,{className:J.sectionTitle,children:`Applies to`}),(0,y.jsxs)(`div`,{className:J.infoList,children:[(0,y.jsxs)(`div`,{className:J.infoItem,children:[(0,y.jsx)(`div`,{className:J.label,children:`Address`}),(0,y.jsxs)(`div`,{className:J.infoValue,children:[(0,y.jsx)(I.IconWallet,{size:14}),(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(f??c)})]})]}),(0,y.jsxs)(`div`,{className:J.infoItem,children:[(0,y.jsx)(`div`,{className:J.label,children:`Chain`}),(0,y.jsxs)(`div`,{className:J.infoValue,children:[(0,y.jsx)(K,{src:_,width:14,height:14,logo:!0}),(0,y.jsx)(`span`,{children:v})]})]}),(0,y.jsxs)(`div`,{className:J.infoItem,children:[(0,y.jsx)(`div`,{className:J.label,children:`Duration`}),(0,y.jsx)(Yc,{options:ca,value:n,onChange:r,classNames:{trigger:J.durationTrigger,item:J.durationItem}})]})]})]}),(0,y.jsxs)(`section`,{children:[(0,y.jsx)(`h2`,{className:J.sectionTitle,children:`About auto-signing`}),(0,y.jsx)(`ul`,{className:J.featureList,children:[`Send transactions without confirmation pop-ups`,`Secured by your wallet signature`,`Revoke permissions any time in settings`].map(e=>(0,y.jsxs)(`li`,{className:J.featureItem,children:[(0,y.jsx)(I.IconCheckCircle,{size:12,className:J.checkIcon}),(0,y.jsx)(`span`,{children:e})]},e))}),(0,y.jsxs)(`a`,{href:`https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction`,target:`_blank`,rel:`noopener noreferrer`,className:J.learnMoreLink,children:[`Learn more `,(0,y.jsx)(I.IconExternalLink,{size:12})]})]})]}),(0,y.jsxs)(ac,{className:J.footer,extra:(0,y.jsxs)(`div`,{className:J.feedbackContainer,children:[A&&(0,y.jsx)(Gc,{level:`error`,children:`Insufficient balance for fee`}),j&&(0,y.jsx)(Gc,{level:`warning`,children:`Unable to verify account status. Try again.`}),!D&&!i&&(0,y.jsx)(Gc,{level:`warning`,children:(0,y.jsxs)(`div`,{className:J.warningContent,children:[(0,y.jsx)(`span`,{children:`You are on an unverified website`}),(0,y.jsx)(`button`,{onClick:()=>a(!0),className:J.ignoreButton,children:`Ignore`})]})})]}),children:[(0,y.jsx)(G.Outline,{onClick:O,children:`Cancel`}),(0,y.jsx)(G.White,{onClick:ee,disabled:te,loading:m,children:`Enable`})]})]})},Rl=()=>{let e=(0,b.useAtomValue)(Hn);return e?(0,y.jsx)(Ll,{},`${e.chainId}:${e.defaultDuration}`):null},zl={container:`_container_mqvhs_1`,badge:`_badge_mqvhs_5`},Bl=e=>{let{offset:t=-4,disabled:n,children:r,className:i}=e;return(0,y.jsxs)(`div`,{className:(0,P.default)(zl.container,i),children:[r,!n&&(0,y.jsx)(`div`,{className:zl.badge,style:{right:t,top:t},"aria-hidden":`true`})]})},Vl={header:`_header_s7mee_1`,back:`_back_s7mee_12`,title:`_title_s7mee_24`},Hl=({title:e,backButton:t,extra:n,children:r})=>{let i=Yt();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`header`,{className:Vl.header,children:[(0,y.jsx)(Qt,{to:t??(i.length>1?-1:`/`),className:Vl.back,shouldReset:!!t,"aria-label":`Go back`,children:(0,y.jsx)(I.IconBack,{size:16,"aria-hidden":`true`})}),(0,y.jsx)(`h1`,{className:Vl.title,children:e}),n]}),(0,y.jsx)(sc,{children:r})]})};function Ul(){let e=Xe();return t=>e.some(e=>e.chain_id===t)}function Wl(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!==`initia`}function Gl(){let e=Ul();return t=>e(t.chain_id)?`initia`:t.chain_type}function Kl(e){return Gl()(e)}function ql(){let e=rn(),{data:t}=(0,u.useSuspenseQuery)({queryKey:nn.chains.queryKey,queryFn:()=>e.get(`v2/info/chains`).json(),select:({chains:e})=>(0,p.sortWith)([(0,p.descend)(({chain_name:e})=>e===`initia`),(0,p.ascend)(({pretty_name:e})=>e)],e),staleTime:z.MINUTE});return t}function Jl(){let e=ql(),t=Qe();return n=>{let r=e.find(e=>e.chain_id===n);if(r)return r;let i=t.find(e=>e.chain_id===n);if(!i)throw Error(`Chain not found: ${n}`);return{chain_id:i.chain_id,chain_name:i.name,pretty_name:i.pretty_name,logo_uri:i.logo,chain_type:`cosmos`,rpc:``,rest:``}}}function Yl(e){return Jl()(e)}function Xl(e,t){try{return(0,_.fromBech32)(e).prefix===t}catch{return!1}}function Zl(){let{initiaAddress:e,hexAddress:t}=Ta(),n=Jl(),r=Gl();return i=>{switch(r(n(i))){case`initia`:return e;case`evm`:return t;default:return``}}}function Ql(){let e=Jl(),t=Gl();return(n,r)=>{let i=e(r);switch(t(i)){case`initia`:return d.InitiaAddress.validate(n);case`evm`:return(0,w.isAddress)(n);case`cosmos`:return i.bech32_prefix?Xl(n,i.bech32_prefix):!1;default:return!1}}}function $l(){let e=Jl(),t=Gl();return({initialAddress:n,initialChainId:r,chainId:i,fallbackAddress:a})=>{let o=t(e(r)),s=t(e(i));if(o===`evm`&&s===`initia`)return(0,d.InitiaAddress)(n).bech32;if(o===`initia`&&s===`evm`)return(0,d.InitiaAddress)(n).hex;if(o===s)return n;if(a){if(s===`initia`)return(0,d.InitiaAddress)(a).bech32;if(s===`evm`)return(0,d.InitiaAddress)(a).hex}return``}}function eu(e){return!e.hidden}function tu(e,t){return e.find(e=>e.denom===t&&eu(e))}function nu(e){return e.find(eu)}function ru(){let e=rn();return(0,u.useSuspenseQuery)({queryKey:nn.allAssets().queryKey,queryFn:()=>e.get(`v2/fungible/assets`).json(),staleTime:z.MINUTE})}function iu(){let{data:{chain_to_assets_map:e}}=ru(),t=ql(),n=(0,u.useQueryClient)();return(0,g.useMemo)(()=>{let r=[];for(let i in e){if(!t.some(e=>e.chain_id===i))continue;let{assets:a}=e[i]??{assets:[]};n.setQueryData(nn.assets(i).queryKey,{chain_to_assets_map:{[i]:e[i]}});for(let e of a)n.setQueryData(nn.asset(i,e.denom).queryKey,e);r.push(...a)}return r},[e,t,n])}function au(e){let t=rn(),n=(0,u.useQueryClient)(),{data:r}=(0,u.useSuspenseQuery)({queryKey:nn.assets(e).queryKey,queryFn:()=>t.get(`v2/fungible/assets`,{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:t})=>{let{assets:r}=t[e]??{assets:[]};for(let t of r)n.setQueryData(nn.asset(e,t.denom).queryKey,t);return[...r].sort((0,p.ascend)(e=>At(e.symbol)))},staleTime:z.MINUTE});return r}function ou(e){let t=au(e);return e=>{let n=t.find(t=>t.denom===e);if(!n)throw Error(`Asset not found: ${e}`);return n}}function su(e,t){return ou(t)(e)}var cu={root:`_root_ekn9t_1`,header:`_header_ekn9t_6`,title:`_title_ekn9t_12`,warning:`_warning_ekn9t_18`,content:`_content_ekn9t_22`,footer:`_footer_ekn9t_26`,secondary:`_secondary_ekn9t_36`},lu=e=>{let{type:t,icon:n,title:r,children:i,primaryButton:a,secondaryButton:o}=e;return(0,y.jsxs)(sc,{className:cu.root,children:[(0,y.jsxs)(`header`,{className:(0,P.default)(cu.header,t&&cu[t]),children:[n,(0,y.jsx)(`h1`,{className:cu.title,children:r})]}),(0,y.jsx)(`div`,{className:cu.content,children:i}),(0,y.jsxs)(`footer`,{className:cu.footer,children:[(0,y.jsx)(G.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),(0,y.jsxs)(`button`,{className:cu.secondary,onClick:o.onClick,children:[(0,y.jsx)(`span`,{children:o.label}),(0,y.jsx)(I.IconChevronRight,{size:14,"aria-hidden":`true`})]})]})]})},uu={list:`_list_k4n3k_1`,row:`_row_k4n3k_9`,dt:`_dt_k4n3k_20`,asset:`_asset_k4n3k_26`},du=({list:e,onNavigate:t,onDismiss:n})=>{let r=B(),i=$e(),a=ft(r);return(0,y.jsx)(lu,{title:`Ready to claim`,primaryButton:{label:`View withdrawal status`,onClick:t},secondaryButton:{label:`Do not show again`,onClick:n},children:(0,y.jsx)(`div`,{className:uu.list,children:[...e].sort((e,t)=>e.chainId.localeCompare(t.chainId)).map(({txHash:e,chainId:t,amount:n,denom:r})=>{let o=i(t),{decimals:s,symbol:c}=a(r),l=(0,d.formatAmount)(n,{decimals:s});return(0,y.jsxs)(`div`,{className:uu.row,children:[(0,y.jsxs)(`div`,{className:uu.dt,children:[(0,y.jsx)(K,{src:o.logoUrl,width:16,height:16,logo:!0}),(0,y.jsx)(`span`,{children:o.name})]}),(0,y.jsxs)(`span`,{className:uu.asset,children:[l,` `,c]})]},e)})})})};function fu(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}var pu=({chainId:e,txHash:t})=>`${V.OP_REMINDER}:${e}:${t}`,mu=(0,be.atomWithStorage)(V.OP_REMINDER,[]);function hu(){let e=U(),[t=[],n]=(0,b.useAtom)(mu);return{reminders:(0,g.useMemo)(()=>t.map(e=>{let t=localStorage.getItem(pu(e));return t?JSON.parse(t):null}).filter(t=>{if(!t)return!1;let{recipient:n,claimableAt:r}=t;return n===e?(0,se.isPast)(r):!1}),[e,t]),addReminder:(0,g.useCallback)((e,r)=>{t.some(t=>fu(t,e))||(n((t=[])=>[...t,e]),localStorage.setItem(pu(e),JSON.stringify(r)))},[t,n]),removeReminder:(0,g.useCallback)(e=>{n((t=[])=>t.filter(t=>!fu(t,e))),localStorage.removeItem(pu(e))},[n]),syncReminders:(0,g.useCallback)(e=>{let r=e.filter(e=>!t.some(t=>fu(t,e)));r.length!==0&&n((e=[])=>[...e,...r])},[t,n]),setReminder:(0,g.useCallback)((e,t)=>{localStorage.setItem(pu(e),JSON.stringify(t)),n((e=[])=>[...e])},[n])}}function gu(){let e=Xt(),{openModal:t,closeModal:n}=bi(),{reminders:r,setReminder:i}=hu();(0,g.useEffect)(()=>{let a=r.filter(e=>!e.dismissed);if(a.length===0)return;let o=()=>{e(`/op/withdrawals`,{chainId:a.every(e=>e.chainId===a[0].chainId)?a[0].chainId:void 0}),s()},s=()=>{n();for(let e of a)i(e,{...e,dismissed:!0})};t({content:(0,g.createElement)(du,{list:a,onNavigate:o,onDismiss:s})})},[r,n,e,t,i])}var _u={wrapper:`_wrapper_5ssm8_1`,balance:`_balance_5ssm8_11`,button:`_button_5ssm8_15`},vu=({onClick:e,children:t,disabled:n})=>(0,y.jsxs)(`div`,{className:_u.wrapper,children:[(0,y.jsx)(I.IconWallet,{size:16,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:_u.balance,children:t}),(0,y.jsx)(`button`,{type:`button`,tabIndex:-1,className:_u.button,onClick:()=>e(),disabled:n,"aria-label":`Use maximum balance`,children:`MAX`})]}),yu={fieldset:`_fieldset_up6fh_1`,upper:`_upper_up6fh_9`,select:`_select_up6fh_14`,account:`_account_up6fh_20`,lower:`_lower_up6fh_25`,wrapper:`_wrapper_up6fh_26`,balance:`_balance_up6fh_33`,value:`_value_up6fh_37`,error:`_error_up6fh_50`},bu=e=>{let{selectButton:t,accountButton:n,quantityInput:r,balanceButton:i,value:a,errorMessage:o,hideNumbers:s}=e;return(0,y.jsxs)(`div`,{className:yu.fieldset,children:[(0,y.jsxs)(`div`,{className:yu.upper,children:[(0,y.jsx)(`div`,{className:yu.select,children:t}),(0,y.jsx)(`div`,{className:yu.account,children:n})]}),!s&&(0,y.jsxs)(`div`,{className:yu.lower,children:[r,(0,y.jsxs)(`div`,{className:yu.wrapper,children:[(0,y.jsx)(`div`,{className:yu.balance,children:i}),a&&(0,y.jsx)(`div`,{className:yu.value,children:a})]}),o&&(0,y.jsxs)(`footer`,{className:yu.error,children:[(0,y.jsx)(I.IconWarningFilled,{size:12,"aria-hidden":`true`}),(0,y.jsx)(`p`,{role:`alert`,children:o})]})]})]})};function xu(){let e=(0,g.useRef)(null),t=dc();return(0,g.useEffect)(()=>{t||e.current?.focus()},[t]),e}var Su={input:`_input_h8073_1`};function Cu(e){let{name:t,control:n,dp:r=6,className:i,rules:a,...o}=e,s=xu();return(0,y.jsx)(F.Controller,{name:t,control:n,rules:a,render:({field:e})=>(0,y.jsx)(Se.NumericFormat,{value:e.value,getInputRef:(0,xe.mergeRefs)([e.ref,s]),className:(0,P.default)(Su.input,i),onValueChange:t=>{e.onChange(t.value)},onBlur:e.onBlur,decimalScale:r,allowNegative:!1,placeholder:`0`,inputMode:`decimal`,autoComplete:`off`,...o})})}var wu={input:`_input_19r9r_1`,placeholder:`_placeholder_19r9r_18`},Tu=({children:e})=>{let t=en(e.replace(/,/g,``)),n=!t||t.isZero();return(0,y.jsx)(`p`,{className:(0,P.default)(wu.input,{[wu.placeholder]:n}),children:e})},Eu=({balance:e,decimals:t,className:n})=>{let{control:r}=(0,F.useFormContext)();return(0,y.jsx)(Cu,{name:`quantity`,control:r,className:(0,P.default)(wu.input,n),rules:{required:`Enter amount`,validate:n=>{let r=en(n);return!r||r.lte(0)?`Enter amount`:tn({quantity:n,balance:e,decimals:t})?`Insufficient balance`:!0}},"aria-label":`Amount`})};Eu.ReadOnly=Tu;var Du=({title:e,content:t,children:n,className:r})=>{let[i,a]=(0,g.useState)(!1);return(0,y.jsx)(zc,{title:e,trigger:n,className:r,open:i,onOpenChange:a,children:t(()=>a(!1))})},Ou={tooltip:`_tooltip_19kvs_1`,small:`_small_19kvs_14`,fadeIn:`_fadeIn_19kvs_1`,fadeOut:`_fadeOut_19kvs_1`,arrow:`_arrow_19kvs_44`},ku=({label:e,children:t,small:n,...r})=>(0,y.jsxs)(N.Tooltip.Root,{...r,children:[(0,y.jsx)(N.Tooltip.Trigger,{asChild:!0,children:t}),(0,y.jsx)(N.Tooltip.Portal,{container:_c(),children:(0,y.jsxs)(N.Tooltip.Content,{className:(0,P.default)(Ou.tooltip,{small:n}),collisionBoundary:_c(),collisionPadding:8,sideOffset:4,children:[e,(0,y.jsx)(N.Tooltip.Arrow,{className:Ou.arrow})]})})]});function Au(e,t){let n=rn(),r=Ql(),i=!!t&&!!e&&r(e,t);return(0,u.useQuery)({queryKey:nn.balances(t,e).queryKey,queryFn:()=>n.post(`v2/info/balances`,{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:e})=>!i||!e?{}:e[t]?.denoms??{},enabled:i,staleTime:z.SECOND})}function ju(e,t,n){let{data:r={}}=Au(e,t);return(0,p.path)([n],r)}function Mu({sourceDenom:e,sourceBalance:t,amountIn:n,feeTokenDenoms:r,balancesByDenom:i,additionalFees:a=[]}){if(!r.includes(e)||t===void 0||n===void 0||i===void 0)return!1;let o=a.reduce((e,t)=>{if(t.amount===void 0||t.amount===``)return e;let n=t.origin_asset.denom,r=e.get(n)??(0,f.default)(0);return e.set(n,r.plus(t.amount)),e},new Map);if(r.some(t=>{if(t===e)return!1;let n=(0,f.default)(i[t]?.amount||0),r=o.get(t);return r?n.gte(r):n.gt(0)}))return!1;let s=o.get(e)??(0,f.default)(0);return s.isZero()?!1:(0,f.default)(t||0).lt((0,f.default)(n||0).plus(s))}var Nu=[[`d`,1440*60],[`h`,3600],[`m`,60],[`s`,1]];function Pu(e){if(!e)return;let{formattedParts:t}=Nu.reduce(({remainingSeconds:e,formattedParts:t},[n,r])=>{let i=Math.floor(e/r);return{remainingSeconds:e-i*r,formattedParts:i>0?[...t,`${i}${n}`]:t}},{remainingSeconds:e,formattedParts:[]});return t.join(` `)}function Fu(e,t){let n=en(e)??(0,f.default)(0),r=en(t)??(0,f.default)(0);return n.times((0,f.default)(100).minus(r)).div(100).integerValue(f.default.ROUND_FLOOR).toFixed(0)}function Iu(e){return e?.map(e=>{let{amount:t,origin_asset:n}=e;return`${(0,d.formatAmount)(t,{decimals:n.decimals??0})} ${n.symbol}`}).join(`, `)}function Lu(e,t,n,r){let{srcChainId:i,srcDenom:a,quantity:o,dstChainId:s,dstDenom:c}=n,l=t.getQueryData(nn.asset(i,a).queryKey);if(!l||l.decimals==null)throw Error(`Failed to refresh route: source asset metadata is unavailable.`);let u=l.decimals;return e.post(`v2/fungible/route`,{signal:r?.signal,json:{amount_in:(0,d.toBaseUnit)(o,{decimals:u}),source_asset_chain_id:i,source_asset_denom:a,dest_asset_chain_id:s,dest_asset_denom:c,is_op_withdraw:r?.isOpWithdraw}}).json()}function Ru(e,t){let{watch:n}=Ls(),r=n(),i=rn(),a={srcChainId:r.srcChainId,srcDenom:r.srcDenom,dstChainId:r.dstChainId,dstDenom:r.dstDenom,quantity:e},o=!a.srcChainId||!a.srcDenom||!a.dstChainId||!a.dstDenom,s=!!en(a.quantity)?.gt(0),c=t?.refreshMs??1e4,l=s&&!t?.disabled&&!o,d=(0,u.useQueryClient)();return(0,u.useQuery)({queryKey:nn.route(a,t?.isOpWithdraw).queryKey,queryFn:async({signal:e})=>Lu(i,d,a,{isOpWithdraw:t?.isOpWithdraw,signal:e}),enabled:l,staleTime:c,refetchInterval:l?c:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:`always`})}function zu(e){return(0,u.useQuery)({queryKey:nn.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof h.HTTPError))return null;let{response:t}=e;return(t.headers.get(`content-type`)??``).includes(`application/json`)?(await t.json()).info??null:null},enabled:!!e})}function Bu(){let{watch:e}=Ls(),{srcChainId:t,srcDenom:n,dstChainId:r,dstDenom:i}=e(),a=Kl(Yl(t)),o=su(n,t),s=su(i,r),c=B(),l=Xe();return a===`initia`&&r===c.chainId&&o.symbol===s.symbol&&l.find(e=>e.chainId===t)?.metadata?.op_denoms?.includes(s.denom)}var Vu={label:`_label_t93ix_1`,wrapper:`_wrapper_t93ix_7`,input:`_input_t93ix_10`,clear:`_clear_t93ix_18`},Hu=({mode:e=`onChange`,myAddress:t,...n})=>{let{validate:r=d.InitiaAddress.validate,chainType:i=`initia`,onApply:a,ref:o}=n,s=xu(),{control:c,getValues:l,setValue:f,formState:p}=(0,F.useFormContext)(),[m,h]=(0,g.useState)(l(`recipient`)),_=Ft(),{data:v,isLoading:b,error:x}=(0,u.useQuery)({queryKey:Pt.address(_.restUrl,m).queryKey,queryFn:()=>_.getAddress(m),staleTime:z.MINUTE,enabled:_.validateUsername(m)}),S=v??(r(m)?m:``),C=t&&d.InitiaAddress.equals(S,t);return(0,g.useEffect)(()=>{e===`onChange`&&(!m&&!p.dirtyFields.recipient||f(`recipient`,v??m,{shouldValidate:!0,shouldDirty:!0}))},[p.dirtyFields.recipient,m,e,f,v]),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`label`,{htmlFor:`recipient`,className:Vu.label,children:[(0,y.jsx)(`span`,{children:`Recipient`}),(0,y.jsx)(G.Small,{type:`button`,tabIndex:-1,onClick:async()=>{try{h((await navigator.clipboard.readText()).trim())}catch{}},children:`Paste`})]}),(0,y.jsxs)(`div`,{className:Vu.wrapper,children:[(0,y.jsx)(F.Controller,{name:`recipient`,control:c,rules:{required:`Recipient address is required`,validate:e=>r(e)||`Invalid address`},render:()=>(0,y.jsx)(`input`,{id:`recipient`,className:(0,P.default)(Vu.input,`monospace`),value:m,onChange:e=>h(e.target.value.trim()),placeholder:i===`initia`?`Address or username`:`Enter address`,autoComplete:`off`,"data-has-value":m?`true`:void 0,ref:e===`onSubmit`?(0,xe.mergeRefs)([o,s]):o})}),!!m&&(0,y.jsx)(`button`,{type:`button`,className:Vu.clear,onClick:()=>h(``),"aria-label":`Clear recipient`,children:(0,y.jsx)(I.IconCloseCircleFilled,{size:16})})]}),(()=>{if(b)return(0,y.jsx)(Hc,{level:`loading`,children:`Resolving username...`});if(x)return(0,y.jsx)(Hc,{level:`error`,children:x.message});if(v)return(0,y.jsx)(Hc,{level:`success`,className:`monospace`,children:v});if(e===`onSubmit`&&m&&!S)return(0,y.jsx)(Hc,{level:`error`,children:`Invalid address`})})(),C&&(0,y.jsx)(Hc,{children:`This is my address`}),e===`onSubmit`&&(0,y.jsx)(ac,{extra:(!t||!!S&&!C)&&(0,y.jsx)(Gc,{level:`warning`,children:`Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable.`}),children:(0,y.jsx)(G.White,{type:`button`,onClick:()=>{b||x||(f(`recipient`,S,{shouldValidate:!0,shouldDirty:!0}),a?.())},disabled:b||!!x||!S,children:`Apply`})})]})},Uu={scrollable:`_scrollable_vgj3r_1`,list:`_list_vgj3r_5`,item:`_item_vgj3r_9`,name:`_name_vgj3r_22`};function Wu({onSelect:e,list:t,...n}){let{getImage:r,getName:i,getKey:a,getIsLoading:o,getDisabled:s}=n;return(0,y.jsx)(sc,{className:Uu.scrollable,children:(0,y.jsx)(`div`,{className:Uu.list,children:t.map(t=>(0,y.jsxs)(`button`,{className:Uu.item,onClick:()=>e(t),disabled:o?.(t)||s?.(t),"aria-busy":!!o?.(t),children:[(0,y.jsx)(K,{src:r(t),width:28,height:28}),(0,y.jsx)(`span`,{className:Uu.name,children:i(t)}),o?.(t)&&(0,y.jsx)(tc,{size:16})]},a(t)))})})}function Gu(){let{cosmosWallets:e=[]}=R(),t=(0,g.useMemo)(()=>{let t=[{name:`Keplr`,image:`https://assets.initia.xyz/images/wallets/Keplr.webp`,getProvider:()=>window.keplr,fallbackUrl:`https://keplr.app/get`}].filter(t=>!e.some(e=>e.name===t.name));return[...e,...t]},[e]);return{list:t,find:e=>t.find(t=>t.name===e)}}var Ku={wrapper:`_wrapper_h04x1_1`,account:`_account_h04x1_8`,clear:`_clear_h04x1_28`,white:`_white_h04x1_39`,warning:`_warning_h04x1_52`},qu=({type:e})=>{let{watch:t,setValue:n}=Ls(),{srcChainId:r,dstChainId:i,cosmosWalletName:a}=t(),o=t(e===`src`?`sender`:`recipient`),s=Kl(Yl(i)),{showNotification:c}=Ec(),{list:l,find:u}=Gu(),f=u(a),p=Zl(),m=Ql(),h=p(i),g=d.InitiaAddress.equals(o,h),_=()=>(0,y.jsx)(Du,{title:`Connect wallet`,content:e=>(0,y.jsx)(Wu,{onSelect:async t=>{let i=t.getProvider();if(!i){t.fallbackUrl?window.open(t.fallbackUrl,`_blank`,`noopener,noreferrer`):c({type:`error`,title:`${t.name} not available`,description:`Please install the wallet extension and try again.`});return}try{let a=await i.getOfflineSigner(r).getAccounts();if(a.length===0)throw Error(`No accounts found`);n(`sender`,a[0].address),n(`cosmosWalletName`,t.name),e()}catch(e){let n=e instanceof Error?e.message:`Unknown error`;c({type:`error`,title:`Failed to connect ${t.name}`,description:n})}},list:l,getImage:e=>e.image,getName:e=>e.name,getKey:e=>e.name}),className:(0,P.default)(Ku.account,{[Ku.white]:!o}),children:o?(0,y.jsxs)(y.Fragment,{children:[f&&(0,y.jsx)(K,{src:f.image,width:18,height:18}),(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{children:`Connect wallet`}),(0,y.jsx)(I.IconChevronRight,{size:14,"aria-hidden":`true`})]})}),v=e=>(0,y.jsx)(Du,{title:`Recipient`,content:e=>(0,y.jsx)(sc,{children:(0,y.jsx)(Hu,{mode:`onSubmit`,myAddress:h,chainType:s,validate:e=>m(e,i),onApply:e})}),className:Ku.account,children:e}),b=()=>{switch(s){case`initia`:case`evm`:return g?v((0,y.jsx)(I.IconWallet,{size:14})):(0,y.jsxs)(`div`,{className:Ku.account,children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)}),(0,y.jsx)(`button`,{type:`button`,className:Ku.clear,onClick:()=>n(`recipient`,h,{shouldValidate:!0}),"aria-label":`Reset to my address`,children:(0,y.jsx)(I.IconCloseCircleFilled,{size:14})})]});case`cosmos`:return v((0,y.jsxs)(y.Fragment,{children:[o?(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)}):(0,y.jsx)(`span`,{children:`Recipient`}),(0,y.jsx)(I.IconEdit,{size:14,"aria-hidden":`true`})]}))}};switch(e){case`src`:return _();case`dst`:return b()}},Ju={images:`_images_cj4xz_1`},Yu=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:i=6,className:a})=>(0,y.jsxs)(`div`,{className:(0,P.default)(Ju.images,a),style:{position:`relative`},"aria-hidden":`true`,children:[(0,y.jsx)(K,{src:e,width:t,height:t,className:Ju.asset,logo:!0}),(0,y.jsx)(K,{src:n,width:r,height:r,className:Ju.chain,style:{position:`absolute`,bottom:0,right:-1*i},logo:!0})]}),Xu={root:`_root_6187w_1`,content:`_content_6187w_10`,details:`_details_6187w_20`,symbol:`_symbol_6187w_26`,chain:`_chain_6187w_34`,chevron:`_chevron_6187w_43`},Zu=({asset:e,chain:t,readOnly:n})=>{let r=(0,y.jsxs)(`div`,{className:Xu.content,children:[(0,y.jsx)(Yu,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),(0,y.jsxs)(`div`,{className:Xu.details,children:[(0,y.jsx)(`div`,{className:Xu.symbol,children:e.symbol||e.denom}),(0,y.jsxs)(`div`,{className:Xu.chain,children:[`on `,t.name]})]})]});return n?(0,y.jsx)(`div`,{className:Xu.root,children:r}):(0,y.jsxs)(`div`,{className:Xu.root,children:[r,(0,y.jsx)(I.IconChevronDown,{size:16,className:Xu.chevron,"aria-hidden":`true`})]})};function Qu(e,t,n){return n.filter(n=>{let r=e.map(e=>n[e]).map(e=>String(e??``).toLowerCase());return(0,p.any)((0,p.includes)(t.toLowerCase()),r)})}var $u={root:`_root_1sh27_1`,label:`_label_1sh27_8`,input:`_input_1sh27_21`,hasValue:`_hasValue_1sh27_31`,clear:`_clear_1sh27_35`},ed=e=>{let{rootClassName:t,padding:n=16,iconSize:r=16,onClear:i,ref:a,...o}=e;return(0,y.jsxs)(`div`,{className:(0,P.default)($u.root,t,{[$u.hasValue]:o.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[(0,y.jsx)(`label`,{htmlFor:`search`,className:$u.label,children:(0,y.jsx)(I.IconSearch,{size:r})}),(0,y.jsx)(`input`,{className:$u.input,id:`search`,type:`text`,maxLength:100,ref:a,...o}),o.value&&(0,y.jsx)(`button`,{type:`button`,className:$u.clear,"aria-label":`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:i,children:(0,y.jsx)(I.IconCloseCircleFilled,{size:r})})]})},td={container:`_container_cd7o8_1`,search:`_search_cd7o8_7`,list:`_list_cd7o8_11`,item:`_item_cd7o8_15`,logo:`_logo_cd7o8_37`,fallback:`_fallback_cd7o8_44`,info:`_info_cd7o8_51`,symbol:`_symbol_cd7o8_57`,name:`_name_cd7o8_66`,balance:`_balance_cd7o8_72`,value:`_value_cd7o8_79`},nd=e=>{let{assets:t,onSelect:n,renderAsset:r=(e,t)=>t(e),searchKeys:i=[`symbol`],placeholder:a=`Search by symbol`,emptyMessage:o=`No assets`,listClassName:s}=e,[c,l]=(0,g.useState)(``),u=Qu(i,c,t);return(0,y.jsxs)(`div`,{className:td.container,children:[(0,y.jsx)(ed,{value:c,onChange:e=>l(e.target.value),onClear:()=>l(``),placeholder:a,rootClassName:td.search,padding:20,ref:xu()}),u.length===0?(0,y.jsx)(Da,{children:o}):(0,y.jsx)(`div`,{className:(0,P.default)(td.list,s),children:u.map(e=>(0,y.jsx)(`button`,{type:`button`,className:td.item,onClick:()=>n(e.denom),children:r(e,e=>{let{denom:t,logoUrl:n,symbol:r,name:i,balance:a,decimals:o,value:s=0}=e;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(K,{src:n,width:32,height:32,className:td.logo,classNames:{placeholder:td.fallback},logo:!0}),(0,y.jsxs)(`div`,{className:td.info,children:[(0,y.jsx)(`div`,{className:td.symbol,children:r||t}),(0,y.jsx)(`div`,{className:td.name,children:i})]}),(0,y.jsxs)(`div`,{className:td.balance,children:[a&&(0,y.jsx)(`div`,{children:(0,d.formatAmount)(a,{decimals:o})}),s>0&&(0,y.jsx)(`div`,{className:td.value,children:q(s)})]})]})})},e.denom))})]})};nd.Placeholder=()=>(0,y.jsxs)(`div`,{className:td.container,children:[(0,y.jsx)(ed,{rootClassName:td.search,padding:20,placeholder:`Search by symbol`,readOnly:!0}),(0,y.jsx)(Da,{children:`Loading...`})]});var rd={stack:`_stack_16oqn_1`,title:`_title_16oqn_9`,grid:`_grid_16oqn_16`,item:`_item_16oqn_22`,button:`_button_16oqn_26`,active:`_active_16oqn_44`},id=({label:e,chains:t,value:n,onSelect:r,getShowIndicator:i})=>(0,y.jsxs)(`div`,{children:[e&&(0,y.jsx)(`h2`,{className:rd.title,children:e}),(0,y.jsx)(`div`,{className:rd.grid,children:t.map(({chainId:e,name:t,logoUrl:a})=>(0,y.jsx)(Bl,{offset:-2,disabled:!i?.(e),className:rd.item,children:(0,y.jsx)(ku,{label:t,disableHoverableContent:!0,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":t,className:(0,P.default)(rd.button,{[rd.active]:e===n}),onClick:()=>r(e),children:(0,y.jsx)(K,{src:a,width:28,height:28,logo:!0})})})},e))})]});id.Stack=({children:e})=>(0,y.jsx)(`div`,{className:rd.stack,children:e});var ad=({address:e,chain:t,onSelect:n})=>{let r=au(t.chain_id),{data:i={}}=Au(e,t.chain_id);return(0,y.jsx)(nd,{assets:(0,p.sortWith)([(0,p.ascend)(e=>At(e.symbol)),(0,p.descend)(e=>e.value),({balance:e=`0`},{balance:t=`0`})=>(0,f.default)(t||0).comparedTo(e||0)??0,(0,p.ascend)(e=>e.symbol.toLowerCase())],r.filter(eu).map(e=>{let{denom:t,symbol:n=(0,d.truncate)(t),logo_uri:r}=e,a=i[t]??{};return{...e,symbol:n,decimals:e.decimals??0,logoUrl:r??``,name:e.name??``,balance:a.amount,value:Number(a.value_usd??0)}})),onSelect:n})},od=({type:e,afterSelect:t})=>{let n=e===`src`?`srcChainId`:`dstChainId`,r=e===`src`?`srcDenom`:`dstDenom`,i=e===`src`?`sender`:`recipient`,a=Ca(),o=ql(),{watch:s,setValue:c}=Ls(),l=s(i),u=s(n),d=s(r),[f,m]=(0,g.useState)(u),h=Yl(f),_=$l(),v=Ul(),[b,x]=(0,p.partition)(e=>v(e.chain_id),o.filter(e=>!e.hidden));return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(id.Stack,{children:[(0,y.jsx)(id,{label:`Interwoven Economy`,chains:b.map(({chain_id:e,chain_name:t,pretty_name:n,logo_uri:r})=>({chainId:e,name:n||t,logoUrl:r??``})),value:f,onSelect:m}),(0,y.jsx)(id,{label:`Chains`,chains:x.map(({chain_id:e,chain_name:t,pretty_name:n,logo_uri:r})=>({chainId:e,name:n||t,logoUrl:r??``})),value:f,onSelect:m})]}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(nd.Placeholder,{}),children:(0,y.jsx)(ad,{address:_({initialAddress:l,initialChainId:u,chainId:f,fallbackAddress:e===`src`?a:void 0}),chain:h,onSelect:e=>{if(u===f&&d===e){t();return}c(n,f),c(r,e),t()}})},f)]})},sd=({type:e})=>{let t=e===`src`?`srcChainId`:`dstChainId`,n=e===`src`?`srcDenom`:`dstDenom`,r=e===`src`?`Select source chain and asset`:`Select destination chain and asset`,{watch:i}=Ls(),a=i(t),o=i(n),s=Yl(a),c=su(o,a);return(0,y.jsx)(Du,{title:r,content:t=>(0,y.jsx)(od,{type:e,afterSelect:t}),children:(0,y.jsx)(Zu,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??``},chain:{chainId:s.chain_id,name:s.pretty_name||s.chain_name,logoUrl:s.logo_uri??``}})})},cd={skeleton:`_skeleton_1l4jn_1`,pulse:`_pulse_1l4jn_1`},ld=({width:e=`100%`,height:t})=>(0,y.jsx)(`div`,{className:cd.skeleton,style:{width:e,height:t},"aria-hidden":`true`}),ud={stack:`_stack_oq1ir_1`,button:`_button_oq1ir_6`,isLoading:`_isLoading_oq1ir_19`,disabled:`_disabled_oq1ir_19`,checked:`_checked_oq1ir_23`,header:`_header_oq1ir_37`,title:`_title_oq1ir_43`,duration:`_duration_oq1ir_52`,warning:`_warning_oq1ir_62`,amount:`_amount_oq1ir_66`,value:`_value_oq1ir_67`},dd=({children:e})=>(0,y.jsx)(`div`,{className:ud.stack,role:`radiogroup`,"aria-label":`Route options`,children:e}),fd=({label:e,query:t,value:n,onSelect:r,...i})=>{let{data:a,isLoading:o}=t,{watch:s}=Ls(),{dstChainId:c,dstDenom:l}=s(),u=su(l,c),f=!o&&i.checked,p=!o&&!a;return(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(ud.button,{[ud.isLoading]:o,[ud.disabled]:p,[ud.checked]:f}),onClick:()=>{o||p||r(n)},role:`radio`,"aria-checked":f,"aria-disabled":p,children:[(0,y.jsxs)(`div`,{className:ud.header,children:[(0,y.jsxs)(`div`,{className:ud.title,children:[(0,y.jsx)(`span`,{children:e}),f&&(0,y.jsx)(I.IconCheck,{size:14,"aria-hidden":`true`})]}),o?(0,y.jsx)(ld,{width:80,height:16}):a?(0,y.jsxs)(`div`,{className:(0,P.default)(ud.duration,{[ud.warning]:n===`op`}),children:[(0,y.jsx)(I.IconClockFilled,{size:12,"aria-hidden":`true`}),(0,y.jsx)(`span`,{children:Pu(a.estimated_route_duration_seconds)})]}):(0,y.jsx)(`div`,{className:ud.duration,children:`Not available`})]}),(o||a)&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:ud.amount,children:o?(0,y.jsx)(ld,{width:260,height:40}):a?(0,d.formatAmount)(a.amount_out,{decimals:u.decimals}):null}),(0,y.jsx)(`div`,{className:ud.value,children:o?(0,y.jsx)(ld,{width:120,height:16}):a?a.usd_amount_out?q(a.usd_amount_out):`$-`:null})]})]})};fd.Stack=dd;function pd(e){let t=en(e);return t?t.lte(0)?{type:`error`,text:`Slippage must be greater than 0`}:t.gt(100)?{type:`error`,text:`Slippage must be less than 100%`}:t.gt(5)?{type:`warning`,text:`Your transaction may be frontrun`}:t.lt(.1)?{type:`warning`,text:`Your transaction may fail`}:null:{type:`error`,text:`Enter a slippage value`}}var md={description:`_description_nuyvt_1`,presets:`_presets_nuyvt_8`,preset:`_preset_nuyvt_8`,active:`_active_nuyvt_29`,custom:`_custom_nuyvt_40`,wrapper:`_wrapper_nuyvt_47`,percent:`_percent_nuyvt_58`},hd=[`0.1`,`0.5`,`1.0`],gd=({afterConfirm:e})=>{let t=Ls(),n=t.getValues(`slippagePercent`),[r,i]=(0,g.useState)(null),{control:a,watch:o,getValues:s,setValue:c}=(0,F.useForm)({defaultValues:{value:n}}),l=o(`value`);(0,g.useEffect)(()=>{let e=hd.findIndex(e=>e===n);i(e>=0?e:null)},[n]);let u=(e,t)=>{c(`value`,e),i(t)},d=()=>{i(null)},f=(0,g.useMemo)(()=>pd(l),[l]),p=f?.type===`error`,m=({value:n})=>{t.setValue(`slippagePercent`,n),e()};return(0,y.jsxs)(sc,{children:[(0,y.jsx)(`p`,{className:md.description,children:`Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed.`}),(0,y.jsxs)(`div`,{className:md.presets,role:`radiogroup`,"aria-label":`Slippage presets`,children:[hd.map((e,t)=>(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(md.preset,{[md.active]:r===t}),onClick:()=>u(e,t),role:`radio`,"aria-checked":r===t,children:[e,`%`]},e)),r===null?(0,y.jsxs)(`div`,{className:md.wrapper,children:[(0,y.jsx)(Cu,{name:`value`,control:a,dp:2,onFocus:d,placeholder:``,className:(0,P.default)(md.preset,md.active),"aria-label":`Slippage percent`}),(0,y.jsx)(`span`,{className:md.percent,children:`%`})]}):(0,y.jsx)(`button`,{type:`button`,className:(0,P.default)(md.preset,md.custom),onClick:()=>i(null),role:`radio`,"aria-checked":r===null,children:`Custom`})]}),f&&(0,y.jsx)(Gc,{level:f.type,children:f.text}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{type:`button`,onClick:()=>m(s()),disabled:p,children:`Confirm`})})]})},_d={form:`_form_1owk5_1`,arrow:`_arrow_1owk5_5`,divider:`_divider_1owk5_14`,flip:`_flip_1owk5_23`,meta:`_meta_1owk5_41`,row:`_row_1owk5_54`,title:`_title_1owk5_60`,description:`_description_1owk5_64`,icon:`_icon_1owk5_71`,edit:`_edit_1owk5_76`,link:`_link_1owk5_94`,warning:`_warning_1owk5_99`};function vd({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}function yd({srcChainType:e,chainFeeAssets:t,srcDenom:n}){switch(e){case`initia`:case`cosmos`:return t.map(({denom:e})=>e);case`evm`:return(0,w.isAddress)(n)?[]:[n];default:return[]}}var bd=(0,f.default)(1),xd=()=>{let e=Xt(),t=dc(),n=Nn(),[r,i]=(0,g.useState)(void 0),[a,o]=(0,g.useState)(!1),[s,c]=(0,ue.useLocalStorage)(V.BRIDGE_ROUTE_TYPE,`default`),{watch:l,setValue:u,handleSubmit:p,formState:m}=Ls(),h=l(),{srcChainId:_,srcDenom:v,dstChainId:b,dstDenom:x,quantity:S,sender:C,slippagePercent:w}=h,T=B(),E=Yl(_),D=Kl(E),ee=Kl(Yl(b)),O=su(v,_),k=su(x,b),{data:A,isError:j}=Au(C,_),te=ju(C,_,v),ne=A!==void 0,M=te?.amount??(A?`0`:void 0),re=!M||(0,f.default)(M||0).isZero(),[ie]=(0,ue.useDebounceValue)(S,300),ae=tn({quantity:ie,balance:M,decimals:O?.decimals}),oe=_===b,se=oe&&_===T.chainId,ce=vd({isLayer1Swap:se,isL2Swap:oe&&D===`initia`&&!se}),le=D!==`initia`&&ee!==`initia`,N=Bu(),de=Ru(ie,{disabled:le,refreshMs:ce}),P=Ru(ie,{isOpWithdraw:!0,disabled:!N,refreshMs:ce}),F=N&&s===`op`,fe=F?P:de,pe=F?de:P,me=F?!le:N,ge=fe.error&&me?pe:fe,{data:L,isLoading:_e,error:ve}=ge,{data:ye}=zu(ve),be=ie&&_e&&!a,xe=()=>{u(`srcChainId`,b),u(`srcDenom`,x),u(`dstChainId`,_),u(`dstDenom`,v),u(`quantity`,``,{shouldTouch:!1,shouldDirty:!1})},{openModal:Se,closeModal:Ce}=bi(),we=p(async t=>{i(void 0),o(!0);try{let r=await ge.refetch();if(r.error||!r.data||!r.dataUpdatedAt){i(r.error instanceof Error?r.error.message:`Failed to refresh route. Please try again.`);return}let a=r.data,o=r.dataUpdatedAt;if(n(`Bridge Simulation Success`,{quantity:t.quantity,srcChainId:t.srcChainId,srcDenom:t.srcDenom,dstChainId:t.dstChainId,dstDenom:t.dstDenom}),a.warning){let{type:n=``,message:r}=a.warning??{};Se({content:(0,y.jsx)(lu,{type:`warning`,icon:(0,y.jsx)(I.IconWarningFilled,{size:40}),title:(0,he.sentenceCase)(n),primaryButton:{label:`Cancel`,onClick:Ce},secondaryButton:{label:`Proceed anyway`,onClick:()=>{e(`/bridge/preview`,{route:a,values:t,quoteVerifiedAt:o}),Ce()}},children:(0,y.jsx)(`p`,{className:_d.warning,children:r})})});return}e(`/bridge/preview`,{route:a,values:t,quoteVerifiedAt:o})}finally{o(!1)}}),Te=(0,g.useMemo)(()=>L?.estimated_fees?.filter(({fee_behavior:e})=>e===`FEE_BEHAVIOR_DEDUCTED`)??[],[L]),Ee=(0,g.useMemo)(()=>L?.estimated_fees?.filter(({fee_behavior:e})=>e===`FEE_BEHAVIOR_ADDITIONAL`)??[],[L]),De=(0,g.useMemo)(()=>{if(ne)for(let e of Ee){let t=A?.[e.origin_asset.denom]?.amount||`0`,n=(L?.source_asset_denom===e.origin_asset.denom?L.amount_in:`0`)||`0`,r=e.amount||`0`;if((0,f.default)(t).lt((0,f.default)(n).plus(r)))return`Insufficient ${e.origin_asset.symbol} for fees`}},[Ee,A,ne,L]),Oe=!!L&&Ee.length>0&&!ne,ke=L?(0,d.formatAmount)(L.amount_out,{decimals:k.decimals}):`0`,Ae=(0,g.useMemo)(()=>E.fee_assets??[],[E.fee_assets]),je=(0,g.useCallback)((e,t)=>{let n=(0,f.default)(A?.[e]?.amount||0),r=e===(t?.sourceDenom??v)?(0,f.default)(t?.amountIn||L?.amount_in||0):(0,f.default)(0);return n.minus(r)},[A,L?.amount_in,v]),Me=(0,g.useMemo)(()=>yd({srcChainType:D,chainFeeAssets:Ae,srcDenom:v}),[Ae,D,v]),Ne=Mu({sourceDenom:v,sourceBalance:M,amountIn:L?.amount_in,feeTokenDenoms:Me,balancesByDenom:A,additionalFees:Ee}),Pe=Me.some(e=>je(e).gt(bd)),Fe=ne&&L&&Me.length>0&&!Pe||Ne?`Insufficient balance for fees`:void 0,Ie=!!r,Le=(0,g.useMemo)(()=>{if(!h.sender)return`Connect wallet`;if(!h.quantity||!ie)return`Enter amount`;if(!h.recipient)return`Enter recipient address`;if(m.errors.quantity)return m.errors.quantity.message;if(j)return`Failed to load balance`;if(ae)return`Insufficient balance`;if(!L)return`Route not found`;if(Oe)return`Loading balances...`;if(De)return De},[ie,De,m,Oe,j,ae,L,h]),Re=(0,g.useMemo)(()=>a?`Refreshing route...`:be?`Simulating...`:!1,[be,a]),ze=(0,g.useCallback)((e,n)=>e.length?(0,y.jsxs)(`div`,{className:_d.description,children:[Iu(e),!t&&(0,y.jsx)(ku,{label:n,children:(0,y.jsx)(`span`,{className:_d.icon,children:(0,y.jsx)(I.IconInfoFilled,{size:12,"aria-hidden":`true`})})})]}):null,[t]),Be=!!en(S)?.gt(0)&&N&&de.data&&P.data&&P.data.estimated_route_duration_seconds>de.data.estimated_route_duration_seconds,Ve=(0,g.useMemo)(()=>{if(!L)return[];let e=Fu(L.amount_out,w);return[{condition:!!L.estimated_fees?.length,title:`Fees`,content:(0,y.jsxs)(`div`,{children:[ze(Te,`Fee deducted from the amount you receive`),ze(Ee,`Fee charged in addition to the amount you enter`)]})},{condition:!Be&&!!Pu(L.estimated_route_duration_seconds),title:`Estimated time`,content:(0,y.jsx)(`span`,{className:_d.description,children:Pu(L.estimated_route_duration_seconds)})},{condition:L.does_swap,title:`Slippage`,content:(0,y.jsxs)(`span`,{className:_d.description,children:[(0,y.jsxs)(`span`,{children:[w,`%`]}),(0,y.jsx)(Du,{title:`Slippage tolerance`,content:e=>(0,y.jsx)(gd,{afterConfirm:e}),className:_d.edit,children:(0,y.jsx)(I.IconSettingFilled,{size:12,"aria-hidden":`true`})})]})},{condition:L.does_swap,title:`Minimum received`,content:(0,y.jsxs)(`span`,{className:_d.description,children:[(0,y.jsx)(`img`,{src:k.logo_uri,alt:k.symbol,width:12,height:12}),(0,d.formatAmount)(e,{decimals:k.decimals}),` `,k.symbol]})}].filter(e=>e.condition)},[Ee,Te,k,ze,L,Be,w]);return(0,y.jsxs)(`form`,{className:_d.form,onSubmit:we,"aria-label":`Bridge and swap form`,children:[(0,y.jsx)(bu,{selectButton:(0,y.jsx)(sd,{type:`src`}),accountButton:D===`cosmos`&&(0,y.jsx)(qu,{type:`src`}),quantityInput:(0,y.jsx)(Eu,{balance:M,decimals:O?.decimals}),balanceButton:(0,y.jsx)(vu,{onClick:()=>u(`quantity`,(0,d.fromBaseUnit)(te?.amount,{decimals:O?.decimals??0}),{shouldValidate:!0}),disabled:re,children:(0,d.formatAmount)(M??`0`,{decimals:O.decimals})}),value:L?.usd_amount_in?q(L.usd_amount_in):`$-`}),(0,y.jsxs)(`div`,{className:_d.arrow,children:[(0,y.jsx)(`div`,{className:_d.divider}),(0,y.jsx)(`button`,{type:`button`,className:_d.flip,onClick:()=>xe(),"aria-label":`Swap source and destination`,children:(0,y.jsx)(I.IconChevronDown,{size:16,"aria-hidden":`true`})})]}),(0,y.jsx)(bu,{selectButton:(0,y.jsx)(sd,{type:`dst`}),accountButton:(0,y.jsx)(qu,{type:`dst`}),quantityInput:(0,y.jsx)(Eu.ReadOnly,{children:ke}),value:L?.usd_amount_out?q(L.usd_amount_out):`$-`,hideNumbers:Be}),(0,y.jsx)(Bc,{children:Be?(0,y.jsxs)(fd.Stack,{children:[(0,y.jsx)(fd,{label:`Fast`,query:de,value:`default`,onSelect:c,checked:s===`default`}),(0,y.jsx)(fd,{label:`Lossless`,query:P,value:`op`,onSelect:c,checked:s===`op`})]}):null}),(0,y.jsx)(ac,{extra:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(Gc.Stack,{children:[j&&(0,y.jsx)(Gc,{level:`error`,children:`Failed to load balance`}),Ie&&(0,y.jsx)(Gc,{level:`error`,children:r}),L?.extra_infos?.map(e=>(0,y.jsx)(Gc,{level:`info`,children:e},e)),ye&&(0,y.jsx)(Gc,{level:`info`,children:ye}),Fe&&(0,y.jsx)(Gc,{level:`warning`,children:Fe}),L?.warning&&(0,y.jsx)(Gc,{level:`warning`,children:L.warning.message}),L?.extra_warnings?.map(e=>(0,y.jsx)(Gc,{level:`warning`,children:e},e))]}),(0,y.jsx)(Bc,{children:Ve.length>0&&(0,y.jsx)(`section`,{className:_d.meta,"aria-label":`Route details`,children:Ve.map((e,t)=>(0,y.jsxs)(`div`,{className:_d.row,children:[(0,y.jsx)(`span`,{className:_d.title,children:e.title}),e.content]},t))})})]}),children:(0,y.jsx)(G.White,{loading:Re,disabled:!!Le||a,children:Le??`Preview route`})})]})},Sd=()=>{gu();let e=Yt(),t=Xt(),n=Ca(),r=(0,F.useForm)({mode:`onChange`,defaultValues:zs()}),{watch:i,setValue:a}=r,{srcChainId:o,dstChainId:s,srcDenom:c,dstDenom:l,quantity:u,slippagePercent:d,recipient:f}=i();i((e,{name:t})=>{(t===`srcChainId`||t===`srcDenom`)&&a(`quantity`,``,{shouldTouch:!1,shouldDirty:!1})});let p=Zl(),m=p(o),h=p(s),_=Ql()(f,s);(0,g.useEffect)(()=>{a(`cosmosWalletName`,void 0),a(`sender`,m)},[o,m,a]),(0,g.useEffect)(()=>{_||a(`recipient`,h)},[h,_,a]);let{showNotification:v}=Ec(),b=Yl(o),x=Yl(s),S=au(o),C=au(s),w=nu(S),T=nu(C),E=!!tu(S,c),D=!!tu(C,l);(0,g.useEffect)(()=>{w&&!E&&(a(`srcDenom`,w.denom),v({type:`info`,title:`Switched to ${w.symbol}`,description:`The selected asset is not available on ${b.pretty_name}.`,autoHide:!0}))},[w,E,a,v,b.pretty_name]),(0,g.useEffect)(()=>{T&&!D&&(a(`dstDenom`,T.denom),v({type:`info`,title:`Switched to ${T.symbol}`,description:`The selected asset is not available on ${x.pretty_name}.`,autoHide:!0}))},[T,D,a,v,x.pretty_name]),(0,g.useEffect)(()=>{!E||!D||(localStorage.setItem(V.BRIDGE_SRC_CHAIN_ID,o),localStorage.setItem(V.BRIDGE_SRC_DENOM,c),localStorage.setItem(V.BRIDGE_DST_CHAIN_ID,s),localStorage.setItem(V.BRIDGE_DST_DENOM,l),localStorage.setItem(V.BRIDGE_QUANTITY,u),localStorage.setItem(V.BRIDGE_SLIPPAGE_PERCENT,d))},[o,c,s,l,u,d,E,D]);let ee=e[0].path===`/bridge`,{reminders:O}=hu();return(0,y.jsx)(Hl,{title:`Bridge/Swap`,backButton:ee?`/`:void 0,extra:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(G.Small,{onClick:()=>t(`/bridge/history`),unpadded:!0,"aria-label":`Bridge/Swap history`,children:(0,y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,width:`12`,height:`12`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z`}),(0,y.jsx)(`path`,{d:`M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z`})]})}),(0,y.jsx)(Bl,{offset:0,disabled:O.length===0,children:(0,y.jsx)(G.Small,{onClick:()=>t(`/op/withdrawals`),disabled:!n,children:(0,y.jsx)(`span`,{children:`Withdrawal status`})})})]}),children:E&&D&&(0,y.jsx)(F.FormProvider,{...r,children:(0,y.jsx)(W,{children:(0,y.jsx)(xd,{})})})})},Cd={button:`_button_1crvp_1`,checkbox:`_checkbox_1crvp_11`,checked:`_checked_1crvp_25`},wd=({checked:e,onClick:t,label:n,className:r})=>(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(Cd.button,r),onClick:t,role:`checkbox`,"aria-checked":e,children:[(0,y.jsx)(`div`,{className:(0,P.default)(Cd.checkbox,{[Cd.checked]:e}),children:e&&(0,y.jsx)(I.IconCheck,{size:12,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:Cd.label,children:n})]}),Td={button:`_button_aoxv2_1`},Ed=({onClick:e,disabled:t})=>{let{ref:n,inView:r}=(0,Ce.useInView)();return(0,g.useEffect)(()=>{r&&e()},[r,e]),(0,y.jsxs)(`button`,{className:Td.button,onClick:e,disabled:t,ref:n,children:[(0,y.jsx)(`span`,{children:`Load more`}),(0,y.jsx)(I.IconChevronDown,{size:12,"aria-hidden":`true`})]})};function Dd(e,t){return e.reduce((e,n)=>{let r=t(n);if(!r)return e;let i=r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),a=e[i]||[];return{...e,[i]:[...a,n]}},{})}var Od=({chainId:e,txHash:t})=>`${V.BRIDGE_HISTORY}:${e}:${t}`;function kd(){let[e,t]=(0,ue.useLocalStorage)(V.BRIDGE_HISTORY,[]);return{history:e,addHistoryItem:(0,g.useCallback)((n,r)=>{localStorage.setItem(Od(n),JSON.stringify(r));for(let t of e.slice(99))localStorage.removeItem(Od(t));t((e=[])=>[n,...e.slice(0,99)])},[e,t]),getHistoryDetails:(0,g.useCallback)(e=>{let t=localStorage.getItem(Od(e));return t?JSON.parse(t):null},[])}}function Ad(e){return(0,ue.useLocalStorage)(Od(e),null)}var jd=(0,m.createQueryKeys)(`interwovenkit:op`,{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function Md(){let{restUrl:e}=B();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e}),[e])}function Nd(e){let t=Md(),{data:n}=(0,u.useSuspenseQuery)({queryKey:jd.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:z.INFINITY});return n}var Pd=20;function Fd(e){let t=U();return(0,u.useSuspenseInfiniteQuery)({queryKey:jd.withdrawals(e,t).queryKey,queryFn:async({pageParam:n})=>{if(!t)return[];let r={limit:Pd,offset:n,order:`desc`},{withdrawals:i}=await h.default.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:r}).json();return i},getNextPageParam:e=>{let t=(0,p.last)(e)?.sequence;return e.length<Pd||!t||t<=1?null:t-1},initialPageParam:0,staleTime:z.SECOND})}function Id(e){let t=Md(),{data:n}=(0,u.useSuspenseQuery)({queryKey:jd.latestOutput(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:e})=>{let[t]=e;return t||null},staleTime:z.SECOND});return n}function Ld({bridge_id:e,output_index:t}){let n=Md(),{data:r}=(0,u.useSuspenseQuery)({queryKey:jd.output(e,t).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:z.SECOND});return r}function Rd({bridge_id:e,sequence:t}){let n=Xe().find(({metadata:t})=>t?.op_bridge_id===e.toString())?.chain_id;if(!n)throw Error(`Chain not found for bridge_id: ${e}`);let r=$e()(n);if(!r)throw Error(`Chain not found: ${n}`);let i=r.metadata?.executor_uri;if(!i)throw Error(`Executor URL not found: ${n}`);let{data:a}=(0,u.useSuspenseQuery)({queryKey:jd.outputResponse(i,t).queryKey,queryFn:()=>h.default.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:z.SECOND});return a}function zd(e,t){let{bridge_id:n}=e,r=Md(),{data:i}=(0,u.useSuspenseQuery)({queryKey:jd.withdrawalClaimed(n,t).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:e})=>e,staleTime:({state:{data:e}})=>e?.claimed?1/0:z.SECOND});return i}function Bd(e){return we.sha3_256.create().update(e).digest()}function Vd(e,t){let n=new ArrayBuffer(t);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function Hd(e){let{bridge_id:t,sequence:n,amount:r,from:i,to:a}=e,o=Vd(t.toString(),8),s=Vd(n.toString(),8),c=Vd(r.amount,8);return Bd(Bd((0,Te.concatBytes)(o,s,Bd((0,Te.utf8ToBytes)(i)),Bd((0,Te.utf8ToBytes)(a)),Bd((0,Te.utf8ToBytes)(r.denom)),c)))}async function Ud(e,t,n){try{return await h.default.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:n}}).json(),!0}catch{return!1}}async function Wd(e,t){let n=h.default.create({prefixUrl:t}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let e=1;e<=24;e++)try{return await n.get(r).json()}catch{await new Promise(e=>setTimeout(e,5e3))}throw Error(`Timeout: ${e} not found`)}function Gd({addressList:e,route:t,slippagePercent:n,signedOpHook:r}){return{address_list:e,amount_in:t.amount_in,amount_out:t.amount_out,source_asset_chain_id:t.source_asset_chain_id,source_asset_denom:t.source_asset_denom,dest_asset_chain_id:t.dest_asset_chain_id,dest_asset_denom:t.dest_asset_denom,slippage_tolerance_percent:n,operations:t.operations,signed_op_hook:r}}async function Kd(e,t){let n=Gd(t),{txs:r}=await e.post(`v2/fungible/msgs`,{json:n}).json();if(!r||r.length===0)throw Error(`No transaction data found`);return r}function qd(e,t){if(!e?.length)throw Error(`Invalid transaction data`);return e.map(({msg_type_url:e,msg:n})=>{if(!(e&&n))throw Error(`Invalid transaction data`);let r=t.converters[e];if(!r)throw Error(`Unsupported message type: ${e}`);return t.fromAmino({type:r.aminoType,value:JSON.parse(n)})})}function Jd({gas:e,gasPrices:t,gasAdjustment:n=Pe}){return t.reduce((t,{amount:r,denom:i})=>(t[i]=(0,f.default)(e).times(n).times(r||0).integerValue(f.default.ROUND_CEIL).toFixed(0),t),{})}function Yd({balances:e,requiredFeeByDenom:t,sourceDenom:n,amountIn:r}){let i=Object.keys(t);return i.length===0?!0:i.some(i=>{let a=(0,f.default)(e[i]?.amount||0),o=i===n?(0,f.default)(r||0):(0,f.default)(0),s=(0,f.default)(t[i]||0);return a.minus(o).gte(s)})}async function Xd(e,t){let{chain_type:n,chain_id:r,chain_name:i,evm_fee_asset:a,rpc:o}=t;if(n!==`evm`)throw Error(`Chain is not an EVM chain: ${i}`);try{await e.send(`wallet_switchEthereumChain`,[{chainId:`0x${Number(r).toString(16)}`}])}catch(t){if((0,p.path)([`error`,`code`],t)!==4902)throw t;if(!a)throw Error(`Fee asset is not defined for chain: ${i}`);await e.send(`wallet_addEthereumChain`,[{chainId:`0x${Number(r).toString(16)}`,chainName:i,nativeCurrency:a,rpcUrls:[o]}]),await e.send(`wallet_switchEthereumChain`,[{chainId:`0x${Number(r).toString(16)}`}])}}function Zd(){return Jt()}function Qd(e,t){let{customFee:n,onCompleted:r}=t??{},i=Xt(),{showNotification:a,updateNotification:o,hideNotification:s}=Ec(),{addHistoryItem:c}=kd(),l=Nn(),{route:p,values:m}=Zd(),{srcChainId:h,sender:g,recipient:_,cosmosWalletName:v}=m,y=Zr(),{requestTxSync:b,submitTxSync:x,waitForTxConfirmation:S}=Ta(),{find:C}=Gu(),w=Rr(),T=zr(),E=Br(),D=Yl(h),ee=Kl(D),O=ou(h),k=(0,u.useQueryClient)(),{registryUrl:A}=R(),te=$e(),ne=B(),{addReminder:M}=hu(),re=rn();return(0,u.useMutation)({mutationFn:async()=>{try{if(`cosmos_tx`in e){if(!e.cosmos_tx.msgs)throw Error(`Invalid transaction data`);let t=qd(e.cosmos_tx.msgs,{converters:T,fromAmino:E.fromAmino.bind(E)});if(ee===`initia`){let{srcDenom:e,quantity:r}=m,{decimals:i}=O(e),a=n?await x({messages:t,chainId:h,fee:n}):await b({messages:t,chainId:h,internal:1,spendCoins:[{denom:e,amount:(0,d.toBaseUnit)(r,{decimals:i})}]});return{txHash:a,wait:S({txHash:a,chainId:h})}}let r=C(v)?.getProvider();if(!r)throw Error(`Wallet not connected`);let i=r.getOfflineSignerOnlyAmino(h),a=await j.SigningStargateClient.connectWithSigner(D.rpc,i,{registry:w,aminoTypes:E}),o=await a.getAllBalances(g),s=D.fee_assets.find(e=>o.some(t=>t.denom===e.denom&&(0,f.default)(t.amount||0).gt(0)));if(!s){let e=[`Insufficient balance for fees.`,`Available fee assets: ${D.fee_assets.map(e=>O(e.denom).symbol).join(`, `)}`,`(note: asset symbols may refer to different tokens across chains)`].join(` `);throw Error(e)}let{denom:c,gas_price:l}=s;if(!l)throw Error(`Gas price not found for ${c}`);let u=await a.simulate(g,t,``),p=j.GasPrice.fromString(l.average+c),_=(0,j.calculateFee)(Math.ceil(u*Pe),p),y=await a.signAndBroadcastSync(g,t,_);return{txHash:y,wait:Qi({txHash:y,client:a})}}if(`evm_tx`in e){let{chain_id:t,to:n,value:r,data:i}=e.evm_tx,a=await y(),o=await a.getSigner();await Xd(a,D);let s=await o.sendTransaction({chainId:t,to:n,value:r,data:`0x${i}`}),c=$r(s.wait(),3e4,`Transaction was not confirmed in time. It may still be processing.`);return{txHash:s.hash,wait:c}}throw Error(`Unlisted chain type`)}catch(e){throw e instanceof Qr?e:await We(e)}},onSuccess:async({txHash:e,wait:t})=>{localStorage.removeItem(V.BRIDGE_QUANTITY),k.removeQueries({queryKey:nn.route._def}),k.removeQueries({queryKey:nn.routeErrorInfo._def}),r?r({txhash:e,chainId:h,timestamp:Date.now(),success:!0,route:p,values:m}):(i(-1),a({type:`loading`,title:`Transaction is pending...`}));try{await t;let n=uf(p)===lf.OP_WITHDRAW,i=n?{success:!0,error:null}:await of(re,e,h);!r&&!i.success&&i.error&&a({type:`error`,title:`Transaction tracking failed`,description:`Failed to track transaction: ${i.error instanceof Error?i.error.message:String(i.error)}. The transaction may still be processing.`,autoHide:!0});let u=i.success,d=rf({txHash:e,srcChainId:h,route:p,values:m,recipient:_},u);if(c(d.tx,d.details),r||o(ef(s)),l(`Bridge Transaction Success`,nf(m,e)),n){let e=te(h).metadata?.op_bridge_id;if(e&&!await Ud(ne.restUrl,Number(e),p.dest_asset_denom)){let e=af(d.tx,p,_);M(d.tx,e)}}}catch(t){let n=t instanceof Error?t.message:String(t);if(t instanceof Qr){let t=rf({txHash:e,srcChainId:h,route:p,values:m,recipient:_},!1);c(t.tx,t.details),r||o(tf(s))}else r?r({success:!1,error:n,route:p,values:m}):o({type:`error`,title:`Transaction not confirmed`,description:n});l(`Bridge Confirmation Failed`,{...nf(m,e),error:n,type:t instanceof Qr?`timeout`:`error`})}finally{k.invalidateQueries({queryKey:nn.balances(h,g).queryKey})}},onError:async e=>{let t=ee===`initia`?await Di(e,te(h),A):e;r?r({success:!1,error:t.message,route:p,values:m}):a({type:`error`,title:`Transaction failed`,description:t.message}),l(`Bridge Transaction Failed`,{...nf(m),error:t.message})}})}function $d(){let e=rn(),t=U(),n=Hr(),{route:r,values:i}=Zd(),a=Jl(),o=zr(),s=Br();return(0,u.useMutation)({mutationFn:async()=>{try{let{chain_id:c,hook:l}=await e.post(`op-hook`,{json:{source_address:t,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:(0,d.InitiaAddress)(i.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await Wd(t,a(r.dest_asset_chain_id).rest);let u=await n(c,t,qd(l,{converters:o,fromAmino:s.fromAmino.bind(s)}),{amount:[],gas:`1`},``,{incrementSequence:c===i.srcChainId?2:0}),f=M.Tx.fromPartial({body:M.TxBody.decode(u.bodyBytes),authInfo:M.AuthInfo.decode(u.authInfoBytes),signatures:u.signatures});return{signer:t,hook:(0,_.toBase64)(M.Tx.encode(f).finish())}}catch(e){throw await We(e)}}})}function ef(e){return{type:`info`,title:`Transaction submitted`,description:(0,g.createElement)(g.Fragment,null,`Check `,(0,g.createElement)(Qt,{to:`/bridge/history`,onClick:e},`the activity page`),` for transaction status`),autoHide:!0}}function tf(e){return{type:`info`,title:`Transaction pending`,description:(0,g.createElement)(g.Fragment,null,`Confirmation is taking longer than expected. Check `,(0,g.createElement)(Qt,{to:`/bridge/history`,onClick:e},`the activity page`),` for updates`),autoHide:!0}}function nf(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function rf(e,t){let{txHash:n,srcChainId:r,route:i,values:a}=e,o={chainId:r,txHash:n},s=uf(i)===lf.OP_WITHDRAW;return{tx:o,details:{...o,timestamp:Date.now(),route:i,values:a,state:s?`success`:void 0,tracked:t},isOpWithdraw:s}}function af(e,t,n){return{...e,recipient:(0,d.InitiaAddress)(n).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function of(e,t,n){for(let r=0;r<=30;r++)try{return await e.post(`v2/tx/track`,{json:{tx_hash:t,chain_id:n}}).json(),{success:!0,error:null}}catch(e){if(r===30)return{success:!1,error:await We(e)};await new Promise(e=>setTimeout(e,1e3))}return{success:!1,error:Error(`Maximum retries exceeded`)}}function sf(e){let{chainId:t,txHash:n,tracked:r}=e,i=rn();return(0,u.useQuery)({queryKey:nn.txTrack(t,n).queryKey,queryFn:async()=>{try{return await i.post(`v2/tx/track`,{json:{tx_hash:n,chain_id:t}}).json()}catch(e){throw await We(e)}},select:({tx_hash:e})=>e,retry:6,retryDelay:5e3,staleTime:z.INFINITY,enabled:!r&&!!t&&!!n})}function cf(e){let{timestamp:t,chainId:n,txHash:r,tracked:i,state:a}=e,o=rn();return(0,u.useQuery)({queryKey:nn.txStatus(n,r).queryKey,queryFn:()=>o.get(`v2/tx/status`,{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&i&&!a,refetchInterval:({state:{data:n}})=>{if(!n)return!1;let{status:r}=n;if(r===`STATE_COMPLETED`)return!1;let i=t+e.route.estimated_route_duration_seconds*1e3,a=Math.floor((i-Date.now())/1e3);return a<=0?1e3:a<=300?5e3:60*1e3},staleTime:z.INFINITY})}var lf=function(e){return e.OP_WITHDRAW=`OP Bridge withdrawal`,e.SKIP=`Skip`,e}({});function uf(e){let{operations:t,dest_asset_denom:n}=e;return(0,p.has)(`op_init_transfer`,(0,p.head)(t))&&n===`uinit`?lf.OP_WITHDRAW:lf.SKIP}var df={success:`_success_t4dfk_1`,error:`_error_t4dfk_5`},ff=({tx:e})=>{let[t,n]=Ad(e);if(!t)throw Error(`Bridge history details not found`);let{data:r}=cf(t),i=t.state??pf(r);switch((0,g.useEffect)(()=>{i!==`loading`&&n(e=>{if(!e)throw Error(`Bridge history details not found`);return{...e,tracked:!0,state:i}})},[n,i]),i){case`error`:return(0,y.jsx)(`div`,{className:df.error,children:(0,y.jsx)(I.IconCloseCircleFilled,{size:14})});case`success`:return(0,y.jsx)(`div`,{className:df.success,children:(0,y.jsx)(I.IconCheckCircleFilled,{size:14})});default:return(0,y.jsx)(tc,{size:14})}};function pf(e){if(!e)return`loading`;switch(e.state){case`STATE_ABANDONED`:case`STATE_COMPLETED_ERROR`:case`STATE_PENDING_ERROR`:return`error`;case`STATE_COMPLETED_SUCCESS`:return`success`;default:return`loading`}}var mf={link:`_link_104m3_1`,header:`_header_104m3_23`,title:`_title_104m3_31`,date:`_date_104m3_37`,explorer:`_explorer_104m3_41`,divider:`_divider_104m3_49`,fees:`_fees_104m3_57`,label:`_label_104m3_65`,content:`_content_104m3_69`,route:`_route_104m3_75`,row:`_row_104m3_80`,asset:`_asset_104m3_86`,amount:`_amount_104m3_94`,chain:`_chain_104m3_99`,account:`_account_104m3_108`,arrow:`_arrow_104m3_115`},hf=({tx:e})=>{let[t,n]=Ad(e);if(!t)throw Error(`Bridge history details not found`);let{chainId:r,txHash:i,route:a,values:o,timestamp:s,tracked:c}=t,{data:u}=sf(t),{address:f=``,connector:p}=(0,l.useAccount)(),{find:m}=Gu();(0,g.useEffect)(()=>{u&&n(e=>{if(!e)throw Error(`Bridge history details not found`);return{...e,tracked:!0}})},[n,u]);let{amount_in:h,amount_out:_,source_asset_chain_id:v,source_asset_denom:b,dest_asset_chain_id:x,dest_asset_denom:S,estimated_fees:C=[]}=a,w=Yl(v),T=Yl(x),E=su(b,v),D=su(S,x),ee=(e,t)=>t?(0,y.jsx)(K,{src:t,width:12,height:12}):d.InitiaAddress.equals(e,f)?(0,y.jsx)(K,{src:p?.icon,width:12,height:12}):(0,y.jsx)(I.IconWallet,{size:12}),O=(e,{symbol:t,decimals:n,logo_uri:r},{chain_name:i,pretty_name:a,...o},s,c)=>(0,y.jsxs)(`div`,{className:mf.row,children:[(0,y.jsx)(Yu,{assetLogoUrl:r,chainLogoUrl:o.logo_uri??void 0}),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:mf.asset,children:[(0,y.jsx)(`span`,{className:mf.amount,children:(0,d.formatAmount)(e,{decimals:n})}),(0,y.jsx)(`span`,{children:t})]}),(0,y.jsxs)(`div`,{className:mf.chain,children:[(0,y.jsxs)(`span`,{children:[`on `,a||i]}),(0,y.jsxs)(`div`,{className:mf.account,children:[c,(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(s)})]})]})]})]}),k=uf(a),A=(0,g.useMemo)(()=>{switch(k){case lf.SKIP:return`Skip Explorer`;case lf.OP_WITHDRAW:return`Initia Scan`}},[k]),j=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`header`,{className:mf.header,children:[(0,y.jsxs)(`div`,{className:mf.title,children:[c?(0,y.jsx)(ff,{tx:e}):(0,y.jsx)(tc,{size:14}),(0,y.jsx)(`div`,{className:mf.date,children:(0,se.format)(new Date(s),`h:mm a`)})]}),(0,y.jsxs)(`div`,{className:mf.explorer,children:[(0,y.jsx)(`span`,{children:A}),(0,y.jsx)(I.IconExternalLink,{size:12,"aria-hidden":`true`})]})]}),(0,y.jsxs)(`div`,{className:mf.route,children:[O(h,E,w,o.sender,ee(o.sender,m(o.cosmosWalletName)?.image)),(0,y.jsx)(`div`,{className:mf.arrow,children:(0,y.jsx)(I.IconArrowDown,{size:12,"aria-hidden":`true`})}),O(_,D,T,o.recipient,ee(o.recipient))]}),C.length>0&&(0,y.jsxs)(`div`,{className:mf.fees,children:[(0,y.jsx)(`span`,{className:mf.label,children:`Fees`}),(0,y.jsx)(`span`,{className:mf.content,children:Iu(C)})]})]});if(k===lf.OP_WITHDRAW)return(0,y.jsx)(wc,{chainId:r,txHash:i,className:mf.link,children:j});let te=new URLSearchParams({tx_hash:i,chain_id:r});return(0,y.jsx)(`a`,{href:new URL(`?${te.toString()}`,`https://explorer.skip.build`).toString(),className:mf.link,target:`_blank`,rel:`noopener noreferrer`,children:j})},gf={history:`_history_13u9z_1`,header:`_header_13u9z_5`,checkbox:`_checkbox_13u9z_9`,groups:`_groups_13u9z_13`,dateGroup:`_dateGroup_13u9z_21`,dateHeader:`_dateHeader_13u9z_26`,list:`_list_13u9z_32`},_f=()=>{let{initiaAddress:e,hexAddress:t}=Ta(),{history:n,getHistoryDetails:r}=kd(),i=n.filter(e=>r(e)),a=i.filter(n=>{let i=r(n);if(!i)return!1;let{values:a}=i,{sender:o,recipient:s}=a;return[o,s].some(n=>[e,t].includes(n))}),[o,s]=(0,g.useState)(1),[c,l]=(0,ue.useToggle)(!a.length),u=c?i:a,d=u.slice(0,o*10),f=(0,g.useMemo)(()=>Dd(d,e=>{let t=r(e);if(t)return new Date(t.timestamp)}),[d,r]);return(0,y.jsx)(Hl,{title:`Bridge/Swap activity`,children:(0,y.jsxs)(`div`,{className:gf.history,children:[i.length>0&&i.length!==a.length&&(0,y.jsx)(`header`,{className:gf.header,children:(0,y.jsx)(wd,{checked:c,onClick:l,label:`Show all transactions stored in this browser`,className:gf.checkbox})}),u.length===0?(0,y.jsx)(Da,{children:`No bridge/swap activity`}):(0,y.jsx)(`div`,{className:gf.groups,children:Object.entries(f).map(([e,t])=>(0,y.jsxs)(`div`,{className:gf.dateGroup,children:[(0,y.jsx)(`div`,{className:gf.dateHeader,children:e}),(0,y.jsx)(`div`,{className:gf.list,children:t.map(e=>(0,y.jsx)(W,{children:(0,y.jsx)(hf,{tx:e})},e.txHash))})]},e))}),u.length>o*10?(0,y.jsx)(Ed,{onClick:()=>s(e=>e+1)}):n.length>=100&&(0,y.jsxs)(Da,{children:[`Only the latest `,100,` items are stored. Older entries will be removed automatically.`]})]})})};function vf({currentState:e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:i}){return{...e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:i}}function yf({currentState:e,route:t,values:n,quoteVerifiedAt:r}){return vf({currentState:e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:!0})}function bf({currentState:e,route:t,values:n,quoteVerifiedAt:r}){return vf({currentState:e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:!1})}var xf=1e4;function Sf(e){return e===void 0?`undefined`:typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(Sf).join(`,`)}]`:`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Sf(t)}`).join(`,`)}}`}function Cf(e){return Sf({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function wf(e,t,n){let r=Xt(),i=Jt(),a=(0,u.useQueryClient)(),o=rn(),[s,c]=(0,g.useState)(!1),[l,d]=(0,g.useState)(void 0),[f,p]=(0,g.useState)(n??0),m=(0,g.useRef)(null);return(0,g.useEffect)(()=>{p(n??0)},[n]),(0,g.useEffect)(()=>()=>{m.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{let s=Math.max(n??0,f);if(Date.now()-s<=xf)return!1;c(!0),d(void 0);let l=new AbortController;m.current=l;try{let n=await Lu(o,a,t,{isOpWithdraw:uf(e)===lf.OP_WITHDRAW,signal:l.signal});if(l.signal.aborted)return!0;let s=Cf(n)!==Cf(e),c=Date.now();return s?(r(0,yf({currentState:i,route:n,values:t,quoteVerifiedAt:c})),!0):(p(c),!1)}catch(e){return e instanceof DOMException&&e.name===`AbortError`||l.signal.aborted||d((await We(e)).message),!0}finally{m.current===l&&(m.current=null),l.signal.aborted||c(!1)}},isRefreshing:s,refreshError:l,clearRefreshError:()=>d(void 0)}}function Tf(e,t){return t?`Confirm updated route`:e||`Confirm`}function Ef({error:e,warning:t,messageRefreshError:n,refreshError:r,requiresReconfirm:i}){if(e)return{level:`error`,text:e};if(n)return{level:`error`,text:n};if(r)return{level:`error`,text:r};if(t)return{level:`warning`,text:t};if(i)return{level:`info`,text:`Route updated. Please review and confirm again.`}}function Df({isCheckingApprovals:e,isCheckingFeeBalance:t,isFetchingMessages:n,isEstimatingGas:r,isRouteTransitioning:i}){return i?`Refreshing route...`:n?`Fetching messages...`:t?`Checking fee balance...`:e?`Checking approvals...`:r?`Estimating gas...`:!1}function Of({isRefreshing:e,isPending:t,backgroundLoadingText:n}){return e?`Refreshing route...`:t?`Signing transaction...`:n}var kf=({tx:e,fee:t,onCompleted:n,confirmMessage:r,error:i,warning:a,isCheckingApprovals:o,isCheckingFeeBalance:s,messageRefreshError:c,isRouteTransitioning:l,isFetchingMessages:u,isEstimatingGas:d})=>{let f=Xt(),p=Jt(),{route:m,values:h,quoteVerifiedAt:g,requiresReconfirm:_}=Zd(),{mutate:v,isPending:b}=Qd(e,{customFee:t,onCompleted:n}),{refreshRouteIfNeeded:x,isRefreshing:S,refreshError:C,clearRefreshError:w}=wf(m,h,g),T=Df({isCheckingApprovals:o,isCheckingFeeBalance:s,isFetchingMessages:u,isEstimatingGas:d,isRouteTransitioning:l}),E=async()=>{if(!(b||S||T||c)){if(_){f(0,bf({currentState:p,route:m,values:h,quoteVerifiedAt:g??Date.now()}));return}await x()||(w(),v())}},D=Ef({error:i,warning:a,messageRefreshError:c,refreshError:C,requiresReconfirm:_}),ee=Of({isRefreshing:S,isPending:b,backgroundLoadingText:T}),O=b||S||!!T||!!c;return(0,y.jsx)(ac,{extra:D&&(0,y.jsx)(Gc,{level:D.level,children:D.text}),children:(0,y.jsx)(G.White,{onClick:E,loading:ee,disabled:!!i||!!a||O,children:Tf(r,!!_)})})};function Af({approvalError:e,approveTokens:t,exactFeeCheckError:n,isApproving:r,isCheckingApprovals:i,isCheckingFeeBalance:a,isFetchingMessages:o,messageRefreshError:s,requiresApproval:c}){return o||s?{kind:`preview`,isFetchingMessages:o,messageRefreshError:s}:a?{kind:`preview`,isCheckingFeeBalance:!0}:n?{kind:`preview`,error:n}:i?{kind:`preview`,isCheckingApprovals:!0}:c&&t?{kind:`approval`,approvalError:e,approveTokens:t,isApproving:!!r}:{kind:`preview`}}var jf={content:`_content_1hzj2_1`,info:`_info_1hzj2_6`,arrow:`_arrow_1hzj2_11`,divider:`_divider_1hzj2_19`,type:`_type_1hzj2_27`,asset:`_asset_1hzj2_47`,amount:`_amount_1hzj2_55`,lower:`_lower_1hzj2_60`,chain:`_chain_1hzj2_66`,address:`_address_1hzj2_72`},Mf=e=>{let{source:t,label:n,amount:r,denom:i,chainId:a,address:o,walletIcon:s}=e,{symbol:c=(0,d.truncate)(i),decimals:l=0,logo_uri:u=ot}=e,{chain_name:f,pretty_name:p,...m}=Yl(a);return(0,y.jsxs)(`div`,{children:[!t&&(0,y.jsxs)(`div`,{className:jf.arrow,children:[(0,y.jsx)(`div`,{className:jf.divider}),n?(0,y.jsx)(ku,{label:n,children:(0,y.jsx)(`button`,{className:jf.type,"aria-label":n,children:(0,y.jsx)(I.IconArrowDown,{size:12})})}):(0,y.jsx)(`span`,{className:jf.type,children:(0,y.jsx)(I.IconArrowDown,{size:12})}),(0,y.jsx)(`div`,{className:jf.divider})]}),(0,y.jsxs)(`div`,{className:jf.content,children:[(0,y.jsx)(Yu,{assetLogoUrl:u,chainLogoUrl:m.logo_uri??void 0}),(0,y.jsxs)(`div`,{className:jf.info,children:[(0,y.jsxs)(`div`,{className:jf.asset,children:[(0,y.jsx)(`span`,{className:jf.amount,children:(0,d.formatAmount)(r,{decimals:l})}),(0,y.jsx)(`span`,{children:c})]}),(0,y.jsxs)(`div`,{className:jf.lower,children:[(0,y.jsxs)(`div`,{className:jf.chain,children:[`on `,p||f]}),o&&(0,y.jsx)(Oc,{value:o,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{className:jf.address,onClick:e,children:[s,t?(0,y.jsx)(`span`,{children:`Copied!`}):(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)})]})})]})]})]})]})},Nf=e=>{let t=su(e.denom,e.chainId);return(0,y.jsx)(Mf,{...e,...t})};Nf.Placeholder=Mf;var Pf={root:`_root_1hbar_1`,flexEnd:`_flexEnd_1hbar_6`,toggle:`_toggle_1hbar_11`,route:`_route_1hbar_36`,content:`_content_1hbar_43`,slideDown:`_slideDown_1hbar_1`,slideUp:`_slideUp_1hbar_1`};function Ff(e){let t=({name:e})=>e===`initia-dex`?`Initia DEX`:(0,he.capitalCase)((0,p.head)(e?.split(`-`)??[])??``);if(`transfer`in e)return{label:`Bridge via IBC`,...e,...e.transfer};if(`bank_send`in e)return{label:`Send`,...e,...e.bank_send};if(`swap`in e){let n=e.swap?.swap_venues?.map(t).join(`, `);return{label:n?`Swap on ${n}`:`Swap`,...e,...e.swap}}if(`axelar_transfer`in e)return{label:`Bridge via Axelar`,...e,...e.axelar_transfer};if(`cctp_transfer`in e)return{label:`Bridge via CCTP`,...e,...e.cctp_transfer};if(`hyperlane_transfer`in e)return{label:`Bridge via Hyperlane`,...e,...e.hyperlane_transfer};if(`evm_swap`in e){let n=e.evm_swap?.swap_venues?.map(t).join(`, `);return{label:n?`Swap on ${n}`:`Swap`,...e,...e.evm_swap}}if(`op_init_transfer`in e)return{label:`Bridge via OP Bridge`,...e,...e.op_init_transfer};if(`go_fast_transfer`in e)return{label:`Bridge via Go Fast`,...e,...e.go_fast_transfer};if(`eureka_transfer`in e)return{label:`Bridge via Eureka`,...e,...e.eureka_transfer};if(`stargate_transfer`in e)return{label:`Bridge via Stargate`,...e,...e.stargate_transfer};if(`layer_zero_transfer`in e)return{label:`Bridge via LayerZero`,...e,...e.layer_zero_transfer};throw Error(`Unknown operation type`)}var If=({addressList:e})=>{let{values:t,route:n}=Zd(),{source_asset_denom:r,source_asset_chain_id:i,amount_in:a,operations:o}=n,s=(0,p.zipObj)(n.required_chain_addresses,e),{find:c}=Gu(),{connector:u,address:f=``}=(0,l.useAccount)(),[m,h]=(0,ue.useToggle)(!1),g=o.length>1,_=(0,y.jsx)(K,{src:t.cosmosWalletName?c(t.cosmosWalletName)?.image:u?.icon,width:12,height:12}),v={amount:a,denom:r,chainId:i,address:t.sender,walletIcon:_},b=e=>d.InitiaAddress.equals(e,f)?_:(0,y.jsx)(I.IconWallet,{size:11}),x=o.map(Ff).map(e=>{let{label:t,amount_out:n,denom:r,denom_out:i=r,chain_id:a,from_chain_id:o,to_chain_id:c=a??o}=e,l=s[c];return{label:g&&!m?void 0:t,amount:n,denom:i,chainId:c,address:l,walletIcon:b(l)}}),S=x.slice(0,-1),C=x[x.length-1];return(0,y.jsxs)(N.Collapsible.Root,{className:Pf.root,open:m,onOpenChange:h,children:[g&&(0,y.jsx)(`div`,{className:Pf.flexEnd,children:(0,y.jsx)(N.Collapsible.Trigger,{className:Pf.toggle,children:m?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I.IconMinus,{size:12}),(0,y.jsx)(`span`,{children:`Hide details`})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I.IconList,{size:12}),(0,y.jsx)(`span`,{children:`Show details`})]})})}),(0,y.jsxs)(`div`,{className:Pf.route,children:[(0,y.jsx)(Nf,{...v,source:!0}),(0,y.jsx)(N.Collapsible.Content,{className:Pf.content,children:S.map((e,t)=>(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Nf.Placeholder,{...e}),errorBoundaryProps:{fallback:(0,y.jsx)(Nf.Placeholder,{...e})},children:(0,y.jsx)(Nf,{...e})},t))}),(0,y.jsx)(Nf,{...C})]})]})},Lf=({error:e})=>{let t=Xt();return(0,y.jsx)(ac,{extra:(0,y.jsx)(Gc,{level:`error`,children:e.message}),children:(0,y.jsx)(G.White,{onClick:()=>t(`/bridge`),children:`Home`})})},Rf=({children:e})=>{let{route:t,values:n}=Zd(),{required_chain_addresses:r}=t,{srcChainId:i,dstChainId:a,sender:o,recipient:s}=n,{initiaAddress:c,hexAddress:l}=Ta(),u=Gr(),f=Jl(),p=Gl(),m=p(f(i)),h=r.slice(0,-1).some(e=>p(f(e))===`cosmos`)&&m!==`cosmos`,[v,b]=(0,g.useState)(void 0),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let e=!1;return(async()=>{try{if(b(void 0),w(null),!h)return;if(!u)throw Error(`Wallet not connected`);S(!0);let[{pubkey:t}]=await u.getAccounts();if(e)return;b(t)}catch(t){let n=await We(t);if(e)return;w(n)}finally{e||S(!1)}})(),()=>{e=!0}},[h,u]),C?(0,y.jsx)(Lf,{error:C}):x?(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{loading:x&&`Generating intermediary addresses...`})}):!h||v?e(r.map((e,t)=>{if(t===r.length-1)return p(f(a))===`initia`?(0,d.InitiaAddress)(s).bech32:s;let n=f(e),u=p(n),m=p(f(i));switch(u){case`initia`:return c;case`evm`:return l;case`cosmos`:if(m===`cosmos`)return(0,_.toBech32)(n.bech32_prefix,(0,_.fromBech32)(o).data);if(!v)throw Error(`Pubkey not found`);return(0,E.pubkeyToAddress)((0,E.encodeSecp256k1Pubkey)(v),n.bech32_prefix);default:throw Error(`Unlisted chain type`)}})):null};function zf(e){return`evm_tx`in e?JSON.stringify({approvals:e.evm_tx.required_erc20_approvals??[],chainId:e.evm_tx.chain_id,signerAddress:e.evm_tx.signer_address}):`non-evm`}function Bf({currentKey:e,isPending:t,nextKey:n}){return!t&&e!==n}function Vf(e,t){return typeof e==`function`?e(t):t.isCheckingApprovals?(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{loading:`Checking approvals...`})}):t.requiresApproval&&t.approveTokens?(0,y.jsx)(ac,{extra:(0,y.jsx)(Gc,{level:`error`,children:t.approvalError}),children:(0,y.jsx)(G.White,{onClick:t.approveTokens,loading:t.isApproving&&`Approving tokens...`,children:`Approve tokens`})}):e}var Hf=({tx:e,children:t})=>{let n=Zr(),r=Jl(),i=(0,u.useQueryClient)(),a=zf(e),o=(0,g.useRef)(a),{data:s,isLoading:c}=(0,u.useQuery)({queryKey:[`interwovenkit:erc20-approvals-needed`,e],queryFn:async()=>{if(!(`evm_tx`in e)||!e.evm_tx.required_erc20_approvals)return[];let{chain_id:t,signer_address:i}=e.evm_tx,a=await n();await Xd(a,r(t));let o=[`function allowance(address owner, address spender) view returns (uint256)`];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async e=>{let{token_contract:t,spender:n}=e,r=await new w.ethers.Contract(t,o,a).allowance(i,n);return{approval:e,currentAllowance:BigInt(r.toString())}}))).filter(({approval:e,currentAllowance:t})=>t<BigInt(e.amount)).map(({approval:e})=>e)},enabled:!!e&&`evm_tx`in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:l,data:d,isPending:f,error:p,reset:m}=(0,u.useMutation)({mutationFn:async()=>{try{if(!(`evm_tx`in e))throw Error(`Transaction is not EVM`);if(!s||s.length===0)throw Error(`No approvals needed`);let{chain_id:t}=e.evm_tx,i=await n(),a=await i.getSigner();await Xd(i,r(t));for(let e of s){let{token_contract:t,spender:n,amount:r}=e;await $r((await new w.ethers.Contract(t,[`function approve(address spender, uint256 amount) external returns (bool)`],a).approve(n,r)).wait(),3e4,`Approval was not confirmed in time. It may still be processing.`)}return!0}catch(t){throw t instanceof Qr?(i.invalidateQueries({queryKey:[`interwovenkit:erc20-approvals-needed`,e]}),t):await We(t)}}});return(0,g.useEffect)(()=>{let e=o.current;Bf({currentKey:e,isPending:f,nextKey:a})&&(o.current=a,m())},[a,f,m]),Vf(t,{approvalError:p?.message,approveTokens:s&&s.length>0&&!d?()=>l():void 0,isApproving:f,isCheckingApprovals:c,requiresApproval:!!s&&s.length>0&&!d})};function Uf({route:e,tx:t,isSrcInitia:n,isDstInitia:r,sender:i,recipient:a}){return!!e&&`cosmos_tx`in t&&!!t.cosmos_tx.msgs?.length&&!e.required_op_hook&&n&&r&&!!i&&!!a}function Wf({hasBalances:e,hasChain:t,requiresExactFeeCheck:n}){return n&&e&&t}function Gf({balances:e,feeDenoms:t}){return e?[...t].sort().map(t=>`${t}:${e[t]?.amount??`0`}`).join(`|`):``}function Kf({tx:e,children:t}){let{route:n,values:r}=Zd(),{sender:i,recipient:a,srcChainId:o,srcDenom:s,dstChainId:c}=r,l=Yl(o),d=Yl(c),f=Kl(l),p=Kl(d),{data:m,isLoading:h,error:g}=Au(i,o),_=zr(),v=Br(),y=Xr(),b=Uf({route:n,tx:e,isSrcInitia:f===`initia`,isDstInitia:p===`initia`,sender:i,recipient:a}),{chain:x,error:S,isLoading:C}=tt(o,b),w=Gf({balances:m,feeDenoms:x?Array.from(new Set([s,...x.fees.fee_tokens.map(({denom:e})=>e)])):[]}),T=Wf({hasBalances:m!==void 0,hasChain:!!x,requiresExactFeeCheck:b}),{data:E,error:D,isLoading:ee}=(0,u.useQuery)({queryKey:[`interwovenkit:bridge-preview-fee-check`,e,i,o,s,n.amount_in,w],queryFn:async()=>{try{if(!(b&&x&&`cosmos_tx`in e&&e.cosmos_tx.msgs?.length&&m))throw Error(`Invalid transaction data`);let t=qd(e.cosmos_tx.msgs,{converters:_,fromAmino:v.fromAmino.bind(v)});return Yd({balances:m,requiredFeeByDenom:Jd({gas:await(await y(o)).simulate(i,t,``),gasPrices:await Pi(x)}),sourceDenom:s,amountIn:n.amount_in})}catch(e){throw await We(e)}},enabled:T,retry:!1});return t(b?S?{exactFeeCheckError:S.message,isCheckingFeeBalance:!1}:g?{exactFeeCheckError:g instanceof Error?g.message:`Failed to load balances`,isCheckingFeeBalance:!1}:C||h||m===void 0||ee?{isCheckingFeeBalance:!0}:D?{exactFeeCheckError:D.message,isCheckingFeeBalance:!1}:E?{isCheckingFeeBalance:!1}:{exactFeeCheckError:`Insufficient balance for fees`,isCheckingFeeBalance:!1}:{isCheckingFeeBalance:!1})}function qf({addressList:e,operations:t,signedOpHook:n}){return JSON.stringify({addressList:e,operations:t,signedOpHook:n??null})}function Jf({previousQuoteVerifiedAt:e,quoteVerifiedAt:t,hasValue:n,hasMessageRefreshError:r}){return n&&r&&e!==void 0&&t!==void 0&&t!==e}function Yf({error:e,loading:t,value:n}){let r=n!==void 0;return{isFetchingMessages:t,messageRefreshError:!t&&r&&e?e.message:void 0,shouldRenderError:!!e&&!r,shouldRenderLoading:!r}}var Xf=({addressList:e,signedOpHook:t,children:n})=>{let r=rn(),{route:i,values:a,quoteVerifiedAt:o}=Zd(),[s,c]=(0,g.useState)(void 0),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(0),h=(0,g.useRef)(o),_=qf({addressList:e,operations:i.operations,signedOpHook:t});(0,g.useEffect)(()=>{let e=h.current;Jf({previousQuoteVerifiedAt:e,quoteVerifiedAt:o,hasValue:s!==void 0,hasMessageRefreshError:d!==null})&&m(e=>e+1),h.current=o},[o,s,d]),(0,g.useEffect)(()=>{let n=!1;return(async()=>{try{if(u(!0),f(null),i.required_op_hook&&!t)throw Error(`Op hook is required`);let o=await Kd(r,{addressList:e,route:{amount_in:i.amount_in,amount_out:i.amount_out,source_asset_chain_id:i.source_asset_chain_id,source_asset_denom:i.source_asset_denom,dest_asset_chain_id:i.dest_asset_chain_id,dest_asset_denom:i.dest_asset_denom,operations:i.operations},slippagePercent:String(a.slippagePercent),signedOpHook:t});if(n)return;let[s]=o;c(s)}catch(e){let t=await We(e);if(n)return;f(t)}finally{n||u(!1)}})(),()=>{n=!0}},[_,p,i.amount_in,i.amount_out,i.source_asset_chain_id,i.source_asset_denom,i.dest_asset_chain_id,i.dest_asset_denom,i.required_op_hook,a.slippagePercent,r]);let v=Yf({error:d,loading:l,value:s});return v.shouldRenderError&&d?(0,y.jsx)(Lf,{error:d}):v.shouldRenderLoading?(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{loading:`Fetching messages...`})}):n(s,{isFetchingMessages:v.isFetchingMessages,messageRefreshError:v.messageRefreshError})},Zf=({children:e})=>{let{route:t}=Zd(),n=$d();return t.required_op_hook&&!n.data?(0,y.jsx)(ac,{extra:(0,y.jsx)(Gc,{level:`error`,children:n.error?.message}),children:(0,y.jsx)(G.White,{onClick:()=>n.mutate(),loading:n.isPending&&`Awaiting signature...`,children:`Authorize conversion`})}):e(n.data)};function Qf({approvalError:e,approveTokens:t,isApproving:n}){return(0,y.jsx)(ac,{extra:e&&(0,y.jsx)(Gc,{level:`error`,children:e}),children:(0,y.jsx)(G.White,{onClick:t,loading:n&&`Approving tokens...`,children:`Approve tokens`})})}var $f=()=>(0,y.jsx)(Hl,{title:`Route preview`,children:(0,y.jsx)(Rf,{children:e=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(If,{addressList:e}),(0,y.jsx)(Zf,{children:t=>(0,y.jsx)(Xf,{addressList:e,signedOpHook:t,children:(e,{isFetchingMessages:t,messageRefreshError:n})=>(0,y.jsx)(Kf,{tx:e,children:({exactFeeCheckError:r,isCheckingFeeBalance:i})=>(0,y.jsx)(Hf,{tx:e,children:({approvalError:a,approveTokens:o,isApproving:s,isCheckingApprovals:c,requiresApproval:l})=>{let u=Af({approvalError:a,approveTokens:o,exactFeeCheckError:r,isApproving:s,isCheckingApprovals:c,isCheckingFeeBalance:i,isFetchingMessages:t,messageRefreshError:n,requiresApproval:l});return u.kind===`approval`?Qf({approvalError:u.approvalError,approveTokens:u.approveTokens,isApproving:u.isApproving}):(0,y.jsx)(kf,{tx:e,error:u.error,isCheckingApprovals:u.isCheckingApprovals,isCheckingFeeBalance:u.isCheckingFeeBalance,isFetchingMessages:u.isFetchingMessages,messageRefreshError:u.messageRefreshError})}})})})})]})})}),ep=(0,g.createContext)(null);function tp(){return(0,g.useContext)(ep)}var np={button:`_button_17r1o_1`,claimed:`_claimed_17r1o_24`},rp=()=>{let{withdrawalTx:e}=tp(),{bridge_id:t,sequence:n,amount:r,output_index:i,withdrawal_proofs:a,storage_root:o,from:s,to:c,version:l}=e,d=B(),f=U(),{requestTxSync:p,waitForTxConfirmation:m}=Ta(),h=Rd(e),g=(0,_.toBase64)(Hd(e)),v=zd(e,g),b=(0,u.useQueryClient)(),{mutate:x,isPending:S}=(0,u.useMutation)({mutationFn:async()=>{if(!h)throw Error(`Output not found`);let{last_block_hash:e}=h;return p({chainId:d.chain_id,messages:[{typeUrl:`/opinit.ophost.v1.MsgFinalizeTokenWithdrawal`,value:{sender:f,bridgeId:BigInt(t),outputIndex:BigInt(i),withdrawalProofs:a.map(_.fromBase64),from:s,to:c,sequence:BigInt(n),amount:r,version:(0,_.fromBase64)(l),storageRoot:(0,_.fromBase64)(o),lastBlockHash:(0,_.fromBase64)(e)}}],internal:!0})},onSuccess:async e=>{await m({chainId:d.chain_id,txHash:e}),b.invalidateQueries({queryKey:jd.withdrawalClaimed(t,g).queryKey})}});return v?(0,y.jsxs)(`div`,{className:np.claimed,children:[(0,y.jsx)(I.IconCheckCircleFilled,{size:14}),(0,y.jsx)(`span`,{children:`Claimed`})]}):(0,y.jsx)(`button`,{className:np.button,onClick:()=>x(),disabled:S,children:`Claim`})},ip=({children:e})=>{let{withdrawalTx:t}=tp(),n=Nd(t.bridge_id),r=Ld(t);return e((0,g.useMemo)(()=>{if(!r)return null;let{bridge_config:e}=n,{output_proposal:t}=r;return(0,se.addSeconds)(new Date(t.l1_block_time),parseFloat(e.finalization_period))},[n,r]))},ap=1e3,op=60,sp=60,cp=24,lp=ap*op,up=lp*sp,dp=up*cp,fp=({date:e})=>{let t=(0,g.useCallback)(()=>{let t=new Date().getTime(),n=e.getTime()-t;return n<=0?{days:0,hours:0,minutes:0,seconds:0}:{days:Math.floor(n/dp),hours:Math.floor(n%dp/up),minutes:Math.floor(n%up/lp),seconds:Math.floor(n%lp/ap)}},[e]),[n,r]=(0,g.useState)(t());(0,g.useEffect)(()=>{let e=window.setInterval(()=>{r(t())},1e3);return()=>window.clearInterval(e)},[t,e]);let i=e=>e.toString().padStart(2,`0`),{days:a,hours:o,minutes:s,seconds:c}=n;return(0,y.jsx)(ku,{label:e.toLocaleString(),children:(0,y.jsxs)(`span`,{className:`monospace`,children:[a,`d `,i(o),`h `,i(s),`m `,i(c),`s`]})})},pp={container:`_container_1lz3w_1`,title:`_title_1lz3w_5`},mp=({date:e})=>(0,y.jsxs)(`div`,{className:pp.container,children:[(0,y.jsx)(`div`,{className:pp.title,children:`Claimable in`}),(0,y.jsx)(fp,{date:e})]}),hp={container:`_container_1oldz_1`,icon:`_icon_1oldz_7`},gp=`Withdrawal will begin within an hour`,_p=()=>{let e=dc();return(0,y.jsxs)(`div`,{className:hp.container,children:[(0,y.jsx)(`span`,{children:`In progress`}),!e&&(0,y.jsx)(ku,{label:gp,children:(0,y.jsx)(`span`,{className:hp.icon,children:(0,y.jsx)(I.IconInfoFilled,{size:12})})})]})},vp=({children:e})=>{let{withdrawalTx:t}=tp(),n=Id(t.bridge_id);return e(t.output_index>Number(n?.output_index))},yp=({date:e,children:t})=>{let{chainId:n,withdrawalTx:r}=tp(),i=zd(r,(0,_.toBase64)(Hd(r))),{setReminder:a,removeReminder:o}=hu();return(0,g.useEffect)(()=>{let t={chainId:n,txHash:r.tx_hash};i?o(t):a(t,{...t,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:(0,se.isPast)(e.getTime())?!0:void 0})},[n,i,e,o,a,r]),t},bp=()=>(0,y.jsx)(vp,{children:e=>e?(0,y.jsx)(_p,{}):(0,y.jsx)(ip,{children:e=>e?(0,y.jsx)(yp,{date:e,children:(0,se.isFuture)(e)?(0,y.jsx)(mp,{date:e}):(0,y.jsx)(rp,{})}):(0,y.jsx)(_p,{})})}),xp={asset:`_asset_6h8u2_1`,info:`_info_6h8u2_7`,symbol:`_symbol_6h8u2_11`},Sp=({amount:e,denom:t})=>{let{symbol:n,logoUrl:r,decimals:i}=pt(t,B());return(0,y.jsxs)(`div`,{className:xp.asset,children:[(0,y.jsx)(K,{src:r,width:32,height:32,logo:!0}),(0,y.jsxs)(`div`,{className:xp.info,children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.formatAmount)(e,{decimals:i})}),(0,y.jsx)(`span`,{className:xp.symbol,children:n})]})]})},Cp={item:`_item_km5w2_1`,more:`_more_km5w2_12`},wp=({chain:e})=>{let t=e.metadata?.executor_uri;if(!t)throw Error(`Executor URL is not defined`);let{data:n,fetchNextPage:r,hasNextPage:i,isFetching:a}=Fd(t),o=(0,g.useMemo)(()=>n?.pages.flat()??[],[n]),{syncReminders:s}=hu();return(0,g.useEffect)(()=>{s(o.map(t=>({chainId:e.chainId,txHash:t.tx_hash})))},[e.chainId,o,s]),o.length?(0,y.jsxs)(y.Fragment,{children:[o.map(t=>{let{amount:n}=t;return(0,y.jsxs)(`div`,{className:Cp.item,children:[(0,y.jsx)(Sp,{...n}),(0,y.jsx)(W,{suspenseFallback:null,children:(0,y.jsx)(ep.Provider,{value:{chainId:e.chainId,withdrawalTx:t},children:(0,y.jsx)(bp,{})})})]},t.sequence)}),i&&(0,y.jsx)(Ed,{onClick:()=>r(),disabled:a})]}):(0,y.jsx)(Da,{children:`No withdrawals`})},Tp={content:`_content_dj1qm_1`,title:`_title_dj1qm_5`},Ep=()=>{let{chainId:e}=Jt(),t=Xe(),n=nt(),[r,i]=(0,g.useState)(e??(n.metadata?.is_l1?``:n.chainId)),a=$e(),{reminders:o}=hu(),s=r?a(r):void 0;return(0,y.jsxs)(Hl,{title:`OP Bridge withdrawals`,children:[(0,y.jsx)(id,{chains:t.filter(({metadata:e})=>!e?.is_l1&&e?.op_denoms?.length),value:r,onSelect:i,getShowIndicator:e=>o.some(t=>t.chainId===e)}),(0,y.jsx)(`div`,{className:Tp.content,children:s?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`h2`,{className:Tp.title,children:s.name}),(0,y.jsx)(W,{children:(0,y.jsx)(wp,{chain:s})},r)]}):(0,y.jsx)(Gc,{level:`info`,children:`Select a chain to display your OP Bridge withdrawals`})})]})},Dp=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,``),Op=`https://explorer-api.walletconnect.com/v3/wallets?projectId=5722e7dffb709492cf5312446ceeff73`,kp=[`interwovenkit:walletconnect-wallets`],Ap=e=>typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`string`&&`name`in e&&typeof e.name==`string`,jp=async e=>{let t=await h.default.get(Op,{signal:e}).json(),n=typeof t==`object`&&t&&`listings`in t?t.listings:t;return Object.values(n??{}).filter(Ap)},Mp=()=>(0,u.useQuery)({queryKey:kp,queryFn:({signal:e})=>jp(e),staleTime:z.INFINITY,gcTime:z.INFINITY,retry:2}),Np=new Set([`io.leapwallet`]),Pp=new Set([`leap`]),Fp=e=>Np.has(e.id)||Pp.has(Dp(e.name)),Y={page:`_page_13y8q_1`,slideFromLeft:`_slideFromLeft_13y8q_1`,pageTop:`_pageTop_13y8q_19`,slideFromRight:`_slideFromRight_13y8q_1`,backButtonFixed:`_backButtonFixed_13y8q_63`,listItem:`_listItem_13y8q_64`,socialButton:`_socialButton_13y8q_65`,arrowIcon:`_arrowIcon_13y8q_66`,searchInputUnderline:`_searchInputUnderline_13y8q_67`,header:`_header_13y8q_72`,title:`_title_13y8q_81`,headerSpacer:`_headerSpacer_13y8q_116`,icon:`_icon_13y8q_120`,installedText:`_installedText_13y8q_124`,divider:`_divider_13y8q_131`,dividerText:`_dividerText_13y8q_152`,loading:`_loading_13y8q_193`,socialIcons:`_socialIcons_13y8q_198`,socialText:`_socialText_13y8q_204`,searchWrapper:`_searchWrapper_13y8q_214`,scrollable:`_scrollable_13y8q_248`,list:`_list_13y8q_64`,listIconWrapper:`_listIconWrapper_13y8q_332`,moreIconSmall:`_moreIconSmall_13y8q_342`,externalLinkIcon:`_externalLinkIcon_13y8q_364`,listName:`_listName_13y8q_368`,listNameMuted:`_listNameMuted_13y8q_381`,recentBadge:`_recentBadge_13y8q_394`,learnMoreLink:`_learnMoreLink_13y8q_408`},Ip=e=>{try{let t=new URL(e.trim());return t.protocol===`https:`&&!t.username&&!t.password}catch{return!1}},Lp=({walletConnectors:e,isPending:t,pendingConnectorId:n,recentConnectorId:r,onConnect:i,onBack:a})=>{let[o,s]=(0,g.useState)(``),{data:c=[],isError:l,isLoading:u,isFetching:d}=Mp(),f=u||d&&c.length===0,p=(0,g.useMemo)(()=>{if(!o)return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[e,o]),m=(0,g.useMemo)(()=>{let t=new Set(e.map(e=>Dp(e.name))),n=o.toLowerCase();return c.filter(e=>!Fp(e)).filter(e=>!t.has(Dp(e.name))).filter(e=>!o||e.name.toLowerCase().includes(n)).sort((e,t)=>e.name.localeCompare(t.name))},[c,e,o]);return(0,y.jsxs)(`div`,{className:Y.pageTop,children:[(0,y.jsx)(`button`,{type:`button`,className:Y.backButtonFixed,onClick:a,"aria-label":`Back`,children:(0,y.jsx)(I.IconBack,{size:16,"aria-hidden":`true`})}),(0,y.jsxs)(`header`,{className:Y.header,children:[(0,y.jsx)(`div`,{className:Y.headerSpacer}),(0,y.jsx)(`h1`,{className:Y.title,children:`All Wallets`}),(0,y.jsx)(`div`,{className:Y.headerSpacer})]}),(0,y.jsx)(`div`,{className:Y.searchWrapper,children:(0,y.jsx)(ed,{rootClassName:Y.searchInputUnderline,placeholder:`Search Wallet`,"aria-label":`Search wallets`,value:o,onChange:e=>s(e.target.value),onClear:()=>s(``)})}),(0,y.jsx)(sc,{className:Y.scrollable,children:(0,y.jsxs)(`div`,{className:Y.list,children:[p.map(e=>{let{name:a,icon:o,id:s}=e,c=r===s,l=n===s,u=`ready`in e?!!e.ready:!0;return(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(Y.listItem,{[Y.loading]:l}),onClick:()=>i(e),disabled:t||!u,"aria-busy":l,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(K,{src:o,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listName,children:a}),l?(0,y.jsx)(tc,{size:16}):c?(0,y.jsx)(`span`,{className:Y.recentBadge,children:`Recent`}):u?(0,y.jsx)(`span`,{className:Y.installedText,children:`Installed`}):null]},`connector:${s}`)}),f&&(0,y.jsxs)(`div`,{className:(0,P.default)(Y.listItem,Y.loading),role:`status`,"aria-live":`polite`,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(tc,{size:16})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:`Loading more wallets...`})]}),m.map(e=>{let t=e.image_url?.sm||e.image_url?.md||e.image_url?.lg,n=t&&Ip(t)?t:void 0;return(0,y.jsxs)(`button`,{type:`button`,className:Y.listItem,disabled:!0,"aria-label":`${e.name} (not installed)`,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:n&&(0,y.jsx)(K,{src:n,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:e.name})]},`wc:${e.id}`)}),l&&(0,y.jsx)(Gc,{level:`error`,children:`Couldn't load additional wallets.`})]})})]})},Rp=(e,t,n,r)=>{if(n<=0)return[];if(e.length<=n)return[...e];let i=r?e.findIndex(e=>e.id===r):-1,a=i>=0?e[i]:void 0,o=i>=0?e.filter((e,t)=>t!==i):e,s=new Set(t.map(e=>e.id)),c=new Set(t.map(e=>Dp(e.name))),l=[],u=[];for(let e of o)s.has(e.id)||c.has(Dp(e.name))?l.push(e):u.push(e);return a?[a,...l,...u].slice(0,n):l.concat(u).slice(0,n)},zp=()=>(0,y.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,y.jsx)(`circle`,{cx:`4`,cy:`8`,r:`1.5`}),(0,y.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.5`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`8`,r:`1.5`})]}),Bp=()=>(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{fill:`#4285F4`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,y.jsx)(`path`,{fill:`#34A853`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,y.jsx)(`path`,{fill:`#FBBC05`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,y.jsx)(`path`,{fill:`#EA4335`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]}),Vp=()=>(0,y.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,y.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),Hp=()=>(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,"aria-hidden":`true`,children:[(0,y.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,y.jsx)(`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`})]}),Up=[{id:`io.rabby`,name:`Rabby`,icon:`https://assets.initia.xyz/images/wallets/Rabby.webp`,url:`https://rabby.io`},{id:`app.phantom`,name:`Phantom`,icon:`https://assets.initia.xyz/images/wallets/Phantom.webp`,url:`https://phantom.com`},{id:`app.keplr`,name:`Keplr`,icon:`https://assets.initia.xyz/images/wallets/Keplr.webp`,url:`https://keplr.app`},{id:`io.metamask`,name:`MetaMask`,icon:`https://assets.initia.xyz/images/wallets/MetaMask.webp`,url:`https://metamask.io`}],Wp=5,Gp=({walletConnectors:e,privyConnector:t,isPending:n,pendingConnectorId:r,recentConnectorId:i,onConnect:a,onShowAll:o,onPrefetchWallets:s})=>{let c=e.filter(e=>!(`ready`in e)||!!e.ready),l=Rp(c,Up,Wp,i),u=new Set(c.map(e=>e.id)),d=new Set(c.map(e=>Dp(e.name))),f=Math.max(0,Wp-l.length),p=Up.filter(e=>!u.has(e.id)&&!d.has(Dp(e.name))).slice(0,f);return(0,y.jsxs)(`div`,{className:Y.page,children:[(0,y.jsxs)(`header`,{className:Y.header,children:[(0,y.jsx)(`div`,{className:Y.headerSpacer}),(0,y.jsx)(`h1`,{className:Y.title,children:`Sign In`}),(0,y.jsx)(`div`,{className:Y.headerSpacer})]}),t&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(Y.socialButton,{[Y.loading]:r===t.id}),onClick:()=>a(t),disabled:n,"aria-busy":r===t.id,children:[(0,y.jsx)(`span`,{className:Y.socialText,children:`Email / Socials`}),r===t.id?(0,y.jsx)(tc,{size:16}):(0,y.jsxs)(`div`,{className:Y.socialIcons,children:[(0,y.jsx)(Bp,{}),(0,y.jsx)(Hp,{}),(0,y.jsx)(Vp,{})]})]}),(0,y.jsx)(`div`,{className:Y.divider,children:(0,y.jsx)(`span`,{className:Y.dividerText,children:`or`})})]}),(0,y.jsx)(sc,{className:Y.scrollable,children:(0,y.jsxs)(`div`,{className:Y.list,children:[l.map(e=>{let{icon:t,id:o,name:s,uid:c}=e,l=r===o,u=i===o;return(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(Y.listItem,{[Y.loading]:l}),onClick:()=>a(e),disabled:n,"aria-busy":l,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(K,{src:t,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listName,children:s}),l?(0,y.jsx)(tc,{size:16}):u?(0,y.jsx)(`span`,{className:Y.recentBadge,children:`Recent`}):(0,y.jsx)(`span`,{className:Y.installedText,children:`Installed`})]},c)}),p.map(e=>(0,y.jsxs)(`a`,{className:Y.listItem,href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`${e.name} (opens in new tab)`,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(K,{src:e.icon,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:e.name}),(0,y.jsx)(I.IconExternalLink,{size:10,className:Y.externalLinkIcon,"aria-hidden":`true`})]},e.id)),(0,y.jsxs)(`button`,{type:`button`,className:Y.listItem,onClick:o,onMouseEnter:s,onFocus:s,disabled:n,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(`div`,{className:Y.moreIconSmall,children:(0,y.jsx)(zp,{})})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:`More wallets`}),(0,y.jsx)(`span`,{className:Y.arrowIcon,"aria-hidden":`true`,children:`→`})]})]})}),(0,y.jsxs)(`a`,{className:Y.learnMoreLink,href:`https://docs.initia.xyz/home/tools/wallet`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Learn more (opens in new tab)`,children:[`Learn more`,(0,y.jsx)(I.IconExternalLink,{size:14,"aria-hidden":`true`})]})]})},Kp=({onSuccess:e})=>{let{connectors:t,connectAsync:n}=(0,l.useConnect)(),r=(0,ue.useReadLocalStorage)(`wagmi.recentConnectorId`),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(`signin`),c=(0,u.useQueryClient)(),d=()=>c.prefetchQuery({queryKey:kp,queryFn:({signal:e})=>jp(e),staleTime:z.INFINITY,gcTime:z.INFINITY}),{mutate:f,isPending:p}=(0,u.useMutation)({mutationFn:async e=>{try{await n({connector:e})}catch(e){throw await We(e)}},onMutate:e=>{a(e.id)},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}}),m=(0,g.useMemo)(()=>[...t].sort((e,t)=>e.id===r?-1:t.id===r?1:e.name.localeCompare(t.name)),[t,r]),h=(0,g.useMemo)(()=>m.find(e=>e.id===ze.id),[m]),_=(0,g.useMemo)(()=>m.filter(e=>e.id!==ze.id&&!Fp(e)),[m]);return o===`all`?(0,y.jsx)(Lp,{walletConnectors:_,isPending:p,pendingConnectorId:i,recentConnectorId:r,onConnect:f,onBack:()=>s(`signin`)}):(0,y.jsx)(Gp,{walletConnectors:_,privyConnector:h,isPending:p,pendingConnectorId:i,recentConnectorId:r,onConnect:f,onShowAll:()=>s(`all`),onPrefetchWallets:d})},qp={button:`_button_69xmz_1`,content:`_content_69xmz_18`},Jp=({title:e,defaultOpen:t=!1,children:n})=>{let[r,i]=(0,ue.useToggle)(t),a=(0,g.useId)();return(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`button`,{type:`button`,className:qp.button,onClick:i,"aria-expanded":r,"aria-controls":a,children:[e,` `,(0,y.jsx)(I.IconChevronDown,{size:12,style:{transform:r?`rotate(180deg)`:`rotate(0deg)`},"aria-hidden":`true`})]}),(0,y.jsx)(Bc,{children:(0,y.jsx)(`div`,{id:a,children:r&&(0,y.jsx)(`div`,{className:qp.content,children:n})})})]})},Yp={row:`_row_70qmb_1`,value:`_value_70qmb_13`,emphasized:`_emphasized_70qmb_23`},Xp=({label:e,children:t,emphasized:n,valueStyle:r})=>(0,y.jsxs)(`div`,{className:(0,P.default)(Yp.row,n&&Yp.emphasized),children:[(0,y.jsx)(`p`,{children:e}),(0,y.jsx)(`div`,{className:Yp.value,style:r,children:t})]}),Zp=/^0x[0-9a-fA-F]{40}$/;function Qp(e,t){if(!e||typeof e!=`object`)throw Error(`Deposit address response is not an object`);let{deposit_address:n,chain_id:r,asset_denom:i,wallet_address:a,cursor:o}=e;if(typeof n!=`string`||!Zp.test(n))throw Error(`Deposit address response has an invalid deposit address: ${String(n)}`);if(r!==t.chainId)throw Error(`Deposit address response chain_id mismatch: ${String(r)}`);if(typeof i!=`string`||H(i)!==H(t.assetDenom))throw Error(`Deposit address response asset_denom mismatch: ${String(i)}`);if(typeof a!=`string`||a.toLowerCase()!==t.walletAddress.toLowerCase())throw Error(`Deposit address response wallet_address mismatch: ${String(a)}`);if(typeof o!=`string`||!o)throw Error(`Deposit address response is missing the cursor`);return{deposit_address:n,chain_id:r,asset_denom:i,wallet_address:a,cursor:o}}function $p(e,t){let{walletAddress:n,chainId:r,assetDenom:i}=t;return{queryKey:Bt.depositAddress(n,r,i).queryKey,queryFn:async()=>{try{return Qp(await e.post(`v1/deposit-address`,{json:{wallet_address:n,chain_id:r,asset_denom:i}}).json(),t)}catch(e){throw await We(e)}}}}function em(e){let{depositApiUrl:t}=R(),n=Vt(),{walletAddress:r,chainId:i,assetDenom:a}=e;return(0,u.useQuery)({...$p(n,e),enabled:!!t&&!!r&&!!i&&!!a,staleTime:z.INFINITY})}function tm({data:e,isFetchedAfterMount:t,isSuccess:n}){return e&&t&&n?e:void 0}function nm(e){let{depositApiUrl:t}=R(),n=Vt(),{walletAddress:r,chainId:i,assetDenom:a}=e,o=(0,u.useQuery)({...$p(n,e),enabled:!!t&&!!r&&!!i&&!!a,staleTime:1/0,refetchOnMount:`always`,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),s=tm({data:o.data,isFetchedAfterMount:o.isFetchedAfterMount,isSuccess:o.isSuccess});return{query:o,data:s,freshCursor:s?.cursor??``}}var rm=e=>!mn.includes(e),im=e=>gn.includes(e);function am(e){return e?im(e.bucket)?e.bucket:`failed`:`waiting`}var om=3e3,sm=15e3,cm=5*6e4,lm=e=>e<cm?om:sm;function um(){let[e]=(0,g.useState)(()=>Date.now());return e}var dm=(e,t)=>e&&rm(e.bucket)?!1:lm(t);function fm(e){let{depositApiUrl:t}=R(),n=Vt(),r=um();return(0,u.useQuery)({queryKey:Bt.deposit(e).queryKey,queryFn:async()=>{try{return await n.get(`v1/deposits/${e}`).json()}catch(e){throw await We(e)}},enabled:!!t&&!!e,refetchInterval:e=>dm(e.state.data,Date.now()-r)})}var pm=class extends Error{};function mm(e,t){let n=t.toLowerCase(),r=e.find(e=>e.deposit_address.toLowerCase()!==n);if(r)throw new pm(`Deposit ${r.id} belongs to ${r.deposit_address}, not the requested ${t}`);return e}function hm({depositAddress:e,after:t}){let{depositApiUrl:n}=R(),r=Vt(),i=um();return(0,u.useQuery)({queryKey:Bt.newDeposits(e,t).queryKey,queryFn:async()=>{try{let{deposits:n}=await r.get(`v1/deposits`,{searchParams:{deposit_address:e,after:t,limit:`1`}}).json();return mm(n,e)}catch(e){throw e instanceof pm?e:await We(e)}},enabled:!!n&&!!e&&!!t,refetchInterval:()=>lm(Date.now()-i)})}function gm(e){let{depositApiUrl:t}=R(),n=Vt();return(0,u.useQuery)({queryKey:Bt.activeDeposits(e).queryKey,queryFn:async()=>{try{let{deposits:t}=await n.get(`v1/deposits`,{searchParams:{deposit_address:e,active:`true`,limit:`1`}}).json();return mm(t,e)}catch(e){throw e instanceof pm?e:await We(e)}},enabled:!!t&&!!e,refetchInterval:sm})}function _m(e,t,n){let r=e&&t&&e.deposit_address.toLowerCase()!==t.toLowerCase()?new pm(`Deposit ${e.id} belongs to ${e.deposit_address}, not the requested ${t}`):null;return{deposit:r?null:e??null,isError:!!n||!!r,error:r??n}}function vm({depositAddress:e,depositId:t}){let n=fm(t);return _m(n.data,e,n.error??null)}function ym(e){let t=(t,n)=>{let r=H(n);return e[t]?.assets.find(e=>H(e.denom)===r)};return{symbol:(e,n)=>t(e,n)?.symbol??on(n),logoUrl:(e,n)=>t(e,n)?.logo_uri??``}}function bm(){let{data:{chain_to_assets_map:e}}=ru();return(0,g.useMemo)(()=>ym(e),[e])}function xm(e,t){let n=On(e,t),r=bm();return(0,g.useMemo)(()=>{let e=new Map;for(let t of n){let n=r.symbol(t.src_chain_id,t.src_denom),i=e.get(n);i?i.routes.push(t):e.set(n,{symbol:n,logoUrl:r.logoUrl(t.src_chain_id,t.src_denom),routes:[t]})}return[...e.values()]},[n,r])}function Sm(e,t){return e.find(e=>e.symbol===t)??e[0]}function Cm(){return(0,F.useFormContext)()}function wm(){let{setValue:e}=Cm();return(0,g.useCallback)(t=>e(`page`,t),[e])}function Tm(){let{setValue:e}=Cm(),t=wm();return(0,g.useCallback)(n=>{e(`trackedDepositId`,n),t(`track`)},[e,t])}function Em(){let{setValue:e}=Cm(),t=wm();return(0,g.useCallback)(n=>{e(`method`,n),t(n)},[e,t])}var Dm={back:`_back_7ercl_6`},Om=({onClick:e})=>{let t=_c(),n=(0,y.jsx)(`button`,{type:`button`,className:Dm.back,onClick:e,"aria-label":`Go back`,children:(0,y.jsx)(I.IconBack,{size:20,"aria-hidden":`true`})});return t?(0,ve.createPortal)(n,t):n},km={title:`_title_ld663_1`,list:`_list_ld663_12`,scroll:`_scroll_ld663_22`,row:`_row_ld663_30`,activeRow:`_activeRow_ld663_48`},Am=({title:e,onBack:t,children:n})=>(0,y.jsxs)(y.Fragment,{children:[t&&(0,y.jsx)(Om,{onClick:t}),(0,y.jsx)(`h2`,{className:km.title,children:e}),n]});Am.List=e=>{let{className:t,maxHeight:n,scroll:r=!0,children:i}=e;return(0,y.jsx)(`div`,{className:(0,P.default)(km.list,r&&km.scroll,t),style:n?{maxHeight:n}:void 0,children:i})},Am.Row=({onClick:e,isActive:t,children:n})=>(0,y.jsx)(`button`,{type:`button`,className:(0,P.default)(km.row,t&&km.activeRow),onClick:e,children:n});var jm={unavailable:`_unavailable_707tc_1`},Mm=`We couldn't fetch a processing time estimate right now. Deposits are unaffected and will be processed normally.`,Nm=({estimate:e})=>{switch(e.status){case`ready`:return un(e.seconds);case`estimating`:return`Estimating…`;case`unavailable`:return(0,y.jsx)(ku,{label:Mm,children:(0,y.jsxs)(`span`,{className:jm.unavailable,children:[(0,y.jsx)(I.IconWarningFilled,{size:12,"aria-hidden":`true`}),`Unavailable`]})})}},Pm={trigger:`_trigger_u1d1r_1 _field_a687c_4`,staticField:`_staticField_u1d1r_15 _field_a687c_4`,triggerValue:`_triggerValue_u1d1r_19`,triggerLabel:`_triggerLabel_u1d1r_27`,logo:`_logo_u1d1r_33`,icon:`_icon_u1d1r_39`,positioner:`_positioner_u1d1r_50`,popup:`_popup_u1d1r_54`,item:`_item_u1d1r_63`,itemText:`_itemText_u1d1r_80`,itemMin:`_itemMin_u1d1r_92`,itemIndicator:`_itemIndicator_u1d1r_101`,active:`_active_u1d1r_107`},Fm=({label:e,options:t,value:n,onChange:r})=>{let i=_c(),a=t.find(e=>e.value===n);if(t.length<=1){let e=t[0];return(0,y.jsx)(`div`,{className:Pm.staticField,children:(0,y.jsxs)(`span`,{className:Pm.triggerValue,children:[e&&(0,y.jsx)(K,{src:e.logoUrl,width:24,height:24,className:Pm.logo,classNames:{placeholder:Pm.logo}}),(0,y.jsx)(`span`,{className:Pm.triggerLabel,children:e?.label})]})})}return(0,y.jsxs)(ge.Select.Root,{value:n,onValueChange:e=>{if(e===null)return;let n=t.find(t=>t.value===e);n&&r(n.value)},modal:!1,children:[(0,y.jsxs)(ge.Select.Trigger,{className:Pm.trigger,"aria-label":e,children:[(0,y.jsxs)(`span`,{className:Pm.triggerValue,children:[a&&(0,y.jsx)(K,{src:a.logoUrl,width:24,height:24,className:Pm.logo,classNames:{placeholder:Pm.logo}}),(0,y.jsx)(`span`,{className:Pm.triggerLabel,children:a?.label??`Select`})]}),(0,y.jsx)(ge.Select.Icon,{className:Pm.icon,children:(0,y.jsx)(I.IconChevronDown,{size:16,"aria-hidden":`true`})})]}),(0,y.jsx)(ge.Select.Portal,{container:i,children:(0,y.jsx)(ge.Select.Positioner,{className:Pm.positioner,alignItemWithTrigger:!1,sideOffset:6,align:`end`,children:(0,y.jsx)(ge.Select.Popup,{className:Pm.popup,children:t.map(e=>(0,y.jsxs)(ge.Select.Item,{className:Pm.item,value:e.value,children:[(0,y.jsx)(K,{src:e.logoUrl,width:20,height:20,className:Pm.logo,classNames:{placeholder:Pm.logo}}),(0,y.jsx)(ge.Select.ItemText,{className:Pm.itemText,children:e.label}),e.minLabel&&(0,y.jsx)(`span`,{className:Pm.itemMin,children:e.minLabel}),(0,y.jsx)(I.IconCheck,{size:12,className:(0,P.default)(Pm.itemIndicator,{[Pm.active]:e.value===n}),"aria-hidden":`true`})]},e.value))})})})]})},Im={root:`_root_1ogu0_5`,selectors:`_selectors_1ogu0_12`,"selector-group":`_selector-group_1ogu0_19`,"selector-label":`_selector-label_1ogu0_29`,"qr-section":`_qr-section_1ogu0_35`,"min-group":`_min-group_1ogu0_44`,min:`_min_1ogu0_44`,warning:`_warning_1ogu0_57`,qr:`_qr_1ogu0_35`,"qr-loading":`_qr-loading_1ogu0_82`,"address-group":`_address-group_1ogu0_87`,address:`_address_1ogu0_87`,copy:`_copy_1ogu0_111`,"label-wrapper":`_label-wrapper_1ogu0_130`,"label-copy":`_label-copy_1ogu0_138`,"label-copied":`_label-copied_1ogu0_142`,copied:`_copied_1ogu0_150`,resume:`_resume_1ogu0_161`,details:`_details_1ogu0_189`,error:`_error_1ogu0_193`},Lm=()=>{let e=wm(),t=Tm(),{watch:n}=Cm(),r=U(),i=n(`receiveSymbol`),a=n(`receiveDenom`),o=n(`receiveChainId`),s=xm(o,a),[c,l]=(0,g.useState)(``),u=Sm(s,c),d=u?.symbol??``,f=u?.routes??[],[p,m]=(0,g.useState)(f[0]?.src_chain_id??``),h=f.find(e=>e.src_chain_id===p)??f[0],_=h?.src_chain_id??``,v=e=>{let t=Sm(s,e);l(e),m(t?.routes[0]?.src_chain_id??``)},b=h?cn(h.min_deposit_amount,h.src_decimals,u?.symbol??``):``,x=wn(h,o,a),S=ql(),C=S.find(e=>e.chain_id===_)?.logo_uri??``,w=f.map(e=>{let t=S.find(t=>t.chain_id===e.src_chain_id);return{value:e.src_chain_id,label:t?.pretty_name??sn(e.src_chain_id),logoUrl:t?.logo_uri??``,minLabel:`Min ${cn(e.min_deposit_amount,e.src_decimals,u?.symbol??``)}`}}),T=s.map(e=>({value:e.symbol,label:e.symbol,logoUrl:e.logoUrl})),{query:E,data:D,freshCursor:ee}=nm({walletAddress:r,chainId:o,assetDenom:a}),{isError:O,error:k}=E,A=D?.deposit_address??``,j=hm({depositAddress:A,after:ee}),te=j.data?.[0]?.id??``;(0,g.useEffect)(()=>{te&&t(te)},[te,t]);let ne=gm(A),M=ne.data?.[0]?.id??``,re=[j.error,ne.error].find(e=>e instanceof pm),ie=(j.isError||ne.isError)&&!re,ae=(O?k:null)??re??null,oe=(0,g.useRef)(null),se=(0,g.useRef)(null),ce=vc(`--gray-0`);return(0,g.useEffect)(()=>{!oe.current||!A||(se.current?se.current.update({data:A,image:C,dotsOptions:{color:ce},cornersSquareOptions:{color:ce},cornersDotOptions:{color:ce}}):(se.current=new Ee.default({type:`canvas`,width:400,height:400,margin:0,data:A,image:C,qrOptions:{mode:`Byte`,errorCorrectionLevel:`H`},dotsOptions:{type:`dots`,color:ce},cornersSquareOptions:{type:`extra-rounded`,color:ce},cornersDotOptions:{type:`dot`,color:ce},backgroundOptions:{color:`transparent`},imageOptions:{hideBackgroundDots:!0,imageSize:.25,margin:8}}),se.current.append(oe.current)))},[A,C,ce]),(0,y.jsx)(Am,{title:`Deposit ${i} via address`,onBack:()=>e(`select-method`),children:(0,y.jsxs)(`div`,{className:Im.root,children:[(0,y.jsxs)(`div`,{className:Im.selectors,children:[(0,y.jsxs)(`div`,{className:Im[`selector-group`],children:[(0,y.jsx)(`span`,{className:Im[`selector-label`],children:`Source asset`}),(0,y.jsx)(Fm,{label:`Source asset`,options:T,value:d,onChange:v})]}),(0,y.jsxs)(`div`,{className:Im[`selector-group`],children:[(0,y.jsx)(`span`,{className:Im[`selector-label`],children:`Supported network`}),(0,y.jsx)(Fm,{label:`Supported network`,options:w,value:_,onChange:m})]})]}),(0,y.jsxs)(`div`,{className:Im[`qr-section`],children:[(0,y.jsxs)(`div`,{className:Im[`min-group`],children:[b&&(0,y.jsxs)(`p`,{className:Im.min,children:[`Minimum deposit: `,b]}),(0,y.jsxs)(`p`,{className:Im.warning,role:`alert`,children:[(0,y.jsx)(I.IconWarningFilled,{size:12,"aria-hidden":`true`}),`Deposits below minimum or with unsupported assets will be lost.`]})]}),ae?(0,y.jsx)(`p`,{className:Im.error,role:`alert`,children:ae.message}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:(0,P.default)(Im.qr,{[Im[`qr-loading`]]:!A}),ref:oe}),(0,y.jsxs)(`div`,{className:Im[`address-group`],children:[(0,y.jsx)(`span`,{className:Im.address,children:A||`Generating your deposit address…`}),(0,y.jsx)(Oc,{value:A,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(Im.copy,{[Im.copied]:t}),onClick:e,disabled:!A,"aria-label":t?`Copied`:`Copy deposit address`,children:[(0,y.jsx)(I.IconCopy,{size:12,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Im[`label-wrapper`],children:[(0,y.jsx)(`span`,{className:Im[`label-copy`],children:`Copy address`}),(0,y.jsx)(`span`,{className:Im[`label-copied`],children:`Copied!`})]})]})})]}),ie&&(0,y.jsx)(`p`,{className:Im.error,role:`alert`,children:`Deposit detection is temporarily unavailable. Your transfer is unaffected; it will appear once the connection recovers.`})]})]}),!ae&&M&&(0,y.jsx)(`button`,{type:`button`,className:Im.resume,onClick:()=>t(M),children:`View the transfer detected at this address`}),(0,y.jsx)(`div`,{className:Im.details,children:(0,y.jsxs)(Jp,{title:`Transaction details`,defaultOpen:!0,children:[h&&(0,y.jsx)(Xp,{label:`Max slippage`,children:ln(h.max_slippage_percent)}),(0,y.jsx)(Xp,{label:`Processing time`,children:(0,y.jsx)(Nm,{estimate:x})})]})})]})})},Rm=1,zm=`0x0000000000000000000000000000000000000000`;function Bm(e){if(e.fiat.length===0||e.crypto.length===0)throw Error(`Onramper returned no supported currencies. onramperApiKey or onramperApiUrl is likely misconfigured.`);return e}function Vm(e,t,n){if(t!==String(Rm))return;let r=n.endsWith(`-native`)?zm:n.toLowerCase();return e.find(e=>e.chainId===Rm&&e.address.toLowerCase()===r)}function Hm(e,{presetCurrency:t,persistedId:n,recommendedCode:r,defaultId:i}){let a=t=>t?e.find(e=>e.id===t):void 0,o=t=>{if(!t)return;let n=t.toLowerCase();return e.find(e=>e.code.toLowerCase()===n)??e.find(e=>e.id===n)};return o(t)??a(n)??o(r)??a(i)??e[0]}var Um=`applepay`;function Wm(){if(typeof window>`u`)return!1;let e=window.ApplePaySession;if(!e)return!1;try{return e.canMakePayments()}catch{return!1}}function Gm(e,t){return t?e:e.filter(e=>e.paymentTypeId!==Um)}function Km(e,t){return e.length>0&&Gm(e,t).length===0}function qm(e){let t=e.map(e=>e.details?.limits?.aggregatedLimit?.max).filter(e=>typeof e==`number`&&Number.isFinite(e));if(t.length!==0)return Math.max(...t)}function Jm(e,t){return`${t}${(0,f.default)(String(e)).toFormat()}`}function Ym(e,t){return`Up to ${Jm(e,t)}`}function Xm(e,t){return e.find(e=>e.paymentTypeId===t)?.details?.limits?.aggregatedLimit}function Zm(e,t,n,r){if(!t)return``;let i=Number(e);if(!(i>0))return``;let a=r?` with ${r}`:``;return t.min!==void 0&&i<t.min?`Minimum purchase${a} is ${Jm(t.min,n)}`:t.max!==void 0&&i>t.max?`Maximum purchase${a} is ${Jm(t.max,n)}`:``}function Qm(e,t){return(0,f.default)((0,d.toBaseUnit)(String(e),{decimals:t.src_decimals})||`0`).lt(t.min_deposit_amount)}function $m(e){return e.charAt(0).toUpperCase()+e.slice(1)}function eh(e,t){return e.find(e=>e.id===t)?.displayName??$m(t)}function th(e){let t=e.filter(e=>typeof e.payout==`number`&&!!e.ramp);if(!t.length)return[];let n=Math.max(...t.map(e=>e.payout));return[...t].sort((e,t)=>t.payout-e.payout).map(e=>{let t=e.payout===n,r=n?(e.payout-n)/n*100:0;return{quote:e,ramp:e.ramp,payout:e.payout,isBest:t,diffLabel:t?``:`${r.toFixed(2)}%`}})}function nh(e,t){return e.find(e=>e.ramp===t)??e[0]??null}function rh(e){return(e.networkFee??0)+(e.transactionFee??0)}var ih=6101,ah=6200,oh=6403,sh=`Providers are temporarily unavailable. Try again in a moment.`,ch=`No provider currently supports this combination. Try a different payment method or currency.`;function lh(e){let t=e.flatMap(e=>e.errors??[]),n=t.find(e=>e.errorId===ih);if(n)return n.message;let r=t.filter(e=>e.errorId!==oh);return r.length>0&&r.every(e=>e.errorId===ah)?sh:ch}function uh(e){if(th(e).length>0)return;let t=e.flatMap(e=>e.errors??[]);t.length!==0&&console.warn(`[onramp] provider quote errors:`,t)}function dh(e){let t=``;try{t=new URL(e).protocol}catch{}if(t!==`https:`)throw Error(`Unexpected checkout URL from the provider: ${e}`)}function fh(e){return{queryKey:Bt.onramperSupported.queryKey,queryFn:async()=>{try{let{message:t}=await e.get(`supported`,{searchParams:{type:`buy`}}).json();return Bm(t)}catch(e){throw await We(e)}},staleTime:z.INFINITY}}function ph(){let{data:e}=(0,u.useSuspenseQuery)(fh(Ht()));return e}function mh(){let e=Ut(),{data:t}=(0,u.useQuery)({...fh(Ht()),enabled:e});return t?.crypto}function hh(){let e=Ht(),{data:t}=(0,u.useSuspenseQuery)({queryKey:Bt.onramperOnramps.queryKey,queryFn:async()=>{try{let{message:t}=await e.get(`supported/onramps/all`,{searchParams:{type:`buy`}}).json();return t}catch(e){throw await We(e)}},staleTime:z.INFINITY});return t}function gh(e){return{queryKey:Bt.onramperGeoDefaults.queryKey,queryFn:async()=>{try{return(await e.get(`supported/defaults/all`,{searchParams:{type:`buy`}}).json())?.message?.recommended?.source??null}catch(e){return console.warn(`[onramp] geo defaults lookup failed:`,e),null}},staleTime:z.INFINITY}}function _h(){let{data:e}=(0,u.useSuspenseQuery)(gh(Ht()));return e}function vh(){let e=Ut(),t=Ht(),n=(0,u.useQueryClient)();(0,g.useEffect)(()=>{e&&n.prefetchQuery(gh(t))},[e,t,n])}function yh(e){let t=hh();return(0,g.useMemo)(()=>t.find(t=>t.id===e),[t,e])}function bh(e){let{fiat:t}=ph();return(0,g.useMemo)(()=>t.find(t=>t.id===e),[t,e])}function xh(e){return bh(e)?.code??e.toUpperCase()}function Sh(e,t){let n=On(e,t),{crypto:r}=ph(),i=(0,g.useMemo)(()=>n.find(e=>Vm(r,e.src_chain_id,e.src_denom)),[n,r]);return(0,g.useMemo)(()=>{if(!i)return null;let e=Vm(r,i.src_chain_id,i.src_denom);return e?{route:i,crypto:e}:null},[i,r])}function Ch(e,t){return Sh(e,t)?.crypto??null}function wh(e,t,n){let r=Ut(),i=Ht();return(0,u.useQuery)({queryKey:Bt.onramperPaymentTypes(e,t).queryKey,queryFn:async()=>{try{let{message:n}=await i.get(`supported/payment-types/${e}`,{searchParams:{destination:t,type:`buy`}}).json();return n}catch(e){throw await We(e)}},enabled:r&&!!e&&!!t,staleTime:z.MINUTE,select:n})}var Th=e=>Gm(e,Wm()),Eh=e=>Km(e,Wm());function Dh(e,t){return wh(e,t,Th)}function Oh(e,t){return wh(e,t,Eh).data??!1}var kh=z.SECOND*30;function Ah({fiat:e,crypto:t,amount:n,paymentMethod:r,enabled:i=!0}){let a=Ut(),o=Ht();return(0,u.useQuery)({queryKey:Bt.onramperQuotes(e,t,n,r).queryKey,queryFn:async({signal:i})=>{try{let a={type:`buy`,amount:n,paymentMethod:r},s=await o.get(`quotes/${e}/${t}`,{searchParams:a,signal:i}).json();return uh(s),s}catch(e){throw await We(e)}},enabled:i&&a&&!!e&&!!t&&Number(n)>0&&!!r,staleTime:kh,refetchInterval:kh})}async function jh(e,t){try{return await e.post(`v1/onramper/checkout`,{json:{wallet_address:t.walletAddress,chain_id:t.chainId,asset_denom:t.assetDenom,onramp:t.onramp,fiat:t.fiat,crypto:t.crypto,network:t.network,amount:t.amount,payment_method:t.paymentMethod,uuid:t.uuid}}).json()}catch(e){throw await We(e)}}function Mh(){let e=Vt();return(0,u.useMutation)({mutationFn:async t=>{let n=await jh(e,t);return dh(n.url),n}})}var Nh=z.SECOND*30;function Ph(e){let t=!e.enabled||e.hasData&&!e.isPlaceholderData;return{isSettled:t,isFailed:!t&&e.isError}}async function Fh(e){if(e instanceof h.HTTPError&&e.response.status===400)return{status:`declined`,reason:await Ue(e)};throw await We(e)}function Ih(e,t,n){if(!n||!e||t===void 0)return{value:``,amountOut:``,isDeclined:!1,declineReason:``};if(e.status===`declined`)return{value:``,amountOut:``,isDeclined:!0,declineReason:e.reason};let r=(0,d.fromBaseUnit)(e.quote.min_received,{decimals:t}),i=(0,d.fromBaseUnit)(e.quote.amount_out,{decimals:t});return{value:r&&(0,f.default)(r).gt(0)?(0,d.formatNumber)(r,{dp:6}):``,amountOut:i&&(0,f.default)(i).gt(0)?i:``,isDeclined:!1,declineReason:``}}function Lh(e,t){return{value:t.isFailed?``:e.value,amountOut:t.isFailed?``:e.amountOut,isDeclined:t.isSettled&&e.isDeclined,declineReason:t.isSettled?e.declineReason:``,...t}}function Rh(e,t,n){let{depositApiUrl:r}=R(),i=Vt(),a=Sh(t,n)?.route,o=a?dn(a,t,n):void 0,s=a&&e&&e>0?(0,f.default)((0,d.toBaseUnit)(String(e),{decimals:a.src_decimals})||0).integerValue(f.default.ROUND_DOWN).toString():``,c=!!r&&!!a&&!!o&&!!s&&(0,f.default)(s).gt(0),{data:l,isPlaceholderData:p,isError:m}=(0,u.useQuery)({queryKey:Bt.minReceived(a?.src_chain_id??``,a?.src_denom??``,t,n,s).queryKey,queryFn:async()=>{try{return{status:`quoted`,quote:await i.get(`v1/quote`,{searchParams:{src_chain_id:a?.src_chain_id??``,src_denom:a?.src_denom??``,dst_chain_id:t,dst_denom:n,amount_in:s}}).json()}}catch(e){return await Fh(e)}},enabled:c,staleTime:Nh,refetchInterval:Nh,placeholderData:u.keepPreviousData}),h=Ph({enabled:c,hasData:!!l,isPlaceholderData:p,isError:m});return Lh(Ih(l,o?.decimals,s),h)}var zh={flag:`_flag_pzx4s_1`},Bh=({fiatId:e,size:t=20})=>(0,y.jsx)(K,{src:bh(e)?.icon??``,alt:``,width:t,height:t,className:zh.flag,classNames:{placeholder:zh.flag}}),Vh={icon:`_icon_14b3n_1`,mono:`_mono_14b3n_11`},Hh=({iconUrl:e,size:t=28})=>{let n=Math.round(t*.625);return(0,y.jsx)(`span`,{className:Vh.icon,style:{width:t,height:t},"aria-hidden":`true`,children:e?(0,y.jsx)(K,{src:e,alt:``,width:n,height:n}):(0,y.jsx)(I.IconPay,{size:n})})},Uh={logo:`_logo_6ip0y_1`},Wh=({ramp:e,size:t=24})=>{let n=yh(e);return(0,y.jsx)(K,{className:Uh.logo,classNames:{placeholder:Uh.logo},src:n?.icon,width:t,height:t,"aria-hidden":`true`})},Gh=2;function Kh({sourceCryptoId:e,sourceRoute:t,fiatAmount:n,limitError:r,quotes:i,providerId:a,quotedFiatAmount:o,fiat:s}){if(!t)return{sourceCryptoId:e,status:`unsupported`};if(!(Number(n)>0))return{sourceCryptoId:e,status:`idle`};if(r)return{sourceCryptoId:e,status:`limit-error`,message:r};if(n!==o)return{sourceCryptoId:e,status:`loading`};if(i.isError&&!i.data)return{sourceCryptoId:e,status:`error`,message:i.errorMessage};if(!i.data)return{sourceCryptoId:e,status:`loading`};let c=th(i.data),l=nh(c,a);if(!l)return{sourceCryptoId:e,status:`no-offers`,reason:lh(i.data)};let u=Qm(l.payout,t.route),f=cn(t.route.min_deposit_amount,t.route.src_decimals,t.crypto.code),p=rh(l.quote);return{sourceCryptoId:e,status:`quoted`,ranked:c,selected:l,belowRouteMinimum:u,routeMinimumLabel:f,quotedFiatAmount:o,feeLabel:`${(0,d.formatNumber)(String(p),{dp:Gh})} ${s}`}}function qh(e,t,n,r){let i=Number(e),a=Number(t);return!Number.isFinite(i)||i<=0||!Number.isFinite(a)||a<=0?``:`1 ${n} ≈ ${(0,d.formatNumber)((0,f.default)(e).div(t).toString(),{dp:Gh})} ${r}`}function Jh({enabled:e=!0}={}){let{control:t}=Cm(),[n,r,i,a,o,s]=(0,F.useWatch)({control:t,name:[`fiatId`,`fiatAmount`,`receiveDenom`,`receiveChainId`,`paymentMethodId`,`providerId`]}),c=Sh(a,i),l=c?.crypto??null,u=bh(n),d=Dh(n,l?.id??``),f=Xm(d.data??[],o),p=d.data?.find(e=>e.paymentTypeId===o)?.name,m=Zm(r,f,u?.symbol??``,p),[h]=(0,ue.useDebounceValue)(r,300),g=Zm(h,f,u?.symbol??``,p),_=Ah({fiat:n,crypto:l?.id??``,amount:g?``:h,paymentMethod:o,enabled:e}),v=xh(n);return Kh({sourceCryptoId:l?.id??``,sourceRoute:c,fiatAmount:r,limitError:m,quotes:{isError:_.isError,data:_.data,errorMessage:_.error?.message??``},providerId:s,quotedFiatAmount:h,fiat:v})}var X={form:`_form_78jgk_1`,card:`_card_78jgk_8`,field:`_field_78jgk_14`,fieldLabel:`_fieldLabel_78jgk_20`,fieldLabelChain:`_fieldLabelChain_78jgk_31`,fieldMain:`_fieldMain_78jgk_39`,pill:`_pill_78jgk_45`,pillChevron:`_pillChevron_78jgk_67`,amount:`_amount_78jgk_75`,amountReadOnly:`_amountReadOnly_78jgk_76`,placeholder:`_placeholder_78jgk_104`,divider:`_divider_78jgk_112`,coin:`_coin_78jgk_119`,chainLogo:`_chainLogo_78jgk_127`,sectionLabel:`_sectionLabel_78jgk_135`,methodField:`_methodField_78jgk_142 _field_a687c_4`,methodLeft:`_methodLeft_78jgk_154`,providerPill:`_providerPill_78jgk_161`};function Yh(e){switch(e.status){case`unsupported`:return`Not available for this asset`;case`idle`:return`Enter amount`;case`limit-error`:return`Amount out of range`;case`loading`:return`Getting quote…`;case`error`:return`Quote unavailable`;case`no-offers`:return`No quote available`;case`quoted`:return e.belowRouteMinimum?`Amount too low`:void 0}return e}function Xh(e){switch(e.status){case`limit-error`:case`error`:return e.message;case`no-offers`:return e.reason;case`quoted`:return e.belowRouteMinimum?`This purchase is below the ${e.routeMinimumLabel} bridge minimum. Increase your amount.`:``;default:return``}}var Zh=()=>{let{control:e,watch:t,setValue:n,handleSubmit:r}=Cm(),{onramp:i}=Jt(),a=wm(),o=Jh(),s=hh(),c=t(`fiatId`),l=t(`receiveSymbol`),u=t(`receiveDenom`),f=t(`receiveChainId`),p=t(`paymentMethodId`),m=kn({denom:u,chainId:f,symbol:l}),h=Dh(c,o.sourceCryptoId),_=h.data?.find(e=>e.paymentTypeId===p);(0,g.useEffect)(()=>{let e=h.data;e?.length&&(e.some(e=>e.paymentTypeId===p)||n(`paymentMethodId`,e[0].paymentTypeId))},[h.data,p,n]);let{fiat:v}=ph(),b=_h();(0,g.useEffect)(()=>{let e=localStorage.getItem(V.ONRAMP_FIAT_ID),t=Hm(v,{presetCurrency:i?.currency&&c!==e?i.currency:null,persistedId:e,recommendedCode:b,defaultId:`usd`});c!==t.id&&n(`fiatId`,t.id)},[v,b,c,i?.currency,n]);let x=o.status===`quoted`?o:null,S=x?.selected??null,C=Rh(S?.payout,f,u),w=wn(Sh(f,u)?.route,f,u),T=xh(c),E=x&&C.isSettled?qh(x.quotedFiatAmount,C.amountOut,l,T):``,D=Yh(o)??(C.isDeclined||C.isFailed?`Quote unavailable`:void 0)??(C.isSettled?void 0:`Getting quote…`),ee=Xh(o)||(C.isDeclined?C.declineReason||`The bridge can't quote this purchase. It may be below the route minimum. Try increasing your amount.`:``)||(C.isFailed?`Couldn't reach the bridge for a quote. It retries automatically. Check your connection if this persists.`:``),O=r(()=>{D||a(`onramp-processing`)});return(0,y.jsx)(Am,{title:`Buy ${l}`,onBack:()=>a(`select-method`),children:(0,y.jsxs)(`form`,{className:X.form,onSubmit:O,"aria-label":`Buy crypto form`,children:[(0,y.jsxs)(`div`,{className:X.card,children:[(0,y.jsxs)(`div`,{className:X.field,children:[(0,y.jsx)(`p`,{className:X.fieldLabel,children:`Pay`}),(0,y.jsxs)(`div`,{className:X.fieldMain,children:[(0,y.jsxs)(`button`,{type:`button`,className:X.pill,onClick:()=>a(`onramp-select-fiat`),children:[(0,y.jsx)(Bh,{fiatId:c,size:24}),T,(0,y.jsx)(I.IconChevronDown,{size:16,className:X.pillChevron,"aria-hidden":`true`})]}),(0,y.jsx)(Cu,{name:`fiatAmount`,control:e,dp:2,className:X.amount,"aria-label":`Amount to pay`})]})]}),(0,y.jsx)(`div`,{className:X.divider}),(0,y.jsxs)(`div`,{className:X.field,children:[(0,y.jsxs)(`p`,{className:X.fieldLabel,children:[`Receive`,(0,y.jsxs)(`span`,{className:X.fieldLabelChain,children:[`on`,(0,y.jsx)(K,{src:m.chainLogoUrl,width:18,height:18,className:X.chainLogo,classNames:{placeholder:X.chainLogo}}),m.chainName]})]}),(0,y.jsxs)(`div`,{className:X.fieldMain,children:[(0,y.jsxs)(`button`,{type:`button`,className:X.pill,onClick:()=>a(`onramp-select-receive`),children:[(0,y.jsx)(K,{src:m.logoUrl,width:24,height:24,className:X.coin,classNames:{placeholder:X.coin}}),m.symbol,(0,y.jsx)(I.IconChevronDown,{size:16,className:X.pillChevron,"aria-hidden":`true`})]}),(0,y.jsx)(`p`,{className:(0,P.default)(X.amountReadOnly,{[X.placeholder]:!C.amountOut}),children:C.amountOut?(0,d.formatNumber)(C.amountOut,{dp:6}):`0`})]})]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:X.sectionLabel,children:`Payment method`}),(0,y.jsxs)(`button`,{type:`button`,className:X.methodField,onClick:()=>a(`onramp-select-payment`),children:[(0,y.jsxs)(`span`,{className:X.methodLeft,children:[(0,y.jsx)(Hh,{iconUrl:_?.icon,size:32}),_?.name??`Select payment method`]}),(0,y.jsx)(I.IconChevronDown,{size:16,className:X.pillChevron,"aria-hidden":`true`})]})]}),(0,y.jsxs)(Jp,{title:`Transaction details`,defaultOpen:!0,children:[(0,y.jsx)(Xp,{label:`Provider`,children:(0,y.jsxs)(`button`,{type:`button`,className:X.providerPill,onClick:()=>a(`onramp-select-provider`),disabled:!S,children:[S?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Wh,{ramp:S.ramp,size:16}),eh(s,S.ramp)]}):`—`,(0,y.jsx)(I.IconChevronDown,{size:12,className:X.pillChevron,"aria-hidden":`true`})]})}),(0,y.jsx)(Xp,{label:`Estimated price`,children:E||`—`}),(0,y.jsx)(Xp,{label:`Estimated time`,children:(0,y.jsx)(Nm,{estimate:w})}),(0,y.jsx)(Xp,{label:`Total fees`,children:x?.feeLabel??`—`}),(0,y.jsxs)(Xp,{label:`Minimum received`,emphasized:!0,children:[(0,y.jsx)(K,{src:m.logoUrl,width:14,height:14,className:X.coin,classNames:{placeholder:X.coin}}),C.value?`${C.value} ${l}`:`—`]})]}),(0,y.jsx)(ac,{extra:ee&&(0,y.jsx)(Gc,{level:`error`,children:ee}),children:(0,y.jsx)(G.White,{type:`submit`,fullWidth:!0,disabled:!!D,children:D??`Buy ${l}`})})]})})},Qh={status:`_status_15jzq_1`,contrast:`_contrast_15jzq_14`},$h=({error:e,...t})=>(0,y.jsx)(Da,{...t,error:e,className:(0,P.default)(Qh.status,{[Qh.contrast]:!e})}),eg={flow:`_flow_11kau_1`,step:`_step_11kau_12`,stepLabel:`_stepLabel_11kau_19`,chip:`_chip_11kau_25`,arrow:`_arrow_11kau_39`,coin:`_coin_11kau_46`},tg=({steps:e})=>(0,y.jsx)(`div`,{className:eg.flow,children:e.map((e,t)=>(0,y.jsxs)(g.Fragment,{children:[t>0&&(0,y.jsx)(I.IconChevronRight,{size:16,className:eg.arrow,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:eg.step,children:[(0,y.jsx)(`span`,{className:eg.stepLabel,children:e.label}),(0,y.jsxs)(`span`,{className:eg.chip,children:[e.icon??(0,y.jsx)(Yu,{assetLogoUrl:e.logoUrl,chainLogoUrl:e.chainLogoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:eg.coin}),e.text]})]})]},e.label))}),ng={body:`_body_1foy4_1`,logo:`_logo_1foy4_11`,heading:`_heading_1foy4_15`,duration:`_duration_1foy4_20`,durationValue:`_durationValue_1foy4_26`,note:`_note_1foy4_31`,addressSection:`_addressSection_1foy4_40`,addressHeader:`_addressHeader_1foy4_53`,addressChain:`_addressChain_1foy4_63`,addressChainLogo:`_addressChainLogo_1foy4_69`,addressField:`_addressField_1foy4_75`,addressValue:`_addressValue_1foy4_100`,addressCaption:`_addressCaption_1foy4_107`,addressOwner:`_addressOwner_1foy4_114`,redirectFallback:`_redirectFallback_1foy4_122`,continueLink:`_continueLink_1foy4_128`};function rg(e){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),t.remove()}function ig(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var ag=5e3,og=()=>{let{watch:e}=Cm(),t=Tm(),[n,r]=(0,g.useState)(null),i=Jh({enabled:!n}),a=hh(),o=U(),s=e(`fiatId`),c=e(`fiatAmount`),l=e(`paymentMethodId`),u=e(`receiveSymbol`),f=e(`receiveDenom`),p=e(`receiveChainId`),m=kn({denom:f,chainId:p,symbol:u}),h=Sh(p,f),_=h?.crypto??null,v=bm(),b=h?v.symbol(h.route.src_chain_id,h.route.src_denom):``,x=h?v.logoUrl(h.route.src_chain_id,h.route.src_denom):``,S=ql(),C=h?S.find(e=>e.chain_id===h.route.src_chain_id):void 0,w=C?.logo_uri??``,T=h?C?.pretty_name??sn(h.route.src_chain_id):``,E=i.status===`quoted`?i.selected.ramp:``,D=i.status===`quoted`&&i.belowRouteMinimum,ee=i.status===`quoted`?i.selected.payout:void 0,O=Rh(n?void 0:ee,p,f),k=_?.id??``,A=_?.network??``,j=wn(h?.route,p,f),{query:te,data:ne,freshCursor:M}=nm({walletAddress:o,chainId:p,assetDenom:f}),{isError:re,refetch:ie}=te,ae=ne?.deposit_address??``,oe=hm({depositAddress:ae,after:M}),se=oe.data?.[0]?.id??``;(0,g.useEffect)(()=>{se&&t(se)},[se,t]);let ce=oe.isError,{mutateAsync:le}=Mh(),[N]=(0,g.useState)(ig),[ue,de]=(0,g.useState)(null),P=n?.ramp??E,F=P?eh(a,P):`your provider`,fe=!!o&&!!E&&!!k&&!!A&&Number(c)>0,pe=fe&&!!ae&&!!M&&O.isSettled,me=(0,g.useRef)(!1);(0,g.useEffect)(()=>{me.current||!pe||(me.current=!0,(async()=>{try{if(D)throw Error(`The amount is now below the route minimum. Please go back and adjust it.`);if(O.isDeclined)throw Error(O.declineReason||`The bridge can't quote this purchase. It may be below the route minimum. Please go back and adjust your amount.`);let e=await le({walletAddress:o,chainId:p,assetDenom:f,onramp:E,fiat:s,crypto:k,network:A,amount:Number(c),paymentMethod:l,uuid:N});rg(e.url),r({url:e.url,ramp:E})}catch(e){de(e instanceof Error?e:Error(String(e)))}})())},[pe,D,O.isDeclined,O.declineReason,le,o,p,f,E,s,k,A,c,l,N]),(0,g.useEffect)(()=>{if(fe&&O.isSettled)return;let e=setTimeout(()=>{me.current||de(Error(`Couldn't start the checkout. Please go back and try again.`))},ag);return()=>clearTimeout(e)},[fe,O.isSettled]);let he=xh(s);if(ue)throw ue;return(0,y.jsx)(Am,{title:`Processing…`,children:(0,y.jsxs)(`div`,{className:ng.body,children:[P?(0,y.jsx)(Wh,{ramp:P,size:48}):null,(0,y.jsxs)(`p`,{className:ng.heading,children:[`Please proceed with `,F]}),n&&(0,y.jsxs)(`p`,{className:ng.redirectFallback,children:[`If you weren't redirected automatically,`,` `,(0,y.jsxs)(`a`,{className:ng.continueLink,href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:[`continue with `,F]})]}),(0,y.jsxs)(`p`,{className:ng.duration,children:[`Estimated duration`,` `,(0,y.jsx)(`span`,{className:ng.durationValue,children:(0,y.jsx)(Nm,{estimate:j})})]}),(0,y.jsx)(`p`,{className:ng.note,children:`Your transaction will continue even if you close this.`}),re&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)($h,{error:!0,children:`Checkout hasn't started because we couldn't prepare your deposit address.`}),(0,y.jsx)(G.White,{onClick:()=>void ie(),children:`Retry`})]}),ce&&!re&&(0,y.jsx)($h,{error:!0,children:`Deposit detection is temporarily unavailable. Your purchase is unaffected; it will appear once the connection recovers.`}),(0,y.jsx)(tg,{steps:[{label:`Pay`,icon:(0,y.jsx)(Bh,{fiatId:s,size:20}),text:he},{label:`Buy`,logoUrl:x,chainLogoUrl:w,text:b},{label:`Receive`,logoUrl:m.logoUrl,chainLogoUrl:m.chainLogoUrl,text:u}]}),ae&&(0,y.jsxs)(`div`,{className:ng.addressSection,children:[(0,y.jsxs)(`div`,{className:ng.addressHeader,children:[(0,y.jsx)(`span`,{children:`Deposit address`}),T&&(0,y.jsxs)(`span`,{className:ng.addressChain,children:[(0,y.jsx)(K,{src:w,width:16,height:16,className:ng.addressChainLogo,classNames:{placeholder:ng.addressChainLogo}}),T]})]}),(0,y.jsx)(Oc,{value:ae,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{type:`button`,className:ng.addressField,onClick:e,"aria-label":t?`Copied`:`Copy deposit address`,children:[(0,y.jsx)(`span`,{className:ng.addressValue,children:ae}),t?(0,y.jsx)(I.IconCheck,{size:12,"aria-hidden":`true`}):(0,y.jsx)(I.IconCopy,{size:12,"aria-hidden":`true`})]})}),P&&b&&(0,y.jsxs)(`p`,{className:ng.addressCaption,children:[F,` sends `,b,` here, then to`,` `,(0,y.jsxs)(`span`,{className:ng.addressOwner,children:[`your wallet (`,(0,d.truncate)(o),`)`]}),`. This should match the address on `,F,`'s page.`]})]})]})})},sg=({error:e,resetErrorBoundary:t})=>{let n=wm(),r=(0,u.useQueryClient)();return(0,y.jsxs)(Am,{title:`Processing…`,onBack:()=>n(`onramp`),children:[(0,y.jsx)($h,{error:!0,children:e.message}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{onClick:()=>{r.resetQueries({queryKey:Bt.assets.queryKey}),r.resetQueries({queryKey:Bt.onramperSupported.queryKey}),r.resetQueries({queryKey:Bt.onramperOnramps.queryKey}),t()},children:`Retry`})})]})},cg=()=>(0,y.jsx)(W,{errorBoundaryProps:{onError:e=>console.error(e),fallbackRender:({error:e,resetErrorBoundary:t})=>(0,y.jsx)(sg,{error:e,resetErrorBoundary:t})},children:(0,y.jsx)(og,{})}),lg={list:`_list_16zre_3`},ug=()=>{let{setValue:e}=Cm(),t=wm(),{fiat:n}=ph();return(0,y.jsx)(Am,{title:`Select fiat currency`,onBack:()=>t(`onramp`),children:(0,y.jsx)(Am.List,{scroll:!1,children:(0,y.jsx)(nd,{assets:n.map(e=>({denom:e.id,symbol:e.code,name:e.name,decimals:0,logoUrl:e.icon})),searchKeys:[`symbol`,`name`],placeholder:`Search by currency`,emptyMessage:`No currencies`,listClassName:lg.list,onSelect:n=>{e(`fiatId`,n),localStorage.setItem(V.ONRAMP_FIAT_ID,n),t(`onramp`)}})})})},dg={name:`_name_1hgng_1`,check:`_check_1hgng_9`},fg=()=>{let{watch:e,setValue:t}=Cm(),n=wm(),r=e(`fiatId`),i=e(`paymentMethodId`),a=e(`receiveDenom`),o=Ch(e(`receiveChainId`),a),{data:s,isPending:c,isError:l,error:u}=Dh(r,o?.id??``),d=Oh(r,o?.id??``);return(0,y.jsx)(Am,{title:`Select payment method`,onBack:()=>n(`onramp`),children:(0,y.jsx)(Am.List,{children:o?l?(0,y.jsx)($h,{error:!0,children:u.message}):c?(0,y.jsx)($h,{children:`Loading…`}):s.length===0?(0,y.jsx)($h,{children:d?`The only payment method for this pair is Apple Pay, which this browser can't complete. Try Safari or an iOS browser.`:`No payment methods`}):s.map(e=>(0,y.jsxs)(Am.Row,{onClick:()=>{t(`paymentMethodId`,e.paymentTypeId),localStorage.setItem(V.ONRAMP_PAYMENT_TYPE_ID,e.paymentTypeId),n(`onramp`)},children:[(0,y.jsx)(Hh,{iconUrl:e.icon,size:28}),(0,y.jsx)(`span`,{className:dg.name,children:e.name}),i===e.paymentTypeId&&(0,y.jsx)(I.IconCheck,{size:16,className:dg.check,"aria-hidden":`true`})]},e.paymentTypeId)):(0,y.jsx)($h,{children:`Not available for this asset`})})})},pg={header:`_header_vqn01_2`,left:`_left_vqn01_16`,name:`_name_vqn01_26`,badge:`_badge_vqn01_31`,"badge-success":`_badge-success_vqn01_41`,right:`_right_vqn01_46`,amount:`_amount_vqn01_53`,diff:`_diff_vqn01_59`},mg=()=>{let{watch:e,setValue:t}=Cm(),n=wm(),r=e(`receiveChainId`),i=e(`receiveDenom`),a=e(`providerId`),o=Jh(),s=hh(),c=Sh(r,i),l=bm(),u=c?l.symbol(c.route.src_chain_id,c.route.src_denom):``;return(0,y.jsxs)(Am,{title:`Select provider`,onBack:()=>n(`onramp`),children:[(0,y.jsxs)(`div`,{className:pg.header,children:[(0,y.jsx)(`span`,{children:`Provider`}),(0,y.jsx)(`span`,{children:`You receive`})]}),(0,y.jsx)(Am.List,{children:o.status===`loading`?(0,y.jsx)($h,{children:`Loading…`}):o.status===`error`?(0,y.jsx)($h,{error:!0,children:o.message}):o.status===`no-offers`?(0,y.jsx)($h,{children:o.reason}):o.status===`quoted`?o.ranked.map(e=>(0,y.jsxs)(Am.Row,{isActive:a===e.ramp,onClick:()=>{t(`providerId`,e.ramp),n(`onramp`)},children:[(0,y.jsxs)(`span`,{className:pg.left,children:[(0,y.jsx)(Wh,{ramp:e.ramp,size:28}),(0,y.jsx)(`span`,{className:pg.name,children:eh(s,e.ramp)}),e.isBest&&(0,y.jsx)(`span`,{className:(0,P.default)(pg.badge,pg[`badge-success`]),children:`Best price`})]}),(0,y.jsxs)(`span`,{className:pg.right,children:[(0,y.jsxs)(`span`,{className:pg.amount,children:[(0,d.formatNumber)(String(e.payout),{dp:6}),` `,u]}),e.diffLabel&&(0,y.jsx)(`span`,{className:pg.diff,children:e.diffLabel})]})]},e.ramp)):(0,y.jsx)($h,{children:`No quotes available`})})]})},hg={asset:`_asset_1n04e_1`,placeholder:`_placeholder_1n04e_17`,activeAsset:`_activeAsset_1n04e_30`,iconContainer:`_iconContainer_1n04e_34`,assetIcon:`_assetIcon_1n04e_44`,chainIcon:`_chainIcon_1n04e_54`,assetPlaceholder:`_assetPlaceholder_1n04e_68`,pulse:`_pulse_1n04e_1`,assetName:`_assetName_1n04e_89`,assetChain:`_assetChain_1n04e_104`,balance:`_balance_1n04e_112`,value:`_value_1n04e_121`},gg=()=>(0,y.jsxs)(`div`,{className:(0,P.default)(hg.asset,hg.placeholder),children:[(0,y.jsxs)(`div`,{className:hg.iconContainer,children:[(0,y.jsx)(`div`,{className:hg.assetIcon}),(0,y.jsx)(`div`,{className:hg.chainIcon})]}),(0,y.jsx)(`div`,{className:hg.assetPlaceholder})]}),_g=({assetLogoUrl:e,assetSymbol:t,chainLogoUrl:n,chainName:r,chainPrettyName:i,balanceLabel:a,valueLabel:o,isActive:s,onClick:c})=>(0,y.jsxs)(`button`,{type:`button`,className:(0,P.default)(hg.asset,s&&hg.activeAsset),onClick:c,children:[(0,y.jsxs)(`div`,{className:hg.iconContainer,children:[(0,y.jsx)(K,{src:e,alt:t,className:hg.assetIcon,classNames:{placeholder:hg.assetIcon}}),(0,y.jsx)(K,{src:n,alt:r,className:hg.chainIcon,classNames:{placeholder:hg.chainIcon}})]}),(0,y.jsxs)(`p`,{className:hg.assetName,children:[t,` `,s&&(0,y.jsx)(`span`,{children:(0,y.jsx)(I.IconCheck,{size:16})})]}),(0,y.jsxs)(`p`,{className:hg.assetChain,children:[`on `,i]}),a!==void 0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:hg.balance,children:a}),(0,y.jsx)(`p`,{className:hg.value,children:o})]})]});_g.Skeleton=gg;var vg=()=>{let{watch:e,setValue:t}=Cm(),n=wm(),{chainAssets:r}=Tn(),{localOptions:i=[]}=Jt(),a=r.filter(e=>i.some(t=>t.chainId===e.chainId&&H(t.denom)===H(e.denom))),{assetGroups:o,unlistedAssets:s}=xa(),c=[...o.flatMap(e=>e.assets),...s],l=(e,t)=>c.find(n=>n.chain.chainId===e&&H(n.denom)===H(t)),u=(0,p.sortWith)([(0,p.descend)(e=>l(e.chainId,e.denom)?.value??0)],a),f=e(`receiveDenom`),m=e(`receiveChainId`);return(0,y.jsx)(Am,{title:`Select receive assets`,onBack:()=>n(`onramp`),children:(0,y.jsx)(Am.List,{children:u.map(e=>{let r=l(e.chainId,e.denom);return(0,y.jsx)(_g,{assetLogoUrl:e.logoUrl,assetSymbol:e.symbol,chainLogoUrl:e.chainLogoUrl,chainName:e.chainName,chainPrettyName:e.chainName,isActive:H(f)===H(e.denom)&&m===e.chainId,onClick:()=>{t(`receiveSymbol`,e.symbol),t(`receiveDenom`,e.denom),t(`receiveChainId`,e.chainId),n(`onramp`)},balanceLabel:r?(0,d.formatAmount)(r.amount,{decimals:r.decimals}):void 0,valueLabel:r?ll(r.value,r.price):void 0},`${e.chainId}-${e.denom}`)})})})},yg={container:`_container_3iif4_1`,page:`_page_3iif4_7`},bg=({page:e,renderPage:t})=>{let n=(0,me.useTransition)(e,{keys:e,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:`absolute`,inset:0},config:{tension:500,friction:30,clamp:!0,duration:150},immediate:(0,ue.useMediaQuery)(`(prefers-reduced-motion: reduce)`)});return(0,y.jsx)(`div`,{className:yg.container,children:n((e,n)=>(0,y.jsx)(me.animated.div,{style:e,className:yg.page,children:t(n)}))})},xg={surface:`_surface_1vgoa_1`},Sg=({children:e})=>(0,y.jsx)(`div`,{className:xg.surface,children:e});function Cg({chainIds:e,chains:t}){return Object.fromEntries(e.map(e=>[e,t?.[e]?.denoms??{}]))}function wg(e,t){if(!e)return;if(e[t])return e[t];let n=H(t),r=Object.keys(e).find(e=>H(e)===n);return r?e[r]:void 0}function Tg(){let e=rn(),{data:t,error:n}=(0,u.useQuery)({queryKey:nn.chains.queryKey,queryFn:()=>e.get(`v2/info/chains`).json(),select:({chains:e})=>e.filter(({chain_type:e,bech32_prefix:t})=>e===`evm`||e===`cosmos`&&t===`init`),staleTime:z.MINUTE});return{chains:t??[],error:n}}function Eg(){let e=rn(),t=Sa(),n=U(),{chains:r,error:i}=Tg(),a=(0,g.useMemo)(()=>r.map(({chain_id:e})=>e),[r]),{data:o,error:s,isLoading:c}=(0,u.useQuery)({queryKey:nn.allBalances(a,[t,n]).queryKey,queryFn:()=>{let i=Object.fromEntries(r.map(e=>[e.chain_id,{address:e.chain_type===`evm`?t:n,denoms:[]}]));return e.post(`v2/info/balances`,{json:{chains:i}}).json()},select:({chains:e})=>Cg({chainIds:a,chains:e}),enabled:!!n&&a.length>0,staleTime:z.SECOND});return{data:o,error:s,isLoading:c,chainsError:i}}var Dg={deposit:{mode:`deposit`,label:`Deposit`,local:{denomKey:`dstDenom`,chainIdKey:`dstChainId`},external:{denomKey:`srcDenom`,chainIdKey:`srcChainId`}},withdraw:{mode:`withdraw`,label:`Withdraw`,local:{denomKey:`srcDenom`,chainIdKey:`srcChainId`},external:{denomKey:`dstDenom`,chainIdKey:`dstChainId`}}};function Og(e){return Dg[e]}var kg=(0,g.createContext)(null);function Ag(){let e=(0,g.useContext)(kg);if(!e)throw Error(`useTransferFlow must be used within TransferFlow`);return e}function jg(){let{mode:e}=Ag();return Og(e)}function Mg(){return(0,F.useFormContext)()}function Ng({mode:e,initialAsset:t,localOptions:n}){let{local:r}=Og(e),i={page:`select-local`,quantity:``,srcDenom:``,srcChainId:``,dstDenom:``,dstChainId:``},a=t??(n.length===1?n[0]:void 0);return a&&(i[r.denomKey]=a.denom,i[r.chainIdKey]=a.chainId,i.page=e===`deposit`?`select-external`:`fields`),i}var Pg=`data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23242629'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%23585F67'/%3e%3cpath%20d='M47.7916%2037.0445C47.7916%2035.2783%2049.2313%2033.8464%2051.0071%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.0071C49.2313%2082.8837%2047.7916%2081.4519%2047.7916%2079.6854V37.0445Z'%20fill='%23585F67'/%3e%3cpath%20d='M91.7372%2056.2323C91.7372%2052.6999%2094.6166%2049.8362%2098.1681%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1681C94.6166%2066.8927%2091.7372%2064.0289%2091.7372%2060.4965V56.2323Z'%20fill='%23242629'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.24%2061.5626C97.4642%2061.5626%2096.0245%2060.1308%2096.0245%2058.3646C96.0245%2056.5984%2097.4642%2055.1665%2099.24%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%23585F67'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%232F3337'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23757C82'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23757C82'/%3e%3c/svg%3e`,Fg=`data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e`;function Ig(e){return e.length===0?``:e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(`, `)}, or ${e[e.length-1]}`}function Lg(e,t,n){let r=[...new Set(e)],i=[],a=[...n,t];for(let e of a)r.includes(e)&&!i.includes(e)&&i.push(e);let o=r.filter(e=>!i.includes(e)).sort((e,t)=>e.localeCompare(t));return[...i,...o]}function Rg(e,t,n){if(!e.length)return``;let r=Lg(e,t,n);return r.length===1&&r[0]===t?`from any app`:`using ${Ig(r)} from any app`}function zg({localSymbol:e,externalSourceSymbols:t,externalChainNames:n,appchainSourceSymbols:r}){let i=`No ${e} available to deposit.`,a=n.length>0,o=Ig(n),s=[...new Set(t)],c=Ig(s),l=Rg(r,e,s),u=!!l,d=s.length!==1||s[0]!==e;return a&&u?{title:i,description:`You can deposit ${e} ${d?`using ${c} from ${o}`:`from ${o}`}, or ${l}.`}:a?d?{title:i,description:`You can deposit ${e} using ${c} from ${o}.`}:{title:i,description:`You can deposit ${e} from ${o}.`}:u?{title:i,description:`You can deposit ${e} ${l}.`}:{title:i,description:`No deposit sources are currently available.`}}var Bg=`1`,Vg=`0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`,Hg=`0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a`,Ug={[bt]:{externalSourceSymbols:[`USDC`,`AUSD`],extraExternalOptions:[{chainId:Bg,denom:Vg},{chainId:Bg,denom:Hg}],extraInitiaSourceSymbols:[`USDC`],externalChainListSource:`extra-options`}};function Wg(e,t,n){return e.chainId===t&&H(e.denom)===H(n)}function Gg(e){return Ug[e]}function Kg(e){return e.pretty_name||e.chain_name}function qg(e){return e.chain_type!==`cosmos`||e.bech32_prefix===`init`}var Jg={data:[],isLoading:!1,balancesError:null,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:``};function Yg(){let{local:e}=jg(),t=iu(),{watch:n}=Mg(),r=n(),i=r[e.chainIdKey],a=r[e.denomKey];return t.find(({denom:e,chain_id:t})=>H(a)===H(e)&&t===i)||null}function Xg(){let{external:e}=jg(),t=iu(),{watch:n}=Mg(),r=n(),i=r[e.chainIdKey],a=r[e.denomKey];return t.find(({denom:e,chain_id:t})=>H(a)===H(e)&&t===i)||null}function Zg(){let{mode:e}=Ag(),t=iu(),n=ql(),r=Jl(),i=Ul(),{data:a,error:o,chainsError:s,isLoading:c}=Eg(),{remoteOptions:l=[]}=Jt(),u=Yg(),d=o??s??null;if(!u)return{...Jg,isLoading:c,balancesError:d};let f=Gg(u.symbol),p=f?.externalSourceSymbols??[u.symbol],m=l.length>0,h=f?.extraExternalOptions??[],g=f?.extraInitiaSourceSymbols??[],_=f?.externalChainListSource??`supported-assets`,v=new Map(n.map(e=>[e.chain_id,e])),y=t.filter(({symbol:e,denom:t,chain_id:n})=>{if(m)return l.some(e=>Wg(e,n,t));let r=h.some(e=>Wg(e,n,t)),a=v.get(n),o=!!a&&i(a.chain_id)&&g.includes(e),s=r||o;return e===u.symbol||s}).map(e=>{if(e.hidden||e.chain_id===u.chain_id)return null;let t=r(e.chain_id);return!t||!qg(t)?null:{asset:e,chain:t,balance:a?.[t.chain_id]?.[e.denom]}}).filter(e=>e!==null),b=y.filter(({balance:t})=>e!==`deposit`||!!t&&Number(t.amount)>0),x=new Map;if(_===`extra-options`)for(let{chainId:e}of h){let t=v.get(e);t&&qg(t)&&(i(t.chain_id)||x.set(t.chain_id,t))}else for(let{chain:e}of b)i(e.chain_id)||x.set(e.chain_id,e);return{data:b,isLoading:c,balancesError:d,supportedExternalChains:Array.from(x.values()).sort((e,t)=>Kg(e).localeCompare(Kg(t))),appchainSourceSymbols:[...new Set(y.filter(({chain:e})=>Wl(e,i)).map(({asset:e})=>e.symbol))],externalSourceSymbols:p,localSymbol:u.symbol}}var Qg={container:`_container_15pv2_1`,"empty-icon":`_empty-icon_15pv2_5`,empty:`_empty_15pv2_5`,"empty-description":`_empty-description_15pv2_20`,list:`_list_15pv2_32`},$g=()=>{let{mode:e,onExit:t}=Ag(),{external:n}=jg(),{data:r,isLoading:i,balancesError:a,supportedExternalChains:o,appchainSourceSymbols:s,externalSourceSymbols:c,localSymbol:l}=Zg(),{setValue:u,watch:f}=Mg(),p=Yg(),{data:m}=an(),{theme:h}=R(),_=f(),v=_[n.denomKey],b=_[n.chainIdKey],x=!i&&r.length===1?`${r[0].chain.chain_id}:${r[0].asset.denom}`:``;function S(t,r){u(n.denomKey,t),u(n.chainIdKey,r),e===`deposit`&&u(`quantity`,``),u(`page`,`fields`)}let C=(0,g.useEffectEvent)(()=>{if(!x)return;let[{asset:e,chain:t}]=r;if(v===e.denom&&b===t.chain_id){u(`page`,`fields`);return}S(e.denom,t.chain_id)});(0,g.useEffect)(()=>{C()},[x]);let w=!!(v&&b),T=w||!!t||m.length>1||e!==`deposit`;function E(){e===`withdraw`||w?u(`page`,`fields`):t?t():u(`page`,`select-local`)}let D=T?E:void 0;if(!p)return(0,y.jsx)(`div`,{className:Qg.container,children:(0,y.jsx)(Am,{title:`No available assets`,onBack:D,children:(0,y.jsx)($h,{children:`No assets found`})})});if(e===`deposit`&&a&&!r.length)return(0,y.jsx)(`div`,{className:Qg.container,children:(0,y.jsx)(Am,{title:`Deposit ${p.symbol} via wallet`,onBack:D,children:(0,y.jsx)($h,{error:!0,children:`Failed to load balances`})})});if(!i&&!r.length){let t=zg({localSymbol:l,externalSourceSymbols:c,externalChainNames:o.map(e=>e.pretty_name||e.chain_name).filter(e=>!!e),appchainSourceSymbols:s}),n=e===`withdraw`?`No supported destinations to withdraw ${p.symbol}.`:t.title;return(0,y.jsx)(`div`,{className:Qg.container,children:(0,y.jsxs)(Am,{title:`No available assets`,onBack:D,children:[(0,y.jsx)(`img`,{src:h===`dark`?Pg:Fg,alt:`No assets`,className:Qg[`empty-icon`]}),(0,y.jsx)(`p`,{className:Qg.empty,children:n}),e===`deposit`&&(0,y.jsx)(`p`,{className:Qg[`empty-description`],children:t.description})]})})}return(0,y.jsx)(`div`,{className:Qg.container,children:(0,y.jsx)(Am,{title:e===`withdraw`?`Select destination`:`Deposit ${p.symbol} via wallet`,onBack:D,children:(0,y.jsxs)(Am.List,{className:Qg.list,maxHeight:`min(70vh, 90vh - 81px)`,children:[i&&Array.from({length:5}).map((e,t)=>(0,y.jsx)(_g.Skeleton,{},t)),!i&&r.sort(({balance:e},{balance:t})=>Number(t?.value_usd??0)-Number(e?.value_usd??0)).map(({asset:e,chain:t,balance:n})=>{let r=v===e.denom&&b===t.chain_id;return(0,y.jsx)(_g,{assetLogoUrl:e.logo_uri,assetSymbol:e.symbol,chainLogoUrl:t.logo_uri||``,chainName:t.chain_name,chainPrettyName:t.pretty_name,isActive:r,onClick:()=>S(e.denom,t.chain_id),balanceLabel:n?(0,d.formatAmount)(n.amount,{decimals:n.decimals||6}):void 0,valueLabel:n?ll(n.value_usd,n.price):void 0},`${e.chain_id}-${e.denom}`)})]})})})},e_={list:`_list_vbla8_3`,asset:`_asset_vbla8_9`,imgPlaceholder:`_imgPlaceholder_vbla8_34`},t_=({assets:e,onSelect:t,isBusy:n})=>(0,y.jsx)(`div`,{className:e_.list,"aria-busy":n,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:e_.asset,onClick:()=>t(e),disabled:n,children:[e.logoUrl?(0,y.jsx)(`img`,{src:e.logoUrl,alt:e.symbol}):(0,y.jsx)(`div`,{className:e_.imgPlaceholder,"aria-hidden":`true`}),e.symbol]},`${e.denom}-${e.chainId}`))}),n_=()=>{let{mode:e}=Ag(),{local:t,external:n}=jg(),{setValue:r}=Mg(),{data:i}=an(),[a,o]=(0,g.useTransition)(),s=(i,a)=>{r(t.denomKey,i),r(t.chainIdKey,a),r(`quantity`,``),r(n.denomKey,``),r(n.chainIdKey,``),o(()=>{r(`page`,e===`withdraw`?`fields`:`select-external`)})};return i.length?(0,y.jsx)(Am,{title:e===`withdraw`?`Select an asset to withdraw`:`Select an asset to receive`,children:(0,y.jsx)(t_,{assets:i.map(({denom:e,chain_id:t,symbol:n,logo_uri:r})=>({denom:e,chainId:t,symbol:n,logoUrl:r})),onSelect:({denom:e,chainId:t})=>s(e,t),isBusy:a})}):(0,y.jsx)(`div`,{children:`No assets found`})},r_={links:`_links_xmk1x_1`,link:`_link_xmk1x_1`,divider:`_divider_xmk1x_25`},i_=({explorerUrl:e,onHistoryClick:t})=>!e&&!t?null:(0,y.jsxs)(`div`,{className:r_.links,children:[e&&(0,y.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:`View transaction`}),e&&t&&(0,y.jsx)(`span`,{className:r_.divider,"aria-hidden":`true`,children:`|`}),t&&(0,y.jsx)(`button`,{type:`button`,className:r_.link,onClick:t,children:`Go to history`})]}),a_=`data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M29%202.71875C43.5%202.71875%2055.2812%2014.5%2055.2812%2029C55.2812%2043.5%2043.5%2055.2812%2029%2055.2812C14.5%2055.2812%202.71875%2043.5%202.71875%2029C2.71875%2014.5%2014.5%202.71875%2029%202.71875ZM29%206.34375C16.4937%206.34375%206.34375%2016.4937%206.34375%2029C6.34375%2041.5062%2016.4937%2051.6562%2029%2051.6562C41.5062%2051.6562%2051.6562%2041.5062%2051.6562%2029C51.6562%2016.4937%2041.5062%206.34375%2029%206.34375Z'%20fill='%23F85454'/%3e%3cpath%20d='M36.1616%2018.7623C37.0109%2017.9129%2038.3885%2017.9129%2039.2378%2018.7623C40.087%2019.6117%2040.0871%2020.9893%2039.2378%2021.8386L32.0763%2029.0001L39.2378%2036.1616L39.3865%2036.3279C40.083%2037.1822%2040.034%2038.4417%2039.2378%2039.2378C38.4417%2040.034%2037.1822%2040.083%2036.3279%2039.3865L36.1616%2039.2378L29.0001%2032.0763L21.8386%2039.2378C20.9893%2040.0871%2019.6117%2040.087%2018.7623%2039.2378C17.9129%2038.3885%2017.9129%2037.0109%2018.7623%2036.1616L25.9238%2029.0001L18.7623%2021.8386C17.9129%2020.9892%2017.9129%2019.6116%2018.7623%2018.7623C19.6116%2017.9129%2020.9892%2017.9129%2021.8386%2018.7623L29.0001%2025.9238L36.1616%2018.7623Z'%20fill='%23F85454'/%3e%3c/svg%3e`,o_=`data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M36%209.71875C50.5%209.71875%2062.2812%2021.5%2062.2812%2036C62.2812%2050.5%2050.5%2062.2812%2036%2062.2812C21.5%2062.2812%209.71875%2050.5%209.71875%2036C9.71875%2021.5%2021.5%209.71875%2036%209.71875ZM36%2013.3438C23.4937%2013.3438%2013.3438%2023.4937%2013.3438%2036C13.3438%2048.5062%2023.4937%2058.6562%2036%2058.6562C48.5062%2058.6562%2058.6562%2048.5062%2058.6562%2036C58.6562%2023.4937%2048.5062%2013.3438%2036%2013.3438Z'%20fill='%23D1242F'/%3e%3cpath%20d='M43.1616%2025.7623C44.0109%2024.9129%2045.3885%2024.9129%2046.2378%2025.7623C47.087%2026.6117%2047.0871%2027.9893%2046.2378%2028.8386L39.0763%2036.0001L46.2378%2043.1616L46.3865%2043.3279C47.083%2044.1822%2047.034%2045.4417%2046.2378%2046.2378C45.4417%2047.034%2044.1822%2047.083%2043.3279%2046.3865L43.1616%2046.2378L36.0001%2039.0763L28.8386%2046.2378C27.9893%2047.0871%2026.6117%2047.087%2025.7623%2046.2378C24.9129%2045.3885%2024.9129%2044.0109%2025.7623%2043.1616L32.9238%2036.0001L25.7623%2028.8386C24.9129%2027.9892%2024.9129%2026.6116%2025.7623%2025.7623C26.6116%2024.9129%2027.9892%2024.9129%2028.8386%2025.7623L36.0001%2032.9238L43.1616%2025.7623Z'%20fill='%23D1242F'/%3e%3c/svg%3e`,s_={container:`_container_1md33_1`,subtitle:`_subtitle_1md33_8`,errorIcon:`_errorIcon_1md33_24`,error:`_error_1md33_24`};function c_(e){if(!e)return`pending`;let t=e.state;return t===`STATE_COMPLETED_SUCCESS`?`success`:t===`STATE_ABANDONED`||t===`STATE_COMPLETED_ERROR`||t===`STATE_PENDING_ERROR`?`failed`:`pending`}function l_(){let{mode:e}=Ag(),{closeModal:t}=Cr(),{theme:n}=R(),{watch:r}=Mg(),{result:i}=r(),{openDrawer:a}=Sr();if(!i)throw Error(`Transfer is completed but result is missing`);let o=!i.success,s=o?``:i.txhash,c=o?``:i.chainId,l=o?0:i.timestamp??0,{route:u,values:d}=i,{srcDenom:f,srcChainId:p,quantity:m}=d,h=bm().symbol(p,f),g=e===`deposit`?`Deposit`:`Withdraw`,{data:_}=sf({chainId:c,txHash:s,tracked:!1,timestamp:l,route:u,values:d}),{data:v}=cf({chainId:c,txHash:s,tracked:!!_,timestamp:l,route:u,values:d}),b=c_(v),x=n===`dark`?a_:o_,S=`https://assets.initia.xyz/videos/Loading${n===`dark`?`Dark`:`Light`}.mp4`,C=`https://assets.initia.xyz/videos/Completed${n===`dark`?`Dark`:`Light`}.mp4`;if(o)return(0,y.jsx)(Am,{title:`${g} failed`,children:(0,y.jsxs)(`div`,{className:s_.container,children:[(0,y.jsx)(`img`,{src:x,alt:`Failed`,className:s_.errorIcon}),(0,y.jsx)(`p`,{className:s_.error,children:i.error}),(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`})]})});let w=Pu(u.estimated_route_duration_seconds),T=new URLSearchParams({tx_hash:s,chain_id:c}),E=new URL(`?${T.toString()}`,`https://explorer.skip.build`),D=()=>(0,y.jsx)(i_,{explorerUrl:E.toString(),onHistoryClick:()=>{t(),a(`/bridge/history`)}});return(0,y.jsx)(Am,{title:(()=>{switch(b){case`pending`:return`${e===`deposit`?`Depositing`:`Withdrawing`} ${m} ${h}`;case`success`:return`${g} complete`;case`failed`:return`${g} failed`}})(),children:(0,y.jsxs)(`div`,{className:s_.container,children:[b===`pending`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`video`,{src:S,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:`72px`,height:`72px`,marginBottom:`12px`}}),(0,y.jsxs)(`p`,{className:s_.subtitle,children:[`Estimated time: `,(0,y.jsx)(`span`,{children:w})]}),D(),(0,y.jsx)(`p`,{className:s_.subtitle,children:`Your transaction will continue even if you close this`})]}),b===`success`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`video`,{src:C,autoPlay:!0,muted:!0,playsInline:!0,style:{width:`72px`,height:`72px`},onTimeUpdate:e=>{let t=e.currentTarget;t.duration-t.currentTime<.1&&t.pause()}}),D(),(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`})]}),b===`failed`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`img`,{src:x,alt:`Failed`,className:s_.errorIcon}),(0,y.jsx)(`p`,{className:s_.error,children:`Your transaction could not be completed`}),(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`})]})]})})}var u_=(0,m.createQueryKeys)(`interwovenkit:tx-gas-estimate`,{estimate:e=>[e]}),d_=({tx:e,children:t})=>{let{values:n}=Zd(),{srcChainId:r}=n,i=U(),a=zr(),o=Br(),s=Xr(),{data:c,isLoading:l,isFetching:d}=(0,u.useQuery)({queryKey:u_.estimate({tx:e,address:i,chainId:r}).queryKey,queryFn:async()=>{if(!(`cosmos_tx`in e)||!e.cosmos_tx.msgs)return null;try{let t=qd(e.cosmos_tx.msgs,{converters:a,fromAmino:o.fromAmino.bind(o)});return{estimatedGas:await(await s(r)).simulate(i,t,``),messages:t}}catch{return null}},enabled:`cosmos_tx`in e&&!!i&&!!r});return`cosmos_tx`in e&&!c&&l?(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{loading:`Estimating gas...`,disabled:!0,fullWidth:!0})}):(0,y.jsx)(y.Fragment,{children:t(c?.estimatedGas??null,{isEstimatingGas:`cosmos_tx`in e&&(l||d)})})};function f_({hasBalancesSnapshot:e,hasBalanceQueryError:t,isBalancesLoading:n}){if(!e){if(n)return`loading`;if(t)return`error`}}function p_({hasBalancesSnapshot:e,balance:t}){if(e)return t??`0`}function m_(e){if(!e)return null;let t=(0,f.default)(e);return!t.isFinite()||t.lt(0)?null:t}function h_({balance:e,requiredAmount:t}){if(t===`0`)return!0;let n=m_(e??`0`),r=m_(t);return!n||!r?!1:n.gte(r)}function g_({sourceDenom:e,feeDetailsByDenom:t}){let n=t.get(e);if(!(!n||n.isSufficient)){for(let[n,r]of t)if(n!==e&&r.isSufficient)return;if((0,f.default)(n.balance||0).gte(n.fee||0))return`Make sure to leave enough for transaction fee`}}function __({feeDenom:e,sourceDenom:t,feeWarning:n,hasSourceBalance:r,isFeeBalanceSufficient:i}){if(!r)return{error:`Insufficient balance`};let a=e===t?n:void 0;return a?{warning:a}:i?{}:{error:`Insufficient balance`}}var v_={container:`_container_1qkz8_1`,token:`_token_1qkz8_11`},y_=({renderFee:e})=>{let{route:t}=Jt(),{values:n}=Zd(),{dstDenom:r,dstChainId:i}=n,a=iu().find(({denom:e,chain_id:t})=>H(e)===H(r)&&t===i),o=U(),s=Ac(),c=t&&t.estimated_route_duration_seconds>60;if(!t||!a)return null;let l=Fu(t.amount_out,n.slippagePercent);return(0,y.jsxs)(`div`,{className:v_.container,children:[(0,y.jsxs)(Jp,{title:`Transaction details`,children:[t.does_swap&&(0,y.jsxs)(Xp,{label:`Slippage`,children:[n.slippagePercent,`%`]}),!!t.estimated_fees?.length&&(0,y.jsx)(Xp,{label:`Bridge fee`,children:Iu(t.estimated_fees)}),e&&(0,y.jsx)(Xp,{label:`Tx fee`,children:e()}),o&&(0,y.jsxs)(Xp,{label:`Receiving address`,children:[(0,y.jsx)(`img`,{src:s,alt:`Wallet`,height:12,width:12}),` `,(0,d.truncate)(o)]}),t.does_swap&&(0,y.jsxs)(Xp,{label:`Minimum received`,children:[(0,y.jsx)(`img`,{src:a.logo_uri,alt:a.symbol,className:v_.token}),` `,(0,d.formatAmount)(l,{decimals:a.decimals}),` `,a.symbol]})]}),(0,y.jsx)(Xp,{label:`Estimated time`,valueStyle:c?{color:`var(--warning)`}:void 0,children:Pu(t.estimated_route_duration_seconds)}),(0,y.jsxs)(Xp,{label:`Estimated received`,emphasized:!0,children:[(0,y.jsx)(`img`,{src:a.logo_uri,alt:a.symbol,className:v_.token}),` `,(0,d.formatAmount)(t.amount_out,{decimals:a.decimals}),` `,a.symbol]})]})},b_={trigger:`_trigger_1c7d7_1`,item:`_item_1c7d7_5`,itemText:`_itemText_1c7d7_13`};function x_(e){return!e.isFetchingMessages&&!e.messageRefreshError}function S_(e,t,n){return x_(n)?(0,y.jsx)(Hf,{tx:e,children:t}):t}function C_({feeDetailsByDenom:e,feeOptions:t,lastUsedFeeDenom:n,preferredFeeDenom:r}){if(r&&e.get(r)?.isSufficient)return r;if(n&&e.get(n)?.isSufficient)return n;for(let n of t){let[{denom:t}]=n.amount;if(e.get(t)?.isSufficient)return t}return t[0]?.amount[0].denom}var w_=({tx:e,gas:t,confirmMessage:n,onCompleted:r,messageRefreshError:i,isRouteTransitioning:a,isFetchingMessages:o,isEstimatingGas:s})=>{let{values:c}=Zd(),{srcChainId:l,srcDenom:u,quantity:p}=c,m=iu().find(({denom:e,chain_id:t})=>e===u&&t===l),h=et(l),_=Lt(h),v=Fi(h),b=Ii(h),x=ft(h),S=t==null?[]:v.map(({amount:e,denom:n})=>(0,j.calculateFee)(Math.ceil(t*Pe),j.GasPrice.fromString(e+n))),C=new Map(S.map(e=>{let[{denom:t}]=e.amount;return[t,e]})),w=new Map(_.map(({denom:e,amount:t})=>[e,t])),T=m?(en(p)??(0,f.default)(0)).times((0,f.default)(10).pow(m.decimals)).toFixed(0):`0`,E=new Map(S.map(e=>{let[{amount:t,denom:n}]=e.amount,r=w.get(n)||`0`,i=m&&u===n?T:`0`,a=(0,f.default)(t||0).plus(i),{symbol:o,decimals:s}=x(n);return[n,{symbol:o,decimals:s,spend:(0,f.default)(i).gt(0)?i:null,fee:t,total:a.toFixed(),balance:r,isSufficient:(0,f.default)(r).gte(a)}]})),[D,ee]=(0,g.useState)(null),O={isRouteTransitioning:a,isFetchingMessages:o,isEstimatingGas:s,messageRefreshError:i},k=C_({feeDetailsByDenom:E,feeOptions:S,lastUsedFeeDenom:b,preferredFeeDenom:D}),A=k?C.get(k):void 0,te=k?E.get(k):null,ne=__({feeDenom:k,sourceDenom:u,feeWarning:g_({sourceDenom:u,feeDetailsByDenom:E}),hasSourceBalance:h_({balance:w.get(u)||`0`,requiredAmount:T}),isFeeBalanceSufficient:te?.isSufficient??!0}),M=(0,y.jsx)(kf,{tx:e,fee:A,onCompleted:r,confirmMessage:n,error:ne.error,warning:ne.warning,...O}),re=(e,t)=>{if((0,d.formatAmount)(e,{decimals:t})===`0.000000`)return 8},ie=e=>{let[{amount:t,denom:n}]=e.amount;if((0,f.default)(t||0).isZero())return`0`;let{symbol:r,decimals:i}=x(n);return`${(0,d.formatAmount)(t,{decimals:i,dp:re(t,i)})} ${r}`};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(y_,{renderFee:S.length>0?()=>{if(S.length===0)return null;if(S.length===1)return(0,y.jsx)(`span`,{className:`monospace`,children:ie(S[0])});if(!A||!k)return null;let e=S.map(e=>{let[{denom:t}]=e.amount,{symbol:n}=x(t);return{value:t,label:ie(e),triggerLabel:n}}),[{amount:t,denom:n}]=A.amount,{decimals:r}=x(n);return(0,y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.formatAmount)(t,{decimals:r,dp:re(t,r)})}),(0,y.jsx)(Yc,{options:e,value:k,onChange:ee,classNames:b_})]})}:void 0}),S_(e,M,O)]})},T_=({tx:e,gas:t,messageRefreshError:n,isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:a})=>{let{mode:o}=Ag(),{setValue:s}=Mg(),c={isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:a,messageRefreshError:n},l=e=>{s(`page`,`completed`),s(`result`,e)},u=o===`withdraw`?`Withdraw`:`Deposit`,d=(0,y.jsx)(kf,{tx:e,fee:void 0,onCompleted:l,confirmMessage:u,...c});return`cosmos_tx`in e?(0,y.jsx)(w_,{tx:e,gas:t,onCompleted:l,confirmMessage:u,...c}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(y_,{}),S_(e,d,c)]})};function E_(e,t){return e?(0,d.InitiaAddress)(e).hex:t}function D_({currentState:e,route:t,quoteVerifiedAt:n,hexAddress:r,values:i}){return{...e,route:t,quoteVerifiedAt:n,values:{sender:r,recipient:E_(e.recipientAddress,r),slippagePercent:`0.1`,...i}}}function O_(e){return{recipient:e.values?.recipient,sender:e.values?.sender}}function k_({currentState:e,nextState:t}){if(e.route!==t.route||e.quoteVerifiedAt!==t.quoteVerifiedAt)return!0;let n=O_(e),r=O_(t);return n.sender!==r.sender||n.recipient!==r.recipient}function A_({mode:e,hasSingleExternalAssetOption:t,canExit:n}){if(e===`deposit`&&t&&n)return{type:`exit`};let r=e===`withdraw`||t;return{type:`page`,page:r?`select-local`:`select-external`,clearLocal:r}}var j_={container:`_container_1wc2a_1`,title:`_title_1wc2a_6`,divider:`_divider_1wc2a_14`,label:`_label_1wc2a_18`,asset:`_asset_1wc2a_25`,assetIcon:`_assetIcon_1wc2a_43`,chainIcon:`_chainIcon_1wc2a_55`,assetName:`_assetName_1wc2a_68`,chevron:`_chevron_1wc2a_80`,input:`_input_1wc2a_84`,balanceContainer:`_balanceContainer_1wc2a_96`,value:`_value_1wc2a_104`,maxButton:`_maxButton_1wc2a_114`};function M_({disabledMessage:e,routeForState:t,routeError:n,isNoRouteError:r,isServerError:i}){return e?`disabled`:t?`ready`:n?r?`no-route`:i?`server-error`:`refresh-failed`:`loading`}function N_({hasRouteState:e,routeStatus:t}){return e&&(t===`ready`||t===`loading`)}function P_({routeStatus:e,disabledMessage:t,isRouteSynced:n}){if(e===`disabled`)return t;if(e===`loading`||e===`ready`&&!n)return`Fetching route...`;if(e===`no-route`)return`No route found`;if(e===`server-error`)return`Server error`;if(e===`refresh-failed`)return`Failed to refresh route`}var F_=typeof window>`u`?g.useEffect:g.useLayoutEffect,I_=()=>{let{mode:e,onExit:t}=Ag(),n=jg(),r=Xt(),i=Jt(),{data:a}=an(),o=Jl(),{data:s,error:c,chainsError:l,isLoading:u}=Eg(),p=Sa(),{watch:m,setValue:_,getValues:v}=Mg(),b=m(),{srcChainId:x,srcDenom:S,quantity:C=``}=b,{recipientAddress:w,route:T}=i,E=b[n.external.denomKey],D=b[n.external.chainIdKey],ee=Yg(),O=Xg(),{data:k,isLoading:A}=Zg(),j=!A&&k.length===1,te=e===`withdraw`&&!A&&k.length>0&&new Set(k.map(({chain:e})=>e.chain_id)).size===1,ne=(0,g.useMemo)(()=>A||!k.length?null:j?k[0]:te?k.reduce((e,t)=>{let n=Number(e.balance?.value_usd??0);return Number(t.balance?.value_usd??0)>n?t:e},k[0]):null,[k,j,te,A]),M=ne?`${ne.chain.chain_id}:${ne.asset.denom}`:``,re=D?o(D):null,ie=wg(s?.[x],S),ae=ie?.amount,oe=ie?.price,se=(0,f.default)(oe||0).times(en(C)??0),[ce]=(0,ue.useDebounceValue)(C,300),le=e===`withdraw`?ee:O,N=f_({hasBalancesSnapshot:s!==void 0,hasBalanceQueryError:!!(c||l),isBalancesLoading:u}),de=p_({hasBalancesSnapshot:s!==void 0,balance:ae}),P=(0,g.useMemo)(()=>{if(e===`deposit`&&!O)return`Select asset`;let t=en(C);if(!t||t.lte(0))return`Enter amount`;if(e===`withdraw`&&!O)return`Select destination`;if(N===`loading`)return`Loading balances...`;if(N===`error`)return`Failed to load balances`;if(de!==void 0){let e=(0,d.fromBaseUnit)(de,{decimals:le?.decimals||6});if(t.gt(e||0))return`Insufficient balance`}},[le,de,N,O,e,C]),{data:F,error:fe,dataUpdatedAt:pe}=Ru(ce,{disabled:(0,g.useMemo)(()=>{if(e===`deposit`&&!O)return!0;let t=en(C);if(!t||t.lte(0)||e===`withdraw`&&!O||N===`error`)return!0;if(de!==void 0){let e=(0,d.fromBaseUnit)(de,{decimals:le?.decimals||6});if(t.gt(e||0))return!0}return!1},[le,de,N,O,e,C])}),me=fe instanceof h.HTTPError&&fe.response.status===400,he=!P&&!me?F:void 0,ge=he&&pe>0?pe:void 0,L=M_({disabledMessage:P,routeForState:he,routeError:fe,isNoRouteError:me,isServerError:fe instanceof h.HTTPError&&fe.response.status===500}),_e=L===`ready`&&i.route===he,ve=L===`loading`||L===`ready`&&!_e,ye=N_({hasRouteState:!!i.route,routeStatus:L}),be=P_({routeStatus:L,disabledMessage:P,isRouteSynced:_e});F_(()=>{let e=D_({currentState:i,route:he,quoteVerifiedAt:ge,hexAddress:p,values:v()});k_({currentState:i,nextState:e})&&r(0,e)},[T,v,p,r,ge,w,he]);let xe=(0,g.useEffectEvent)(()=>{if(!ne||E&&D)return;let{asset:t,chain:r}=ne;_(n.external.denomKey,t.denom),_(n.external.chainIdKey,r.chain_id),e===`deposit`&&_(`quantity`,``)});if((0,g.useEffect)(()=>{xe()},[M]),!ee||e===`deposit`&&!O)return null;let Se=le?.decimals||6,Ce=e===`withdraw`?`Select chain`:`Select asset`,we=()=>{let r=A_({mode:e,hasSingleExternalAssetOption:j,canExit:!!t});if(r.type===`exit`){t?.();return}_(`quantity`,``),_(n.external.denomKey,``),_(n.external.chainIdKey,``),r.clearLocal&&(_(n.local.denomKey,``),_(n.local.chainIdKey,``)),_(`page`,r.page)},Te=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:j_.label,children:e===`withdraw`?`Destination`:`From`}),(0,y.jsxs)(`button`,{className:j_.asset,disabled:j,onClick:()=>_(`page`,`select-external`),children:[(0,y.jsx)(`div`,{className:j_.assetIcon,children:O?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`img`,{src:O.logo_uri,alt:O.symbol}),(0,y.jsx)(`img`,{src:re?.logo_uri||``,alt:re?.pretty_name,className:j_.chainIcon})]}):e===`withdraw`&&(0,y.jsx)(`div`,{className:j_.chainIcon})}),(0,y.jsx)(`p`,{className:j_.assetName,children:O?(0,y.jsxs)(y.Fragment,{children:[O.symbol,(0,y.jsx)(`br`,{}),(0,y.jsxs)(`span`,{children:[`on `,re?.pretty_name]})]}):Ce}),!j&&(0,y.jsx)(I.IconChevronDown,{className:j_.chevron,size:16})]})]}),Ee=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:j_.label,children:`Amount`}),(0,y.jsx)(Eu,{balance:de,decimals:Se,className:j_.input}),de!==void 0&&(0,y.jsxs)(`div`,{className:j_.balanceContainer,children:[(0,y.jsx)(`p`,{className:j_.value,children:C?ll(se.toString(),oe):`$-`}),(0,y.jsxs)(`button`,{className:j_.maxButton,onClick:()=>{let e=(0,d.fromBaseUnit)(de,{decimals:Se});en(C)?.eq(e||0)||_(`quantity`,e)},children:[(0,y.jsx)(I.IconWallet,{size:16}),` `,(0,d.formatAmount)(de,{decimals:Se}),` `,(0,y.jsx)(`span`,{children:`MAX`})]})]})]});return(0,y.jsxs)(`section`,{className:j_.container,"aria-label":`Transfer form`,children:[(t!==void 0||a.length>1)&&(0,y.jsx)(Om,{onClick:we}),(0,y.jsx)(`h3`,{className:j_.title,children:e===`deposit`?`Deposit ${ee.symbol} via wallet`:`${n.label} ${ee.symbol}`}),e===`withdraw`?(0,y.jsxs)(y.Fragment,{children:[Ee,(0,y.jsx)(`div`,{className:j_.divider}),Te]}):(0,y.jsxs)(y.Fragment,{children:[Te,(0,y.jsx)(`div`,{className:j_.divider}),Ee]}),(l||c)&&(0,y.jsx)($h,{error:!0,children:`Failed to load balances`}),ye?(0,y.jsx)(Rf,{children:e=>(0,y.jsx)(Zf,{children:t=>(0,y.jsx)(Xf,{addressList:e,signedOpHook:t,children:(e,{isFetchingMessages:t,messageRefreshError:n})=>(0,y.jsx)(d_,{tx:e,children:(r,{isEstimatingGas:i})=>(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{loading:`Estimating gas...`,disabled:!0,fullWidth:!0})}),children:(0,y.jsx)(T_,{tx:e,gas:r,isRouteTransitioning:ve,isFetchingMessages:t,isEstimatingGas:i,messageRefreshError:n})})})})})}):(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{type:`submit`,loading:ve&&`Fetching route...`,disabled:!0,fullWidth:!0,children:be})})]})},L_=({mode:e,initialAsset:t,onExit:n})=>{let{localOptions:r=[]}=Jt(),i=(0,F.useForm)({mode:`onChange`,defaultValues:Ng({mode:e,initialAsset:t,localOptions:r})});Eg();let a=(0,g.useMemo)(()=>({mode:e,onExit:n}),[e,n]),o=(0,y.jsx)(R_,{});return(0,y.jsx)(kg.Provider,{value:a,children:(0,y.jsx)(F.FormProvider,{...i,children:n?o:(0,y.jsx)(Bc,{children:o})})})},R_=()=>{let{watch:e}=Mg(),t=e(`page`),n=e=>{switch(e){case`select-local`:return(0,y.jsx)(n_,{});case`select-external`:return(0,y.jsx)($g,{});case`fields`:return(0,y.jsx)(I_,{});case`completed`:return(0,y.jsx)(l_,{})}};return(0,y.jsx)(bg,{page:t,renderPage:e=>(0,y.jsx)(Sg,{children:n(e)})})};function z_(e,t={},n){let r={page:`select-asset`,receiveSymbol:``,receiveDenom:``,receiveChainId:``,method:`address`,trackedDepositId:``,fiatId:n?.currency||t.fiatId||`usd`,fiatAmount:n?.amount??``,paymentMethodId:t.paymentMethodId||`creditcard`,providerId:``};if(e.length===1){let[{denom:t,chainId:n}]=e;r.receiveDenom=t,r.receiveChainId=n,r.page=`select-method`}return r}function B_(e){let{amountOut:t,sentAmount:n,dstDecimals:r,srcDecimals:i,receiveSymbol:a,sentSymbol:o}=e,s=t&&r!==void 0?(0,d.fromBaseUnit)(t,{decimals:r}):``;if(s&&(0,f.default)(s).gt(0))return`${(0,d.formatNumber)(s,{dp:6})} ${a}`;let c=n&&i!==void 0?(0,d.fromBaseUnit)(n,{decimals:i}):``;return c&&(0,f.default)(c).gt(0)?`${(0,d.formatNumber)(c,{dp:6})} ${o}`:`Your ${a}`}var V_={body:`_body_nhvhe_1`,heading:`_heading_nhvhe_11`,delayHeading:`_delayHeading_nhvhe_16`,successIcon:`_successIcon_nhvhe_23`,failIcon:`_failIcon_nhvhe_27`,confirming:`_confirming_nhvhe_31`,chainLogo:`_chainLogo_nhvhe_37`},H_=60*1e3,U_=()=>{let e=wm(),{closeModal:t}=Cr(),{openDrawer:n}=Sr(),{watch:r}=Cm(),i=U(),a=r(`receiveSymbol`),o=r(`receiveDenom`),s=r(`receiveChainId`),c=r(`method`),l=r(`trackedDepositId`),u=kn({denom:o,chainId:s,symbol:a}),{data:d,isError:f,error:p}=em({walletAddress:i,chainId:s,assetDenom:o}),{deposit:m,isError:h,error:_}=vm({depositAddress:d?.deposit_address??``,depositId:l}),v=_ instanceof pm||f&&!m,b=am(m),x=rm(b),[S,C]=(0,g.useState)(null),w=m?.status,T=!!w&&S===w;(0,g.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>C(w),H_);return()=>clearTimeout(e)},[w]);let E=bm(),D=ql(),ee=m?E.symbol(m.src_chain_id,m.src_denom):``,O=m?E.logoUrl(m.src_chain_id,m.src_denom):``,k=m?D.find(e=>e.chain_id===m.src_chain_id):void 0,A=m?k?.pretty_name??sn(m.src_chain_id):``,j=m?.bot_tx_explorer_url?(0,pe.default)(Sc(m.bot_tx_explorer_url)):``,te=En(m?.src_chain_id??``,m?.src_denom??``),ne=m?.required_min_amount&&te?cn(m.required_min_amount,te.src_decimals,ee):``,M=m&&te?dn(te,m.dst_chain_id,m.dst_denom):void 0,re=B_({amountOut:m?.amount_out,sentAmount:m?.amount,dstDecimals:M?.decimals,srcDecimals:te?.src_decimals,receiveSymbol:a,sentSymbol:ee}),ie=()=>{if(v)return`Deposit status`;switch(b){case`waiting`:return`Confirming your deposit…`;case`processing`:return`Transferring…`;case`completed`:return c===`onramp`?`Transaction complete`:`Transfer complete`;case`failed`:case`below_minimum`:return`Deposit status`}},ae=m&&(0,y.jsx)(tg,{steps:[{label:`You sent`,logoUrl:O,chainLogoUrl:k?.logo_uri??``,text:ee},{label:`You receive`,logoUrl:u.logoUrl,chainLogoUrl:u.chainLogoUrl,text:a}]}),oe=()=>T?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:V_.delayHeading,children:`This is taking a little longer`}),(0,y.jsxs)($h,{children:[`We hit a temporary delay and are retrying.`,(0,y.jsx)(`br`,{}),`Your funds are safe at your deposit address.`]})]}):m?b===`waiting`?(0,y.jsx)($h,{children:(0,y.jsxs)(`span`,{className:V_.confirming,children:[`Your deposit is confirming on`,(0,y.jsx)(K,{src:k?.logo_uri??``,width:16,height:16,className:V_.chainLogo,classNames:{placeholder:V_.chainLogo}}),A]})}):(0,y.jsx)($h,{children:`We're moving your funds to the destination chain now.`}):null;return(0,y.jsxs)(Am,{title:ie(),children:[(0,y.jsxs)(`div`,{className:V_.body,children:[(()=>{if(v)return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I.IconCloseCircleFilled,{size:48,className:V_.failIcon,"aria-hidden":`true`}),(0,y.jsx)(`p`,{className:V_.heading,children:`Couldn't track your deposit`}),(0,y.jsx)($h,{error:!0,children:(p??_)?.message??`Something went wrong while tracking your deposit.`})]});switch(b){case`completed`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I.IconCheckCircleFilled,{size:48,className:V_.successIcon,"aria-hidden":`true`}),(0,y.jsxs)($h,{children:[re,` was delivered to your wallet on `,u.chainName,`. It may take a moment to appear in your activity.`]}),(0,y.jsx)(i_,{explorerUrl:j,onHistoryClick:()=>n(`/activity`)})]});case`failed`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I.IconCloseCircleFilled,{size:48,className:V_.failIcon,"aria-hidden":`true`}),(0,y.jsx)(`p`,{className:V_.heading,children:`Deposit failed`}),(0,y.jsx)($h,{error:!0,children:`This deposit could not be completed. Your funds remain at the deposit address with no automatic refund.`}),(0,y.jsx)(i_,{explorerUrl:j})]});case`below_minimum`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I.IconCloseCircleFilled,{size:48,className:V_.failIcon,"aria-hidden":`true`}),(0,y.jsx)(`p`,{className:V_.heading,children:`Amount below minimum`}),(0,y.jsxs)($h,{error:!0,children:[ne?`Deposits below ${ne} can't be processed. `:``,`Your funds remain at the deposit address with no automatic refund.`]})]});case`waiting`:case`processing`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(tc,{size:40,color:`var(--success)`}),oe(),ae]})}})(),h&&!v&&!x&&(0,y.jsx)($h,{error:!0,children:`Connection lost. Retrying…`})]}),v||b===`failed`||b===`below_minimum`?(0,y.jsx)(ac,{children:(0,y.jsx)(G.Outline,{fullWidth:!0,onClick:t,children:`Close`})}):b===`completed`?(0,y.jsx)(ac,{children:c===`onramp`?(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`}):(0,y.jsx)(G.Outline,{fullWidth:!0,onClick:()=>e(`address`),children:`Make another transfer`})}):null]})},W_=()=>{let{setValue:e}=Cm(),t=wm(),{data:n,isLoading:r,error:i}=an(),[a,o]=(0,g.useTransition)();if(!n.length)throw Error(`openDeposit requires at least one denom`);let s=n.filter(({symbol:e})=>!e);if(s.length){if(i)throw i;if(r)return(0,y.jsx)($h,{children:`Loading...`});throw Error(`Asset metadata not found for ${s.map(({denom:e})=>e).join(`, `)}`)}return(0,y.jsx)(Am,{title:`Select an asset to receive`,children:(0,y.jsx)(t_,{assets:n.map(({denom:e,chain_id:t,symbol:n,logo_uri:r})=>({denom:e,chainId:t,symbol:n,logoUrl:r})),onSelect:({denom:n,chainId:r,symbol:i})=>{e(`receiveSymbol`,i),e(`receiveDenom`,n),e(`receiveChainId`,r),o(()=>{t(`select-method`)})},isBusy:a})})},G_=`Card or bank transfer`,K_=()=>{let{watch:e}=Cm(),t=e(`fiatId`),n=e(`receiveDenom`),r=e(`receiveChainId`),i=bh(t),a=qm(Dh(t,Ch(r,n)?.id??``).data??[]);return a===void 0||!i?G_:Ym(a,i.symbol)},q_={list:`_list_1j214_1`,section:`_section_1j214_7`,method:`_method_1j214_19`,icon:`_icon_1j214_43`,details:`_details_1j214_51`,title:`_title_1j214_59`,subtext:`_subtext_1j214_64`},J_=({sections:e,onSelect:t})=>(0,y.jsx)(`div`,{className:q_.list,children:e.map(e=>(0,y.jsxs)(g.Fragment,{children:[(0,y.jsx)(`p`,{className:q_.section,children:e.label}),e.methods.map(({id:e,title:n,subtext:r,Icon:i,iconUrl:a,disabled:o})=>(0,y.jsxs)(`button`,{type:`button`,className:q_.method,onClick:()=>t(e),disabled:o,children:[(0,y.jsx)(`span`,{className:q_.icon,children:a?(0,y.jsx)(K,{src:a,width:24,height:24,placeholder:(0,y.jsx)(i,{size:24})}):(0,y.jsx)(i,{size:24})}),(0,y.jsxs)(`span`,{className:q_.details,children:[(0,y.jsx)(`span`,{className:q_.title,children:n}),(0,y.jsx)(`span`,{className:q_.subtext,children:r})]})]},e))]},e.label))}),Y_=({availability:e,onrampUnavailableReason:t})=>{let n=Ut(),r=wm(),i=Em(),a=Sa(),o=Ac();vh();let{remoteOptions:s=[],recipientAddress:c}=Jt(),l=c||s.length>0?`Unavailable for this deposit request`:void 0,u=`Your connected wallet · ${(0,d.truncate)(a,[4,4])}`,f=e.status!==`available`||!!l,p=l??(e.status===`unavailable`?e.reason:void 0);return(0,y.jsx)(J_,{sections:[{label:`Crypto`,methods:[{id:`wallet`,title:`Deposit via wallet`,subtext:u,Icon:I.IconWallet,iconUrl:o},{id:`address`,title:`Deposit via address`,subtext:p??`From any wallet or exchange · No limit`,Icon:I.IconQrCode,disabled:f}]},{label:`Cash`,methods:[{id:`onramp`,title:`Buy with cash/card`,subtext:p??t?p??t:n?e.status===`loading`?G_:(0,y.jsx)(W,{errorBoundaryProps:{fallbackRender:()=>G_},suspenseFallback:G_,children:(0,y.jsx)(K_,{})}):`Unavailable on this app`,Icon:I.IconBuy,disabled:f||!n||!!t}]}],onSelect:e=>{switch(e){case`wallet`:r(`wallet`);break;case`address`:case`onramp`:i(e);break}}})},X_=()=>{let{watch:e}=Cm(),t=e(`receiveDenom`),n=On(e(`receiveChainId`),t),r=mh(),i=r&&!n.some(e=>Vm(r,e.src_chain_id,e.src_denom))?`Not available for this asset`:void 0;return(0,y.jsx)(Y_,{availability:n.length>0?{status:`available`}:{status:`unavailable`,reason:`Not supported for this asset`},onrampUnavailableReason:i})},Z_=()=>{let{depositApiUrl:e}=R(),{watch:t}=Cm(),{localOptions:n=[]}=Jt(),r=wm(),i=(0,u.useQueryClient)(),a=t(`receiveSymbol`);return(0,y.jsx)(Am,{title:a?`Deposit ${a}`:`Deposit`,onBack:n.length===1?void 0:()=>r(`select-asset`),children:e?(0,y.jsx)(W,{errorBoundaryProps:{onError:e=>console.error(e),fallbackRender:({resetErrorBoundary:e})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Y_,{availability:{status:`unavailable`,reason:`Unavailable right now`}}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{onClick:()=>{i.resetQueries({queryKey:Bt.assets.queryKey}),e()},children:`Retry`})})]})},suspenseFallback:(0,y.jsx)(Y_,{availability:{status:`loading`}}),children:(0,y.jsx)(X_,{})}):(0,y.jsx)(Y_,{availability:{status:`unavailable`,reason:`Unavailable on this network`}})})},Q_=()=>{let{localOptions:e=[],onramp:t}=Jt();return(0,y.jsxs)(F.FormProvider,{...(0,F.useForm)({mode:`onChange`,defaultValues:z_(e,{paymentMethodId:localStorage.getItem(V.ONRAMP_PAYMENT_TYPE_ID),fiatId:localStorage.getItem(V.ONRAMP_FIAT_ID)},t)}),children:[(0,y.jsx)($_,{}),(0,y.jsx)(ev,{})]})},$_=()=>{let{watch:e,setValue:t}=Cm(),n=e(`receiveSymbol`),r=e(`receiveDenom`),i=e(`receiveChainId`),{data:a,isLoading:o,error:s}=an(),c=a.find(({denom:e,chain_id:t})=>e===r&&t===i)?.symbol;if((0,g.useEffect)(()=>{n||!c||t(`receiveSymbol`,c)},[n,c,t]),r&&!n&&!c&&!o)throw s??Error(`Asset metadata not found for ${r} on ${i}`);return null},ev=()=>{let{watch:e}=Cm(),t=e(`page`),n=e=>{switch(e){case`select-asset`:return(0,y.jsx)(W_,{});case`select-method`:return(0,y.jsx)(Z_,{});case`wallet`:return(0,y.jsx)(tv,{});case`address`:return(0,y.jsx)(Lm,{});case`track`:return(0,y.jsx)(U_,{});case`onramp`:return(0,y.jsx)(Zh,{});case`onramp-select-fiat`:return(0,y.jsx)(ug,{});case`onramp-select-receive`:return(0,y.jsx)(vg,{});case`onramp-select-payment`:return(0,y.jsx)(fg,{});case`onramp-select-provider`:return(0,y.jsx)(mg,{});case`onramp-processing`:return(0,y.jsx)(cg,{})}};return(0,y.jsx)(Bc,{children:(0,y.jsx)(bg,{page:t,renderPage:e=>e===`wallet`?n(e):(0,y.jsx)(Sg,{children:n(e)})})})},tv=()=>{let{watch:e}=Cm(),t=wm();return(0,y.jsx)(L_,{mode:`deposit`,initialAsset:{denom:e(`receiveDenom`),chainId:e(`receiveChainId`)},onExit:()=>t(`select-method`)})},nv=()=>(0,y.jsx)(L_,{mode:`withdraw`}),rv={root:`_root_1lo0i_1`,address:`_address_1lo0i_9`,copy:`_copy_1lo0i_19`,labelWrapper:`_labelWrapper_1lo0i_33`,labelCopy:`_labelCopy_1lo0i_43`,labelCopied:`_labelCopied_1lo0i_47`,copied:`_copied_1lo0i_55`,derived:`_derived_1lo0i_65`,derivedLabel:`_derivedLabel_1lo0i_79`,derivedAddress:`_derivedAddress_1lo0i_83`,hexAddress:`_hexAddress_1lo0i_89`,derivedCopy:`_derivedCopy_1lo0i_94`},iv=()=>{let e=(0,g.useRef)(null),t=(0,g.useRef)(null),{initiaAddress:n,hexAddress:r}=Ta(),i=vc(`--gray-0`);return(0,g.useEffect)(()=>{e.current&&(t.current?t.current.update({data:n}):(t.current=new Ee.default({type:`canvas`,width:400,height:400,margin:0,data:n,image:`https://registry.initia.xyz/images/INIT.png`,qrOptions:{mode:`Byte`,errorCorrectionLevel:`H`},imageOptions:{crossOrigin:`anonymous`,margin:12},dotsOptions:{type:`dots`,color:i},cornersSquareOptions:{type:`extra-rounded`,color:i},cornersDotOptions:{type:`dot`,color:i},backgroundOptions:{color:`transparent`}}),t.current.append(e.current)))},[n,i]),(0,y.jsx)(Hl,{title:`Receive`,children:(0,y.jsxs)(`div`,{className:rv.root,children:[(0,y.jsx)(`div`,{ref:e,style:{width:200,height:200}}),(0,y.jsx)(`span`,{className:rv.address,children:n}),(0,y.jsx)(Oc,{value:n,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{className:(0,P.default)(rv.copy,{[rv.copied]:t}),onClick:e,"aria-label":t?`Copied`:`Copy address`,children:[(0,y.jsx)(I.IconCopy,{size:12,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:rv.labelWrapper,children:[(0,y.jsx)(`span`,{className:rv.labelCopy,children:`Copy address`}),(0,y.jsx)(`span`,{className:rv.labelCopied,children:`Copied!`})]})]})}),(0,y.jsx)(Oc,{value:r,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{className:(0,P.default)(rv.derived,{[rv.copied]:t}),onClick:e,"aria-label":t?`Copied`:`Copy derived address`,children:[(0,y.jsx)(`span`,{className:rv.derivedLabel,children:`Derived from`}),(0,y.jsxs)(`span`,{className:rv.derivedAddress,children:[(0,y.jsx)(`span`,{className:rv.hexAddress,children:(0,d.truncate)(r)}),(0,y.jsx)(I.IconCopy,{size:12,className:rv.derivedCopy,"aria-hidden":`true`}),t&&(0,y.jsx)(`span`,{className:rv.copiedText,children:`Copied!`})]})]})})]})})};function av(e,t){return t==null?e:e.filter(e=>e.grantee===t)}function ov(){let e=U();return(0,u.useQueries)({queries:Xe().map(t=>({queryKey:ii.grants(t.chainId,e).queryKey,queryFn:async()=>{let n=av(ei(await _t(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:t.restUrl},`grants`)),e?lr(e,t.chainId):null);return{chainId:t.chainId,grants:n}},enabled:!!e,staleTime:z.SECOND,retry:!1}))})}var sv={countdown:`_countdown_vfms8_1`},cv=({expiration:e})=>{let t=()=>{let t=(0,se.differenceInSeconds)(e,new Date),n=Math.floor(t/(1440*60)),r=Math.floor(t%(1440*60)/3600),i=Math.floor(t%3600/60),a=t%60,o=[];return n>0&&o.push(`${n}d`),(r>0||n>0)&&o.push(`${r}h`),(i>0||r>0||n>0)&&o.push(`${i}m`),o.push(`${a}s`),o.join(` `)},[n,r]=(0,g.useState)(t());return(0,ue.useInterval)(()=>{r(t())},1e3),(0,se.isPast)(e)?`Expired`:(0,y.jsxs)(y.Fragment,{children:[`Expires in `,(0,y.jsx)(`span`,{className:sv.countdown,children:n})]})},lv={container:`_container_1l528_1`,info:`_info_1l528_11`,header:`_header_1l528_17`,chainName:`_chainName_1l528_23`,expiration:`_expiration_1l528_29`,revokeButton:`_revokeButton_1l528_35`},uv=({chainId:e,grantee:t,expiration:n})=>{let r=et(e),{mutate:i,isPending:a}=sa({grantee:t,internal:!0});return(0,y.jsxs)(`div`,{className:lv.container,children:[(0,y.jsxs)(`div`,{className:lv.info,children:[(0,y.jsxs)(`div`,{className:lv.header,children:[(0,y.jsx)(K,{src:r.logoUrl,width:16,height:16,logo:!0}),(0,y.jsx)(`div`,{className:lv.chainName,children:r.name})]}),(0,y.jsx)(`div`,{className:lv.expiration,children:n?(0,y.jsx)(cv,{expiration:n}):`Until revoked`})]}),(0,y.jsx)(`button`,{className:lv.revokeButton,onClick:()=>i(e),disabled:a,"aria-busy":a,children:a?`Revoking...`:`Revoke`})]})},dv=({chainId:e,grants:t})=>{let n=new Map;for(let e of t){let t=n.get(e.grantee),r=e.expiration?new Date(e.expiration):void 0;if(!t){n.set(e.grantee,{grantee:e.grantee,expiration:r});continue}t.expiration=vi([t.expiration,r])}return[...n.values()].map(t=>(0,g.createElement)(uv,{...t,chainId:e,key:t.grantee}))},fv={content:`_content_q36qs_1`},pv=()=>{let e=ov();return(0,y.jsx)(Hl,{title:`Manage auto-signing`,backButton:`/settings`,children:(()=>{let t=e.filter(e=>e.data&&e.data.grants.length>0).map(e=>e.data);return t.length===0?(0,y.jsx)(Da,{children:`No permissions found`}):(0,y.jsx)(`div`,{className:fv.content,children:t.map(({chainId:e,grants:t})=>(0,y.jsx)(dv,{chainId:e,grants:t},e))})})()})},mv={version:`_version_1sf5y_1`},hv=()=>(0,y.jsxs)(`aside`,{className:mv.version,children:[`v`,`2.11.1`]}),gv={link:`_link_se23z_1`,title:`_title_se23z_17`,subtitle:`_subtitle_se23z_23`,icon:`_icon_se23z_30`},_v=({title:e,subtitle:t,rightSection:n,onClick:r})=>(0,y.jsxs)(`button`,{className:gv.link,onClick:r,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:gv.title,children:e}),t&&(0,y.jsx)(`p`,{className:gv.subtitle,children:t})]}),(0,y.jsx)(`div`,{className:gv.icon,children:n??(0,y.jsx)(I.IconChevronRight,{size:16,"aria-hidden":`true`})})]}),vv=`https://export.initia.xyz/`,yv=()=>(0,y.jsx)(_v,{title:`Export private key`,rightSection:(0,y.jsx)(I.IconExternalLink,{size:16}),onClick:()=>window.open(vv,`_blank`,`width=600,height=768,scrollbars=yes,resizable=yes,noopener,noreferrer`)}),bv={container:`_container_1vxr7_1`,separator:`_separator_1vxr7_7`},xv=()=>{let e=Xt(),{connector:t}=(0,l.useAccount)();return(0,y.jsx)(Hl,{title:`Settings`,backButton:`/`,children:(0,y.jsxs)(`div`,{className:bv.container,children:[(0,y.jsx)(_v,{title:`Manage auto-signing`,subtitle:`Manage chain auto-signing permissions by apps`,onClick:()=>e(`/settings/autosign`)}),t?.id===`cmbq1ozyc006al70lx4uciz0q`&&(0,y.jsx)(yv,{}),(0,y.jsx)(De.Separator,{className:bv.separator}),(0,y.jsx)(hv,{})]})})},Sv={trigger:`_trigger_1yjkd_1`,icon:`_icon_1yjkd_23`,full:`_full_1yjkd_27`,triggerContent:`_triggerContent_1yjkd_32`,triggerText:`_triggerText_1yjkd_40`,popoverBackdrop:`_popoverBackdrop_1yjkd_51`,popoverPositioner:`_popoverPositioner_1yjkd_70`,popoverPopup:`_popoverPopup_1yjkd_74`,search:`_search_1yjkd_99`,viewport:`_viewport_1yjkd_105`,item:`_item_1yjkd_111`,highlighted:`_highlighted_1yjkd_127`,active:`_active_1yjkd_131`,itemContent:`_itemContent_1yjkd_136`,extra:`_extra_1yjkd_142`,connectedTag:`_connectedTag_1yjkd_149`},Cv=({value:e,onChange:t,chainIds:n,renderExtra:r,fullWidth:i})=>{let{defaultChainId:a}=R(),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(0),[f,p]=(0,g.useState)(),m=(0,g.useRef)([]),h=(0,g.useRef)(null),_=Xe(),v=n.map(e=>_.find(t=>t.chainId===e)).filter(Boolean),b=e=>(0,y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 14 14`,children:[(0,y.jsx)(`path`,{fill:`var(--dimmed)`,d:`M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z`}),(0,y.jsx)(`path`,{fill:`var(--dimmed)`,d:`M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z`})]}),x=(0,g.useMemo)(()=>({chainId:``,name:`All`,logoUrl:b}),[]),S=(0,g.useMemo)(()=>{let e=[x,...v];if(!o)return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.chainId.toLowerCase().includes(t))},[v,o,x]),C=v.find(t=>t.chainId===e)||x,w=parseInt(vc(`--drawer-offset`)),T=()=>{if(s(``),d(-1),h.current){let e=h.current.getBoundingClientRect().bottom+6;p(window.innerHeight-e-2*w)}l(!0)};(0,g.useEffect)(()=>{u>=0&&u<m.current.length&&m.current[u]?.scrollIntoView({block:`nearest`,behavior:`auto`})},[u]);let E=(0,g.useCallback)(e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),d(e=>(e+1)%S.length);break;case`ArrowUp`:e.preventDefault(),d(e=>(e-1+S.length)%S.length);break;case`Enter`:e.preventDefault(),S[u]&&(t(S[u].chainId),l(!1));break;case`Escape`:e.preventDefault(),l(!1);break}},[S,u,t,l]),D=e=>{t(e),l(!1)};return(0,y.jsxs)(ke.Popover.Root,{open:c,onOpenChange:T,modal:`trap-focus`,children:[(0,y.jsx)(ke.Popover.Trigger,{render:(0,y.jsxs)(`button`,{className:(0,P.default)(Sv.trigger,{[Sv.full]:i}),"aria-expanded":c,role:`listbox`,ref:h,children:[(0,y.jsxs)(`div`,{className:Sv.triggerContent,children:[typeof C.logoUrl==`string`?(0,y.jsx)(K,{src:C.logoUrl,width:14,height:14,logo:!0}):C.logoUrl(14),(0,y.jsx)(`span`,{className:Sv.triggerText,children:C.name})]}),(0,y.jsx)(I.IconChevronDown,{size:16,className:Sv.icon})]})}),(0,y.jsxs)(ke.Popover.Portal,{container:_c(),children:[(0,y.jsx)(ke.Popover.Backdrop,{className:Sv.popoverBackdrop,onClick:()=>l(!1)}),(0,y.jsx)(ke.Popover.Positioner,{className:Sv.popoverPositioner,align:`end`,side:`bottom`,sideOffset:6,collisionAvoidance:{side:`none`},children:(0,y.jsxs)(ke.Popover.Popup,{className:(0,P.default)(Sv.popoverPopup,{[Sv.full]:i}),style:{maxHeight:f},children:[(0,y.jsx)(ed,{value:o,onChange:e=>{s(e.target.value),d(0)},onClear:()=>s(``),onKeyDown:E,placeholder:`Search apps`,rootClassName:Sv.search,ref:xu()}),(0,y.jsx)(`div`,{className:Sv.viewport,role:`listbox`,children:S.length===0?(0,y.jsx)(Da,{children:`No apps found`}):S.map(({chainId:t,name:n,logoUrl:i},o)=>(0,y.jsxs)(`div`,{className:(0,P.default)(Sv.item,{[Sv.highlighted]:o===u,[Sv.active]:e===t}),onClick:()=>D(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),D(t))},onMouseEnter:()=>d(o),role:`option`,"aria-selected":e===t,tabIndex:-1,ref:e=>{e&&(m.current[o]=e)},children:[(0,y.jsxs)(`div`,{className:Sv.itemContent,children:[typeof i==`string`?(0,y.jsx)(K,{src:i,width:16,height:16,logo:!0}):i(16),(0,y.jsx)(`span`,{className:Sv.name,children:n}),t===a&&(0,y.jsx)(`span`,{className:Sv.connectedTag,children:`Connected`})]}),r&&(0,y.jsx)(`span`,{className:Sv.extra,children:r(t)})]},t))})]})})]})]})},wv={container:`_container_1nap1_1`,controls:`_controls_1nap1_7`,search:`_search_1nap1_13`},Tv={Root:({children:e})=>(0,y.jsx)(`div`,{className:wv.container,children:e}),Controls:({children:e})=>(0,y.jsx)(`div`,{className:wv.controls,children:e}),SearchInput:e=>(0,y.jsx)(ed,{...e,rootClassName:wv.search})},Ev=(0,b.atom)(``),Dv=(0,b.atom)(``),Ov=(0,b.atom)(``),kv=(0,b.atom)(``),Av=(0,b.atom)(``),jv={change:`_change_1nm9m_1`,positive:`_positive_1nm9m_8`,negative:`_negative_1nm9m_12`},Mv=({amount:e,asset:t})=>{let{denom:n,symbol:r,decimals:i}=t,a=e||`0`,o=(0,f.default)(a).isPositive(),s=(0,f.default)(a).abs().toString();return(0,y.jsxs)(`div`,{className:(0,P.default)(jv.change,o?jv.positive:jv.negative),children:[o?`+`:`-`,(0,d.formatAmount)(s,{decimals:i}),` `,r||n]})},Nv=({changes:e,chain:t})=>{let n=ft(t);return e.map(({amount:e,denom:t},r)=>(0,y.jsx)(Mv,{amount:e,asset:n(t)},r))},Pv=({changes:e,chain:t})=>{let n=ft(t);return e.map(({amount:e,metadata:r},i)=>(0,y.jsx)(fl,{metadata:r,chain:t,children:t=>(0,y.jsx)(Mv,{amount:e,asset:n(t)})},i))},Fv=({events:e,chain:t})=>{let{initiaAddress:n,hexAddress:r}=Ta();return t.metadata?.is_l1||t.metadata?.minitia?.type===`minimove`?(0,y.jsx)(Pv,{changes:dl(e,r),chain:t}):(0,y.jsx)(Nv,{changes:ul(e,n),chain:t})},Iv={message:`_message_1qc8m_1`,more:`_more_1qc8m_9`},Lv=({messages:e})=>(0,y.jsxs)(y.Fragment,{children:[e.slice(0,3).map((e,t)=>(0,y.jsx)(`p`,{className:Iv.message,children:(0,he.sentenceCase)(e[`@type`].split(`Msg`)[1])},t)),e.length>3&&(0,y.jsx)(`footer`,{className:Iv.more,children:`+${e.length-3} more`})]}),Rv={link:`_link_1vbb0_1`,inner:`_inner_1vbb0_16`,header:`_header_1vbb0_21`,time:`_time_1vbb0_30`,error:`_error_1vbb0_36`,timestamp:`_timestamp_1vbb0_40`,chainInfo:`_chainInfo_1vbb0_45`,content:`_content_1vbb0_53`,messages:`_messages_1vbb0_61`,changes:`_changes_1vbb0_67`},zv=({txItem:e,chain:t})=>(0,y.jsx)(wc,{txHash:e.txhash,chainId:t.chainId,className:Rv.link,children:(0,y.jsxs)(`div`,{className:Rv.inner,children:[(0,y.jsxs)(`div`,{className:Rv.header,children:[(0,y.jsxs)(`div`,{className:Rv.time,children:[e.code!==0&&(0,y.jsx)(I.IconWarningFilled,{size:14,className:Rv.error}),(0,y.jsx)(`span`,{className:Rv.timestamp,children:(0,se.format)(new Date(e.timestamp),`h:mm a`)})]}),(0,y.jsxs)(`div`,{className:Rv.chainInfo,children:[(0,y.jsx)(K,{src:t.logoUrl,width:12,height:12,logo:!0}),(0,y.jsx)(`span`,{children:t.name})]})]}),(0,y.jsxs)(`div`,{className:Rv.content,children:[(0,y.jsx)(`div`,{className:Rv.messages,children:(0,y.jsx)(Lv,{messages:e.tx.body.messages})}),(0,y.jsx)(`div`,{className:Rv.changes,children:(0,y.jsx)(W,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:(0,y.jsx)(Fv,{...e,chain:t})})})]})]})}),Bv={list:`_list_1mv55_1`,dateGroup:`_dateGroup_1mv55_7`,dateHeader:`_dateHeader_1mv55_12`,more:`_more_1mv55_18`},Vv=({list:e,chainId:t})=>{let n=U(),r=(0,g.useMemo)(()=>Dd(e,e=>{if(e.timestamp)return new Date(e.timestamp)}),[e]);return e.length===0?(0,y.jsx)(Da,{children:`No activity found`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:Bv.list,children:Object.entries(r).map(([e,t])=>(0,y.jsxs)(`div`,{className:Bv.dateGroup,children:[(0,y.jsx)(`div`,{className:Bv.dateHeader,children:e}),t.map(e=>(0,y.jsx)(W,{errorBoundaryProps:{fallback:null},children:(0,y.jsx)(zv,{txItem:e,chain:e.chain})},e.txhash))]},e))}),(0,y.jsx)(wc,{chainId:t,accountAddress:n,pathSuffix:`/txs`,className:Bv.more,showIcon:!0,children:`View more on Initia Scan`})]})},Hv=()=>{let{activities:e,isLoading:t}=Mi(),[n,r]=(0,b.useAtom)(Av),i=B(),a=(0,g.useMemo)(()=>Array.from(new Set(e.map(e=>e.chain.chainId))),[e]),o=(0,g.useMemo)(()=>n?e.filter(e=>e.chain.chainId===n):e,[e,n]);return t&&e.length===0?(0,y.jsx)(Da,{children:`Loading activities...`}):!e.length&&!t?(0,y.jsx)(Da,{children:`No activity yet. Recent transactions may take a moment to appear.`}):(0,y.jsxs)(Tv.Root,{children:[(0,y.jsx)(Tv.Controls,{children:(0,y.jsx)(Cv,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),(0,y.jsx)(Vv,{list:o,chainId:n||i.chainId})]})},Uv={thumbnail:`_thumbnail_1xyqw_1`,placeholder:`_placeholder_1xyqw_18`,clickable:`_clickable_1xyqw_24`},Wv=({nftInfo:e,size:t,onClick:n})=>{let{collection_addr:r,object_addr:i,nft:a,chain:o}=e,{glyphUrl:s}=R(),c=new URL(`/v1/${o.chainId}/${r}/${i||a.token_id}`,s).toString();return n?(0,y.jsx)(`button`,{className:(0,P.default)(Uv.thumbnail,Uv.clickable),onClick:n,style:{width:t,height:t},children:(0,y.jsx)(K,{src:c,classNames:{placeholder:Uv.placeholder}})}):(0,y.jsx)(`div`,{className:Uv.thumbnail,style:{width:t,height:t},children:(0,y.jsx)(K,{src:c,classNames:{placeholder:Uv.placeholder}})})},Gv={collectionName:`_collectionName_qs5tw_1`,nftName:`_nftName_qs5tw_6`,chainInfo:`_chainInfo_qs5tw_10`},Kv=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:n,chainIconSize:r=12,classNames:i})=>{let{collection_name:a,name:o,chain:s}=e;return(0,y.jsxs)(`div`,{className:i?.root,children:[(0,y.jsx)(Wv,{nftInfo:e,onClick:t,size:n}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:(0,P.default)(Gv.collectionName,i?.collectionName),children:a}),(0,y.jsx)(`div`,{className:(0,P.default)(Gv.nftName,i?.nftName),children:o}),(0,y.jsxs)(`div`,{className:(0,P.default)(Gv.chainInfo,i?.chainInfo),children:[(0,y.jsx)(K,{src:s.logoUrl,width:r,height:r,logo:!0}),(0,y.jsx)(`span`,{children:s.name})]})]})]})},qv=(0,m.createQueryKeys)(`interwovenkit:nft`,{nfts:(e,t)=>[e,t],metadata:e=>[e]});function Jv(e,t){let{nft:n}=e,r=t.name??n.token_id;return{...e,...n,...t,name:r}}function Yv(e,t){return e.flatMap((e,n)=>(t[n]??[]).map(t=>({...t,chain:e})))}var Xv=()=>{let e=U(),t=Xe(),n=(0,u.useQueries)({queries:t.map(t=>({queryKey:qv.nfts(t.indexerUrl,e).queryKey,queryFn:()=>_t(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:t.indexerUrl},`tokens`),staleTime:z.SECOND}))}),r=Yv(t,n.map((0,p.prop)(`data`))),i=r.reduce((e,{chain:t})=>({...e,[t.chainId]:(e[t.chainId]||0)+1}),{});return{nftInfos:r,chainCounts:i,totalCount:Object.values(i).reduce((e,t)=>e+t,0),isLoading:n.some(e=>e.isLoading)}};function Zv(e){let t=Qv(e);return(0,u.useQuery)({queryKey:qv.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};let e=await h.default.get(t).json();return{...e,image:Qv(e.image)}}catch{return{}}},staleTime:z.INFINITY})}function Qv(e){return e?.replace(`ipfs://`,`https://ipfs.io/ipfs/`)}var $v=({nftInfo:e,children:t})=>{let{data:n={}}=Zv(e.nft.uri);return t(Jv(e,n))},ey={grid:`_grid_1wwdn_1`,root:`_root_1wwdn_7`,collectionName:`_collectionName_1wwdn_15`,nftName:`_nftName_1wwdn_23`,chainInfo:`_chainInfo_1wwdn_32`},ty=()=>{let[e,t]=(0,b.useAtom)(Ov),[n,r]=(0,b.useAtom)(kv),{nftInfos:i,chainCounts:a,totalCount:o,isLoading:s}=Xv(),c=Xt(),l=(0,g.useMemo)(()=>i.filter(({collection_addr:t,collection_name:r,nft:i,object_addr:a,chain:o})=>{if(n&&o.chainId!==n)return!1;if(e){let n=e.trim().toLowerCase();return t.toLowerCase().includes(n)||r.toLowerCase().includes(n)||i.token_id.toLowerCase().includes(n)||a.toLowerCase().includes(n)}return!0}),[i,n,e]),u=(0,g.useMemo)(()=>Array.from(new Set(i.map(({chain:e})=>e.chainId))),[i]);return s&&i.length===0?(0,y.jsx)(Da,{children:`Loading NFTs...`}):!i.length&&!e&&!s?(0,y.jsx)(Da,{children:`No NFTs`}):(0,y.jsxs)(Tv.Root,{children:[(0,y.jsxs)(Tv.Controls,{children:[(0,y.jsx)(Tv.SearchInput,{value:e,onChange:e=>t(e.target.value),onClear:()=>t(``),placeholder:`Search NFTs`}),(0,y.jsx)(Cv,{value:n,onChange:r,chainIds:u,renderExtra:e=>e?a[e]||0:o})]}),l.length===0?(0,y.jsx)(Da,{children:`No NFTs found`}):(0,y.jsx)(`div`,{className:ey.grid,children:l.map(e=>{let{collection_addr:t,nft:n}=e;return(0,y.jsx)($v,{nftInfo:e,children:e=>(0,y.jsx)(Kv,{normalizedNft:e,onThumbnailClick:()=>c(`/nft`,e),classNames:ey})},t+n.token_id)})})]})},ny=(0,g.createContext)(null);function ry(){return(0,g.useContext)(ny)}var iy={popup:`_popup_nbecp_1`,item:`_item_nbecp_19`},ay=({asset:e,children:t})=>{let{denom:n,decimals:r,symbol:i,logoUrl:a,unlisted:o,address:s,chain:c}=e,{chainId:d}=c,[f,p]=(0,g.useState)(!1),m=Xt(),h=ry(),{showNotification:_}=Ec(),{defaultChainId:v}=R(),{evm_chain_id:b}=nt(),x=(0,l.useChainId)(),{switchChainAsync:S}=(0,l.useSwitchChain)(),{watchAssetAsync:C}=(0,l.useWatchAsset)(),w=()=>{p(!1),m(`/send`,{denom:n,chain:c})},T=()=>{p(!1),m(`/bridge`,{srcChainId:d,srcDenom:n,quantity:``})},E=(0,u.useMutation)({mutationFn:async()=>{if(!s)throw Error(`Address is required`);let e=a;return await S({chainId:Number(b)}),C({type:`ERC20`,options:{address:s,symbol:i,decimals:r,image:e}})},onSuccess:()=>{_({type:`success`,title:`Asset added`,description:`Asset added to wallet`})},onError:e=>{_({type:`error`,title:`Asset addition failed`,description:e.message})}});return(0,y.jsxs)(De.Menu.Root,{open:f,onOpenChange:p,modal:!1,children:[(0,y.jsx)(De.Menu.Trigger,{render:t}),(0,y.jsx)(De.Menu.Portal,{container:h,children:(0,y.jsx)(De.Menu.Positioner,{side:`bottom`,sideOffset:-6,align:`end`,children:(0,y.jsxs)(De.Menu.Popup,{className:iy.popup,children:[(0,y.jsxs)(De.Menu.Item,{className:iy.item,onClick:w,children:[(0,y.jsx)(I.IconArrowRight,{size:16}),(0,y.jsx)(`span`,{children:`Send`})]}),(0,y.jsxs)(De.Menu.Item,{className:iy.item,onClick:T,disabled:o,children:[(0,y.jsx)(I.IconSwap,{size:16}),(0,y.jsx)(`span`,{children:`Bridge/Swap`})]}),d===v&&b===x&&!!s&&(0,y.jsxs)(De.Menu.Item,{className:iy.item,onClick:()=>E.mutate(),disabled:E.isPending||E.data,children:[E.data?(0,y.jsx)(I.IconCheck,{size:16}):(0,y.jsx)(I.IconPlus,{size:16}),(0,y.jsx)(`span`,{children:`Add to Wallet`})]})]})})})]})},oy={item:`_item_38qhm_1`,info:`_info_38qhm_23`,images:`_images_38qhm_29`,name:`_name_38qhm_33`,value:`_value_38qhm_39`,amount:`_amount_38qhm_47`,usd:`_usd_38qhm_53`},sy=({asset:e})=>{let{amount:t,value:n,logoUrl:r,chain:i}=e,a=(0,d.formatAmount)(t,{decimals:e.decimals});return(0,y.jsx)(ay,{asset:e,children:(0,y.jsxs)(`button`,{className:oy.item,children:[(0,y.jsxs)(`div`,{className:oy.info,children:[(0,y.jsx)(Yu,{assetLogoUrl:r,chainLogoUrl:i.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:oy.images}),(0,y.jsx)(`span`,{className:oy.name,children:i.name})]}),(0,y.jsxs)(`div`,{className:oy.value,children:[(0,y.jsx)(`span`,{className:oy.amount,children:a}),Number(n)>0&&(0,y.jsx)(`span`,{className:oy.usd,children:q(n)})]})]})})},cy={container:`_container_ytg3p_1`,assetItem:`_assetItem_ytg3p_6`,expandIcon:`_expandIcon_ytg3p_22`,assetInfo:`_assetInfo_ytg3p_27`,logo:`_logo_ytg3p_33`,details:`_details_ytg3p_37`,symbol:`_symbol_ytg3p_42`,chainName:`_chainName_ytg3p_53`,chainInfos:`_chainInfos_ytg3p_59`,chainLogos:`_chainLogos_ytg3p_65`,chainLogo:`_chainLogo_ytg3p_65`,moreChains:`_moreChains_ytg3p_76`,expanded:`_expanded_ytg3p_93`,valueColumn:`_valueColumn_ytg3p_98`,amount:`_amount_ytg3p_108`,value:`_value_ytg3p_98`,collapsibleContent:`_collapsibleContent_ytg3p_121`,slideDown:`_slideDown_ytg3p_1`,slideUp:`_slideUp_ytg3p_1`,chainsList:`_chainsList_ytg3p_151`},ly=(0,b.atom)([]),uy=({assetGroup:e})=>{let{symbol:t,logoUrl:n,assets:r}=e,i=r.length===1,[a,o]=(0,b.useAtom)(ly),s=(0,g.useMemo)(()=>pa(e),[e]),c=(0,g.useMemo)(()=>fa(e),[e]),l=a.includes(t),u=()=>{o(e=>l?e.filter(e=>e!==t):[...new Set([...e,t])])},f=()=>(0,y.jsxs)(`button`,{className:cy.assetItem,children:[(0,y.jsxs)(`div`,{className:cy.assetInfo,children:[n&&(0,y.jsx)(K,{src:n,width:32,height:32,className:cy.logo,logo:!0}),(0,y.jsxs)(`div`,{className:cy.details,children:[(0,y.jsx)(`div`,{className:cy.symbol,children:t}),i?(0,y.jsx)(`div`,{className:cy.chainName,children:r[0].chain.name}):(0,y.jsxs)(`div`,{className:cy.chainInfos,children:[(0,y.jsx)(`div`,{className:cy.chainLogos,children:r.slice(0,5).map(({chain:e})=>(0,y.jsx)(K,{src:e.logoUrl,width:16,height:16,className:cy.chainLogo,logo:!0},e.chainId))}),r.length>5&&(0,y.jsxs)(`span`,{className:cy.moreChains,children:[`+`,r.length-5]}),(0,y.jsx)(I.IconChevronDown,{size:16,className:(0,P.default)(cy.expandIcon,{[cy.expanded]:l})})]})]})]}),(0,y.jsxs)(`div`,{className:cy.valueColumn,children:[(0,y.jsx)(`div`,{className:cy.amount,children:(0,d.formatNumber)(s,{dp:r[0].unlisted?0:6})}),c>0&&(0,y.jsx)(`div`,{className:cy.value,children:q(c)})]})]});if(i){let[e]=r;return(0,y.jsx)(`div`,{className:cy.container,children:(0,y.jsx)(ay,{asset:e,children:f()})})}return(0,y.jsx)(`div`,{className:cy.container,children:(0,y.jsxs)(N.Collapsible.Root,{open:l,onOpenChange:u,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:f()}),(0,y.jsx)(N.Collapsible.Content,{className:cy.collapsibleContent,children:(0,y.jsx)(`div`,{className:cy.chainsList,children:r.map(e=>(0,y.jsx)(sy,{asset:e},e.chain.chainId))})})]})})},dy={collapsible:`_collapsible_1g7rh_1`,trigger:`_trigger_1g7rh_5`,divider:`_divider_1g7rh_20`,label:`_label_1g7rh_28`,chevron:`_chevron_1g7rh_33`,content:`_content_1g7rh_41`,list:`_list_1g7rh_45`},fy=({unlistedAssets:e})=>{let[t,n]=(0,g.useState)(!1),r=ry(),i=(0,g.useRef)(null),[a,o]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(i.current){let e=i.current.scrollHeight;o(e)}},[e]);let s=(0,g.useRef)(null),c=e=>{n(e),e&&s.current&&r?.current&&window.setTimeout(()=>{if(!s.current||!i.current||!r?.current)return;let e=r.current,t=e.getBoundingClientRect(),n=s.current.getBoundingClientRect(),a=i.current.scrollHeight;if(n.bottom+a>t.bottom){let r=n.top-t.top+e.scrollTop-16;e.scrollTo({top:r,behavior:`smooth`})}},50)},l=(0,me.useSpring)({height:t?a:0,opacity:+!!t,config:{tension:500,friction:30,clamp:!0}}),u=(0,g.useMemo)(()=>e.map(e=>({...e,assets:[e],totalValue:e.value??0,totalAmount:Number(e.quantity)})),[e]);return e.length===0?null:(0,y.jsxs)(N.Collapsible.Root,{open:t,onOpenChange:c,className:dy.collapsible,children:[(0,y.jsxs)(N.Collapsible.Trigger,{ref:s,className:dy.trigger,children:[(0,y.jsx)(`div`,{className:dy.divider}),(0,y.jsxs)(`span`,{className:dy.label,children:[`Unlisted assets (`,e.length,`)`]}),(0,y.jsx)(I.IconChevronDown,{className:dy.chevron,size:12,"data-state":t?`open`:`closed`}),(0,y.jsx)(`div`,{className:dy.divider})]}),(0,y.jsx)(N.Collapsible.Content,{forceMount:!0,asChild:!0,children:(0,y.jsx)(me.animated.div,{className:dy.content,style:l,children:(0,y.jsx)(`div`,{className:dy.list,ref:i,children:u.map(e=>(0,y.jsx)(uy,{assetGroup:e},e.assets[0].denom))})})})]})},py={container:`_container_15xfg_1`,header:`_header_15xfg_7`,title:`_title_15xfg_13`,totalValue:`_totalValue_15xfg_19`,list:`_list_15xfg_26`},my=()=>{let[e,t]=(0,b.useAtom)(Ev),[n,r]=(0,b.useAtom)(Dv),{assetGroups:i,unlistedAssets:a,chainsByValue:o,totalValue:s,isLoading:c}=xa(),l=o.map(({chainId:e})=>e),u=(0,g.useMemo)(()=>{let t=e?i.filter(t=>{let{symbol:n,assets:r}=t;return n.toLowerCase().includes(e.toLowerCase())||r.some(({denom:t,address:n})=>t.toLowerCase().includes(e.toLowerCase())||n?.toLowerCase().includes(e.toLowerCase()))}):i;return n?t.map(e=>({...e,assets:e.assets.filter(({chain:e})=>e.chainId===n)})).filter(e=>e.assets.length>0):t},[i,e,n]),d=(0,g.useMemo)(()=>{let t=e?a.filter(({denom:t,address:n})=>t.toLowerCase().includes(e.toLowerCase())||n?.toLowerCase().includes(e.toLowerCase())):a;return n?t.filter(({chain:e})=>e.chainId===n):t},[a,e,n]);return c&&i.length===0?(0,y.jsx)(Da,{children:`Loading assets...`}):!u.length&&!d.length&&!e&&!n&&!c?(0,y.jsx)(Da,{children:`No assets`}):(0,y.jsxs)(Tv.Root,{children:[(0,y.jsxs)(Tv.Controls,{children:[(0,y.jsx)(Tv.SearchInput,{value:e,onChange:e=>t(e.target.value),onClear:()=>t(``),placeholder:`Search assets`}),(0,y.jsx)(Cv,{value:n,onChange:r,chainIds:l,renderExtra:e=>{if(!e)return q(s);let t=o.find(t=>t.chainId===e);return t?q(t.value):null}})]}),(0,y.jsx)(`div`,{children:u.length===0&&d.length===0?(0,y.jsx)(Da,{children:`No assets found`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:py.list,children:u.map(e=>(0,y.jsx)(uy,{assetGroup:e},e.symbol))}),(0,y.jsx)(fy,{unlistedAssets:d})]})})]})},hy={container:`_container_11k2x_1`},gy=({height:e,length:t=1,width:n=`100%`})=>{let r=Array.from({length:t},(e,t)=>t);return t===1?(0,y.jsx)(ld,{height:e,width:n}):(0,y.jsx)(`div`,{className:hy.container,"aria-hidden":`true`,children:r.map(t=>(0,y.jsx)(ld,{height:e,width:n},t))})},_y=(0,g.memo)(({searchQuery:e,selectedChain:t,denomLogos:n,symbolLogos:r,chainInfoMap:i,chainPrices:a})=>{let{balances:o,isLoading:s}=qs(),c=B(),{listedGroups:l,unlistedAssets:u}=(0,g.useMemo)(()=>Fs(o,i,a,c.chainId),[o,i,a,c.chainId]),d=(0,g.useMemo)(()=>js(l,n,r),[l,n,r]),{filteredAssets:f,totalAssetsValue:p,filteredUnlistedAssets:m}=(0,g.useMemo)(()=>Ps(d,u,e,t),[d,u,e,t]);return(0,y.jsxs)(`div`,{className:py.container,children:[(0,y.jsxs)(`div`,{className:py.header,children:[(0,y.jsx)(`span`,{className:py.title,children:`Assets`}),f.length>0&&(0,y.jsx)(`span`,{className:py.totalValue,children:q(p)})]}),f.length>0?(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:py.list,children:f.map(e=>(0,y.jsx)(uy,{assetGroup:e},e.symbol))}),(0,y.jsx)(fy,{unlistedAssets:m})]}):d.length===0&&s?(0,y.jsx)(gy,{height:56,length:3}):(0,y.jsx)(Da,{children:`No liquid assets`})]})}),Z={container:`_container_vjtpl_1`,section:`_section_vjtpl_7`,sectionHeader:`_sectionHeader_vjtpl_19`,sectionTitle:`_sectionTitle_vjtpl_25`,sectionLabel:`_sectionLabel_vjtpl_31`,externalLink:`_externalLink_vjtpl_37`,sectionTitleLink:`_sectionTitleLink_vjtpl_49`,sectionValue:`_sectionValue_vjtpl_63`,tokenList:`_tokenList_vjtpl_70`,stakingTokenList:`_stakingTokenList_vjtpl_76`,tokenRow:`_tokenRow_vjtpl_86`,tokenMain:`_tokenMain_vjtpl_92`,tokenTrigger:`_tokenTrigger_vjtpl_98`,tokenChevron:`_tokenChevron_vjtpl_114`,expanded:`_expanded_vjtpl_125`,triggerValue:`_triggerValue_vjtpl_129`,tokenInfo:`_tokenInfo_vjtpl_136`,tokenInfoLabel:`_tokenInfoLabel_vjtpl_142`,tokenLogo:`_tokenLogo_vjtpl_148`,tokenSymbol:`_tokenSymbol_vjtpl_152`,tokenValues:`_tokenValues_vjtpl_158`,tokenAmount:`_tokenAmount_vjtpl_164`,tokenValue:`_tokenValue_vjtpl_158`,typeBreakdown:`_typeBreakdown_vjtpl_178`,typeRow:`_typeRow_vjtpl_186`,typeLabel:`_typeLabel_vjtpl_194`,typeValues:`_typeValues_vjtpl_200`,typeAmount:`_typeAmount_vjtpl_206`,typeValue:`_typeValue_vjtpl_200`,perpRow:`_perpRow_vjtpl_220`,perpLeft:`_perpLeft_vjtpl_227`,perpLogo:`_perpLogo_vjtpl_235`,perpInfo:`_perpInfo_vjtpl_241`,perpPair:`_perpPair_vjtpl_249`,perpDirectionLong:`_perpDirectionLong_vjtpl_255`,perpDirectionShort:`_perpDirectionShort_vjtpl_261`,perpRight:`_perpRight_vjtpl_267`,perpValue:`_perpValue_vjtpl_275`,perpPnl:`_perpPnl_vjtpl_283`,perpPnlPositive:`_perpPnlPositive_vjtpl_290`,perpPnlNegative:`_perpPnlNegative_vjtpl_294`,perpPnlNeutral:`_perpPnlNeutral_vjtpl_298`,collapsibleContent:`_collapsibleContent_vjtpl_302`,slideDown:`_slideDown_vjtpl_1`,slideUp:`_slideUp_vjtpl_1`};function vy(e){return[...e].sort((e,t)=>_s(t.position)-_s(e.position)).map(e=>e.id)}var yy=({protocols:e,denomLogoMap:t,chainName:n,isInitia:r,getClaimableInitByType:i,initPrice:a})=>{let o=e[0]?.manageUrl,s=(0,g.useMemo)(()=>bs(e.flatMap(e=>e.positions)),[e]);return s.size===0?null:(0,y.jsx)(`div`,{className:Z.container,children:Array.from(s.entries()).map(([e,s])=>(0,y.jsx)(by,{sectionKey:e,sectionGroup:s,denomLogoMap:t,chainName:n,isInitia:r,manageUrl:o,getClaimableInitByType:i,initPrice:a},e))})},by=({sectionKey:e,sectionGroup:t,denomLogoMap:n,chainName:r,isInitia:i,manageUrl:a,getClaimableInitByType:o,initPrice:s})=>{let{positions:c,totalValue:l}=t,u=ys(e,{isInitia:i,chainName:r}),d=e===`staking`,f=r?.toLowerCase()===St,p=d&&!f,m=e===`perp`,h=(0,g.useMemo)(()=>m?[]:Ds(c),[c,m]),_=(0,g.useMemo)(()=>{if(!m)return[];let e=new Map;return c.filter(e=>e.type===`perp-position`).map(t=>{let n=`${t.pair}-${t.direction}`,r=e.get(n)??0;return e.set(n,r+1),{id:`${n}-${r}`,position:t}})},[c,m]),v=_.map(e=>e.id).sort().join(`|`),[b,x]=(0,g.useState)(()=>({signature:v,ids:vy(_)}));b.signature!==v&&x({signature:v,ids:vy(_)});let S=(0,g.useMemo)(()=>{let e=new Map(_.map(e=>[e.id,e.position]));return b.ids.map(t=>({id:t,position:e.get(t)})).filter(e=>e.position!=null)},[_,b.ids]);return(0,y.jsxs)(`section`,{className:Z.section,"aria-label":u,children:[(0,y.jsxs)(`div`,{className:Z.sectionHeader,children:[p&&a?(0,y.jsxs)(`a`,{href:Sc(a),target:`_blank`,rel:`noopener noreferrer`,className:Z.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Z.sectionLabel,children:u}),(0,y.jsx)(I.IconExternalLink,{size:14,"aria-hidden":`true`})]}):(0,y.jsx)(`div`,{className:Z.sectionTitle,children:(0,y.jsx)(`span`,{className:Z.sectionLabel,children:u})}),(0,y.jsx)(`span`,{className:Z.sectionValue,children:q(l)})]}),m?(0,y.jsx)(`div`,{className:Z.tokenList,children:S.map(({id:e,position:t})=>(0,y.jsx)(Sy,{position:t},e))}):(0,y.jsx)(`div`,{className:(0,P.default)(Z.tokenList,{[Z.stakingTokenList]:p}),children:h.map(e=>(0,y.jsx)(Cy,{group:e,showTypeBreakdown:p,denomLogoMap:n,getClaimableInitByType:o,initPrice:s},e.denom))})]})};function xy(e){return e==null||!Number.isFinite(e)||e===0?Z.perpPnlNeutral:e>0?Z.perpPnlPositive:Z.perpPnlNegative}var Sy=({position:e})=>{let t=e.direction===`long`,n=ds(e),r=fs(e),i=_s(e),a=ps(e),o=hs(n,r),s=o?`${ms(n)} ${o}`:ms(n),c=t?`Long`:`Short`,l=gs(e.leverage),u=l?`${l}X ${c}`:c,d=a?`—`:q(i);return(0,y.jsxs)(`div`,{className:Z.perpRow,children:[(0,y.jsxs)(`div`,{className:Z.perpLeft,children:[e.imageUrl&&(0,y.jsx)(K,{src:e.imageUrl,width:20,height:20,className:Z.perpLogo}),(0,y.jsxs)(`div`,{className:Z.perpInfo,children:[(0,y.jsx)(`span`,{className:Z.perpPair,children:e.pair}),(0,y.jsx)(`span`,{className:t?Z.perpDirectionLong:Z.perpDirectionShort,children:u})]})]}),(0,y.jsxs)(`div`,{className:Z.perpRight,children:[(0,y.jsx)(`span`,{className:Z.perpValue,children:d}),(0,y.jsx)(`span`,{className:(0,P.default)(Z.perpPnl,xy(n)),children:s})]})]})},Cy=({group:e,showTypeBreakdown:t,denomLogoMap:n,getClaimableInitByType:r,initPrice:i})=>{let{denom:a,symbol:o,totalAmount:s,totalValue:c,positions:l}=e,u=n.get(a),[f,p]=(0,g.useState)(!1),m=(0,g.useMemo)(()=>{if(!t)return null;let e=Ts(l);return e.size>0?e:null},[l,t]);return m?(0,y.jsxs)(N.Collapsible.Root,{open:f,onOpenChange:p,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:Z.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:Z.tokenInfo,children:[(0,y.jsx)(I.IconChevronDown,{size:14,className:(0,P.default)(Z.tokenChevron,{[Z.expanded]:f}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Z.tokenInfoLabel,children:[u?.assetLogo&&(0,y.jsx)(K,{src:u.assetLogo,width:20,height:20,className:Z.tokenLogo}),(0,y.jsx)(`span`,{className:Z.tokenSymbol,children:o})]})]}),(0,y.jsx)(`span`,{className:Z.triggerValue,children:q(c)})]})}),(0,y.jsx)(N.Collapsible.Content,{className:Z.collapsibleContent,children:(0,y.jsx)(wy,{typeGroups:m,symbol:o,denom:a,getClaimableInitByType:r,initPrice:i})})]}):(0,y.jsx)(`div`,{className:Z.tokenRow,children:(0,y.jsxs)(`div`,{className:Z.tokenMain,children:[(0,y.jsxs)(`div`,{className:Z.tokenInfo,children:[u?.assetLogo&&(0,y.jsx)(K,{src:u.assetLogo,width:20,height:20,className:Z.tokenLogo}),(0,y.jsx)(`span`,{className:Z.tokenSymbol,children:o})]}),(0,y.jsxs)(`div`,{className:Z.tokenValues,children:[(0,y.jsx)(`span`,{className:Z.tokenAmount,children:(0,d.formatNumber)(s,{dp:6})}),(0,y.jsx)(`span`,{className:Z.tokenValue,children:q(c)})]})]})})},wy=({typeGroups:e,symbol:t,denom:n,getClaimableInitByType:r,initPrice:i})=>{let a=(0,g.useMemo)(()=>Array.from(e.entries()).map(([e,t])=>({type:e,typeAmount:t.reduce((e,t)=>t.type===`fungible-position`||t.type===`perp-position`||t.balance.type===`unknown`?e:e+t.balance.formattedAmount,0),typeValue:t.reduce((e,t)=>e+_s(t),0)})),[e]),o=(0,g.useMemo)(()=>{if(!r)return 0;let e=0;for(let{type:t}of a){let i=r(n,t);e+=Number(i)}return e},[n,r,a]),s=o>0;return(0,y.jsxs)(`div`,{className:Z.typeBreakdown,children:[a.map(({type:e,typeAmount:n,typeValue:r})=>(0,y.jsxs)(`div`,{className:Z.typeRow,children:[(0,y.jsx)(`span`,{className:Z.typeLabel,children:ws(e)}),(0,y.jsxs)(`div`,{className:Z.typeValues,children:[(0,y.jsxs)(`span`,{className:Z.typeAmount,children:[(0,d.formatNumber)(n,{dp:6}),` `,t]}),(0,y.jsx)(`span`,{className:Z.typeValue,children:q(r)})]})]},e)),s&&(0,y.jsxs)(`div`,{className:Z.typeRow,children:[(0,y.jsx)(`span`,{className:Z.typeLabel,children:`Claimable rewards`}),(0,y.jsxs)(`div`,{className:Z.typeValues,children:[(0,y.jsxs)(`span`,{className:Z.typeAmount,children:[(0,d.formatNumber)(o,{dp:6}),` `,`INIT`]}),(0,y.jsx)(`span`,{className:Z.typeValue,children:q(o*(i??0))})]})]})]})},Ty={container:`_container_jelqd_1`,trigger:`_trigger_jelqd_6`,expandIcon:`_expandIcon_jelqd_22`,chainInfo:`_chainInfo_jelqd_27`,logo:`_logo_jelqd_33`,chainNameContainer:`_chainNameContainer_jelqd_37`,chainName:`_chainName_jelqd_37`,externalLink:`_externalLink_jelqd_49`,externalIcon:`_externalIcon_jelqd_53`,chainNameLink:`_chainNameLink_jelqd_58`,valueColumn:`_valueColumn_jelqd_75`,value:`_value_jelqd_75`,expanded:`_expanded_jelqd_92`,collapsibleContent:`_collapsibleContent_jelqd_97`,slideDown:`_slideDown_jelqd_1`,slideUp:`_slideUp_jelqd_1`,content:`_content_jelqd_109`},Ey=(0,b.atom)([]),Dy=({chainGroup:e})=>{let{chainId:t,chainName:n,chainLogo:r,protocols:i}=e,a=Xe(),o=dt(),{denomLogos:s,symbolLogos:c}=(0,g.useMemo)(()=>us(o,a),[o,a]);return(0,y.jsx)(yy,{protocols:i,denomLogoMap:(0,g.useMemo)(()=>{let e=new Map;for(let n of i)for(let i of n.positions){if(i.type===`fungible-position`||i.type===`perp-position`||i.balance.type===`unknown`)continue;let{denom:n,symbol:a}=i.balance,o=a.toUpperCase(),l=`${t}:${n}`,u=s.get(l)??c.get(o);u&&e.set(n,{assetLogo:u,chainLogo:r??``})}return e},[i,s,c,t,r]),chainName:n})},Oy=({chainGroup:e})=>{let{chainName:t,prettyName:n,chainLogo:r,protocols:i}=e,a=i[0]?.manageUrl,[o,s]=(0,b.useAtom)(Ey),c=(0,g.useMemo)(()=>i.reduce((e,t)=>e+t.positions.reduce((e,t)=>e+_s(t),0),0),[i]),l=[`civitia`,`yominet`],u=o.includes(t),d=t?.toLowerCase(),f=l.includes(d);return(0,y.jsx)(`div`,{className:Ty.container,children:(0,y.jsxs)(N.Collapsible.Root,{open:u,onOpenChange:()=>{s(e=>u?e.filter(e=>e!==t):[...new Set([...e,t])])},children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:Ty.trigger,children:[(0,y.jsxs)(`div`,{className:Ty.chainInfo,children:[r&&(0,y.jsx)(K,{src:r,width:32,height:32,className:Ty.logo,logo:!0}),a?(0,y.jsxs)(`a`,{href:Sc(a),target:`_blank`,rel:`noopener noreferrer`,className:Ty.chainNameLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Ty.chainName,children:n}),(0,y.jsx)(I.IconExternalLink,{size:14,className:Ty.externalIcon})]}):(0,y.jsx)(`div`,{className:Ty.chainNameContainer,children:(0,y.jsx)(`span`,{className:Ty.chainName,children:n})})]}),(0,y.jsxs)(`div`,{className:Ty.valueColumn,children:[!f&&(0,y.jsx)(`span`,{className:Ty.value,children:q(c)}),(0,y.jsx)(I.IconChevronDown,{size:16,className:(0,P.default)(Ty.expandIcon,{[Ty.expanded]:u})})]})]})}),(0,y.jsx)(N.Collapsible.Content,{className:Ty.collapsibleContent,children:(0,y.jsx)(`div`,{className:Ty.content,children:(0,y.jsx)(Dy,{chainGroup:e})})})]})})},Q={container:`_container_176wa_1`,section:`_section_176wa_6`,sectionHeader:`_sectionHeader_176wa_14`,sectionTitle:`_sectionTitle_176wa_20`,sectionLabel:`_sectionLabel_176wa_26`,externalLink:`_externalLink_176wa_32`,sectionTitleLink:`_sectionTitleLink_176wa_44`,sectionValue:`_sectionValue_176wa_58`,tokenList:`_tokenList_176wa_65`,tokenTrigger:`_tokenTrigger_176wa_77`,tokenChevron:`_tokenChevron_176wa_93`,expanded:`_expanded_176wa_104`,tokenInfo:`_tokenInfo_176wa_108`,tokenInfoLabel:`_tokenInfoLabel_176wa_114`,tokenLogo:`_tokenLogo_176wa_120`,pairedLogos:`_pairedLogos_176wa_124`,coinLogo:`_coinLogo_176wa_129`,tokenSymbol:`_tokenSymbol_176wa_147`,triggerValue:`_triggerValue_176wa_153`,clammBreakdownContent:`_clammBreakdownContent_176wa_160`,clammPositionRow:`_clammPositionRow_176wa_168`,statusDot:`_statusDot_176wa_177`,inRange:`_inRange_176wa_184`,outRange:`_outRange_176wa_188`,unknown:`_unknown_176wa_192`,clammStatusValue:`_clammStatusValue_176wa_196`,breakdownContent:`_breakdownContent_176wa_206`,breakdownRow:`_breakdownRow_176wa_214`,breakdownLabel:`_breakdownLabel_176wa_222`,breakdownValues:`_breakdownValues_176wa_228`,breakdownAmount:`_breakdownAmount_176wa_234`,breakdownValue:`_breakdownValue_176wa_228`,empty:`_empty_176wa_248`,collapsibleContent:`_collapsibleContent_176wa_255`,slideDown:`_slideDown_176wa_1`,slideUp:`_slideUp_176wa_1`},ky=({data:e,denomLogoMap:t})=>{let{totalValue:n,rows:r}=e;return r.length===0?null:(0,y.jsx)(`div`,{className:Q.container,children:(0,y.jsxs)(`section`,{className:Q.section,"aria-label":`Liquidity positions`,children:[(0,y.jsxs)(`div`,{className:Q.sectionHeader,children:[(0,y.jsxs)(`a`,{href:wt,target:`_blank`,rel:`noopener noreferrer`,className:Q.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Q.sectionLabel,children:`Liquidity`}),(0,y.jsx)(I.IconExternalLink,{size:14,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:Q.sectionValue,children:q(n)})]}),(0,y.jsx)(`div`,{className:Q.tokenList,children:r.map(e=>(0,y.jsx)(Ry,{row:e,denomLogoMap:t},e.denom))})]})})},Ay={deposit:`Deposit`,staking:`Staking`,lockStaking:`Lock staking`,unstaking:`Unstaking`};function jy(e){return e===void 0?Q.unknown:e?Q.inRange:Q.outRange}function My(e){return e===void 0?`Status unavailable`:e?`In range`:`Out of range`}function Ny(e,t){return e===void 0?`-`:`${(0,d.formatNumber)(e,{dp:6})} ${t}`}function Py({isOpen:e,symbol:t,coinLogos:n,singleLogoUrl:r,rightContent:i}){let a=n&&n.length>0&&n.some(e=>e);return(0,y.jsxs)(`button`,{className:Q.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:Q.tokenInfo,children:[(0,y.jsx)(I.IconChevronDown,{size:14,className:(0,P.default)(Q.tokenChevron,{[Q.expanded]:e}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Q.tokenInfoLabel,children:[a?(0,y.jsx)(`div`,{className:Q.pairedLogos,children:n.map((e,t)=>(0,y.jsx)(K,{src:e,width:20,height:20,className:Q.coinLogo,logo:!0},t))}):r&&(0,y.jsx)(K,{src:r,width:20,height:20,className:Q.tokenLogo}),(0,y.jsx)(`span`,{className:Q.tokenSymbol,children:t})]})]}),i]})}var Fy=({position:e})=>{let t=jy(e.inRange),n=My(e.inRange);return(0,y.jsxs)(`div`,{className:Q.clammPositionRow,children:[(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Position ID`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:e.positionId})})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Deposit`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(e.value)})})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Status`}),(0,y.jsxs)(`div`,{className:Q.clammStatusValue,children:[(0,y.jsx)(`span`,{className:(0,P.default)(Q.statusDot,t)}),(0,y.jsx)(`span`,{children:n})]})]}),e.isFullRange?(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Range Bounds`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:`Full range`})})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Min`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:Ny(e.minPrice,e.pricePairLabel)})})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Max`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:Ny(e.maxPrice,e.pricePairLabel)})})]})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Claimable rewards`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(e.rewardValue)})})]})]})},Iy=({row:e,denomLogoMap:t})=>{let[n,r]=(0,g.useState)(!1),{denom:i,symbol:a,totalValue:o,coinLogos:s,logoUrl:c,clamm:l}=e,u=t.get(i);if(!l)return null;let d=c||u?.assetLogo;return(0,y.jsxs)(N.Collapsible.Root,{open:n,onOpenChange:r,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:Py({isOpen:n,symbol:a,coinLogos:s,singleLogoUrl:d,rightContent:(0,y.jsx)(`span`,{className:Q.triggerValue,children:q(o)})})}),(0,y.jsx)(N.Collapsible.Content,{className:Q.collapsibleContent,children:(0,y.jsxs)(`div`,{className:Q.clammBreakdownContent,children:[(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Claimable rewards`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(l.totalRewardValue)})})]}),l.positions.map(e=>(0,y.jsx)(Fy,{position:e},e.tokenAddress))]})})]})},Ly=({row:e,denomLogoMap:t})=>{let{denom:n,symbol:r,totalValue:i,breakdown:a,logoUrl:o,coinLogos:s,claimableInit:c}=e,[l,u]=(0,g.useState)(!1),f=t.get(n),p=o||f?.assetLogo,m=e.totalAmount>0?e.totalValue/e.totalAmount:0,h=(0,g.useMemo)(()=>Object.entries(a).filter(([,e])=>e>0),[a]),_=c&&Number(c.total)>0;return(0,y.jsxs)(N.Collapsible.Root,{open:l,onOpenChange:u,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:Py({isOpen:l,symbol:r,coinLogos:s,singleLogoUrl:p,rightContent:(0,y.jsx)(`span`,{className:Q.triggerValue,children:q(i)})})}),(0,y.jsx)(N.Collapsible.Content,{className:Q.collapsibleContent,children:(0,y.jsxs)(`div`,{className:Q.breakdownContent,children:[h.map(([e,t])=>{let n=t*m;return(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:Ay[e]}),(0,y.jsxs)(`div`,{className:Q.breakdownValues,children:[(0,y.jsxs)(`span`,{className:Q.breakdownAmount,children:[(0,d.formatNumber)(t,{dp:6}),` LP`]}),(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(n)})]})]},e)}),_&&(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Claimable rewards`}),(0,y.jsxs)(`div`,{className:Q.breakdownValues,children:[(0,y.jsxs)(`span`,{className:Q.breakdownAmount,children:[(0,d.formatNumber)(Number(c.total),{dp:6}),` `,`INIT`]}),(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(c.totalValue)})]})]})]})})]})},Ry=({row:e,denomLogoMap:t})=>e.clamm?(0,y.jsx)(Iy,{row:e,denomLogoMap:t}):(0,y.jsx)(Ly,{row:e,denomLogoMap:t}),$={container:`_container_1nf0m_1`,section:`_section_1nf0m_6`,sectionHeader:`_sectionHeader_1nf0m_14`,sectionLabel:`_sectionLabel_1nf0m_20`,sectionTitleLink:`_sectionTitleLink_1nf0m_26`,sectionValue:`_sectionValue_1nf0m_40`,tokenList:`_tokenList_1nf0m_47`,tokenTrigger:`_tokenTrigger_1nf0m_59`,tokenChevron:`_tokenChevron_1nf0m_75`,expanded:`_expanded_1nf0m_86`,tokenInfo:`_tokenInfo_1nf0m_90`,tokenInfoLabel:`_tokenInfoLabel_1nf0m_96`,pairedLogos:`_pairedLogos_1nf0m_102`,coinLogo:`_coinLogo_1nf0m_107`,tokenSymbol:`_tokenSymbol_1nf0m_125`,triggerValue:`_triggerValue_1nf0m_131`,statusDot:`_statusDot_1nf0m_138`,active:`_active_1nf0m_145`,inactive:`_inactive_1nf0m_149`,statusValue:`_statusValue_1nf0m_153`,breakdownContent:`_breakdownContent_1nf0m_163`,breakdownRow:`_breakdownRow_1nf0m_171`,breakdownLabel:`_breakdownLabel_1nf0m_179`,breakdownValues:`_breakdownValues_1nf0m_185`,breakdownValue:`_breakdownValue_1nf0m_185`,curatorLink:`_curatorLink_1nf0m_198`,collapsibleContent:`_collapsibleContent_1nf0m_209`,slideDown:`_slideDown_1nf0m_1`,slideUp:`_slideUp_1nf0m_1`},zy=({data:e,chainId:t})=>{let{totalValue:n,rows:r}=e;return r.length===0?null:(0,y.jsx)(`div`,{className:$.container,children:(0,y.jsxs)(`section`,{className:$.section,"aria-label":`Vault positions`,children:[(0,y.jsxs)(`div`,{className:$.sectionHeader,children:[(0,y.jsxs)(`a`,{href:wt,target:`_blank`,rel:`noopener noreferrer`,className:$.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:$.sectionLabel,children:`Vault`}),(0,y.jsx)(I.IconExternalLink,{size:14,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:$.sectionValue,children:q(n)})]}),(0,y.jsx)(`div`,{className:$.tokenList,children:r.map(e=>(0,y.jsx)(By,{row:e,chainId:t},e.vaultAddress))})]})})},By=({row:e,chainId:t})=>{let[n,r]=(0,g.useState)(!1),{symbol:i,coinLogos:a,value:o,claimableValue:s,isActive:c,curatorAddress:l}=e,u=a.some(e=>e);return(0,y.jsxs)(N.Collapsible.Root,{open:n,onOpenChange:r,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:$.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:$.tokenInfo,children:[(0,y.jsx)(I.IconChevronDown,{size:14,className:(0,P.default)($.tokenChevron,{[$.expanded]:n}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:$.tokenInfoLabel,children:[u&&(0,y.jsx)(`div`,{className:$.pairedLogos,children:a.map((e,t)=>(0,y.jsx)(K,{src:e,width:20,height:20,className:$.coinLogo,logo:!0},t))}),(0,y.jsx)(`span`,{className:$.tokenSymbol,children:i})]})]}),(0,y.jsx)(`span`,{className:$.triggerValue,children:q(o+s)})]})}),(0,y.jsx)(N.Collapsible.Content,{className:$.collapsibleContent,children:(0,y.jsxs)(`div`,{className:$.breakdownContent,children:[(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Deposit`}),(0,y.jsx)(`div`,{className:$.breakdownValues,children:(0,y.jsx)(`span`,{className:$.breakdownValue,children:q(o)})})]}),(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Status`}),(0,y.jsxs)(`div`,{className:$.statusValue,children:[(0,y.jsx)(`span`,{className:(0,P.default)($.statusDot,c?$.active:$.inactive)}),(0,y.jsx)(`span`,{children:c?`Active`:`Inactive`})]})]}),l&&(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Curator`}),(0,y.jsx)(wc,{chainId:t,accountAddress:l,className:$.curatorLink,showIcon:!0})]}),(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Claimable rewards`}),(0,y.jsx)(`div`,{className:$.breakdownValues,children:(0,y.jsx)(`span`,{className:$.breakdownValue,children:q(s)})})]})]})})]})},Vy={container:`_container_1fdqm_1`,section:`_section_1fdqm_6`,sectionHeader:`_sectionHeader_1fdqm_14`,sectionTitle:`_sectionTitle_1fdqm_20`,sectionLabel:`_sectionLabel_1fdqm_26`,externalLink:`_externalLink_1fdqm_32`,sectionTitleLink:`_sectionTitleLink_1fdqm_44`,sectionValue:`_sectionValue_1fdqm_58`,tokenList:`_tokenList_1fdqm_65`,tokenTrigger:`_tokenTrigger_1fdqm_77`,tokenChevron:`_tokenChevron_1fdqm_93`,expanded:`_expanded_1fdqm_104`,tokenInfo:`_tokenInfo_1fdqm_108`,tokenInfoLabel:`_tokenInfoLabel_1fdqm_114`,tokenLogo:`_tokenLogo_1fdqm_120`,tokenName:`_tokenName_1fdqm_124`,triggerValue:`_triggerValue_1fdqm_130`,breakdownContent:`_breakdownContent_1fdqm_137`,breakdownRow:`_breakdownRow_1fdqm_145`,breakdownLabel:`_breakdownLabel_1fdqm_153`,breakdownValues:`_breakdownValues_1fdqm_159`,breakdownAmount:`_breakdownAmount_1fdqm_165`,breakdownValue:`_breakdownValue_1fdqm_159`,collapsibleContent:`_collapsibleContent_1fdqm_179`,slideDown:`_slideDown_1fdqm_1`,slideUp:`_slideUp_1fdqm_1`},Hy=({data:e})=>{let{totalValue:t,rows:n}=e;return n.length===0?null:(0,y.jsx)(`div`,{className:Vy.container,children:(0,y.jsxs)(`section`,{className:Vy.section,"aria-label":`VIP rewards`,children:[(0,y.jsxs)(`div`,{className:Vy.sectionHeader,children:[(0,y.jsxs)(`a`,{href:Tt,target:`_blank`,rel:`noopener noreferrer`,className:Vy.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Vy.sectionLabel,children:`VIP`}),(0,y.jsx)(I.IconExternalLink,{size:14,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:Vy.sectionValue,children:q(t)})]}),(0,y.jsx)(`div`,{className:Vy.tokenList,children:n.map(e=>(0,y.jsx)(Uy,{row:e},`${e.bridgeId}-${e.version}`))})]})})},Uy=({row:e})=>{let{name:t,logoUrl:n,lockedReward:r,lockedRewardValue:i,claimableReward:a,claimableRewardValue:o}=e,[s,c]=(0,g.useState)(!1),l=i+o;return(0,y.jsxs)(N.Collapsible.Root,{open:s,onOpenChange:c,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:Vy.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:Vy.tokenInfo,children:[(0,y.jsx)(I.IconChevronDown,{size:14,className:(0,P.default)(Vy.tokenChevron,{[Vy.expanded]:s}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Vy.tokenInfoLabel,children:[(0,y.jsx)(K,{src:n,width:20,height:20,className:Vy.tokenLogo,logo:!0}),(0,y.jsx)(`span`,{className:Vy.tokenName,children:t})]})]}),(0,y.jsx)(`span`,{className:Vy.triggerValue,children:q(l)})]})}),(0,y.jsx)(N.Collapsible.Content,{className:Vy.collapsibleContent,children:(0,y.jsxs)(`div`,{className:Vy.breakdownContent,children:[r>0&&(0,y.jsxs)(`div`,{className:Vy.breakdownRow,children:[(0,y.jsx)(`span`,{className:Vy.breakdownLabel,children:`Locked`}),(0,y.jsxs)(`div`,{className:Vy.breakdownValues,children:[(0,y.jsxs)(`span`,{className:Vy.breakdownAmount,children:[(0,d.formatNumber)(r,{dp:2}),` INIT`]}),(0,y.jsx)(`span`,{className:Vy.breakdownValue,children:q(i)})]})]}),a>0&&(0,y.jsxs)(`div`,{className:Vy.breakdownRow,children:[(0,y.jsx)(`span`,{className:Vy.breakdownLabel,children:`Claimable rewards`}),(0,y.jsxs)(`div`,{className:Vy.breakdownValues,children:[(0,y.jsxs)(`span`,{className:Vy.breakdownAmount,children:[(0,d.formatNumber)(a,{dp:2}),` INIT`]}),(0,y.jsx)(`span`,{className:Vy.breakdownValue,children:q(o)})]})]})]})})]})},Wy={container:`_container_jelqd_1`,trigger:`_trigger_jelqd_6`,expandIcon:`_expandIcon_jelqd_22`,chainInfo:`_chainInfo_jelqd_27`,logo:`_logo_jelqd_33`,chainNameContainer:`_chainNameContainer_jelqd_37`,chainName:`_chainName_jelqd_37`,externalLink:`_externalLink_jelqd_49`,externalIcon:`_externalIcon_jelqd_53`,chainNameLink:`_chainNameLink_jelqd_58`,valueColumn:`_valueColumn_jelqd_75`,value:`_value_jelqd_75`,expanded:`_expanded_jelqd_92`,collapsibleContent:`_collapsibleContent_jelqd_97`,slideDown:`_slideDown_jelqd_1`,slideUp:`_slideUp_jelqd_1`,content:`_content_jelqd_109`},Gy=(0,b.atom)(!1),Ky=()=>{let{totalValue:e}=No(),{totalValue:t}=Ko(),{totalValue:n}=os(),{totalValue:r}=ts(),i=e+t+n+r;return(0,y.jsx)(`span`,{className:Wy.value,children:q(i)})},qy=({chainId:e,chainLogo:t,denomLogos:n,symbolLogos:r,initPrice:i})=>{let{positions:a}=No(),{data:o}=jo(),{data:s}=Mo(),c=(0,g.useMemo)(()=>{let i=new Map;for(let o of a){if(o.type===`fungible-position`||o.type===`perp-position`||o.balance.type===`unknown`)continue;let{denom:a,symbol:s}=o.balance,c=s.toUpperCase(),l=`${e}:${a}`,u=n.get(l)??r.get(c);u&&i.set(a,{assetLogo:u,chainLogo:t})}return i},[a,n,r,e,t]),l=(0,g.useMemo)(()=>(e,t)=>{let n=(0,d.denomToMetadata)(e);if(t===`staking`){let e=o?.get(n);return e?(0,d.fromBaseUnit)(e.amount,{decimals:6}):`0`}if(t===`lockstaking`){let e=s?.get(n);return e?(0,d.fromBaseUnit)(e.amount,{decimals:6}):`0`}return`0`},[o,s]),u=(0,g.useMemo)(()=>a.length===0?[]:[{protocol:`Initia`,manageUrl:wt,positions:a}],[a]);return u.length===0?null:(0,y.jsx)(yy,{protocols:u,denomLogoMap:c,isInitia:!0,getClaimableInitByType:l,initPrice:i})},Jy=({chainId:e,chainLogo:t,denomLogos:n,symbolLogos:r})=>{let i=Ko(),a=(0,g.useMemo)(()=>{let a=new Map;for(let o of i.rows){let{denom:i,symbol:s}=o,c=s.toUpperCase(),l=`${e}:${i}`,u=n.get(l)??r.get(c);u&&a.set(i,{assetLogo:u,chainLogo:t})}return a},[i.rows,n,r,e,t]);return i.rows.length===0?null:(0,y.jsx)(ky,{data:i,denomLogoMap:a})},Yy=()=>{let e=os();return e.rows.length===0?null:(0,y.jsx)(Hy,{data:e})},Xy=({chainId:e})=>{let t=ts();return t.rows.length===0?null:(0,y.jsx)(zy,{data:t,chainId:e})},Zy=({chainGroup:e})=>{let{chainId:t,prettyName:n,chainLogo:r}=e,[i,a]=(0,b.useAtom)(Gy),o=Xe(),s=dt(),{denomLogos:c,symbolLogos:l}=(0,g.useMemo)(()=>us(s,o),[s,o]),{data:u}=it(B()),d=(0,g.useMemo)(()=>u?.find(e=>e.id===`uinit`)?.price??0,[u]);return(0,y.jsx)(`div`,{className:Wy.container,children:(0,y.jsxs)(N.Collapsible.Root,{open:i,onOpenChange:a,children:[(0,y.jsx)(N.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:Wy.trigger,children:[(0,y.jsxs)(`div`,{className:Wy.chainInfo,children:[r&&(0,y.jsx)(K,{src:r,width:32,height:32,className:Wy.logo,logo:!0}),(0,y.jsxs)(`a`,{href:wt,target:`_blank`,rel:`noopener noreferrer`,className:Wy.chainNameLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Wy.chainName,children:n}),(0,y.jsx)(I.IconExternalLink,{size:14,className:Wy.externalIcon})]})]}),(0,y.jsxs)(`div`,{className:Wy.valueColumn,children:[(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:16,width:60,length:1}),children:(0,y.jsx)(Ky,{})}),(0,y.jsx)(I.IconChevronDown,{size:16,className:(0,P.default)(Wy.expandIcon,{[Wy.expanded]:i})})]})]})}),(0,y.jsx)(N.Collapsible.Content,{className:Wy.collapsibleContent,children:(0,y.jsxs)(`div`,{className:Wy.content,children:[(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:36,length:2}),children:(0,y.jsx)(qy,{chainId:t,chainLogo:r,denomLogos:c,symbolLogos:l,initPrice:d})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:36,length:1}),children:(0,y.jsx)(Xy,{chainId:t})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:36,length:2}),children:(0,y.jsx)(Jy,{chainId:t,chainLogo:r,denomLogos:c,symbolLogos:l})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:36,length:1}),children:(0,y.jsx)(Yy,{})})]})})]})})},Qy={totalValue:`_totalValue_1v2ca_1`},$y=({filteredChainGroups:e})=>{let{totalValue:t}=No(),{totalValue:n}=Ko(),{totalValue:r}=os(),{totalValue:i}=ts(),a=t+n+r+i,o=(0,g.useMemo)(()=>{let t=e.some(e=>e.isInitia);return e.reduce((e,t)=>t.isInitia?e:e+t.totalValue,0)+(t?a:0)},[e,a]);return(0,y.jsx)(`span`,{className:Qy.totalValue,children:q(o)})},eb={container:`_container_1eubu_1`,header:`_header_1eubu_7`,title:`_title_1eubu_13`,list:`_list_1eubu_19`,skeletonWrapper:`_skeletonWrapper_1eubu_24`},tb=(0,g.memo)(({searchQuery:e,selectedChain:t,chainInfoMap:n})=>{let{positions:r,isLoading:i}=qs(),a=B(),o=(0,g.useMemo)(()=>{let i=[];for(let o of r){if(!Array.isArray(o.positions))continue;let r=n.get(o.chainName.toLowerCase()),s=o.chainName.toLowerCase(),c=(r?.prettyName??o.chainName).toLowerCase();if(t&&r?.chainId!==t||!o.positions.some(e=>e.positions.some(e=>e.type!==`fungible-position`)))continue;if(e){let t=e.toLowerCase();if(!s.includes(t)&&!c.includes(t))continue}let l=o.positions.filter(t=>e&&!t.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(t.positions)&&t.positions.length>0),u=a.chainId===r?.chainId,d=l.reduce((e,t)=>e+t.positions.reduce((e,t)=>e+_s(t),0),0);i.push({chainId:r?.chainId??``,chainName:o.chainName,prettyName:r?.prettyName??o.chainName,chainLogo:r?.logoUrl??``,protocols:l,isInitia:u,totalValue:d})}let o=[`civitia`,`yominet`];return(0,p.sortWith)([(0,p.descend)(e=>e.isInitia??!1),(0,p.ascend)(e=>o.includes(e.chainName.toLowerCase())),(0,p.descend)(e=>e.totalValue??0),(0,p.ascend)(e=>e.prettyName.toLowerCase())],i)},[r,n,e,t,a.chainId]),s=o.length>0;return(0,y.jsxs)(`div`,{className:eb.container,children:[(0,y.jsxs)(`div`,{className:eb.header,children:[(0,y.jsx)(`span`,{className:eb.title,children:`Positions`}),s&&(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:16,width:60,length:1}),children:(0,y.jsx)($y,{filteredChainGroups:o})})]}),s?(0,y.jsx)(`div`,{className:eb.list,children:o.map(e=>e.isInitia?(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(`div`,{className:eb.skeletonWrapper,children:(0,y.jsx)(gy,{height:56,length:1})}),children:(0,y.jsx)(Zy,{chainGroup:e})},e.chainName):(0,y.jsx)(Oy,{chainGroup:e},e.chainName))}):r.length===0&&i?(0,y.jsx)(gy,{height:56,length:3}):(0,y.jsx)(Da,{children:`No positions`})]})}),nb={content:`_content_1w1ad_1`},rb=({selectedChain:e,setSelectedChain:t})=>{let{defaultChainId:n}=R(),r=B(),i=Ys(),{totalValue:a}=os(),{totalValue:o}=ts(),{chainIds:s,chainIdToValueMap:c,totalBalance:l}=(0,g.useMemo)(()=>{let e=new Map,t=0;for(let n of i)e.set(n.chainId,n.totalBalance),t+=n.totalBalance;let s=a+o;return s>0&&(e.set(r.chainId,(e.get(r.chainId)??0)+s),t+=s),{chainIds:(0,p.sortWith)([(0,p.descend)(e=>e===n),(0,p.descend)(e=>e===r.chainId),(0,p.descend)(t=>e.get(t)??0)],i.map(e=>e.chainId)),chainIdToValueMap:e,totalBalance:t}},[i,n,r,a,o]);return(0,y.jsx)(Cv,{value:e,onChange:t,chainIds:s,renderExtra:e=>q(e?c.get(e)??0:l)})},ib=()=>{let[e,t]=(0,b.useAtom)(Ev),[n,r]=(0,b.useAtom)(Dv),i=Xe(),a=dt(),{denomLogos:o,symbolLogos:s}=(0,g.useMemo)(()=>us(a,i),[a,i]),c=at(),l=(0,g.useMemo)(()=>Os(i,c),[i,c]),u=Js();return(0,y.jsxs)(Tv.Root,{children:[(0,y.jsxs)(Tv.Controls,{children:[(0,y.jsx)(Tv.SearchInput,{value:e,onChange:e=>t(e.target.value),onClear:()=>t(``),placeholder:`Search portfolio`}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(ld,{height:44,width:132}),children:(0,y.jsx)(rb,{selectedChain:n,setSelectedChain:r})})]}),(0,y.jsxs)(`section`,{className:nb.content,"aria-label":`Assets and positions`,children:[(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:48,length:5}),children:(0,y.jsx)(_y,{searchQuery:e,selectedChain:n,denomLogos:o,symbolLogos:s,chainInfoMap:u,chainPrices:l})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gy,{height:56,length:3}),children:(0,y.jsx)(tb,{searchQuery:e,selectedChain:n,chainInfoMap:u})})]})]})},ab={totalValue:`_totalValue_5pf7e_1`,totalLabel:`_totalLabel_5pf7e_7`,totalAmount:`_totalAmount_5pf7e_13`,loading:`_loading_5pf7e_18`,skeletonWrapper:`_skeletonWrapper_5pf7e_23`,nav:`_nav_5pf7e_28`,item:`_item_5pf7e_34`,tabs:`_tabs_5pf7e_59`,tab:`_tab_5pf7e_59`},ob=()=>{let{totalValue:e,isLoading:t}=xa();return(0,y.jsx)(`div`,{className:(0,P.default)(ab.totalAmount,{[ab.loading]:t}),children:q(e)})},sb=()=>{let e=Xs(),t=Zs(),n=e+ss()+t;return(0,y.jsx)(`div`,{className:ab.totalAmount,children:q(n)})},cb=()=>{gu();let e=Ws();(0,g.useEffect)(()=>{e()},[e]);let t=Is(),n=Xt(),r=qt(),i=(0,g.useRef)(null);return(0,y.jsx)(ny.Provider,{value:i,children:(0,y.jsxs)(sc,{ref:i,children:[(0,y.jsxs)(`div`,{className:ab.totalValue,children:[(0,y.jsx)(`div`,{className:ab.totalLabel,children:`Total value`}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(`div`,{className:ab.skeletonWrapper,children:(0,y.jsx)(ld,{height:48,width:120})}),children:t?(0,y.jsx)(ob,{}):(0,y.jsx)(sb,{})})]}),(0,y.jsxs)(`nav`,{className:ab.nav,"aria-label":`Quick actions`,children:[(0,y.jsxs)(Qt,{to:`/send`,className:ab.item,children:[(0,y.jsx)(I.IconSend,{size:20}),(0,y.jsx)(`span`,{children:`Send`})]}),(0,y.jsxs)(Qt,{to:`/bridge`,className:ab.item,children:[(0,y.jsx)(I.IconBridge,{size:20}),(0,y.jsx)(`span`,{children:`Bridge/Swap`})]}),(0,y.jsxs)(Qt,{to:`/receive`,className:ab.item,children:[(0,y.jsx)(I.IconQrCode,{size:20}),(0,y.jsx)(`span`,{children:`Receive`})]})]}),(0,y.jsxs)(Oe.Tabs.Root,{value:r,onValueChange:n,children:[(0,y.jsxs)(Oe.Tabs.List,{className:ab.tabs,children:[(0,y.jsx)(Oe.Tabs.Tab,{className:ab.tab,value:`/`,children:t?`Assets`:`Portfolio`}),(0,y.jsx)(Oe.Tabs.Tab,{className:ab.tab,value:`/nfts`,children:`NFTs`}),(0,y.jsx)(Oe.Tabs.Tab,{className:ab.tab,value:`/activity`,children:`Activity`})]}),(0,y.jsx)(Oe.Tabs.Panel,{value:`/`,children:t?(0,y.jsx)(my,{}):(0,y.jsx)(ib,{})}),(0,y.jsx)(Oe.Tabs.Panel,{value:`/nfts`,children:(0,y.jsx)(ty,{})}),(0,y.jsx)(Oe.Tabs.Panel,{value:`/activity`,children:(0,y.jsx)(Hv,{})})]})]})})},lb={root:`_root_th990_1`,collectionName:`_collectionName_th990_9`,nftName:`_nftName_th990_13`,chainInfo:`_chainInfo_th990_17`,attributes:`_attributes_th990_21`,title:`_title_th990_24`,count:`_count_th990_29`,item:`_item_th990_33`,type:`_type_th990_39`,value:`_value_th990_45`},ub=()=>{let e=Xt(),t=Jt(),{attributes:n}=t;return(0,y.jsxs)(Hl,{title:`NFT details`,children:[(0,y.jsx)(Kv,{normalizedNft:t,chainIconSize:14,classNames:lb}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{onClick:()=>e(`/nft/send`,t),sm:!0,children:`Send`})}),n&&(0,y.jsxs)(`div`,{className:lb.attributes,children:[(0,y.jsxs)(`header`,{className:lb.title,children:[`Traits `,(0,y.jsxs)(`span`,{className:lb.count,children:[`(`,n.length,`)`]})]}),(0,y.jsx)(`div`,{children:n.map(({trait_type:e,value:t})=>(0,y.jsxs)(`div`,{className:lb.item,children:[(0,y.jsx)(`div`,{className:lb.type,children:e}),(0,y.jsx)(`div`,{className:lb.value,children:t})]},e))})]})]})};function db({balances:e,gasPrices:t,gas:n}){return t.map(({denom:t,amount:r})=>({amount:(0,f.default)(r||0).times(n).toFixed(0,f.default.ROUND_CEIL),denom:t,balance:e.find(e=>e.denom===t)?.amount||`0`})).filter(({amount:e,balance:t})=>(0,f.default)(t).gte(e))}function fb({denom:e,balances:t,gasPrices:n,lastFeeDenom:r,gas:i}){let a=t.find(t=>t.denom===e)?.amount||`0`,o=db({balances:t,gasPrices:n,gas:i}),s=o.find(e=>e.denom===r);if(o.length===0)return a;if(e===r&&s){let e=(0,f.default)(a).minus(s.amount);return f.default.max(e,0).toString()}let c=o.find(t=>t.denom!==e)||o[0];if(!s&&e===c.denom){let e=(0,f.default)(a).minus(c.amount);return f.default.max(e,0).toString()}return(0,f.default)(a).toString()}var pb=({chain:e,onSelect:t})=>(0,y.jsx)(nd,{assets:zt(e),onSelect:t}),mb=({afterSelect:e})=>{let{watch:t,setValue:n}=(0,F.useFormContext)(),{chainId:r,denom:i}=t(),{chainId:a}=t(),[o,s]=(0,g.useState)(a),c=et(o),l=Xe();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(id.Stack,{children:(0,y.jsx)(id,{chains:l,value:o,onSelect:s})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(nd.Placeholder,{}),children:(0,y.jsx)(pb,{chain:c,onSelect:t=>{if(r===o&&i===t){e();return}n(`chainId`,o),n(`denom`,t),n(`quantity`,``,{shouldTouch:!1,shouldDirty:!1}),e()}})},o)]})},hb={fields:`_fields_brpej_1`,divider:`_divider_brpej_11`},gb=(0,m.createQueryKeys)(`interwovenkit:send`,{gas:e=>[e]}),_b=()=>{let{address:e,initiaAddress:t,estimateGas:n,requestTxSync:r}=Ta(),{register:i,watch:a,setValue:o,handleSubmit:s,formState:c}=(0,F.useFormContext)(),{errors:l}=c,{chainId:p,denom:m,recipient:h,quantity:_,memo:v}=a(),b=et(p),x=Lt(b),S=Fi(b),C=Ii(b),w=pt(m,b),{data:T}=it(b),{decimals:E}=w,D=x.find(e=>e.denom===m)?.amount||`0`,ee=T?.find(({id:e})=>e===m)?.price,{data:O=0,isLoading:k}=(0,u.useQuery)({queryKey:gb.gas({chainId:p,denom:m,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>n({messages:[{typeUrl:`/cosmos.bank.v1beta1.MsgSend`,value:Ae.MsgSend.fromPartial({fromAddress:t,toAddress:(0,d.InitiaAddress)(h).bech32,amount:[{denom:m,amount:`1`}]})}],chainId:p}),enabled:d.InitiaAddress.validate(h),staleTime:z.INFINITY}),A=fb({denom:m,balances:x,gasPrices:S,lastFeeDenom:C,gas:Math.ceil(O*Pe)}),j=(0,f.default)(D).isZero(),te=S.some(({denom:e})=>e===m)&&k,ne=j||te,M=en(_),re=M?ll(M.times(ee??0),ee):`$0`,{mutate:ie,isPending:ae}=(0,u.useMutation)({mutationFn:({chainId:e,denom:n,quantity:i,recipient:a,memo:o})=>{let s=(0,d.toBaseUnit)(i,{decimals:E});return r({messages:[{typeUrl:`/cosmos.bank.v1beta1.MsgSend`,value:Ae.MsgSend.fromPartial({fromAddress:t,toAddress:(0,d.InitiaAddress)(a).bech32,amount:[{denom:n,amount:s}]})}],memo:o,chainId:e,gas:O,gasAdjustment:Pe,gasPrices:S,spendCoins:[{denom:n,amount:s}],internal:`/`})}}),oe=(0,g.useMemo)(()=>{if(!_)return`Enter amount`;if(l.quantity)return l.quantity.message;if(!h)return`Enter recipient address`;if(l.recipient)return l.recipient.message;if(l.memo)return l.memo.message},[_,h,l.quantity,l.recipient,l.memo]);return(0,y.jsx)(Hl,{title:`Send`,children:(0,y.jsxs)(`form`,{onSubmit:s(e=>ie(e)),"aria-label":`Send token form`,children:[(0,y.jsxs)(`div`,{className:hb.fields,children:[(0,y.jsx)(bu,{selectButton:(0,y.jsx)(Du,{title:`Select chain and asset`,content:e=>(0,y.jsx)(mb,{afterSelect:e}),children:(0,y.jsx)(Zu,{asset:w,chain:b})}),quantityInput:(0,y.jsx)(Eu,{balance:D,decimals:E}),balanceButton:(0,y.jsx)(vu,{onClick:()=>o(`quantity`,(0,d.fromBaseUnit)(A,{decimals:E}),{shouldValidate:!0}),disabled:ne,children:(0,d.formatAmount)(D??`0`,{decimals:E})}),value:re}),(0,y.jsx)(`div`,{className:hb.divider}),(0,y.jsx)(Hu,{myAddress:e}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{htmlFor:`memo`,children:`Memo (optional)`}),(0,y.jsx)(`input`,{...i(`memo`,{validate:e=>!e||new Blob([e]).size<=256||`Memo is too long`}),id:`memo`,autoComplete:`off`})]}),(0,y.jsx)(Gc.Stack,{children:!v&&(0,y.jsx)(Gc,{level:`warning`,children:`Check if the above transaction requires a memo`})})]}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{type:`submit`,loading:(k?`Estimating gas...`:!1)||ae,disabled:!!oe,children:oe??`Confirm`})})]})})},vb=()=>{let e=Jt(),t=nt(),n=ut(t),{chain:r=t}=e,i=(0,p.head)(n);if(!e.denom&&!i)throw Error(`Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.`);let a=e.denom??i?.denom;return(0,y.jsx)(F.FormProvider,{...(0,F.useForm)({mode:`onChange`,defaultValues:{chainId:r.chainId,denom:a,quantity:``,recipient:``,memo:``}}),children:(0,y.jsx)(_b,{})})};async function yb(e,t){let n=e.replace(`ibc/`,``),{class_trace:r}=await h.default.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${n}`).json();return r}async function bb(e,t){let n=new w.Interface([{inputs:[],name:`name`,outputs:[{internalType:`string`,name:``,type:`string`}],stateMutability:`view`,type:`function`}]),{response:r}=await h.default.create({prefixUrl:t}).post(`minievm/evm/v1/call`,{json:{sender:(0,d.InitiaAddress)(`0x1`).bech32,contract_addr:(0,d.InitiaAddress)(e).hex,input:n.encodeFunctionData(`name`)}}).json();return n.decodeFunctionResult(`name`,r)[0]}async function xb(e,t,n){if(t.startsWith(`evm/`))return e;let{token_infos:r}=await h.default.create({prefixUrl:n}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(`,`)}}).json();return r.map(({token_origin_id:e})=>e)}async function Sb({collection_addr:e},{restUrl:t}){let n=await bb(e,t);if(!n.startsWith(`ibc/`))return{class_id:`evm/${(0,d.InitiaAddress)(e).rawHex}`,class_trace:void 0};let r=await yb(n,t);return r?{class_id:n,class_trace:r}:{class_id:`evm/${(0,d.InitiaAddress)(e).rawHex}`,class_trace:void 0}}async function Cb(e,t){let{data:n}=await h.default.create({prefixUrl:t}).post(`initia/move/v1/view/json`,{json:{address:`0x1`,module_name:`collection`,function_name:`name`,type_args:[`0x1::collection::Collection`],args:[JSON.stringify(e)]}}).json();return JSON.parse(n)}async function wb({object_addr:e,collection_addr:t},{restUrl:n}){let r=await Cb(t,n);return r.startsWith(`ibc/`)?d.InitiaAddress.equals((0,d.createObjectAddress)(`0x1`,r),t)?{class_id:r,class_trace:await yb(r,n)}:{class_id:`move/${e.replace(`0x`,``).padStart(64,`0`)}`,class_trace:await yb(r,n)}:{class_id:`move/${t.replace(`0x`,``).padStart(64,`0`)}`,class_trace:void 0}}async function Tb(e,t){let n=(0,_.toBase64)((0,Te.utf8ToBytes)(JSON.stringify({contract_info:{}}))),{data:r}=await h.default.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return r.name}async function Eb(e,t){let{collection:n}=await h.default.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return n.collection.creator}async function Db(e,t){let n=(0,_.toBase64)((0,Te.toBytes)(JSON.stringify({outgoing_proxy:{}}))),{data:r}=await h.default.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return r}function Ob(e){let t=e.match(/^(.*channel-\d+)\/(.*)$/);if(!t)throw Error("Pattern `channel-{number}/` not found.");let[,n,r]=t;return[n,r]}async function kb({collection_addr:e},t,n){let r=(0,d.InitiaAddress)(e).bech32,i=await Tb(r,t.restUrl),a=t.metadata?.ibc_channels?.find(({chain_id:e,version:t})=>e===n.chain_id&&t.includes(`ics721-1`));if(!a)throw Error(`Channel not found`);let o=a.port_id,s=o.split(`.`)[1],c=(0,_.toBase64)((0,Te.toBytes)(JSON.stringify({class_id:{contract:r}}))),{data:l}=await h.default.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${s}/smart/${c}`).json(),u=l??r,f=await Db(s,t.restUrl),p=await Eb(r,t.indexerUrl);if(u===r)return{class_id:u,class_trace:void 0,outgoing_proxy:f};if(l&&p!==o.replace(`wasm.`,``)){let[e,t]=Ob(l);return{class_id:r,class_trace:{path:e,base_class_id:t},outgoing_proxy:f}}let[m,g]=Ob(i);return{class_id:r,class_trace:{path:m,base_class_id:g},outgoing_proxy:f}}var Ab={minimove:wb,minievm:Sb,miniwasm:kb};async function jb({nft:e,srcChain:t,intermediaryChain:n}){let r=t.metadata?.is_l1?`minimove`:t.metadata?.minitia?.type;if(!(r===`minimove`||r===`minievm`||r===`miniwasm`))throw Error(`Unsupported minitia type: ${r}`);let i=await Ab[r](e,t,n);return Object.assign(i,r===`minievm`&&{token_ids:await xb([e.token_id],i.class_id,t.restUrl)})}var Mb={root:`_root_1tyvn_1`,collectionName:`_collectionName_1tyvn_10`,nftName:`_nftName_1tyvn_15`,chainInfo:`_chainInfo_1tyvn_19`,fields:`_fields_1tyvn_24`,chain:`_chain_1tyvn_19`},Nb=(0,m.createQueryKeys)(`interwovenkit:send-nft`,{simulation:e=>[e]}),Pb=()=>{let e=Xe(),t=Jt(),{chain:n,collection_addr:r}=t,{routerApiUrl:i}=R(),a=Br(),o=B(),{address:s,initiaAddress:c,requestTxSync:l}=Ta(),{watch:f,setValue:p,handleSubmit:m,formState:_}=(0,F.useFormContext)(),{errors:v}=_,{recipient:b,dstChainId:x}=f(),S=et(x),{data:C,isLoading:w,error:T}=(0,u.useQuery)({queryKey:Nb.simulation({collection_addr:r,nft:t,sender:c,recipient:b,srcChain:n,dstChain:S,layer1:o,routerApiUrl:i}).queryKey,queryFn:async()=>{let e=Object.assign({from_address:c,from_chain_id:n.chainId,to_address:(0,d.InitiaAddress)(b).bech32,to_chain_id:S.chainId,collection_address:r,token_ids:[t.token_id],object_addresses:[t.object_addr]},n.chainId!==S.chainId&&await jb({nft:t,srcChain:n,intermediaryChain:o})),{msgs:s}=await h.default.create({prefixUrl:i}).post(`nft`,{json:e}).json();return s.map(e=>a.fromAmino(e))},enabled:d.InitiaAddress.validate(b)}),E=(0,u.useQueryClient)(),{mutate:D,isPending:ee}=(0,u.useMutation)({mutationFn:async()=>{if(!C)throw Error(`Route not found`);await l({messages:C,chainId:n.chainId,internal:`/nfts`})},onSuccess:()=>{E.invalidateQueries({queryKey:qv.nfts._def})}}),O=(0,g.useMemo)(()=>{if(!b)return`Enter recipient address`;if(v.recipient)return v.recipient.message;if(T)return`Route not found`},[b,v.recipient,T]);return(0,y.jsxs)(`form`,{onSubmit:m(()=>D()),children:[(0,y.jsx)(Kv,{normalizedNft:t,thumbnailSize:80,classNames:Mb}),(0,y.jsxs)(`div`,{className:Mb.fields,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`label`,children:`Destination app`}),(0,y.jsxs)(Du,{title:`Destination app`,content:t=>(0,y.jsx)(Wu,{onSelect:({chainId:e})=>{p(`dstChainId`,e),t()},list:e,getImage:e=>e.logoUrl,getName:e=>e.name,getKey:e=>e.chainId}),className:(0,P.default)(`input`,Mb.chain),children:[(0,y.jsx)(K,{src:S.logoUrl,width:20,height:20,logo:!0}),(0,y.jsx)(`span`,{children:S.name})]})]}),(0,y.jsx)(Hu,{myAddress:s,ref:xu()})]}),(0,y.jsx)(ac,{children:(0,y.jsx)(G.White,{loading:(w?`Finding route...`:!1)||ee,disabled:!!O,children:O??`Confirm`})})]})},Fb=()=>{let{chain:e}=Jt();return(0,y.jsx)(Hl,{title:`Send NFT`,children:(0,y.jsx)(F.FormProvider,{...(0,F.useForm)({mode:`onChange`,defaultValues:{dstChainId:e.chainId,recipient:``}}),children:(0,y.jsx)(Pb,{})})})},Ib=()=>{let e=Xt(),t=qt(),n=Ca(),{closeDrawer:r}=Sr(),{closeModal:i}=bi();(0,g.useEffect)(()=>{i(),t.startsWith(`/bridge/`)&&t!==`/bridge/history`&&e(`/bridge`),(t===`/collection`||t.startsWith(`/nft`))&&e(`/nfts`)},[n]);let a=Nn();if((0,g.useEffect)(()=>{a(`Page View`)},[t,a]),t===`/connect`)return n?null:(0,y.jsx)(Kp,{onSuccess:r});if(t===`/blank`)return null;if(!n)return(0,y.jsx)(Kp,{});switch(t){case`/`:case`/nfts`:case`/activity`:return(0,y.jsx)(cb,{});case`/send`:return(0,y.jsx)(vb,{},n);case`/receive`:return(0,y.jsx)(iv,{});case`/nft`:return(0,y.jsx)(ub,{});case`/nft/send`:return(0,y.jsx)(Fb,{},n);case`/bridge`:return(0,y.jsx)(Sd,{},n);case`/bridge/preview`:return(0,y.jsx)($f,{});case`/bridge/history`:return(0,y.jsx)(_f,{});case`/op/withdrawals`:return(0,y.jsx)(Ep,{});case`/tx`:return(0,y.jsx)(Sl,{});case`/autosign/enable`:return(0,y.jsx)(Rl,{});case`/settings`:return(0,y.jsx)(xv,{});case`/settings/autosign`:return(0,y.jsx)(pv,{});case`/deposit`:return(0,y.jsx)(Q_,{});case`/withdraw`:return(0,y.jsx)(nv,{})}},Lb=`https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap`,Rb=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.googleapis.com`}),(0,y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.gstatic.com`,crossOrigin:``}),(0,y.jsx)(`link`,{rel:`stylesheet`,href:Lb}),(0,y.jsx)(`link`,{rel:`stylesheet`,href:`https://assets.initia.xyz/fonts/PilatWide.css`})]}),zb=()=>(Qs(),hr(),_i(),Xe(),Gs(),ss(),dt(),null),Bb=({children:e,...t})=>((0,g.useEffect)(()=>{cs()},[]),(0,ue.useIsClient)()?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Rb,{}),(0,y.jsx)(He.Provider,{value:{...Ie,...t},children:(0,y.jsx)($t,{children:(0,y.jsx)(Ol,{children:(0,y.jsx)(N.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:(0,y.jsx)(Dl,{children:(0,y.jsxs)(Cl,{children:[e,(0,y.jsx)($s,{}),(0,y.jsx)(W,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:(0,y.jsx)(zb,{})}),(0,y.jsx)(Ic,{children:(0,y.jsx)(Ib,{})}),(0,y.jsx)(Pc,{children:(0,y.jsx)(Ib,{})})]})})})})})})]}):null),Vb=({bridge:e})=>(0,y.jsx)($t,{initialEntry:{path:e?`/bridge`:`/`,state:e},children:(0,y.jsx)(`div`,{className:`body`,children:(0,y.jsx)(Lc.Provider,{value:!!e,children:(0,y.jsx)(W,{children:(0,y.jsx)(Ib,{})})})})}),Hb={1:`https://ethereum-rpc.publicnode.com`,42161:`https://arbitrum-one-rpc.publicnode.com`,8453:`https://base-rpc.publicnode.com`};function Ub(e){let{id:t=`testWallet`,name:n=`Test Wallet`,rpcUrls:r,debug:i=!1,sendTransactionOverrides:a}=e;if(`mnemonic`in e&&e.mnemonic===``)throw Error(`mnemonic must not be empty`);if(!(`mnemonic`in e&&e.mnemonic)&&!(`privateKey`in e&&e.privateKey))throw Error(`Either mnemonic or privateKey is required`);let o;try{o=e.mnemonic?(0,je.mnemonicToAccount)(e.mnemonic):(0,je.privateKeyToAccount)(e.privateKey)}catch(n){throw Error(`[${t}] Failed to create account from ${e.mnemonic?`mnemonic`:`privateKey`}`,{cause:n})}let s=1,c={};function l(e,...t){c[e]?.forEach(e=>{e(...t)})}let u={...Hb,...r},d={1:Me.mainnet};function f(e){if(u[e])return u[e];let n=d[e];if(n)return n.rpcUrls.default.http[0];throw Error(`[${t}] No RPC configured for chain ${e}`)}async function p(e,n){let r=f(s),i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:e,params:n??[]})});if(!i.ok)throw Error(`[${t}] RPC "${e}" failed: HTTP ${i.status} ${i.statusText} (${r})`);let a;try{a=await i.json()}catch(n){throw Error(`[${t}] RPC "${e}" returned non-JSON response (${r})`,{cause:n})}if(a.error)throw new k.EIP1193ProviderRpcError(a.error.code,a.error.message);return a.result}let m={request:async({method:e,params:n})=>{switch(i&&console.log(`[${t}] ${e}`,n),e){case`eth_requestAccounts`:case`eth_accounts`:return[o.address];case`eth_chainId`:return`0x${s.toString(16)}`;case`wallet_switchEthereumChain`:{let[{chainId:e}]=n,t=Number(e);if(!d[t]&&!u[t])throw new k.EIP1193ProviderRpcError(4902,`Unrecognized chain ID`);return!d[t]&&u[t]&&(d[t]={id:t,name:`Chain ${t}`,nativeCurrency:{name:`ETH`,symbol:`ETH`,decimals:18},rpcUrls:{default:{http:[u[t]]}}}),s=t,l(`chainChanged`,e),null}case`wallet_addEthereumChain`:{let[e]=n,r=e.rpcUrls?.[0];if(!r)throw Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);let a=Number(e.chainId);return d[a]?i&&console.log(`[${t}] Chain ${a} already registered, skipping`):d[a]={id:a,name:e.chainName??`Chain ${a}`,nativeCurrency:{name:`ETH`,symbol:`ETH`,decimals:18},rpcUrls:{default:{http:[r]}}},null}case`personal_sign`:{let[e]=n;return o.signMessage({message:{raw:e}})}case`eth_signTypedData`:case`eth_signTypedData_v4`:{let[,e]=n;return o.signMessage({message:{raw:e}})}case`wallet_getPermissions`:case`wallet_requestPermissions`:return[{parentCapability:`eth_accounts`}];case`eth_sendTransaction`:{let[e]=n,r=d[s];if(!r)throw Error(`[${t}] No chain registered for chain ${s}. Call wallet_switchEthereumChain first.`);return(0,k.createWalletClient)({account:o,chain:r,transport:(0,k.http)(f(s))}).sendTransaction({to:e.to,value:e.value?BigInt(e.value):void 0,data:e.data,chainId:s,...a})}default:return p(e,n)}},on:(e,t)=>{(c[e]??=new Set).add(t)},removeListener:(e,t)=>{c[e]?.delete(t)},removeAllListeners:()=>{for(let e of Object.keys(c))delete c[e]}};return(0,Ne.injected)({target:()=>({id:t,name:n,provider:m})})}var Wb={"noble-1":`noble`,celestia:`celestia`,"neutron-1":`neutron`,"osmosis-1":`osmo`};function Gb(e){let{mnemonic:t,name:n=`Test Cosmos Wallet`,image:r,chains:i,debug:a=!1}=e;if(!t)throw Error(`mnemonic is required`);let o=new Map;function s(e){return i?.[e]?i[e].prefix:Wb[e]?Wb[e]:e.replace(/-\d+$/,``)}function c(e){let r=s(e),i=o.get(r);if(i)return i;a&&console.log(`[${n}] Creating wallet for chain ${e} (prefix: ${r})`);let c=E.Secp256k1HdWallet.fromMnemonic(t,{prefix:r});return c.catch(e=>{o.delete(r),console.error(`[${n}] Failed to create wallet for prefix "${r}":`,e)}),o.set(r,c),c}function l(e){return{async getAccounts(){return(await c(e)).getAccounts()},async signAmino(t,n){return(await c(e)).signAmino(t,n)}}}let u={getOfflineSigner(e){return l(e)},getOfflineSignerOnlyAmino(e){return l(e)}};return{name:n,image:r,getProvider:()=>u}}exports.DEFAULT_GAS_ADJUSTMENT=Pe,exports.DEFAULT_GAS_PRICE_MULTIPLIER=Fe,exports.InterwovenKit=Vb,exports.InterwovenKitProvider=Bb,exports.MAINNET=Ie,exports.MoveError=xi,exports.PRIVY_APP_ID=Re,exports.TESTNET=Le,exports.createTestCosmosWallet=Gb,exports.createTestWalletConnector=Ub,exports.initiaPrivyWallet=Ve,exports.initiaPrivyWalletConnector=Be,exports.initiaPrivyWalletOptions=ze,exports.injectStyles=hc,exports.useAddress=Ca,exports.useHexAddress=Sa,exports.useInitiaAddress=U,exports.useInterwovenKit=Ta,exports.usePortfolio=xa,exports.useUsernameQuery=wa;
|
|
5
|
+
Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function Kn(e,t){let n=(0,A.hexToBytes)(e);if(n.length!==65)throw Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${n.length}`);let r=(0,A.hexToBytes)((0,A.keccak256)((0,A.bytesToHex)(n.slice(0,64)))),i=C.Bip39.encode(r),a=await C.Bip39.mnemonicToSeed(i),o=(0,C.stringToPath)(`m/44'/60'/0'/0/0`),{privkey:s}=C.Slip10.derivePath(C.Slip10Curve.Secp256k1,a,o),c=await C.Secp256k1.makeKeypair(s);return{privateKey:s,publicKey:C.Secp256k1.compressPubkey(c.pubkey),address:(0,_.toBech32)(t,(0,A.hexToBytes)((0,A.keccak256)((0,A.bytesToHex)(c.pubkey.slice(1)))).slice(-20))}}function qn(e,t){return`${e}:${t}`}var Jn=(0,b.atom)(null),Yn=(0,b.atom)({}),Xn=(0,b.atom)({}),Zn=(0,b.atom)({}),Qn=(0,b.atom)(0),$n=`autosign:`;function er(e,t){let n=e.get(Qn)+1;return e.set(Qn,n),`${t}:${n}`}function tr(e,t){return e.get(Zn)[t]}function nr(e,t,n){e.set(Zn,e=>({...e,[t]:n}))}function rr(e,t){e.set(Zn,e=>{let n={...e};return delete n[t],n})}function ir(e,t,n){let r=tr(e,t);!r||r.token!==n||rr(e,t)}function ar(e,t,n){let r=tr(e,t);return!!r&&r.token===n}function or(e,t){return e.get(Xn)[t]}function sr(e,t,n){e.set(Xn,e=>({...e,[t]:n}))}function cr(e,t){e.set(Xn,e=>{let n={...e};return delete n[t],n})}function lr(e,t,n){e.set(Yn,e=>({...e,[t]:n}))}function ur(e,t){e.set(Yn,e=>{let n={...e};return delete n[t],n})}function dr(e,t){return`${$n}${e}:${t}`}function fr(e,t,n){try{return e.getItem(dr(t,n))}catch{return null}}function pr(e,t,n,r){try{e.setItem(dr(t,n),r)}catch{}}function mr(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function hr(e,t){let n=mr();if(n)return fr(n,e,t)}function gr(e,t,n){let r=mr();r&&pr(r,e,t,n)}function _r(e){return{publicKey:e.publicKey,address:e.address}}function vr(e){e&&e.fill(0)}function yr(e){e.set(Zn,{});let t=e.get(Xn);for(let e of Object.values(t))vr(e);e.set(Xn,{}),e.set(Yn,{})}function br(e,t){return e!==``&&e!==t}function xr(){let e=U(),t=(0,b.useStore)(),n=(0,g.useRef)(e);(0,g.useEffect)(()=>{let r=n.current;br(r,e)&&yr(t),n.current=e},[t,e])}var Sr=class{constructor(e,t){this.wallet=e,this.privateKey=t}async getAccounts(){return[{address:this.wallet.address,algo:`ethsecp256k1`,pubkey:this.wallet.publicKey}]}async signAmino(e,t){if(this.wallet.address!==e)throw Error(`Signer address does not match the derived wallet address`);let n=(0,S.escapeCharacters)((0,S.sortedJsonStringify)(t)),r=(0,_.fromHex)(w.ethers.hashMessage(n).replace(`0x`,``)),i=await C.Secp256k1.createSignature(r,this.privateKey),a=new Uint8Array([...i.r(32),...i.s(32)]);return{signed:t,signature:Bn(this.wallet.publicKey,a)}}};function Cr(){let e=(0,b.useStore)(),{signMessageAsync:t}=(0,l.useSignMessage)(),n=et(),r=U();return{deriveWallet:async i=>{if(!r)throw Error(`User address not available`);let a=n(i),o=qn(r,a.bech32_prefix),s=e.get(Yn)[o];if(s&&or(e,o))return s;let c=tr(e,o);if(c)return c.promise;let l=er(e,o),u=(async()=>{try{let n=window.location.origin,i=Gn(n),s=await t({message:i});Wn(r,Vn(i,s));let c=await Kn(s,a.bech32_prefix),u=_r(c);if(ar(e,o,l))return sr(e,o,c.privateKey),lr(e,o,u),u;throw vr(c.privateKey),Error(`Wallet derivation was cancelled`)}finally{ir(e,o,l)}})();return nr(e,o,{promise:u,token:l}),u},getWallet:t=>{if(!r)return;let i=qn(r,n(t).bech32_prefix);if(or(e,i))return e.get(Yn)[i]},getWalletPrivateKey:t=>{if(r)return or(e,qn(r,n(t).bech32_prefix))},clearWallet:t=>{if(!r)return;let i=qn(r,n(t).bech32_prefix),a=or(e,i);tr(e,i)&&rr(e,i),vr(a),cr(e,i),ur(e,i)},clearAllWallets:()=>{yr(e)}}}function wr({granteeAddress:e,messages:t,encoder:n}){return[{typeUrl:`/cosmos.authz.v1beta1.MsgExec`,value:T.MsgExec.fromPartial({grantee:e,msgs:t.map(e=>({typeUrl:e.typeUrl,value:n.encode(e)}))})}]}async function Tr({chainId:e,granterAddress:t,messages:n,fee:r,memo:i,derivedWallet:a,privateKey:o,encoder:s,signWithEthSecp256k1:c}){let l=wr({granteeAddress:a.address,messages:n,encoder:s}),u={...r,granter:t},d=new Uint8Array(o),f=new Sr(a,d);try{return await c(e,a.address,l,u,i,{customSigner:f})}finally{vr(d)}}var Er=(0,b.atom)(!1),Dr=(0,b.atom)(!1);function Or(){let e=Qt(),[t,n]=(0,b.useAtom)(Er),r=(0,b.useSetAtom)(Dr),i=Fn();return{isDrawerOpen:t,openDrawer:(t,a)=>{t&&e(t,a),r(!1),n(!0),i(`Widget Opened`)},closeDrawer:()=>{n(!1),i(`Widget Closed`)}}}function kr(){let e=Qt(),[t,n]=(0,b.useAtom)(Dr),r=(0,b.useSetAtom)(Er),i=Fn();return{isModalOpen:t,openModal:(t,a)=>{t&&e(t,a),r(!1),n(!0),i(`Widget Opened`)},closeModal:()=>{n(!1),i(`Widget Closed`)}}}function Ar(){let e=Zt(),{closeDrawer:t}=Or(),{closeModal:n}=kr(),{disconnect:r}=(0,l.useDisconnect)(),{clearAllWallets:i}=Cr();return()=>{e(`/blank`),t(),n(),r(),i(),localStorage.removeItem(H.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(H.BRIDGE_SRC_DENOM),localStorage.removeItem(H.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(H.BRIDGE_DST_DENOM),localStorage.removeItem(H.BRIDGE_QUANTITY),localStorage.removeItem(H.BRIDGE_SLIPPAGE_PERCENT)}}function jr(e){if(typeof e.amount!=`string`||typeof e.currency!=`string`)throw Error(`onramp amount and currency must be strings`);let t=e.amount.trim(),n=e.currency.trim().toLowerCase();if(!/^\d+(?:\.\d{1,2})?$/.test(t))throw Error(`onramp amount must be a non-negative decimal with at most 2 decimal places`);if(!/^[a-z]{3}$/.test(n))throw Error(`onramp currency must be a 3-letter ISO code`);return{amount:t,currency:n}}function Mr(){let e=Ma(),t=rt(),{openModal:n}=kr(),r=Tn();return i=>{if(!e)throw Error(`No wallet connected`);let{denoms:a,chainId:o,srcOptions:s,recipientAddress:c,onramp:l}=i;if(a.length===0)throw Error(`denoms cannot be empty`);let u=l?jr(l):void 0;r();let d=o??t.chainId;n(`/deposit`,{localOptions:a.map(e=>({denom:e,chainId:d})),remoteOptions:s,recipientAddress:c,onramp:u})}}function Nr(){let e=Ma(),t=rt(),{openModal:n}=kr();return r=>{if(!e)throw Error(`No wallet connected`);let{denoms:i,chainId:a,dstOptions:o,recipientAddress:s}=r;if(i.length===0)throw Error(`denoms cannot be empty`);let c=a??t.chainId;n(`/withdraw`,{localOptions:i.map(e=>({denom:e,chainId:c})),remoteOptions:o,recipientAddress:s})}}function Pr(e){if(e?.typeUrl===`/initia.crypto.v1beta1.ethsecp256k1.PubKey`){let{key:t}=O.PubKey.decode(e.value);return(0,E.encodeSecp256k1Pubkey)(t)}return(0,D.decodeOptionalPubkey)(e)}function Fr({typeUrl:e,value:t}){if(e===`/cosmos.auth.v1beta1.BaseAccount`){let{address:e,pubKey:n,accountNumber:r,sequence:i}=re.BaseAccount.decode(t);return{address:e,pubkey:Pr(n),accountNumber:Number(r),sequence:Number(i)}}return(0,M.accountFromAny)({typeUrl:e,value:t})}var Ir=`/cosmos.feegrant.v1beta1.MsgGrantAllowance`,Lr=`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`,Rr=`cosmos-sdk/AllowedMsgAllowance`;function zr(){let e=ne.aminoConverters[Ir];if(!e)throw Error(`Missing base converter for MsgGrantAllowance`);return e}var Br=zr();function Vr(e){if(e.typeUrl===Lr){let t=ie.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw Error(`AllowedMsgAllowance is missing nested allowance`);return{type:Rr,value:{allowance:Vr(t.allowance),allowed_messages:t.allowedMessages}}}return Br.toAmino({granter:``,grantee:``,allowance:e}).allowance}function Hr(e){if(e.type===Rr){let t=e.value;if(!t.allowance)throw Error(`AllowedMsgAllowance amino value is missing nested allowance`);let n=Hr(t.allowance);return{typeUrl:Lr,value:ie.AllowedMsgAllowance.encode(ie.AllowedMsgAllowance.fromPartial({allowance:n,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Br.fromAmino({granter:``,grantee:``,allowance:e}).allowance}var Ur={...ne.aminoConverters,[Ir]:{...Br,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Vr(e.allowance)}:Br.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Hr(e.allowance)})}},Wr=()=>{let e=z();return new D.Registry([...ne.protoRegistry,...e.protoTypes??[]])},Gr=()=>{let e=z();return{...Ur,...e.aminoConverters}},Kr=()=>new M.AminoTypes(Gr()),qr=class{constructor(e,t,n){this.address=e,this.signMessage=t,this.restUrl=n}cachedPublicKey=null;setCachedPublicKey(e){this.cachedPublicKey=e,Wn(this.address,e)}async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;let e=Un(this.address);if(e)return this.cachedPublicKey=e,e;let t=await this.getPublicKeyFromRestApi();if(t)return this.setCachedPublicKey(t),t;let n=await this.getPublicKey();return this.setCachedPublicKey(n),n}async getPublicKeyFromRestApi(){try{let e=(await h.default.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return e?(0,_.fromBase64)(e):null}catch{return null}}async getPublicKey(){let e=`Sign this message to identify your Initia account.`;return Vn(e,await this.signMessage(e))}async getAccounts(){return[{address:this.address,algo:`ethsecp256k1`,pubkey:await this.getCachedPublicKey()}]}async signAmino(e,t){if(this.address!==e)throw Error(`Signer address does not match the provided address`);let n=(0,S.escapeCharacters)((0,S.sortedJsonStringify)(t)),r=await this.signMessage(n),i=Vn(n,r);this.setCachedPublicKey(i);let a=(0,_.fromHex)(r.replace(`0x`,``)).subarray(0,-1);return{signed:t,signature:Bn(i,C.Secp256k1Signature.fromFixedLength(a).toFixedLength())}}};function Jr(e){let t=U(),n=ai();return(0,u.useQuery)({queryKey:Ft.sequence(e,t).queryKey,queryFn:async()=>(await n(e)).getSequence(t),enabled:!!t,staleTime:0,gcTime:0,retry:!1})}function Yr(){let e=(0,u.useQueryClient)();return()=>e.invalidateQueries({queryKey:Ft.sequence._def})}function Xr({data:e,isError:t}){return t?void 0:e}function Zr(){let e=Wr(),t=Kr(),n=ei(),r=ai();return async function(i,a,o,s,c,l){let u=l?.customSigner??n;if(!u)throw Error(`Signer not initialized`);let d=await r(i),{accountNumber:f,sequence:p}=l?.accountSequence??await $r({getSequence:e=>d.getSequence(e),signerAddress:a,incrementSequence:l?.incrementSequence??0,allowMissingAccount:!!l?.customSigner}),m=te.SignMode.SIGN_MODE_EIP_191,h=(0,S.makeSignDoc)(o.map(e=>t.toAmino(e)),s,i,c,f,p),{signature:g,signed:v}=await u.signAmino(a,h),y=Rn(zn((0,_.fromBase64)(g.pub_key.value))),b={typeUrl:`/cosmos.tx.v1beta1.TxBody`,value:{messages:v.msgs.map(e=>t.fromAmino(e)),memo:c}},x=e.encode(b),C=j.Int53.fromString(v.fee.gas).toNumber(),w=(0,D.makeAuthInfoBytes)([{pubkey:y,sequence:j.Int53.fromString(v.sequence).toNumber()}],v.fee.amount,C,v.fee.granter,v.fee.payer,m);return N.TxRaw.fromPartial({bodyBytes:x,authInfoBytes:w,signatures:[(0,_.fromBase64)(g.signature)]})}}function Qr(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function $r({getSequence:e,signerAddress:t,incrementSequence:n,allowMissingAccount:r}){try{let{accountNumber:r,sequence:i}=await e(t);return{accountNumber:r,sequence:i+n}}catch(e){if(r&&Qr(e,t))return{accountNumber:0,sequence:n};throw e}}function ei(){let e=U(),{signMessageAsync:t}=(0,l.useSignMessage)(),n=V();return(0,g.useMemo)(()=>new qr(e,e=>t({message:e}),n.restUrl),[e,t,n.restUrl])}var ti=new Map,ni=new Map;function ri(e,t){let n=`${e}:${t}`;ni.delete(n)}function ii(){let e=et();return async t=>{if(ti.has(t))return ti.get(t);let{rpcUrl:n}=e(t),r=await ee.Comet38Client.create(new ee.HttpClient(n));return ti.set(t,r),r}}function ai(){let e=Wr(),t=Kr(),n=ei(),r=U(),i=ii();return async a=>{let o=`${r}:${a}`;if(ni.has(o))return ni.get(o);if(!n)throw Error(`Signer not initialized`);let s=await i(a),c=await M.SigningStargateClient.createWithSigner(s,n,{registry:e,aminoTypes:t,accountParser:Fr,broadcastPollIntervalMs:500});return ni.set(o,c),c}}function oi(){let{connector:e}=(0,l.useAccount)();return async()=>{if(!e)throw Error(`Wallet not connected`);return new w.BrowserProvider(await e.getProvider())}}var si=class extends Error{constructor(e){super(e),this.name=`TimeoutError`}};function ci(e,t,n){let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(new si(n)),t)});return Promise.race([e,i]).finally(()=>{clearTimeout(r)})}function li(e){return e.filter(e=>e.authorization[`@type`].includes(`GenericAuthorization`)).filter(e=>!!e.authorization.msg)}function ui(e){return e[`@type`]===`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`?e.allowance?.expiration:e.expiration}function di(e){if(e[`@type`]===`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`)return e.allowedMessages??e.allowed_messages??[]}function fi(){let e=U(),t=et();return{fetchFeegrant:async(n,r)=>{if(!e)return null;let i=t(n),a=h.default.create({prefixUrl:i.restUrl});try{let{allowance:t}=await a.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return t}catch(e){if(e instanceof h.HTTPError&&[404,500].includes(e.response.status))return null;throw e}},fetchGrants:async(n,r)=>{if(!e)return[];let i=t(n),{grants:a}=await h.default.create({prefixUrl:i.restUrl}).get(`cosmos/authz/v1beta1/grants`,{searchParams:{granter:e,grantee:r}}).json();return a},fetchAllGrants:async n=>{let r=t(n),i=e;return i?li(await vt(`cosmos/authz/v1beta1/grants/granter/${i}`,{prefixUrl:r.restUrl},`grants`)):[]}}}var pi=(0,m.createQueryKeys)(`interwovenkit:autosign`,{expirations:(e,t,n)=>[e,t,n],grants:(e,t)=>[e,t]}),mi=4,hi=4;function gi(e){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${e}:${[...t].sort().join(`,`)}`).join(`|`)}function _i(){let e=z(),t=rt(),{enableAutoSign:n,defaultChainId:r}=e;if(!n)return{[r]:[]};if(typeof n!=`boolean`)return n;switch(t.metadata?.minitia?.type){case`minievm`:return{[r]:[`/minievm.evm.v1.MsgCall`]};case`miniwasm`:return{[r]:[`/cosmwasm.wasm.v1.MsgExecuteContract`]};default:return{[r]:[`/initia.move.v1.MsgExecute`]}}}function vi(){let{data:e}=yi(),t=_i();return(n,r)=>{let i=r.every(e=>{let r=t[n];return r?r.includes(e.typeUrl):!1}),a=e?.isEnabledByChain[n]??!1;return i&&a}}function yi(){let e=U(),t=_i(),n=gi(t),{fetchFeegrant:r,fetchAllGrants:i}=fi();return(0,u.useQuery)({queryKey:pi.expirations(e,n,t).queryKey,queryFn:()=>bi({initiaAddress:e,messageTypes:t,fetchAllGrants:i,fetchFeegrant:r}),staleTime:B.MINUTE,retry:1})}async function bi(e){let{initiaAddress:t,messageTypes:n,fetchAllGrants:r,fetchFeegrant:i}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};let a={},o={},s={},c={},l=[];for(let[e,t]of Object.entries(n))a[e]=null,o[e]=void 0,s[e]=!1,t.length>0&&l.push([e,t]);if(l.length===0)return{expiredAtByChain:a,isEnabledByChain:s,granteeByChain:o};let u=await xi(l,mi,async([e,n])=>{let a=hr(t,e);try{let t=await r(e),o=wi(a===void 0?t:a===null?[]:t.filter(e=>e.grantee===a),n);if(o.length===0)return{chainId:e,expectedAddress:a,expiration:null,grantee:void 0};let s=await Ci({chainId:e,candidates:o,fetchFeegrant:i,concurrency:hi});if(!s)return{chainId:e,expectedAddress:a,expiration:null,grantee:void 0};let c=s.grantee.grants.filter(e=>n.includes(e.authorization.msg)).map(e=>e.expiration),l=ui(s.feegrant.allowance),u=Di([...c,l]);return{chainId:e,expectedAddress:a,expiration:u?new Date(u):void 0,grantee:s.grantee.grantee}}catch{return{chainId:e,expectedAddress:a,expiration:null,grantee:void 0}}});for(let e of u)c[e.chainId]=e.expectedAddress,a[e.chainId]=e.expiration,o[e.chainId]=e.grantee;for(let[e]of l)s[e]=Ti({expiration:a[e],grantee:o[e],expectedAddress:c[e]});return{expiredAtByChain:a,isEnabledByChain:s,granteeByChain:o}}async function xi(e,t,n){let r=Array(e.length),i=Math.max(1,t),a=0,o=Array.from({length:Math.min(i,e.length)},async()=>{for(;;){let t=a;if(a+=1,t>=e.length)return;r[t]=await n(e[t],t)}});return await Promise.all(o),r}function Si(e){let t=di(e.allowance);if(!(!t||t.includes(`/cosmos.authz.v1beta1.MsgExec`)))return!1;let n=ui(e.allowance);if(!n)return!0;let r=new Date(n);return!Number.isNaN(r.getTime())&&(0,oe.isFuture)(r)}async function Ci(e){let{chainId:t,candidates:n,fetchFeegrant:r,concurrency:i=hi}=e,a=await xi(n,i,async e=>{let n=await r(t,e.grantee);return n&&Si(n)?{grantee:e,feegrant:n}:null});for(let e of a)if(e)return e;return null}function wi(e,t){if(t.length===0)return[];let n=new Map;for(let t of e){let e=n.get(t.grantee)||[];e.push({authorization:t.authorization,expiration:t.expiration}),n.set(t.grantee,e)}let r=[];for(let[e,i]of n){let n=i.filter(e=>!e.expiration||(0,oe.isFuture)(new Date(e.expiration))),a=n.map(e=>e.authorization.msg);t.every(e=>a.includes(e))&&r.push({grantee:e,grants:n})}return r}function Ti(e){let{expiration:t,grantee:n,expectedAddress:r}=e,i=r===void 0?!!n:!!n&&r===n;switch(t){case null:return!1;case void 0:return i;default:return i&&(0,oe.isFuture)(t)}}function Ei(){let{data:e,refetch:t}=yi();(0,g.useEffect)(()=>{if(!e)return;let n=new Date,r=Object.values(e.expiredAtByChain).filter(e=>e instanceof Date&&(0,oe.isFuture)(e));if(r.length===0)return;let i=Di(r);if(!i)return;let a=i.getTime()-n.getTime();if(a<=0)return;let o=setTimeout(()=>{t()},a+100);return()=>clearTimeout(o)},[e,t])}function Di(e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return[...t].sort((e,t)=>new Date(e).getTime()-new Date(t).getTime())[0]}var Oi=(0,g.createContext)(null),ki=()=>(0,g.useContext)(Oi),Ai=class extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(e,t,n,r,i,a,o){super(e),this.name=`MoveError`,this.originalError=t,this.moduleAddress=n,this.moduleName=r,this.errorCode=i,this.errorCodeHex=a,this.isFromRegistry=o}},ji=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Mi=new Map;function Ni(e){let t=e.match(ji);if(!t)return null;let[,n,r,i]=t;return{moduleAddress:`0x${n.replace(/^0+/,``)||`0`}`,moduleName:r,errorCode:i.replace(/^0+/,``)||`0`}}async function Pi(e,t,n){let r=`${e}:${t}`;if(Mi.has(r))return Mi.get(r);try{let i=`${n}/errors/${t===`0x1`?`0x1.json`:`${e}/${t}.json`}`,{errors:a={}}=await h.default.get(i).json();return Mi.set(r,a),a}catch{return null}}function Fi(e,t,n,r,i,a,o){return new Ai(e,t,n,r,i,a,o)}async function Ii(e,t,n){if(e instanceof Ai)return e;if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!==`minimove`)return await Ge(e);let r=Ni(e.message);if(!r)return await Ge(e);let i=await Pi(t.chain_name,r.moduleAddress,n),a=`0x${parseInt(r.errorCode,10).toString(16)}`,o=`Failed with code ${a} in module ${r.moduleName} at ${r.moduleAddress}`,s=i?.[r.moduleName]?.[r.errorCode],c=s||o,l=!!s;return Fi(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,l)}var Li=5e3;function Ri(){let e=U();return(t,n)=>(0,u.queryOptions)({queryKey:Ft.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];let{txs:r}=await h.default.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:{"pagination.reverse":!0,"pagination.limit":10}}).json();return r},staleTime:B.SECOND})}function zi(e,t){return(0,u.useSuspenseQuery)(Ri()(e,t))}function Bi(e,t){let n=e.flatMap((e,n)=>(t[n]??[]).map(t=>({...t,chain:e})));return(0,p.sortWith)([(0,p.descend)(e=>new Date(e.timestamp).getTime())])(n)}var Vi=()=>{let e=Ze(),t=Ri();return(0,u.useQueries)({queries:e.map(e=>({...t(e,{enabled:!0}),refetchInterval:Li})),combine:t=>({activities:Bi(e,t.map((0,p.prop)(`data`))),isLoading:t.some(e=>e.isLoading)})})};function Hi({denom:e,amount:t}){let n=(t||``).trim();if(!n)return null;let r=e===`uinit`?1:Pe;return{amount:(0,f.default)(n).times(r).toFixed(18),denom:e}}async function Ui(e){if(e.metadata?.is_l1){let{restUrl:t}=e,{gas_prices:n}=await h.default.create({prefixUrl:t}).get(`initia/tx/v1/gas_prices`).json(),r=[...n].sort((0,p.descend)(({denom:e})=>e===`uinit`)).flatMap(e=>{let t=Hi(e);return t?[t]:(console.error(`Gas price entry has empty amount for ${e.denom}`),[])});if(r.length===0)throw Error(`Gas prices response is empty or invalid`);return r}return e.fees.fee_tokens.map(({denom:e,fixed_min_gas_price:t})=>{if((0,p.isNil)(t))throw Error(`${e} has no price`);return{amount:String(t),denom:e}})}function Wi(e){let{data:t}=(0,u.useSuspenseQuery)({queryKey:Ke.gasPrices(e).queryKey,queryFn:()=>Ui(e),staleTime:B.SECOND});return t}function Gi(e){let t=U(),{data:n}=zi(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;let r=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return r;try{return n.find(({tx:e})=>e.auth_info.signer_infos.some(e=>d.InitiaAddress.equals(t,(0,w.computeAddress)(`0x${(0,_.toHex)(C.Secp256k1.uncompressPubkey((0,_.fromBase64)(e.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}var Ki=`approve`,qi=(0,b.atom)(),Ji=(0,b.atom)(null),Yi=Ne,Xi=1.5;function Zi({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:n,allowedFeeDenoms:r}){let i=r?.length?e.filter(({denom:e})=>r.includes(e)):e;if(i.length===0)throw Error(`No allowed gas price tokens available for auto-sign`);let a=e=>e?i.find(t=>t.denom===e):void 0;return a(t)??a(n)??i[0]}function Qi({simulatedGas:e,gasPrices:t,preferredFeeDenom:n,fallbackFeeDenom:r,policy:i}){if(!Number.isFinite(e)||e<=0)throw Error(`Auto-sign gas simulation failed`);let{gasMultiplier:a,maxGasMultiplierFromSim:o,allowedFeeDenoms:s}=i;if(a<=0||o<=0||a>o)throw Error(`Invalid auto-sign gas multiplier policy`);let c=Math.ceil(e*a),l=Zi({gasPrices:t,preferredFeeDenom:n,fallbackFeeDenom:r,allowedFeeDenoms:s});return(0,M.calculateFee)(c,M.GasPrice.fromString(`${l.amount}${l.denom}`))}function $i({derivedAddress:e,messages:t,encoder:n}){return{messages:wr({granteeAddress:e,messages:t,encoder:n})}}function ea(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase(),n=e.code,r=e.cause?.code,i=t.includes(`user rejected`)||t.includes(`rejected the request`)||t.includes(`user denied`)||t.includes(`denied by user`)||t.includes(`user cancelled`)||t.includes(`user canceled`)||t.includes(`cancelled by user`)||t.includes(`canceled by user`);return n===4001||n===`ACTION_REJECTED`||r===4001||r===`ACTION_REJECTED`||i}async function ta({queryClient:e,messages:t,memo:n,pubkey:r,sequence:i}){let a=new ae.ServiceClientImpl((0,M.createProtobufRpcClient)(e)),o=N.Tx.fromPartial({authInfo:N.AuthInfo.fromPartial({fee:N.Fee.fromPartial({}),signerInfos:[{publicKey:r,sequence:BigInt(i),modeInfo:{single:{mode:te.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:N.TxBody.fromPartial({messages:Array.from(t),memo:n}),signatures:[new Uint8Array]});return await a.Simulate(ae.SimulateRequest.fromPartial({txBytes:N.Tx.encode(o).finish()}))}function na(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e}async function ra({address:e,chainId:t,messages:n,memo:r,fee:i,preferredFeeDenom:a,client:o,allowAutoSign:s=!0,allowWalletDerivation:c=!1,accountSequence:l},u){let d=async()=>u.signWithEthSecp256k1(t,e,n,i,r,{accountSequence:l}),f=(e,n)=>{u.onAutoSignFallback?.({chainId:t,reason:e,errorMessage:na(n)})};if(!s)return d();if(!u.validateAutoSign(t,n))return f(`validation_failed`),d();let p=u.getWallet(t),m=!1;if(!p&&c)try{p=await u.deriveWallet(t)}catch(e){if(ea(e))throw e;f(`derive_wallet_failed`,e),m=!0,p=void 0}if(!p)return m||f(`missing_derived_wallet`),d();let h;try{let e=o??await u.getSigningClient(t);h=await u.computeAutoSignFee({chainId:t,messages:n,memo:r,derivedWallet:p,preferredFeeDenom:a,fallbackFeeDenom:i.amount[0]?.denom,client:e})}catch(e){if(e instanceof Error&&Ni(e.message))throw await u.formatError(t,e);return f(`fee_computation_failed`,e),d()}try{return await u.signWithDerivedWallet(t,e,n,h,r,p)}catch(e){return f(`derived_wallet_sign_failed`,e),d()}}function ia(){let e=U(),{autoSignFeePolicy:t,registryUrl:n}=z(),r=et(),i=ii(),a=ai(),o=Wr(),s=vi(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:u}=Cr(),d=Zr(),f=Fn(),p=e=>{let n=t?.[e];return{gasMultiplier:n?.gasMultiplier??Yi,maxGasMultiplierFromSim:n?.maxGasMultiplierFromSim??Xi,allowedFeeDenoms:n?.allowedFeeDenoms}},m=async({chainId:e,messages:t,memo:n,derivedWallet:a,preferredFeeDenom:s,fallbackFeeDenom:c,client:l})=>{let u=await Ui(r(e)),d=$i({derivedAddress:a.address,messages:t,encoder:o}).messages.map(e=>o.encodeAsAny(e)),f=Rn(zn(a.publicKey)),{sequence:m}=await $r({getSequence:e=>l.getSequence(e),signerAddress:a.address,incrementSequence:0,allowMissingAccount:!0}),h=await i(e),{gasInfo:g}=await ta({queryClient:M.QueryClient.withExtensions(h,M.setupTxExtension),messages:d,memo:n,pubkey:f,sequence:m});return Qi({simulatedGas:g?Number(g.gasUsed.toString()):0,gasPrices:u,preferredFeeDenom:s,fallbackFeeDenom:c,policy:p(e)})},h=async(e,t,n,r,i,a)=>{let s=a??c(e);s||=await l(e);let f=u(e);if(!f)throw Error(`Derived wallet key not initialized`);return await Tr({chainId:e,granterAddress:t,messages:n,fee:r,memo:i,derivedWallet:s,privateKey:f,encoder:o,signWithEthSecp256k1:d})};return t=>ra({...t,address:e},{validateAutoSign:s,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:m,signWithDerivedWallet:h,signWithEthSecp256k1:d,formatError:(e,t)=>Ii(t,r(e),n),onAutoSignFallback:({chainId:e,reason:t,errorMessage:n})=>{f(`AutoSign Fallback`,{chainId:e,reason:t,errorMessage:n})}})}function aa(){let e=(0,b.useAtomValue)(qi);if(!e)throw Error(`Tx request not found`);return e}function oa(){let e=Zt(),t=U(),{defaultChainId:n,registryUrl:r}=z(),i=et(),{openDrawer:a,closeDrawer:o}=Or(),{openModal:s,closeModal:c}=ki(),l=(0,b.useSetAtom)(qi),u=(0,b.useSetAtom)(Ji),d=ii(),f=ai(),p=ei(),m=Wr(),h=ia(),g=Yr(),_=async({messages:e,memo:a,chainId:o=n})=>{try{return await(await f(o)).simulate(t,e,a)}catch(e){throw await Ii(e,i(o),r)}},v=async({messages:e,memo:r,chainId:i=n})=>{let a=await d(i),o=M.QueryClient.withExtensions(a,M.setupTxExtension),s=e.map(e=>m.encodeAsAny(e)),[c]=await p.getAccounts(),l=(0,E.encodeSecp256k1Pubkey)(c.pubkey),{sequence:u}=await(await f(i)).getSequence(t);return o.tx.simulate(s,r,l,u)},y=async({txRequest:t,broadcaster:u})=>{let d={memo:``,chainId:n,gas:t.gas||await _(t),gasAdjustment:Ne,gasPrices:null,spendCoins:[],internal:!1,...t};return new Promise((t,n)=>{l({txRequest:d,resolve:async a=>{try{t(await u(await f(d.chainId),N.TxRaw.encode(a).finish())),typeof d.internal==`string`&&e(d.internal)}catch(e){n(await Ii(e,i(d.chainId),r))}finally{p()}},reject:e=>{n(e),p()}}),d.internal?s({path:`/tx`}):a(`/tx`);let p=()=>{if(!d.internal){e(`/blank`),o();return}c()}})},x=async e=>{let t=e.chainId??n;try{let n=await y({txRequest:e,broadcaster:async(e,t)=>await e.broadcastTxSync(t)});return e.internal&&typeof e.internal!=`number`&&(u({txHash:n,chainId:t,status:`loading`}),D({txHash:n,chainId:e.chainId}).then(e=>{u({status:e.code===0?`success`:`error`,chainId:t,txHash:n})}).catch(()=>{u({status:`error`,chainId:t,txHash:n})})),n}catch(n){throw e.internal&&typeof e.internal!=`number`&&u({status:`error`,chainId:t,error:n}),n}},S=(e,t=30*1e3,n=.5*1e3)=>y({txRequest:e,broadcaster:async(e,r)=>{let i=await e.broadcastTx(r,t,n);if(g(),i.code!==0)throw Error(i.rawLog);return i}}),C=async({chainId:e,messages:t,memo:n=``,fee:r,preferredFeeDenom:i})=>{let a=await f(e);return{client:a,signedTx:await h({chainId:e,messages:t,memo:n,fee:r,preferredFeeDenom:i,client:a,allowWalletDerivation:!0})}},w=async e=>{let t=e.chainId??n;try{let{client:n,signedTx:r}=await C({...e,chainId:t});return await n.broadcastTxSync(N.TxRaw.encode(r).finish())}catch(e){throw await Ii(e,i(t),r)}},T=async(e,t=30*1e3,a=.5*1e3)=>{let o=e.chainId??n;try{let{client:n,signedTx:r}=await C({...e,chainId:o}),i=await n.broadcastTx(N.TxRaw.encode(r).finish(),t,a);if(g(),i.code!==0)throw Error(i.rawLog);return i}catch(e){throw await Ii(e,i(o),r)}},D=async({chainId:e=n,...t})=>{try{let n=await f(e),r=await sa({...t,client:n});return g(),r}catch(t){throw t instanceof si?t:await Ii(t,i(e),r)}};return{estimateGas:_,simulateTx:v,requestTxSync:x,requestTxBlock:S,submitTxSync:w,submitTxBlock:T,waitForTxConfirmation:D}}async function sa({txHash:e,client:t,timeoutMs:n=30*1e3,intervalMs:r=.5*1e3}){let i=Date.now();for(;;){let a=await t.getTx(e);if(a){if(a.code!==0)throw Error(a.rawLog);return a}if(Date.now()-i>=n)throw new si(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(e=>setTimeout(e,r))}}var ca=`/cosmos.authz.v1beta1.MsgExec`;function la(e){if(e.explicitGrantee)return[e.explicitGrantee];let t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(e=>!!e);return[...new Set(t)]}function ua(e){let t=[e.currentGrantee,e.expectedGrantee].filter(e=>!!e);return[...new Set(t)]}function da(e){let{isEnabledOnTargetChain:t,hasEnabledSibling:n,didBroadcast:r,hasExplicitGrantee:i}=e;return n?!1:t===!1?!0:t===void 0&&r&&!i}function fa(e){return[...new Set(e.map(e=>e.authorization.msg))].filter(e=>!!e)}async function pa(e){let t=[pi.expirations._def,pi.grants._def];for(let n of t)await e.invalidateQueries({queryKey:n})}function ma(){let e=U(),{fetchFeegrant:t,fetchGrants:n}=fi();return async r=>{let{chainId:i,grantee:a}=r;if(!e)throw Error(`Granter wallet not initialized`);let o=await t(i,a),s=await n(i,a),c=o?[{typeUrl:`/cosmos.feegrant.v1beta1.MsgRevokeAllowance`,value:ce.MsgRevokeAllowance.fromPartial({granter:e,grantee:a})}]:[],l=fa(s).map(t=>({typeUrl:`/cosmos.authz.v1beta1.MsgRevoke`,value:T.MsgRevoke.fromPartial({granter:e,grantee:a,msgTypeUrl:t})}));return[...c,...l]}}function ha(){let e=U(),t=_i(),{requestTxBlock:n}=oa(),r=(0,u.useQueryClient)(),[i,a]=(0,b.useAtom)(Jn),{closeDrawer:o}=Or(),s=ma(),{deriveWallet:c}=Cr();return(0,u.useMutation)({mutationFn:async r=>{if(!i)throw Error(`No pending request`);let{chainId:a}=i;if(!e)throw Error(`Wallet not connected`);let o=t[a];if(!o||o.length===0)throw Error(`No message types configured for chain ${a}`);let l=await c(a);ri(e,a);let u=hr(e,a),d=ua({currentGrantee:l.address,expectedGrantee:u}),f=(await Promise.all(d.map(e=>s({chainId:a,grantee:e})))).flat(),p=r===0?void 0:(0,oe.addMilliseconds)(new Date,r),m={typeUrl:`/cosmos.feegrant.v1beta1.BasicAllowance`,value:ie.BasicAllowance.encode(ie.BasicAllowance.fromPartial({expiration:p})).finish()},h={typeUrl:`/cosmos.feegrant.v1beta1.MsgGrantAllowance`,value:ce.MsgGrantAllowance.fromPartial({granter:e,grantee:l.address,allowance:{typeUrl:`/cosmos.feegrant.v1beta1.AllowedMsgAllowance`,value:ie.AllowedMsgAllowance.encode(ie.AllowedMsgAllowance.fromPartial({allowance:m,allowedMessages:[ca]})).finish()}})},g=o.map(t=>({typeUrl:`/cosmos.authz.v1beta1.MsgGrant`,value:T.MsgGrant.fromPartial({granter:e,grantee:l.address,grant:{authorization:{typeUrl:`/cosmos.authz.v1beta1.GenericAuthorization`,value:se.GenericAuthorization.encode(se.GenericAuthorization.fromPartial({msg:t})).finish()},expiration:p}})}));return await n({messages:[...f,h,...g],chainId:a,internal:!0}),{chainId:a,derivedWallet:l}},onSuccess:async({chainId:t,derivedWallet:n})=>{e&&gr(e,t,n.address),await pa(r),i?.resolve()},onError:e=>{i?.reject(e)},onSettled:()=>{a(null),o()}})}function ga(e){let t=z(),n=Ze(),r=et(),{getWallet:i,clearWallet:a}=Cr(),{requestTxBlock:o}=oa(),s=(0,u.useQueryClient)(),c=ma(),{data:l,refetch:d}=yi();return(0,u.useMutation)({mutationFn:async(n=t.defaultChainId)=>{let r=i(n),a=l?.granteeByChain[n],s;e?.grantee||(s=(await d()).data?.granteeByChain[n]);let u=la({explicitGrantee:e?.grantee,cachedDerivedAddress:r?.address,statusGrantee:a,refetchedStatusGrantee:s});if(u.length===0)throw Error(`No grantee address available`);let f=(await Promise.all(u.map(e=>c({chainId:n,grantee:e})))).flat();return f.length===0?{chainId:n,didBroadcast:!1}:(await o({messages:f,chainId:n,internal:e?.internal}),{chainId:n,didBroadcast:!0})},onSuccess:async({chainId:t,didBroadcast:i})=>{await pa(s);let o=r(t),c=n.filter(e=>e.bech32_prefix===o.bech32_prefix).map(e=>e.chain_id).filter(e=>e!==t),u;try{u=(await d()).data}catch{u=void 0}let f=u??l,p=!1;c.length>0&&f&&(p=c.some(e=>f?.isEnabledByChain[e])),da({isEnabledOnTargetChain:i?u?.isEnabledByChain[t]:(u??l)?.isEnabledByChain[t],hasEnabledSibling:p,didBroadcast:i,hasExplicitGrantee:!!e?.grantee})&&a(t)}})}var _a=[{value:10*Dt,label:`for 10 minutes`},{value:Ot,label:`for 1 hour`},{value:kt,label:`for 1 day`},{value:7*kt,label:`for 7 days`},{value:0,label:`until revoked`}],va=_a[0].value;function ya(e){return e===void 0?va:_a.some(t=>t.value===e)?e:va}function ba(){let{defaultChainId:e}=z(),{openDrawer:t}=Or(),n=(0,b.useSetAtom)(Jn),r=ga(),{data:i={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:a}=yi(),o=async(r=e,i)=>new Promise((e,a)=>{n({chainId:r,defaultDuration:ya(i?.defaultDuration),resolve:e,reject:a}),t(`/autosign/enable`)}),s=async(t=e)=>{await r.mutateAsync(t)};return{...i,isLoading:a,enable:o,disable:s}}function xa(e){return e.assets.reduce((e,{value:t})=>e+(t??0),0)}function Sa(e){return e.assets.reduce((e,{quantity:t})=>e.plus(t||0),(0,f.default)(0)).toString()}function Ca(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??st}}function wa(e){return(0,p.pick)([`chainId`,`name`,`logoUrl`],e)}function Ta(e){return(0,p.sortWith)([(0,p.ascend)(({symbol:e})=>jt(e)),(0,p.descend)(xa),(0,p.descend)(({assets:e})=>e.length),(0,p.ascend)(({symbol:e})=>e)])(e)}function Ea(e){return(0,p.sortWith)([(0,p.descend)(({value:e})=>e??0),(0,p.descend)(({quantity:e})=>Number(e)),(0,p.ascend)(({chain:e})=>e.name)])(e)}function Da(e,t){return(0,p.sortWith)([(0,p.descend)(({chain:e})=>e.chainId===t),(0,p.ascend)(({chain:e})=>e.name),(0,p.ascend)(({denom:e})=>e)])(e)}function Oa(e,t){return(0,p.sortWith)([(0,p.descend)(({chainId:e})=>e===t),(0,p.descend)((0,p.prop)(`value`))])(e)}function ka(e,t,n,r,i){let a=e.find(e=>e.metadata?.is_l1)?.chainId,o={};for(let i of e){let e=i.chainId,a=t[e]??[],s=n[e],c=r[e],l=[];for(let{amount:e,denom:t}of a){if(!(0,f.default)(e||0).gt(0))continue;let n=s?.find(e=>e.denom===t),r=c?.find(e=>e.id===t)?.price,a=n?.decimals??0,o=(0,d.fromBaseUnit)(e,{decimals:a}),u=r?(0,f.default)(o||0).times(r).toNumber():void 0;l.push({...Ca(t,n),amount:e,denom:t,decimals:a,quantity:o,price:r,value:u,address:n?.address,unlisted:!n,chain:wa(i)})}o[e]=l}let s=new Map;for(let[t,n]of Object.entries(o)){if(n.length===0)continue;let r=e.find(e=>e.chainId===t);if(!r)continue;let i=n.reduce((e,{value:t})=>e+(t??0),0);s.set(t,{...wa(r),value:i})}let c=new Map;for(let e of Object.values(o))for(let t of e)if(!t.unlisted){let{symbol:e}=t,n=c.get(e)??[];c.set(e,[...n,t])}let l=[];for(let[e,t]of c){let n=(0,p.head)(t);if(!n)continue;let r=Ea(t),i=r.reduce((e,{value:t})=>e+(t??0),0),a=r.reduce((e,{quantity:t})=>e.plus(t||0),(0,f.default)(0)).toNumber();l.push({symbol:e,logoUrl:n.logoUrl,assets:r,totalValue:i,totalAmount:a})}let u=[];for(let e of Object.values(o))for(let t of e)t.unlisted&&u.push(t);return{chainsByValue:Oa(Array.from(s.values()),i),assetGroups:Ta(l),unlistedAssets:Da(u,a),totalValue:l.reduce((e,t)=>e+t.totalValue,0)}}function Aa(){let{defaultChainId:e}=z(),t=Ze(),n=zt(),r=ft(),i=ot(),a=t.map(e=>e.chainId),o=ka(t,(0,p.zipObj)(a,n.map((0,p.prop)(`data`))),(0,p.zipObj)(a,r.map((0,p.prop)(`data`))),(0,p.zipObj)(a,i.map((0,p.prop)(`data`))),e),s=[n,r,i].flat().some(({isLoading:e})=>e),c=()=>{n.forEach(({refetch:e})=>e()),r.forEach(({refetch:e})=>e()),i.forEach(({refetch:e})=>e())};return{...o,isLoading:s,refetch:c}}function U(){let e=ja();return e?(0,d.InitiaAddress)(e).bech32:``}function ja(){let{address:e}=(0,l.useAccount)();return e?(0,d.InitiaAddress)(e).hex:``}function Ma(){let e=rt(),t=U(),n=ja();return e.metadata?.minitia?.type===`minievm`?n:t}function Na(e){let t=Ma(),n=e??t,r=It();return(0,u.useQuery)({queryKey:Ft.username(r.restUrl,n).queryKey,queryFn:()=>r.getUsername(n),enabled:!!n,staleTime:B.MINUTE})}function Pa(){let e=Ma(),t=U(),n=ja(),{data:r}=Na(),i=ei(),a=Ar(),o=ba(),{isDrawerOpen:s,openDrawer:c}=Or(),{isModalOpen:l}=kr(),u=()=>{c(`/`)},d=()=>{c(`/connect`)},f=e=>{c(`/bridge`,e)},p=Mr(),m=Nr(),h=oa();return{address:e,initiaAddress:t,hexAddress:n,username:r,offlineSigner:i,isConnected:!!e,isOpen:s||l,openConnect:d,openWallet:u,openBridge:f,openDeposit:p,openWithdraw:m,disconnect:a,autoSign:o,...h}}var Fa={status:`_status_tn9m1_1`,error:`_error_tn9m1_9`},Ia=({error:e,className:t,children:n})=>(0,y.jsx)(`p`,{className:(0,F.default)(Fa.status,{[Fa.error]:e},t),role:e?`alert`:`status`,children:n}),W=({errorBoundaryProps:e={fallbackRender:({error:e})=>(0,y.jsx)(Ia,{error:!0,children:e.message})},suspenseFallback:t=(0,y.jsx)(Ia,{children:`Loading...`}),children:n})=>(0,y.jsx)(ue.ErrorBoundary,{...e,children:(0,y.jsx)(g.Suspense,{fallback:t,children:n})}),La=1n<<64n,Ra=1n<<63n,za=(1n<<128n)-1n;function Ba(e){let t=BigInt(e);return t>=Ra?t-La:t}var Va=(1n<<256n)-1n,Ha=443636n,Ua=255738958999603826347141n;function Wa(e,t,n){let r=Number(Ba(e)),i=Number(Ba(t)),a=Math.floor(-Number(Ha)/n)*n,o=Math.floor(Number(Ha)/n)*n;return r===a&&i===o}function Ga(e){return e>>64n}function Ka(e){let t=e>>64n;return e%La===0n?t:t+1n}function qa(e){return e}function Ja(e){if(e<0n||e>za)throw Error(`INPUT_OUT_OF_RANGE`);return e}function Ya(e,t){let n=e*t>>64n;if(n>za)throw Error(`OVERFLOW`);return n}function Xa(e,t){return e>t?[t,e]:[e,t]}function Za(e,t,n,r){if(e===t)return 0n;let[i,a]=Xa(e,t);if(i===0n||a===0n)return 0n;let o=n*La*(a-i);if(o===0n)return 0n;let s=i*a;return r?(o-1n)/s+1n:o/s}function Qa(e,t,n,r){if(e===t)return 0n;let[i,a]=Xa(e,t),o=(a-i)*n;return r?Ka(Ja(o)):Ga(Ja(o))}function $a(e,t,n){return Za(e,t,n<0n?-n:n,n>=0n)}function eo(e,t,n){return Qa(e,t,n<0n?-n:n,n>=0n)}var to=1n<<64n,no=1n<<65n,ro=64n;function io(e){if(e<=0n)throw Error(`LOG_2_ZERO_UNBOUNDED`);let t=qa(e),n=0n,r=0n,i=1n<<ro-1n,a=0n,o=1;for(;t>=no;)t>>=1n,n+=to;for(;t<to;)o=0,t<<=1n,r+=to;for(;a<62n;){let e=t>>1n;t=e*e>>62n,t>=no&&(t>>=1n,n+=i),i>>=1n,a+=1n}let s=Ja(o>0?n:r-n);return[o,s]}function ao(e){let t=e<0n?-e:e;if(t>443636n)throw Error(`MAX_TICK`);let n=(t&1n)==0n?340282366920938463463374607431768211456n:340265354078544963557816517032075149313n;(t&2n)!=0n&&(n=n*340248342086729790484326174814286782778n>>128n),(t&4n)!=0n&&(n=n*340214320654664324051920982716015181260n>>128n),(t&8n)!=0n&&(n=n*340146287995602323631171512101879684304n>>128n),(t&16n)!=0n&&(n=n*340010263488231146823593991679159461444n>>128n),(t&32n)!=0n&&(n=n*339738377640345403697157401104375502016n>>128n),(t&64n)!=0n&&(n=n*339195258003219555707034227454543997025n>>128n),(t&128n)!=0n&&(n=n*338111622100601834656805679988414885971n>>128n),(t&256n)!=0n&&(n=n*335954724994790223023589805789778977700n>>128n),(t&512n)!=0n&&(n=n*331682121138379247127172139078559817300n>>128n),(t&1024n)!=0n&&(n=n*323299236684853023288211250268160618739n>>128n),(t&2048n)!=0n&&(n=n*307163716377032989948697243942600083929n>>128n),(t&4096n)!=0n&&(n=n*277268403626896220162999269216087595045n>>128n),(t&8192n)!=0n&&(n=n*225923453940442621947126027127485391333n>>128n),(t&16384n)!=0n&&(n=n*149997214084966997727330242082538205943n>>128n),(t&32768n)!=0n&&(n=n*66119101136024775622716233608466517926n>>128n),(t&65536n)!=0n&&(n=n*12847376061809297530290974190478138313n>>128n),(t&131072n)!=0n&&(n=n*485053260817066172746253684029974020n>>128n),(t&262144n)!=0n&&(n=n*691415978906521570653435304214168n>>128n),e>=0n&&(n=Va/n);let r=n/La;return n%La===0n?r:r+1n}function oo(e){if(e<4295048017n||e>=79226673515401279992447579062n)throw Error(`INVALID_SQRT_PRICE`);let[,t]=io(Ja(e)),n=Ga(Ya(t,Ja(Ua))),r,i,a;if(n===0n?(r=-1n,i=0n,a=1n):e<18446744073709551616n?(r=-n-1n,i=-n,a=-n+1n):(r=n-1n,i=n,a=n+1n),r<-443636n&&(r=-Ha),a>443636n&&(a=Ha),ao(a)<=e){if(a>=443636n)throw Error(`GTE_MAX_TICK`);if(ao(a+1n)<=e)throw Error(`NO_SAFE_TICK_FOUND`);return a}if(ao(i)<=e)return i;if(ao(r)<=e)return r;throw Error(`NO_SAFE_TICK_FOUND`)}function so(e,t,n,r){let[i,a]=Xa(t,n);return e<i?[$a(i,a,r),0n]:e<a?[$a(e,a,r),eo(i,e,r)]:[0n,eo(i,a,r)]}function co({tickLower:e,tickUpper:t,liquidity:n,sqrtPrice:r}){let i=ao(Ba(e)),a=ao(Ba(t));return so(BigInt(r),BigInt(i),BigInt(a),BigInt(n))}var lo=La*La,uo=1e-300,fo=BigInt(2**53-1);function po(e){let t=e*e,n=t/lo,r=t%lo;return n>fo?Number(n):Number(n)+Number(r)/Number(lo)}function mo(e){if(!Number.isFinite(e)||e<0)throw Error(`calculateTokens: price must be finite and non-negative`);return 1/Math.max(e,uo)}function ho({tickLower:e,tickUpper:t,isReversed:n=!1}){let r=ao(Ba(e)),i=ao(Ba(t)),a=po(r),o=po(i);return n?{min:mo(o),max:mo(a)}:{min:a,max:o}}var go=(0,m.createQueryKeys)(`interwovenkit:initia-liquidity`,{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,n)=>[e,t,n],clammFees:(e,t,n)=>[e,t,n],clammIncentive:(e,t,n,r)=>[e,t,n,r]}),_o={lens:`lens`,pool:`pool`,farming:`farming`},vo={"interwoven-1":{clammModuleAddress:`0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e`,incentiveModuleAddress:`0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351`},"initiation-2":{clammModuleAddress:`0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d`,incentiveModuleAddress:`0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753`}};function yo(e){return e.startsWith(`0x`)?`0x${e.replace(/^0x/,``).padStart(64,`0`)}`:(0,d.InitiaAddress)(e).hex}function bo(e){return(0,_.toBase64)((0,d.InitiaAddress)(yo(e),32).bytes)}function xo(e,t){return`${e}:${t}`}function So(e){return`clamm:${e}`}function Co(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function wo(e){return e.map(e=>({tokenAddress:e.token_address,lpMetadata:e.lp_metadata,tickLower:e.tick_lower,tickUpper:e.tick_upper,liquidity:e.liquidity,incentives:e.incentives.map(e=>({incentiveAddress:e.incentive_address,rewardMetadata:e.reward_metadata}))}))}function To(e){let{dexUrl:t}=z();return(0,u.useSuspenseQuery)({queryKey:go.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];let n=[],r;do{let i={"pagination.limit":`100`};r&&(i[`pagination.key`]=r);let a=await h.default.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:i}).json().catch(()=>({positions:[],pagination:{next_key:null,total:`0`}}));n.push(...Co(a.positions)),r=a.pagination.next_key||void 0}while(r);return wo(n)},staleTime:B.MINUTE})}function Eo(e){let t=V(),{viewFunction:n}=(0,d.createMoveClient)(t.restUrl),r=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:go.clammPoolInfo(t.restUrl,t.chainId,e).queryKey,queryFn:async()=>{let r=vo[t.chainId];if(!r)return null;try{let t=await n({moduleAddress:r.clammModuleAddress,moduleName:_o.lens,functionName:`get_pool_info`,typeArgs:[],args:[bo(e)]});return!t?.sqrt_price||!t?.tick_spacing?null:{sqrtPrice:t.sqrt_price,tickSpacing:t.tick_spacing}}catch{return null}},staleTime:B.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>{t.set(e,r[n]??null)}),t},[e,r])}function Do(e){let t=V(),{viewFunction:n}=(0,d.createMoveClient)(t.restUrl),r=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:go.clammFees(t.restUrl,t.chainId,e).queryKey,queryFn:async()=>{let r=vo[t.chainId];if(!r)return null;try{let t=await n({moduleAddress:r.clammModuleAddress,moduleName:_o.pool,functionName:`fees_available`,typeArgs:[],args:[bo(e)]});return Array.isArray(t)?t:null}catch{return null}},staleTime:B.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>{let i=r[n];i&&t.set(e,i)}),t},[e,r])}function Oo(e){let t=V(),{viewFunction:n}=(0,d.createMoveClient)(t.restUrl),r=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:go.clammIncentive(t.restUrl,t.chainId,e.tokenAddress,e.incentiveAddress).queryKey,queryFn:async()=>{let r=vo[t.chainId];if(!r)return`0`;try{let t=await n({moduleAddress:r.incentiveModuleAddress,moduleName:_o.farming,functionName:`pending_reward_info`,typeArgs:[],args:[bo(e.tokenAddress),bo(e.incentiveAddress)]});return typeof t==`string`?t:Array.isArray(t)&&typeof t[0]==`string`?t[0]:`0`}catch{return`0`}},staleTime:B.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,n)=>{t.set(xo(e.tokenAddress,e.incentiveAddress),r[n]||`0`)}),t},[e,r])}function ko(e){let{dexUrl:t}=z(),n=(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:go.poolByMetadata(t,e).queryKey,queryFn:async()=>{try{return(await h.default.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(e)}`).json()).pool}catch{return null}},staleTime:B.MINUTE}))}).map(e=>e.data);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{t.set(e,n[r]??null)}),t},[e,n])}function Ao(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(e=>t.get(e.denom)?.logoUrl||``)}function jo(e){return ko(e)}function Mo(e){let t=dt(V()),n=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.denom,n);return e},[t]),r=(0,g.useMemo)(()=>e.map(e=>(0,d.denomToMetadata)(e)),[e]),i=ko(r);return(0,g.useMemo)(()=>{let t=new Map;return e.forEach((e,a)=>{let o=r[a];if(!o){t.set(e,null);return}let s=i.get(o);if(!s){t.set(e,null);return}if(e===`uoinit`){t.set(e,{...s,symbol:St});return}let c=s.coins.map(e=>n.get(e.denom)?.symbol||e.denom).join(`-`);t.set(e,{...s,symbol:c})}),t},[e,r,i,n])}var No=`lock_staking`;function Po(e,t){return(0,d.InitiaAddress)((0,d.createObjectAddress)(e,`${t}::lock_staking::StakingAccount`)).bech32}var Fo=(0,m.createQueryKeys)(`interwovenkit:initia-staking`,{delegations:(e,t)=>[e,t],undelegations:(e,t,n)=>[e,t,n],lockStaking:(e,t,n)=>[e,t,n],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,n)=>[e,t,n]});function Io(){let{restUrl:e}=V(),t=U();return(0,u.useSuspenseQuery)({queryKey:Fo.delegations(e,t||``).queryKey,queryFn:async()=>t?(await h.default.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:e=>{let t=new Map;for(let n of e){let e=n.delegation.validator_address;for(let r of n.balance){let n=(0,d.denomToMetadata)(r.denom),i={denom:r.denom,metadata:n,amount:r.amount,validator:e},a=t.get(n)??[];a.push(i),t.set(n,a)}}return t},staleTime:B.MINUTE})}function Lo(){let{restUrl:e}=V(),{lockStakeModuleAddress:t}=z(),n=U(),r=n?Po(n,t):``;return(0,u.useSuspenseQuery)({queryKey:Fo.undelegations(e,n||``,r).queryKey,queryFn:async()=>{if(!n)return[];let t=await h.default.get(`${e}/initia/mstaking/v1/delegators/${n}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),i=await h.default.get(`${e}/initia/mstaking/v1/delegators/${r}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...t.unbonding_responses,...i.unbonding_responses]},select:e=>{let t=new Map;for(let n of e){let e=n.validator_address;for(let r of n.entries)for(let n of r.balance){let i=(0,d.denomToMetadata)(n.denom),a={denom:n.denom,metadata:i,amount:n.amount,validator:e,completionTime:r.completion_time},o=t.get(i)??[];o.push(a),t.set(i,o)}}return t},staleTime:B.MINUTE})}function Ro(){let{restUrl:e}=V(),{lockStakeModuleAddress:t}=z(),n=U();return(0,u.useSuspenseQuery)({queryKey:Fo.lockStaking(e,n||``,t).queryKey,queryFn:async()=>{if(!n)return[];let{viewFunction:r}=(0,d.createMoveClient)(e);return await r({moduleAddress:t,moduleName:No,functionName:`get_locked_delegations`,typeArgs:[],args:[(0,_.toBase64)((0,d.InitiaAddress)(n,32).bytes)]})??[]},select:e=>{let t=new Map;for(let n of e){let e={metadata:n.metadata,amount:n.amount,validator:n.validator,releaseTime:n.release_time},r=t.get(n.metadata)??[];r.push(e),t.set(n.metadata,r)}return t},staleTime:B.MINUTE})}function zo(e){let t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(let n of e.total){if(!n?.denom||!n?.dec_coins)continue;let e=(0,d.denomToMetadata)(n.denom),r=new f.default(0);for(let e of n.dec_coins)e?.amount&&(r=r.plus(e.amount));let i=t.get(e);if(i){let e=new f.default(i.amount);r=r.plus(e)}t.set(e,{denom:n.denom,amount:r.toString()})}return t}function Bo(){let{restUrl:e}=V(),t=U();return(0,u.useSuspenseQuery)({queryKey:Fo.stakingRewards(e,t||``).queryKey,queryFn:async()=>t?await h.default.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:zo,staleTime:B.MINUTE})}function Vo(){let{restUrl:e}=V(),{lockStakeModuleAddress:t}=z(),n=U(),r=n?Po(n,t):``;return(0,u.useSuspenseQuery)({queryKey:Fo.lockStakingRewards(e,n??``,r).queryKey,queryFn:async()=>n?await h.default.get(`${e}/initia/distribution/v1/delegators/${r}/rewards`).json():{rewards:[],total:[]},select:zo,staleTime:B.MINUTE})}function Ho(){let e=V(),t=dt(e),{data:n,isLoading:r}=at(e),{data:i}=Io(),{data:a}=Lo(),{data:o}=Ro(),s=gt((0,g.useMemo)(()=>{let e=new Set;for(let t of i.keys())e.add(t);for(let t of o.keys())e.add(t);for(let t of a.keys())e.add(t);return Array.from(e)},[i,o,a])),c=(0,g.useMemo)(()=>{let e=new Map;if(n)for(let t of n)e.set(t.id,t.price);return e},[n]),l=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.denom,n);return e},[t]),u=(0,g.useMemo)(()=>{let e=[],t=e=>{let t=l.get(e);return t?{symbol:t.symbol,decimals:t.decimals}:null};for(let[n,r]of i){let i=s.get(n)??r[0]?.denom;if(!i)continue;let a=t(i);if(!a)continue;let o=c.get(i)??0;for(let t of r){let{symbol:n,decimals:r}=a,s=Number((0,d.fromBaseUnit)(t.amount,{decimals:r})),c={type:`asset`,denom:i,symbol:n,amount:t.amount,formattedAmount:s,decimals:r,value:s*o};e.push({type:`staking`,validator:t.validator,balance:c})}}for(let[n,r]of o){let i=s.get(n);if(!i)continue;let a=t(i);if(!a)continue;let o=c.get(i)??0;for(let t of r){let{symbol:n,decimals:r}=a,s=Number((0,d.fromBaseUnit)(t.amount,{decimals:r})),c={type:`asset`,denom:i,symbol:n,amount:t.amount,formattedAmount:s,decimals:r,value:s*o},l=Number(t.releaseTime);e.push({type:`lockstaking`,validator:t.validator,releaseTime:Number.isNaN(l)?0:l,balance:c})}}for(let[n,r]of a){let i=s.get(n)??r[0]?.denom;if(!i)continue;let a=t(i);if(!a)continue;let o=c.get(i)??0;for(let t of r){let{symbol:n,decimals:r}=a,s=Number((0,d.fromBaseUnit)(t.amount,{decimals:r})),c={type:`asset`,denom:i,symbol:n,amount:t.amount,formattedAmount:s,decimals:r,value:s*o},l=new Date(t.completionTime).getTime(),u=Number.isNaN(l)?0:Math.floor(l/1e3);e.push({type:`unstaking`,validator:t.validator,completionTime:u,balance:c})}}return e.filter(e=>e.type!==`fungible-position`&&e.type!==`perp-position`&&e.balance.denom===`uinit`)},[i,o,a,s,l,c]);return{positions:u,totalValue:(0,g.useMemo)(()=>u.reduce((e,t)=>t.type===`fungible-position`||t.type===`perp-position`||t.balance.type===`unknown`?e:e+(t.balance.value??0),0),[u]),isLoading:r}}function Uo(e){let t=new Map;for(let n of e){let e=(0,d.denomToMetadata)(n.denom),r={...n,metadata:e},i=t.get(e)??[];i.push(r),t.set(e,i)}return t}function Wo(e,t){return e.map(e=>t.get(e)?.symbol||e).join(`/`)}function Go(e){let{dexUrl:t}=z();return(0,u.useSuspenseQuery)({queryKey:go.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;let n=await h.default.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(n.data))},staleTime:B.MINUTE})}function Ko(){let e=Rt(V()),{data:t}=Go((0,g.useMemo)(()=>e.map(e=>e.denom),[e]));return(0,g.useMemo)(()=>Uo(e.filter(e=>t.get(e.denom)===!0)),[e,t])}function qo(e){let{dexUrl:t}=z();return(0,u.useSuspenseQuery)({queryKey:go.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;let{prices:n}=await h.default.get(`${t}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(`,`))}`).json();return Array.isArray(n)?new Map(n.map(({denom:e,price:t})=>[e,t])):new Map(Object.entries(n))},staleTime:B.MINUTE})}function Jo(e,t,n,r){let i=new Set;for(let t of e.keys())i.add(t);for(let[e,n]of t){let t=n[0]?.denom;t&&t!==`uinit`&&i.add(e)}for(let e of n.keys())i.add(e);for(let[e,t]of r){let n=t[0]?.denom;n&&n!==`uinit`&&i.add(e)}return Array.from(i)}function Yo(e){let t=[];for(let[,n]of e)n&&n!==`uinit`&&t.push(n);return t}function Xo(e,t,n){let r=t.get(e)??null,i=r?.symbol||e,a=Ao(r,n),o=a.length>0&&a.some(e=>e),s=o?void 0:n.get(e)?.logoUrl;return{denom:e,symbol:i,totalAmount:0,totalValue:0,decimals:n.get(e)?.decimals??6,poolType:r?.pool_type,logoUrl:s,coinLogos:o?a:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Zo(e,t,n,r,i){for(let[a,o]of e){let e=t.get(a)??o[0]?.denom;if(!e||e===`uinit`)continue;let s=r.get(e);if(s)for(let t of o){let r=s.decimals,a=Number((0,d.fromBaseUnit)(String(t.amount),{decimals:r})),o=a*(n.get(e)??0);s.breakdown[i]+=a,s.totalAmount+=a,s.totalValue+=o}}}function Qo(e,t,n,r,i){for(let[a,o]of e){let e=t.get(a);if(!e||e===`uinit`)continue;let s=r.get(e);if(s)for(let t of o){let r=s.decimals,a=Number((0,d.fromBaseUnit)(String(t.amount),{decimals:r})),o=a*(n.get(e)??0);s.breakdown[i]+=a,s.totalAmount+=a,s.totalValue+=o}}}function $o(e,t,n,r){for(let[i,a]of e){let e=(0,d.denomToMetadata)(i),o=t?.get(e),s=o?(0,d.fromBaseUnit)(o.amount,{decimals:6}):`0`,c=n?.get(e),l=c?(0,d.fromBaseUnit)(c.amount,{decimals:6}):`0`,u=Number(s)+Number(l);u<=0||(a.claimableInit={staking:s,lockStaking:l,total:String(u),totalValue:u*r})}}function es(e){return`#${e.replace(/^0x/,``).slice(-6)}`}function ts(){let e=V(),t=dt(e),n=U(),r=Ko(),{data:i}=Io(),{data:a}=Ro(),{data:o}=Lo(),{data:s}=Bo(),{data:c}=Vo(),{data:l}=at(e),{data:u}=To(n),f=(0,g.useMemo)(()=>{let e=new Map;for(let t of u){let n=e.get(t.lpMetadata)??[];n.push(t),e.set(t.lpMetadata,n)}return e},[u]),p=(0,g.useMemo)(()=>Array.from(f.keys()),[f]),m=jo(p),h=Eo(p),_=Do((0,g.useMemo)(()=>u.map(e=>e.tokenAddress),[u])),v=Oo((0,g.useMemo)(()=>{let e=[];for(let t of u)for(let n of t.incentives)e.push({tokenAddress:t.tokenAddress,incentiveAddress:n.incentiveAddress});return e},[u])),y=gt((0,g.useMemo)(()=>{let e=new Set;for(let t of u)for(let n of t.incentives)e.add(n.rewardMetadata);return Array.from(e)},[u]),{failSoft:!0}),b=gt((0,g.useMemo)(()=>Jo(r,i,a,o),[r,i,a,o])),x=(0,g.useMemo)(()=>Yo(b),[b]),{data:S}=qo(x),C=Mo(x),w=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.denom,n);return e},[t]),T=(0,g.useMemo)(()=>{let e=new Map;for(let t of l??[])e.set(t.id,t.price);return e},[l]),{rows:E,totalValue:D}=(0,g.useMemo)(()=>{let e=l?.find(e=>e.id===`uinit`)?.price??0,t=new Map;for(let e of x)t.set(e,Xo(e,C,w));Zo(r,b,S,t,`deposit`),Zo(i,b,S,t,`staking`),Qo(a,b,S,t,`lockStaking`),Zo(o,b,S,t,`unstaking`),$o(t,s,c,e);for(let e of p){let n=f.get(e)??[];if(n.length===0)continue;let r=m.get(e),i=h.get(e),a=So(e),o=r?.coins.map(e=>e.denom)??[],s=r?Ao(r,w).filter(Boolean):[],c=o.map(e=>w.get(e)?.symbol||e),l=r?.symbol||c.join(`-`)||a,u=Wo(o,w),p=n.map(e=>{let t,n,a,s=!1,c=0,l=0;try{let r=ho({tickLower:e.tickLower,tickUpper:e.tickUpper});t=r.min,n=r.max}catch{t=void 0,n=void 0}if(i){try{let t=oo(BigInt(i.sqrtPrice)),n=Ba(e.tickLower),r=Ba(e.tickUpper),o=Number(i.tickSpacing);s=Number.isFinite(o)&&o>0?Wa(e.tickLower,e.tickUpper,o):!1,a=s||t>=n&&t<r}catch{a=void 0,s=!1}if(r&&o.length>0)try{co({sqrtPrice:i.sqrtPrice,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:e.liquidity}).forEach((e,t)=>{let n=r.coins[t];if(!n)return;let i=w.get(n.denom)?.decimals??6,a=T.get(n.denom)??0,o=Number((0,d.fromBaseUnit)(String(e),{decimals:i}));c+=o*a})}catch{c=0}}return r&&((_.get(e.tokenAddress)??[]).forEach((e,t)=>{let n=r.coins[t];if(!n)return;let i=w.get(n.denom)?.decimals??6,a=T.get(n.denom)??0,o=Number((0,d.fromBaseUnit)(e,{decimals:i}));l+=o*a}),e.incentives.forEach(t=>{let n=v.get(xo(e.tokenAddress,t.incentiveAddress))??`0`,r=y.get(t.rewardMetadata);if(!r)return;let i=w.get(r)?.decimals??6,a=T.get(r)??0,o=Number((0,d.fromBaseUnit)(n,{decimals:i}));l+=o*a})),{tokenAddress:e.tokenAddress,positionId:es(e.tokenAddress),inRange:a,isFullRange:s,minPrice:t,maxPrice:n,pricePairLabel:u,rewardValue:l,value:c}}),g=p.reduce((e,t)=>e+t.value,0),b=p.reduce((e,t)=>e+t.rewardValue,0),x=s.length>0;t.set(a,{denom:a,symbol:l,totalAmount:0,totalValue:g,decimals:6,poolType:`CLAMM`,logoUrl:void 0,coinLogos:x?s:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:e,totalRewardValue:b,positions:p}})}let n=Array.from(t.values()).filter(e=>e.totalAmount>0||e.isClamm).sort((e,t)=>t.totalValue-e.totalValue);return{rows:n,totalValue:n.reduce((e,t)=>e+t.totalValue,0)}},[l,x,C,w,r,i,a,o,b,S,s,c,p,f,m,h,_,v,y,T]);return{totalValue:D,rows:E}}var ns=`vault`,rs=`vault_staking`,is=(0,m.createQueryKeys)(`interwovenkit:initia-vault`,{staked:(e,t,n)=>[e,t,n],info:(e,t,n)=>[e,t,n],shareToAsset:(e,t,n,r)=>[e,t,n,r],claimable:(e,t,n,r)=>[e,t,n,r]}),as=e=>d.bcs.object().serialize(e).toBase64(),os=e=>d.bcs.address().serialize(e).toBase64();function ss(e,t,n,r){return(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:is.info(t,n,e.metadata).queryKey,queryFn:()=>r({moduleAddress:n,moduleName:ns,functionName:`vault_info`,typeArgs:[],args:[as(e.metadata)]}),staleTime:B.MINUTE})),combine:e=>e.map(e=>e.data)})}function cs(e,t,n,r){return(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:is.shareToAsset(t,n,e.metadata,e.amount).queryKey,queryFn:()=>r({moduleAddress:n,moduleName:ns,functionName:`vault_share_to_asset`,typeArgs:[],args:[as(e.metadata),d.bcs.u64().serialize(e.amount).toBase64()]}),staleTime:B.MINUTE})),combine:e=>e.map(e=>e.data)})}function ls(e,t,n,r,i){return(0,u.useSuspenseQueries)({queries:e.map(e=>({queryKey:is.claimable(t,n,e.metadata,r).queryKey,queryFn:()=>i({moduleAddress:n,moduleName:ns,functionName:`user_claimable_rewards`,typeArgs:[],args:[as(e.metadata),os(r)]}),staleTime:B.MINUTE})),combine:e=>e.map(e=>e.data??[])})}function us(){let e=U(),t=V(),{restUrl:n}=t,{clammVaultModuleAddress:r}=z(),{viewFunction:i}=(0,d.createMoveClient)(n),{data:a}=at(t),o=dt(t),{data:s}=(0,u.useSuspenseQuery)({queryKey:is.staked(n,r,e).queryKey,queryFn:async()=>e?await i({moduleAddress:r,moduleName:rs,functionName:`user_staked_tokens`,typeArgs:[],args:[os(e)]})??[]:[],staleTime:B.MINUTE}),c=ss(s,n,r,i),l=cs(s,n,r,i),p=ls(s,n,r,e,i),m=[...new Set(c.flatMap(e=>e?[e.asset_0,e.asset_1]:[]))],h=[...new Set(p.flatMap(e=>e.map(e=>e.metadata)))],_=gt(m,{failSoft:!0}),v=gt(h,{failSoft:!0});return(0,g.useMemo)(()=>{let e=new Map(o.map(e=>[e.denom,e])),t=e=>a?.find(t=>t.id===e)?.price??0,n=s.map((n,r)=>{let i=c[r],a=l[r];if(!i||!a)return null;let o=(0,f.default)(i.oracle_price_0||0).times(a[0]||0).plus((0,f.default)(i.oracle_price_1||0).times(a[1]||0)).toNumber(),s=e.get(_.get(i.asset_0)??``),u=e.get(_.get(i.asset_1)??``),m=p[r].reduce((n,r)=>{let i=v.get(r.metadata)??``,a=e.get(i),o=(0,d.fromBaseUnit)(r.amount,{decimals:a?.decimals??6});return n.plus((0,f.default)(o||0).times(t(i)))},(0,f.default)(0)).toNumber();return{vaultAddress:n.metadata,symbol:[s?.symbol,u?.symbol].filter(Boolean).join(`-`),coinLogos:[s?.logoUrl??``,u?.logoUrl??``],isActive:i.is_active,curatorAddress:i.curator?(0,d.InitiaAddress)(i.curator).bech32:``,value:o,claimableValue:m}}).filter(e=>e!==null).sort((e,t)=>t.value+t.claimableValue-(e.value+e.claimableValue));return{totalValue:n.reduce((e,t)=>e+t.value+t.claimableValue,0),rows:n}},[s,c,l,p,_,v,o,a])}var ds=(0,m.createQueryKeys)(`interwovenkit:initia-vip`,{allVestingPositions:(e,t)=>[e,t]});function fs(e){return e.filter(e=>e.data.length>0).map(e=>{let t=e.data[0].bridge_id,n=e.data[0].version,r=e.data.reduce((e,t)=>e+t.claimed_reward,0);return{claimableReward:e.total_claimable_reward,claimedReward:r,initialReward:e.total_vesting_reward,lockedReward:e.total_locked_reward,requiredScore:e.required_score,rollup:{bridgeId:t,version:n}}}).filter(e=>e.initialReward>0).sort((e,t)=>t.initialReward-e.initialReward)}function ps(){let{vipUrl:e}=z(),t=U();return(0,u.useQuery)({queryKey:ds.allVestingPositions(e,t).queryKey,queryFn:async()=>(await h.default.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:e})=>e>0),staleTime:B.MINUTE,enabled:!!t})}function ms(){let e=Ze(),t=$e();return(0,g.useCallback)(n=>{let r=e.find(({metadata:e})=>e?.op_bridge_id===String(n));if(r)return r;let i=t.find(e=>e.op_bridge_id===String(n));if(i)return{name:i.pretty_name,logoUrl:i.logo}},[e,t])}function hs(){let{data:e}=ps(),{data:t}=at(V()),n=ms(),r=(0,g.useMemo)(()=>t?.find(e=>e.id===`uinit`)?.price??0,[t]),i=(0,g.useMemo)(()=>e?fs(e).map(e=>{let t=n(e.rollup.bridgeId),i=Number((0,d.fromBaseUnit)(String(e.lockedReward),{decimals:6})),a=Number((0,d.fromBaseUnit)(String(e.claimableReward),{decimals:6})),o=(0,f.default)((0,d.fromBaseUnit)(String(e.lockedReward),{decimals:6})||0).times(r).toNumber(),s=(0,f.default)((0,d.fromBaseUnit)(String(e.claimableReward),{decimals:6})||0).times(r).toNumber();return{bridgeId:e.rollup.bridgeId,version:e.rollup.version,name:t?.name||`Bridge #${e.rollup.bridgeId}`,logoUrl:t?.logoUrl||st,lockedReward:i,lockedRewardValue:o,claimableReward:a,claimableRewardValue:s}}).filter(e=>e.lockedReward+e.claimableReward>0):[],[e,r,n]);return{rows:i,totalValue:(0,g.useMemo)(()=>i.reduce((e,t)=>e+t.lockedRewardValue+t.claimableRewardValue,0),[i])}}function gs(){let{totalValue:e}=ts(),{totalValue:t}=us(),{data:n}=Io(),{data:r}=Ro(),{data:i}=Lo(),{data:a}=ps(),o=gt((0,g.useMemo)(()=>Array.from(r.keys()),[r])),{data:s}=at(V()),c=(0,g.useMemo)(()=>s?.find(e=>e.id===`uinit`)?.price??0,[s]);return(0,g.useMemo)(()=>{let s=0,l=0,u=c??0;for(let[,e]of n)for(let{denom:t,amount:n}of e)t===`uinit`&&(s+=Number((0,d.fromBaseUnit)(n,{decimals:6}))*u);for(let[e,t]of r)if(o.get(e)===`uinit`)for(let{amount:e}of t)l+=Number((0,d.fromBaseUnit)(e,{decimals:6}))*u;for(let[,e]of i)for(let{denom:t,amount:n}of e)t===`uinit`&&(s+=Number((0,d.fromBaseUnit)(n,{decimals:6}))*u);let f=0;if(a)for(let e of a){let t=e.total_locked_reward??0,n=e.total_claimable_reward??0;f+=Number((0,d.fromBaseUnit)(String(t+n),{decimals:6}))*u}return s+l+e+f+t},[n,r,o,i,a,c,e,t])}function _s(){let e=[`initia-wallet-widget:last-connected-wallet`,`initia-wallet-widget:fee-denoms`,`initia-wallet-widget:chain-ids`,`initia-wallet-widget:opened-layers-assets`,`initia-wallet-widget:opened-layers-nft`],t={"initia-wallet-widget:ethereum-public-keys":{prefix:H.PUBLIC_KEY,getSuffix:e=>(0,d.InitiaAddress)(e).bech32}};for(let t of e)localStorage.removeItem(t);for(let[e,{prefix:n,getSuffix:r}]of Object.entries(t)){let t=localStorage.getItem(e);if(t)try{let i=JSON.parse(t);for(let[e,t]of Object.entries(i)){let i=`${n}:${r(e)}`;localStorage.setItem(i,t)}localStorage.removeItem(e)}catch{}}}var vs=(0,m.createQueryKeys)(`interwovenkit:minity`,{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,n)=>[e,t,n],initiaPositions:(e,t)=>[e,`initia`,t],echelonPositions:(e,t)=>[e,`echelon`,t],inertiaPositions:(e,t)=>[e,`inertia`,t],ravePositions:(e,t,n)=>[e,`rave`,t,n],yominetPositions:(e,t)=>[e,`yominet`,t],chainPositions:(e,t,n)=>[e,t,n]});function ys(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i++){let a=e[i],o=t[i],s=a.data;if(!(!o||!s)){for(let e of s)if(e.logoUrl&&!e.logoUrl.includes(`undefined`)){let t=`${o.chainId}:${e.denom}`;n.has(t)||n.set(t,e.logoUrl);let i=e.symbol.toUpperCase();r.has(i)||r.set(i,e.logoUrl)}}}return{denomLogos:n,symbolLogos:r}}function bs(e){return e.pnl??null}function xs(e){return e.balance.type===`unknown`?null:e.balance.value??null}function Ss(e){return xs(e)==null}function Cs(e){if(e==null||!Number.isFinite(e))return`—`;let t=(0,f.default)(e).decimalPlaces(2,f.default.ROUND_HALF_UP);return t.isZero()?`$0.00`:`${t.gt(0)?`+`:`-`}$${(0,d.formatNumber)(t.abs().toNumber(),{dp:2})}`}function ws(e,t){if(e==null||t==null||!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return``;let n=(0,f.default)(e).div(t).times(100).decimalPlaces(2,f.default.ROUND_HALF_UP);return n.isZero()?`(0.00%)`:`(${n.gt(0)?`+`:`-`}${n.abs().toFixed(2)}%)`}function Ts(e){return!Number.isFinite(e)||e<1?``:(0,f.default)(e).decimalPlaces(0,f.default.ROUND_DOWN).toString()}function Es(e){if(e.type===`fungible-position`)return e.value??0;if(e.type===`perp-position`){let t=xs(e);if(t==null)return 0;let n=bs(e);return(0,f.default)(t).plus(n??0).toNumber()}if(e.balance.type===`unknown`)return 0;let t=e.balance.value??0;return e.type===`lending`&&e.direction===`borrow`?-t:t}function Ds(e){switch(e.type){case`fungible-position`:return null;case`perp-position`:return`perp`;case`staking`:case`unstaking`:case`lockstaking`:return`staking`;case`lending`:return e.direction===`supply`?`lending`:`borrowing`;default:return e}}function Os(e,t={}){let{isInitia:n=!1,chainName:r}=t,i=r?.toLowerCase()===Ct;switch(e){case`staking`:return i?`Vault`:n?`INIT staking`:`Staking`;case`perp`:return`Perpetuals`;case`borrowing`:return`Borrowing`;case`lending`:return`Lending`;default:return e.charAt(0).toUpperCase()+e.slice(1)}}function ks(e){let t=new Map;for(let n of e){let e=Ds(n);if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}let n=new Map,r=new Map;for(let[e,i]of t){let t=i.reduce((e,t)=>e+Es(t),0),a=i.reduce((e,t)=>e+Math.abs(Es(t)),0);n.set(e,t),r.set(e,a)}let i=(r.get(`lending`)??0)+(r.get(`borrowing`)??0),a=[...t.keys()].sort((e,t)=>{let n=e===`lending`||e===`borrowing`?i:r.get(e)??0,a=t===`lending`||t===`borrowing`?i:r.get(t)??0;return(e===`lending`||e===`borrowing`)&&(t===`lending`||t===`borrowing`)?e===`lending`?-1:1:a-n}),o=new Map;for(let e of a)o.set(e,{positions:t.get(e),totalValue:n.get(e)??0});return o}function As(e){return e.type===`fungible-position`?e.title:e.type===`perp-position`?e.pair:e.balance.denom}function js(e){return e.type===`fungible-position`?e.title:e.type===`perp-position`?e.pair:e.balance.type===`unknown`?e.balance.denom:e.balance.symbol}function Ms(e){return e.type===`fungible-position`||e.type===`perp-position`?null:e.balance}function Ns(e){switch(e){case`staking`:return`Staking`;case`unstaking`:return`Unstaking`;case`lockstaking`:return`Lock staking`;case`lending`:return`Lending`;case`fungible-position`:return`Position`;case`perp-position`:return`Perpetuals`;default:return``}}function Ps(e){let t=new Map;for(let n of e){let e=t.get(n.type)??[];e.push(n),t.set(n.type,e)}return t}function Fs(e,t){let n=jt(e.symbol),r=jt(t.symbol);return n===r?t.totalValue===e.totalValue?e.symbol.localeCompare(t.symbol,void 0,{sensitivity:`base`}):t.totalValue-e.totalValue:n-r}function Is(e){let t=new Map;for(let n of e){let e=As(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return Array.from(t.entries()).map(([e,t])=>{let n=Ms(t[0]),r=0;for(let e of t)e.type===`fungible-position`||e.type===`perp-position`||e.balance.type!==`unknown`&&(r+=e.balance.formattedAmount);return{denom:e,symbol:js(t[0]),positions:t,totalValue:t.reduce((e,t)=>e+Es(t),0),totalAmount:r,balance:n}}).sort(Fs)}function Ls(e,t){let n=new Map;return e.forEach((e,r)=>{let i=t[r]?.data;if(i&&i.length>0){let t=new Map(i.map(e=>[e.id,e.price]));n.set(e.chainId,t)}}),n}function Rs(e,t){return e.map(e=>({...e,balances:e.balances.map(n=>{if(n.type===`unknown`||n.value!=null&&n.value>0)return n;let r=t.get(e.chainId);if(r){let e=r.get(n.denom)??0;if(e>0)return{...n,value:n.formattedAmount*e}}return n})}))}function zs(e,t){let n=jt(e.symbol),r=jt(t.symbol);return n===r?t.totalValue===e.totalValue?e.symbol.localeCompare(t.symbol,void 0,{sensitivity:`base`}):t.totalValue-e.totalValue:n-r}function Bs(e,t,n){return e.map(e=>{let r=e.assets.map(e=>{let r=e.symbol.toUpperCase(),i=`${e.chain.chainId}:${e.denom}`,a=t.get(i)??n.get(r)??``;return a===e.logoUrl?e:{...e,logoUrl:a}}),i=``;for(let e of r)if(e.logoUrl){i=e.logoUrl;break}return i||=n.get(e.symbol.toUpperCase())??``,i!==e.logoUrl||r!==e.assets?{...e,logoUrl:i,assets:r}:e})}function Vs(e,t,n){let r=t?e.filter(e=>{let{symbol:n,assets:r}=e,i=t.toLowerCase();return n.toLowerCase().includes(i)||r.some(({denom:e})=>e.toLowerCase().includes(i))}):e,i=n?r.map(e=>{let t=e.assets.filter(({chain:e})=>e.chainId===n);return{...e,assets:t,totalValue:t.reduce((e,t)=>e+(t.value??0),0),totalAmount:t.reduce((e,t)=>e+Number(t.quantity),0)}}).filter(e=>e.assets.length>0):r;return{filteredAssets:i,totalAssetsValue:i.reduce((e,t)=>e+t.assets.reduce((e,t)=>e+(t.value??0),0),0)}}function Hs(e,t,n){let r=t?e.filter(({denom:e,address:n})=>{let r=t.toLowerCase();return e.toLowerCase().includes(r)||n?.toLowerCase().includes(r)}):e;return n?r.filter(({chain:e})=>e.chainId===n):r}function Us(e,t,n,r){let{filteredAssets:i,totalAssetsValue:a}=Vs(e,n,r);return{filteredAssets:i,totalAssetsValue:a,filteredUnlistedAssets:Hs(t,n,r)}}function Ws(e,t,n,r){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};let i=new Map,a=[];for(let r of e){let{chainName:e,chainId:o,balances:s}=r;if(!Array.isArray(s))continue;let c=t.get(e.toLowerCase()),l=c?.chainId??o??e,u=c?.prettyName??e,d=c?.logoUrl??``,f=n.get(l);for(let e of s){if(e.type===`unknown`){if(!e.amount||e.amount===`0`)continue;a.push({symbol:e.denom,logoUrl:``,denom:e.denom,amount:e.amount,decimals:0,quantity:e.amount,value:void 0,unlisted:!0,chain:{chainId:l,name:u,logoUrl:d}});continue}if(e.type===`lp`||(e.value??0)<=0&&(e.formattedAmount??0)<=0)continue;let t=e.value;if((t==null||t<=0)&&f){let n=f.get(e.denom)??0;n>0&&(t=e.formattedAmount*n)}let n={symbol:e.symbol,logoUrl:``,denom:e.denom,amount:e.amount,decimals:e.decimals,quantity:String(e.formattedAmount),value:t,chain:{chainId:l,name:u,logoUrl:d}},r=i.get(e.symbol);r?r.push(n):i.set(e.symbol,[n])}}a.sort((e,t)=>{let n=e.chain.chainId===r,i=t.chain.chainId===r;if(n&&!i)return-1;if(!n&&i)return 1;let a=e.chain.name.localeCompare(t.chain.name);if(a!==0)return a;try{let n=BigInt(e.amount),r=BigInt(t.amount);if(n>r)return-1;if(n<r)return 1}catch{let n=e.amount.localeCompare(t.amount);if(n!==0)return-n}return e.denom.localeCompare(t.denom)});let o=[];for(let[e,t]of i){t.sort((e,t)=>(t.value??0)-(e.value??0));let n=0,r=0;for(let e of t)n+=e.value??0,r+=Number(e.quantity);o.push({symbol:e,logoUrl:``,assets:t,totalValue:n,totalAmount:r})}return o.sort(zs),{listedGroups:o,unlistedAssets:a}}function Gs(){return V().network_type===`testnet`}function Ks(){return(0,I.useFormContext)()}function qs(e){let t=tn(e);return t&&t.gt(0)?e:null}function Js(){let e=Yt(),t=Gs(),n={quantity:``,slippagePercent:`0.5`,sender:``,cosmosWalletName:``,recipient:``},r={...n,srcChainId:`initiation-2`,srcDenom:`uusdc`,dstChainId:`initiation-2`,dstDenom:`uinit`},i={...n,srcChainId:`interwoven-1`,srcDenom:`ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4`,dstChainId:`interwoven-1`,dstDenom:`uinit`},a=(0,p.pickBy)(e=>e!==null,{srcChainId:localStorage.getItem(H.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(H.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(H.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(H.BRIDGE_DST_DENOM),quantity:localStorage.getItem(H.BRIDGE_QUANTITY),slippagePercent:qs(localStorage.getItem(H.BRIDGE_SLIPPAGE_PERCENT))});return{...t?r:i,...a,...e}}var Ys={balances:[],positions:[],isLoading:!0,isComplete:!1},Xs=(0,b.atom)(0),Zs=1e3,Qs=0;function $s(){let e=(0,b.useSetAtom)(Xs);return(0,g.useCallback)(t=>{let n=Date.now();(t?.force||n-Qs>=Zs)&&(Qs=n,e(e=>e+1))},[e])}function ec(){let e=(0,u.useQueryClient)(),t=U(),{minityUrl:n}=z(),r=Gs(),i=(0,b.useAtomValue)(Xs),a=(0,g.useEffectEvent)((e,t)=>{let n=Array.isArray(e.balances)?e.balances:[];t.set(e.chain,{chainName:e.chain,chainId:e.chainId,balances:n})}),o=(0,g.useEffectEvent)((e,t)=>{let n=Array.isArray(e.positions)?e.positions:[];t.set(e.chain,{chainName:e.chain,chainId:e.chainId,positions:n})}),s=(0,g.useEffectEvent)((r,i)=>{let a=vs.ssePortfolio(t??``,n).queryKey,o=e.getQueryData(a)??Ys,s=r.size>0||i.size>0;e.setQueryData(a,{...o,balances:Array.from(r.values()),positions:Array.from(i.values()),isLoading:s?!1:o.isLoading,isComplete:!1})});(0,g.useEffect)(()=>{if(!t||r)return;let i=vs.ssePortfolio(t,n).queryKey,c=e.getQueryData(i),l=new Map,u=new Map;for(let e of c?.balances??[])l.set(e.chainName,e);for(let e of c?.positions??[])u.set(e.chainName,e);let d=`${n}/v1/chain/all/${encodeURIComponent(t)}`,f=null,p=!1;return e.setQueryData(i,{balances:c?.balances??[],positions:c?.positions??[],isLoading:!0,isComplete:!1}),f=new EventSource(d),f.onmessage=e=>{if(!p)try{let t=JSON.parse(e.data);t.type===`balances`?a(t,l):t.type===`positions`&&o(t,u),s(l,u)}catch{}},f.onerror=()=>{f?.close()},()=>{p=!0,f?.close()}},[t,r,i])}var tc={balances:[],positions:[],isLoading:!0,isComplete:!1};function nc(){let e=U(),{minityUrl:t}=z(),n=vs.ssePortfolio(e??``,t).queryKey,{data:r}=(0,u.useQuery)({queryKey:n,queryFn:()=>tc,enabled:!!e,staleTime:B.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return r??tc}function rc(){let e=Ze();return(0,g.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.chain_name.toLowerCase();t.set(e,{chainId:n.chainId,chainName:n.chain_name,prettyName:n.name||n.chain_name,logoUrl:n.logoUrl||``})}return t},[e])}function ic(){let{balances:e,positions:t}=nc(),n=Ze(),r=(0,g.useMemo)(()=>{let e=new Map;for(let t of n)e.set(t.chain_name.toLowerCase(),t);return e},[n]);return(0,g.useMemo)(()=>{let n=e=>e.type===`unknown`?0:e.value??0,i=e=>e.positions.reduce((e,t)=>e+Es(t),0),a=new Map,o=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[];for(let{chainName:e,balances:t}of o){if(!Array.isArray(t))continue;let r=t.reduce((e,t)=>e+n(t),0);a.set(e,(a.get(e)||0)+r)}for(let{chainName:e,positions:t}of s){if(!Array.isArray(t))continue;let n=t.reduce((e,t)=>e+i(t),0);a.set(e,(a.get(e)||0)+n)}let c=Array.from(a.values()).reduce((e,t)=>e+t,0),l=Array.from(a.entries()).filter(([,e])=>e>0).map(([e,t])=>{let n=r.get(e.toLowerCase());return{chainId:n?.chainId||``,chainName:n?.name||e,logoUrl:n?.logoUrl||``,totalBalance:t,percentage:c>0?t/c:0}}).filter(e=>e.chainId!==``);return(0,p.sortWith)([(0,p.descend)(e=>e.chainName.toLowerCase()===`initia`),(0,p.descend)((0,p.prop)(`totalBalance`))],l)},[e,t,r])}function ac(){let{balances:e}=nc(),t=Ze(),n=ot(),r=(0,g.useMemo)(()=>Ls(t,n),[t,n]);return(0,g.useMemo)(()=>{let t=e=>e.type===`unknown`?0:e.value??0,n=0,i=Rs(Array.isArray(e)?e:[],r);for(let{balances:e}of i)if(Array.isArray(e))for(let r of e)r.type!==`lp`&&(n+=t(r));return n},[e,r])}function oc(){let{positions:e}=nc();return(0,g.useMemo)(()=>{let t=e=>e.positions.reduce((e,t)=>e+Es(t),0),n=[`initia`,`civitia`,`yominet`],r=0,i=Array.isArray(e)?e:[];for(let{chainName:e,positions:a}of i){let i=e.toLowerCase();n.includes(i)||Array.isArray(a)&&(r+=a.reduce((e,n)=>e+t(n),0))}return r},[e])}function sc(){let e=an();(0,u.usePrefetchQuery)({queryKey:rn.chains.queryKey,queryFn:()=>e.get(`v2/info/chains`).json(),staleTime:B.MINUTE}),(0,u.usePrefetchQuery)({queryKey:rn.allAssets().queryKey,queryFn:()=>e.get(`v2/fungible/assets`).json(),staleTime:B.MINUTE})}var cc=()=>(Nn(),Pn(),null),lc={loader:`_loader_1vxch_1`,spin:`_spin_1vxch_1`},uc=({size:e=24,color:t=`currentColor`,border:n=2})=>{let r={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${n}px`};return(0,y.jsx)(`div`,{className:lc.loader,style:r,role:`status`,"aria-label":`Loading`})},dc={button:`_button_1q027_1`,outline:`_outline_1q027_28`,sm:`_sm_1q027_46`,full:`_full_1q027_53`,small:`_small_1q027_57`,span:`_span_1q027_76`,unpadded:`_unpadded_1q027_88`},fc=e=>{let{sm:t,fullWidth:n,loading:r,className:i,children:a,disabled:o,...s}=e;return(0,y.jsx)(`button`,{...s,className:(0,F.default)(dc.button,{[dc.sm]:t,[dc.full]:n},i),disabled:!!r||o,"aria-busy":!!r,children:r?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(uc,{color:`currentColor`,size:16}),typeof r==`string`&&(0,y.jsx)(`span`,{className:dc.loading,children:r})]}):a})},G={White:fc,Outline:({className:e,...t})=>(0,y.jsx)(fc,{...t,className:(0,F.default)(dc.outline,e)}),Small:({className:e,unpadded:t,...n})=>(0,y.jsx)(`button`,{...n,className:(0,F.default)(dc.small,{[dc.unpadded]:t},e)})},pc={footer:`_footer_1vp4h_1`,actions:`_actions_1vp4h_10`},mc=({extra:e,className:t,children:n})=>(0,y.jsxs)(`footer`,{className:(0,F.default)(pc.footer,t),children:[e,(0,y.jsx)(`div`,{className:pc.actions,children:n})]}),hc={scrollable:`_scrollable_13su7_1`},gc=({className:e,children:t,ref:n})=>(0,y.jsx)(`div`,{ref:n,className:(0,F.default)(hc.scrollable,e),children:t}),_c=`interwovenkit:`;function vc(e){let[t]=e;return typeof t==`string`&&t.startsWith(_c)}function yc(e){e.removeQueries({predicate:e=>vc(e.queryKey)})}function bc(){return(0,le.useMediaQuery)(`(max-width: 576px)`)}var xc=`interwoven-kit`;function Sc(){let e=document.querySelector(xc)||document.body.appendChild(document.createElement(xc));return e.shadowRoot||e.attachShadow({mode:`open`})}function Cc(){let{theme:e,container:t}=z();return(0,g.useEffect)(()=>{document.querySelector(xc)?.setAttribute(`data-theme`,e)},[e]),t??Sc()}function wc(e){let t=Sc(),n=document.createElement(`style`);n.textContent=e,t.appendChild(n)}var Tc=(0,g.createContext)(null);function Ec(){let{container:e}=(0,g.useContext)(Tc);return e}function Dc(e){let t=Ec();return t?getComputedStyle(t).getPropertyValue(e):``}function Oc(){return(0,le.useScrollLock)(),null}function kc(e){return/^[A-F0-9]{64}$/i.test(e)}function Ac(e,t){let{txHash:n,accountAddress:r,pathSuffix:i}=t;if(n)return kc(n)?(0,p.path)([`explorers`,0,`tx_page`],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!d.InitiaAddress.validate(r))return;let t=(0,p.path)([`explorers`,0,`account_page`],e)?.replace(/\$\{accountAddress\}/g,r);return t&&i?t+i:t}}function jc(e){try{let t=new URL(e,window.location.href);if(![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid protocol`);return t.toString()}catch{return`#`}}var Mc={link:`_link_j1lkz_1`},Nc=({chainId:e,txHash:t,accountAddress:n,pathSuffix:r,...i})=>{let{showIcon:a,className:o,children:s,onClick:c,...l}=i,u=Ac(tt(e),{txHash:t,accountAddress:n,pathSuffix:r}),f=t?(0,d.truncate)(t):n?(0,d.truncate)(n):``,p=s??f;return u?(0,y.jsxs)(`a`,{...l,href:(0,fe.default)(jc(u)),className:(0,F.default)(Mc.link,o),onClick:c,target:`_blank`,rel:`noopener noreferrer`,children:[p,a&&(0,y.jsx)(L.IconExternalLink,{size:12,"aria-hidden":`true`})]}):(0,y.jsx)(`span`,{...l,className:(0,F.default)(Mc.link,o),children:p})},Pc=(0,g.createContext)(null),Fc=()=>(0,g.useContext)(Pc),Ic=()=>{let[e,t]=(0,b.useAtom)(Ji),{showNotification:n,updateNotification:r,hideNotification:i}=Fc(),a=(0,u.useQueryClient)(),o=$s();return(0,g.useEffect)(()=>{if(!e)return;let{status:s,chainId:c,txHash:l,error:u}=e,d=u?u.message:l?(0,y.jsx)(Nc,{txHash:l,chainId:c,onClick:i,showIcon:!0,children:`View on Initia Scan`}):null,f=()=>{a.invalidateQueries({queryKey:Ft.balances._def}),o({force:!0}),t(null)};switch(s){case`loading`:n({type:`loading`,title:`Transaction is pending...`});break;case`error`:r({type:`error`,title:`Transaction failed`,description:d}),f();break;case`success`:r({type:`success`,title:`Transaction is successful!`,description:d,autoHide:!0}),f();break}},[e,t,n,r,i,a,o]),null},Lc=({value:e,children:t})=>{let[n,r]=(0,g.useState)(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},Rc={placeholder:`_placeholder_wrm07_1`,logo:`_logo_wrm07_8`},K=({src:e,alt:t,placeholder:n,classNames:r,style:i,logo:a,...o})=>{let[s,c]=(0,g.useState)(void 0),{width:l,height:u}=o,d=n??(0,y.jsx)(`span`,{className:(0,F.default)(Rc.placeholder,r?.placeholder),style:{width:l,height:u,...i},"aria-hidden":`true`});return!e||s===e?d:(0,y.jsx)(`img`,{...o,className:(0,F.default)(o.className,{[Rc.logo]:a}),style:{width:l,height:u,...i},src:e,alt:t??``,loading:`lazy`,onError:()=>c(e)})};function zc(){let{connector:e}=(0,l.useAccount)();if(e)return e.id===`io.privy.wallet`?`https://assets.initia.xyz/images/wallets/Privy.webp`:e.icon}var Bc={header:`_header_1q8ju_1`,account:`_account_1q8ju_17`,name:`_name_1q8ju_28`,address:`_address_1q8ju_32`,icon:`_icon_1q8ju_36`,copied:`_copied_1q8ju_43`,button:`_button_1q8ju_58`,settings:`_settings_1q8ju_69`,disconnect:`_disconnect_1q8ju_73`,label:`_label_1q8ju_83`,expanded:`_expanded_1q8ju_91`},Vc=()=>{let e=Ar(),{address:t,username:n}=Pa(),r=zc(),i=n??t,[a,o]=(0,g.useState)(!1),s=(0,g.useRef)(null),c=(0,pe.useSpring)({width:a?140:52,config:{tension:500,friction:30,clamp:!0}}),l=()=>{a?e():o(!0)},u=()=>{a&&(s.current=setTimeout(()=>{o(!1)},500))},f=()=>{s.current&&=(clearTimeout(s.current),null)};return(0,g.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),t?(0,y.jsxs)(`header`,{className:Bc.header,children:[(0,y.jsx)(Lc,{value:t,children:({copy:e,copied:n})=>(0,y.jsxs)(`button`,{className:(0,F.default)(Bc.account,{[Bc.copied]:n}),onClick:e,"aria-label":n?`Copied`:`Copy address`,children:[(0,y.jsx)(K,{src:r,width:18,height:18}),(0,y.jsx)(`div`,{className:Bc.address,children:(0,d.truncate)(t)}),(0,y.jsx)(`div`,{className:Bc.name,children:(0,d.truncate)(i)}),(0,y.jsx)(L.IconCopy,{className:Bc.icon,size:12,"aria-hidden":`true`}),n?`Copied!`:``]})}),(0,y.jsx)($t,{to:`/settings`,className:(0,F.default)(Bc.button,Bc.settings),"aria-label":`Open settings`,children:(0,y.jsx)(L.IconSettingFilled,{size:16,"aria-hidden":`true`})}),(0,y.jsxs)(pe.animated.button,{className:(0,F.default)(Bc.button,Bc.disconnect,{[Bc.expanded]:a}),style:c,onClick:l,onMouseLeave:u,onMouseEnter:f,"aria-label":`Disconnect wallet`,children:[(0,y.jsx)(L.IconSignOut,{size:16,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:Bc.label,children:`Disconnect`})]})]}):null},Hc={overlay:`_overlay_jij9g_1`,content:`_content_jij9g_28`,inner:`_inner_jij9g_60`},Uc=({children:e})=>{let{isDrawerOpen:t,closeDrawer:n}=Or(),{setContainer:r}=(0,g.useContext)(Tc),i=(0,g.useCallback)(e=>{e&&r(e)},[r]),a=bc(),o=Cc(),s=(0,b.useAtomValue)(qi),c=(0,b.useAtomValue)(Jn),l=(0,u.useIsMutating)({mutationKey:[Ki]}),d=()=>{let e=l?`User exited before response arrived. Transaction may succeed or fail.`:`User rejected`;n(),s?.reject(Error(e)),c?.reject(Error(`User rejected`))},f=Jt(),p=Zt(),m=(0,u.useQueryClient)();return(0,y.jsx)(de.Dialog.Root,{open:t,onOpenChange:e=>!e&&d(),modal:!1,children:(0,y.jsxs)(de.Dialog.Portal,{container:o,children:[a&&(0,y.jsx)(de.Dialog.Backdrop,{className:Hc.overlay,onClick:d,children:(0,y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z`}),(0,y.jsx)(`path`,{d:`M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z`})]})}),(0,y.jsx)(de.Dialog.Popup,{className:Hc.content,"aria-label":`Initia wallet`,children:(0,y.jsxs)(`div`,{className:(0,F.default)(Hc.inner,`body`),ref:i,children:[a&&(0,y.jsx)(Oc,{}),(0,y.jsx)(Ic,{}),(0,y.jsx)(Vc,{}),(0,y.jsx)(W,{errorBoundaryProps:{fallbackRender:({error:e,resetErrorBoundary:t})=>(0,y.jsxs)(gc,{children:[(0,y.jsx)(Ia,{error:!0,children:e.message}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{onClick:()=>{f===`/bridge`&&(localStorage.removeItem(H.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(H.BRIDGE_SRC_DENOM),localStorage.removeItem(H.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(H.BRIDGE_DST_DENOM)),p(`/`),yc(m),t()},children:`Retry`})})]})},children:e})]})})]})})},Wc={backdrop:`_backdrop_1polz_1`,modal:`_modal_1polz_12`,content:`_content_1polz_18`,closeButton:`_closeButton_1polz_59`},Gc=({children:e})=>{let{isModalOpen:t,closeModal:n}=kr(),{setContainer:r}=(0,g.useContext)(Tc),i=(0,g.useCallback)(e=>{e&&r(e)},[r]),a=Cc();return(0,y.jsx)(de.Dialog.Root,{open:t,onOpenChange:e=>!e&&n(),children:(0,y.jsxs)(de.Dialog.Portal,{container:a,children:[(0,y.jsx)(de.Dialog.Backdrop,{className:Wc.backdrop,onClick:n}),(0,y.jsxs)(de.Dialog.Popup,{className:Wc.modal,ref:i,"aria-label":`Initia wallet`,children:[(0,y.jsx)(`button`,{className:Wc.closeButton,onClick:n,"aria-label":`Close`,children:(0,y.jsx)(L.IconClose,{size:20})}),(0,y.jsx)(`div`,{className:Wc.content,children:(0,y.jsx)(W,{children:e})})]})]})})},Kc=(0,g.createContext)(!1),qc={overlay:`_overlay_1iyfl_1`,fullscreen:`_fullscreen_1iyfl_15`,content:`_content_1iyfl_19`,header:`_header_1iyfl_56`,title:`_title_1iyfl_65`,close:`_close_1iyfl_70`},Jc=({title:e,children:t,trigger:n,className:r,open:i,onOpenChange:a})=>{let o=Ec(),s=(0,g.useContext)(Kc);return o?(0,y.jsxs)(de.Dialog.Root,{open:i,onOpenChange:a,modal:!1,children:[n&&(0,y.jsx)(de.Dialog.Trigger,{className:r,children:n}),(0,y.jsxs)(de.Dialog.Portal,{container:o,children:[(0,y.jsx)(de.Dialog.Backdrop,{className:(0,F.default)(qc.overlay,{[qc.fullscreen]:s}),onClick:()=>a(!1),forceRender:!0}),(0,y.jsxs)(de.Dialog.Popup,{className:(0,F.default)(qc.content,{[qc.fullscreen]:s}),children:[e&&(0,y.jsxs)(`header`,{className:qc.header,children:[(0,y.jsx)(de.Dialog.Title,{className:qc.title,children:e}),(0,y.jsx)(de.Dialog.Close,{className:qc.close,"aria-label":`Close`,children:(0,y.jsx)(L.IconClose,{size:20,"aria-hidden":`true`})})]}),t]})]})]}):null},Yc=({children:e})=>{let t=(0,g.useRef)(null),[n,r]=(0,g.useState)(0),[i,a]=(0,g.useState)(!1),o=(0,pe.useSpring)({height:n,config:{tension:500,friction:30,clamp:!0},immediate:!i});return(0,g.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let{height:t}=e.getBoundingClientRect();r(t),a(!0)};n();let i=new ResizeObserver(n);return i.observe(e),()=>i.disconnect()},[e]),e?(0,y.jsx)(pe.animated.div,{style:{overflow:`hidden`,...o},children:(0,y.jsx)(`div`,{ref:t,children:e})}):null},Xc={help:`_help_qcmtq_1`,icon:`_icon_qcmtq_10`,info:`_info_qcmtq_19`,warning:`_warning_qcmtq_23`,error:`_error_qcmtq_27`,success:`_success_qcmtq_33`},Zc=({level:e,className:t,mt:n=8,children:r})=>r?(0,y.jsxs)(`div`,{className:(0,F.default)(Xc.help,e&&Xc[e],t),style:{marginTop:n},role:e===`error`?`alert`:`status`,children:[(0,y.jsx)(`div`,{className:Xc.icon,"aria-hidden":`true`,children:(()=>{switch(e){case`loading`:return(0,y.jsx)(uc,{size:12});case`info`:return(0,y.jsx)(L.IconInfoFilled,{size:12});case`warning`:case`error`:return(0,y.jsx)(L.IconWarningFilled,{size:12});default:return(0,y.jsx)(L.IconCheckCircleFilled,{size:12})}})()}),r]}):null,Qc={stack:`_stack_a6m7u_1`,help:`_help_a6m7u_6`,info:`_info_a6m7u_14`,warning:`_warning_a6m7u_19`,error:`_error_a6m7u_24`,success:`_success_a6m7u_29`},$c=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:(0,y.jsx)(Yc,{children:(0,y.jsx)(`div`,{className:Qc.stack,children:e})}),el=({mt:e=0,...t})=>(0,y.jsx)(Zc,{...t,className:(0,F.default)(Qc.help,Qc[t.level]),mt:e});el.Stack=$c;var tl={root:`_root_16p5j_1`,item:`_item_16p5j_10`,chevron:`_chevron_16p5j_14`,trigger:`_trigger_16p5j_19`,content:`_content_16p5j_39`,slideDown:`_slideDown_16p5j_1`,slideUp:`_slideUp_16p5j_1`};function nl(e){let{list:t,getKey:n,renderHeader:r,renderContent:i,footer:a,...o}=e;return(0,y.jsxs)(P.Accordion.Root,{className:tl.root,type:`multiple`,...o,children:[t.map((e,t)=>(0,y.jsxs)(P.Accordion.Item,{className:tl.item,value:n?.(e)??String(t),children:[(0,y.jsx)(P.Accordion.Header,{children:(0,y.jsxs)(P.Accordion.Trigger,{className:tl.trigger,children:[r(e),(0,y.jsx)(L.IconChevronDown,{className:tl.chevron,size:16,"aria-hidden":`true`})]})}),(0,y.jsx)(P.Accordion.Content,{className:tl.content,children:i(e)})]},n?.(e)??t)),a]})}var rl={trigger:`_trigger_u613p_1`,icon:`_icon_u613p_18`,content:`_content_u613p_27`,item:`_item_u613p_36`,itemText:`_itemText_u613p_52`,itemIndicator:`_itemIndicator_u613p_57`,active:`_active_u613p_60`};function il({options:e,value:t,onChange:n,classNames:r}){let i=Ec(),a=e.find(e=>e.value===t);if(!a)throw Error(`Selected option not found`);return(0,y.jsxs)(he.Select.Root,{value:String(t),onValueChange:t=>{let r=e.find(e=>String(e.value)===t);if(!r)throw Error(`Option not found: ${t}`);n(r.value)},modal:!1,children:[(0,y.jsxs)(he.Select.Trigger,{className:(0,F.default)(rl.trigger,r?.trigger),children:[(0,y.jsx)(he.Select.Value,{children:a.triggerLabel||a.label}),(0,y.jsx)(he.Select.Icon,{className:rl.icon,children:(0,y.jsx)(L.IconChevronDown,{size:12,"aria-hidden":`true`})})]}),(0,y.jsx)(he.Select.Portal,{container:i,children:(0,y.jsx)(he.Select.Positioner,{className:rl.content,alignItemWithTrigger:!1,sideOffset:6,align:`end`,children:(0,y.jsx)(he.Select.Popup,{className:rl.popup,children:e.map(e=>(0,y.jsxs)(he.Select.Item,{className:(0,F.default)(rl.item,r?.item),value:String(e.value),children:[(0,y.jsx)(he.Select.ItemText,{className:(0,F.default)(rl.itemText,r?.itemText),children:e.label}),(0,y.jsx)(L.IconCheck,{size:12,className:(0,F.default)(rl.itemIndicator,{[rl.active]:e.value===t}),"aria-hidden":`true`})]},String(e.value)))})})})]})}function al(e,t){if((0,d.formatAmount)(e,{decimals:t})===`0.000000`)return 8}function ol(e,t){let[{amount:n,denom:r}]=e.amount;if((0,f.default)(n||0).isZero())return`0`;let{symbol:i,decimals:a}=t(r);return`${(0,d.formatAmount)(n,{decimals:a,dp:al(n,a)})} ${i}`}var sl={root:`_root_1t37n_1`,trigger:`_trigger_1t37n_7`,item:`_item_1t37n_11`,itemText:`_itemText_1t37n_17`},cl=({options:e,value:t,onChange:n})=>{let{txRequest:r}=aa(),i=pt(tt(r.chainId)),a=e.map(e=>{let[{denom:t}]=e.amount,{symbol:n}=i(t);return{value:t,label:ol(e,i),triggerLabel:n}});if(e.length===1)return(0,y.jsx)(`span`,{className:`monospace`,children:ol(e[0],i)});let o=e.find(e=>e.amount[0].denom===t);if(!o)throw Error(`Fee option not found`);let[{amount:s,denom:c}]=o.amount,{decimals:l}=i(c),u=al(s,l);return(0,y.jsxs)(`div`,{className:sl.root,children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.formatAmount)(s,{decimals:l,dp:u})}),(0,y.jsx)(il,{options:a,value:t,onChange:n,classNames:sl})]})},ll={root:`_root_16nr2_1`,trigger:`_trigger_16nr2_5`,chevron:`_chevron_16nr2_13`,panel:`_panel_16nr2_27`,details:`_details_16nr2_39`,row:`_row_16nr2_48`},ul=({spend:e,fee:t,total:n,balance:r,symbol:i,decimals:a})=>{let o=[e&&{label:`Spend`,value:e},{label:`Fee`,value:t},e&&{label:`Required (spend + fee)`,value:n},{label:`Balance`,value:r}].filter(Boolean),s=a===6?void 0:8;return(0,y.jsxs)(R.Collapsible.Root,{className:ll.root,children:[(0,y.jsxs)(R.Collapsible.Trigger,{className:ll.trigger,children:[(0,y.jsx)(`span`,{children:`Insufficient balance for fee`}),(0,y.jsx)(L.IconChevronDown,{className:ll.chevron,size:16})]}),(0,y.jsx)(R.Collapsible.Panel,{className:ll.panel,children:(0,y.jsx)(`div`,{className:ll.details,children:o.map(({label:e,value:t})=>(0,y.jsxs)(`div`,{className:ll.row,children:[(0,y.jsx)(`span`,{children:e}),(0,y.jsxs)(`span`,{children:[(0,d.formatAmount)(t,{decimals:a,dp:s}),` `,i]})]},e))})})]})};function dl(e){switch(typeof e){case`string`:return e;case`number`:case`bigint`:return e.toString();case`boolean`:return e?`true`:`false`;case`object`:return e===null?`null`:e instanceof Uint8Array?(0,_.toBase64)(e):Array.isArray(e)?`[${e.map(dl).join(`,`)}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t);default:return`unknown`}}var fl={container:`_container_1xzyq_1`,toggle:`_toggle_1xzyq_5`,list:`_list_1xzyq_11`,arg:`_arg_1xzyq_16`,type:`_type_1xzyq_21`},pl=(0,m.createQueryKeys)(`interwovenkit:move`,{abi:(e,t,n,r)=>[e,t,n,r]}),ml=({type:e,arg:t})=>dl((0,d.resolveBcsType)(e).parse(t)),hl=({msg:e,chainId:t,fallback:n})=>{let[r,i]=(0,le.useToggle)(!1),{restUrl:a}=tt(t),{moduleAddress:o,moduleName:s,functionName:c,args:l}=e,{data:d}=(0,u.useQuery)({queryKey:pl.abi(a,o,s,c).queryKey,queryFn:async()=>{let e=await h.default.create({prefixUrl:a}).get(`initia/move/v1/accounts/${o}/modules/${s}`).json(),t=JSON.parse(e.module.abi).exposed_functions.find(({name:e})=>e===c);if(!t)throw Error(`Function ${c} not found in module ${s}`);return t.params.filter(e=>!e.startsWith(`&`))},staleTime:B.INFINITY});return d?(0,y.jsxs)(`div`,{className:fl.container,children:[(0,y.jsx)(G.Small,{className:fl.toggle,onClick:i,disabled:!d,children:r?`Encode`:`Decode`}),r?(0,y.jsx)(`div`,{className:fl.list,children:l.map((e,t)=>{let n=d[t];return(0,y.jsxs)(`div`,{className:fl.arg,children:[(0,y.jsx)(`div`,{className:fl.type,children:n}),(0,y.jsx)(ue.ErrorBoundary,{fallback:(0,y.jsx)(`div`,{className:`error`,children:`Error decoding argument`}),children:(0,y.jsx)(ml,{type:n,arg:e})})]},t)})}):n]}):n},gl={list:`_list_oip9m_1`,key:`_key_oip9m_9`,value:`_value_oip9m_14`},_l=({message:e,chainId:t})=>{let{typeUrl:n,value:r}=e;return(0,y.jsx)(`div`,{className:gl.list,children:Object.entries(r).map(([e,i])=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:gl.key,children:e}),(0,y.jsx)(`div`,{className:gl.value,children:n===`/initia.move.v1.MsgExecute`&&e===`args`?(0,y.jsx)(hl,{msg:r,chainId:t,fallback:dl(i)}):dl(i)})]},e))})},vl={item:`_item_1n572_1`,title:`_title_1n572_10`,content:`_content_1n572_14`},yl=({title:e,content:t})=>(0,y.jsxs)(`div`,{className:vl.item,children:[(0,y.jsx)(`div`,{className:vl.title,children:e}),(0,y.jsx)(`div`,{className:vl.content,children:t})]});function q(e){let t=e?(0,f.default)(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return`< $0.01`;let n=e&&(0,f.default)(e).lt(0),r=(0,d.formatNumber)(t?.toString()??e,{dp:2});return r?n?`-$${r}`:`$${r}`:``}function bl(e,t){return t==null?`$-`:q(e??0)}function xl(e,t){let n={};for(let r of e)if(r.attributes.some(e=>e.key===`msg_index`)){if(r.type===`coin_spent`){let e=r.attributes.find(e=>e.key===`spender`)?.value,i=r.attributes.find(e=>e.key===`amount`)?.value;if(e===t&&i){let[e,t]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];e&&t&&(n[t]=(n[t]||BigInt(0))-BigInt(e))}}if(r.type===`coin_received`){let e=r.attributes.find(e=>e.key===`receiver`)?.value,i=r.attributes.find(e=>e.key===`amount`)?.value;if(e===t&&i){let[e,t]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];e&&t&&(n[t]=(n[t]||BigInt(0))+BigInt(e))}}}return Object.entries(n).filter(([,e])=>e!==BigInt(0)).map(([e,t])=>({amount:t.toString(),denom:e}))}function Sl(e,t){let n={};for(let r of e)if(r.attributes.some(e=>e.key===`msg_index`)&&r.type===`move`){let e=r.attributes.find(e=>e.key===`type_tag`)?.value,i=r.attributes.find(e=>e.key===`data`)?.value;if(!e||!i)continue;let a;try{a=JSON.parse(i)}catch{continue}if(e===`0x1::fungible_asset::WithdrawEvent`){let e=a.store_addr,r=a.amount,i=a.metadata_addr;e&&r&&i&&(0,d.createUserDerivedObjectAddress)(t,i)===e&&(n[i]=(n[i]||BigInt(0))-BigInt(r))}if(e===`0x1::fungible_asset::DepositEvent`){let e=a.store_addr,r=a.amount,i=a.metadata_addr;e&&r&&i&&(0,d.createUserDerivedObjectAddress)(t,i)===e&&(n[i]=(n[i]||BigInt(0))+BigInt(r))}}return Object.entries(n).filter(([,e])=>e!==BigInt(0)).map(([e,t])=>({amount:t.toString(),metadata:e}))}var Cl=({metadata:e,chain:t,children:n})=>{let{restUrl:r}=t,{data:i}=(0,u.useSuspenseQuery)({queryKey:ct.denom(r,e).queryKey,queryFn:()=>h.default.create({prefixUrl:r}).get(`initia/move/v1/denom`,{searchParams:{metadata:e}}).json(),select:({denom:e})=>e,staleTime:B.INFINITY});return n(i)},wl={root:`_root_1p8a4_1`,title:`_title_1p8a4_8`,changes:`_changes_1p8a4_14`,change:`_change_1p8a4_14`,amount:`_amount_1p8a4_35`,text:`_text_1p8a4_42`,value:`_value_1p8a4_49`},Tl=({amount:e,asset:t,price:n})=>{let{denom:r,symbol:i,decimals:a,logoUrl:o}=t,s=(0,d.formatAmount)(e,{decimals:a}),c=n&&(0,f.default)((0,d.fromBaseUnit)(e,{decimals:a})||0).times(n).abs();return(0,y.jsxs)(`div`,{className:wl.change,children:[(0,y.jsxs)(`div`,{className:wl.amount,children:[(0,y.jsx)(K,{src:o,width:14,height:14,logo:!0}),(0,y.jsxs)(`span`,{className:wl.text,children:[s,` `,i||r]})]}),c&&(0,y.jsx)(`div`,{className:wl.value,children:q(c)})]})},El=({changes:e,chain:t})=>{let n=pt(t),{data:r}=at(t);return e.map(({amount:e,denom:t},i)=>{let a=n(t),o=r?.find(({id:e})=>e===t)?.price;return(0,y.jsx)(Tl,{amount:e,asset:a,price:o},i)})},Dl=({changes:e,chain:t})=>{let n=pt(t),{data:r}=at(t);return e.map(({amount:e,metadata:i},a)=>(0,y.jsx)(Cl,{metadata:i,chain:t,children:t=>{let i=r?.find(({id:e})=>e===t)?.price;return(0,y.jsx)(Tl,{amount:e,asset:n(t),price:i})}},a))};function Ol(e,t){return typeof t==`bigint`?t.toString():t}var kl=(0,m.createQueryKeys)(`interwovenkit:tx`,{simulate:e=>[JSON.stringify(e,Ol)]}),Al=({messages:e,memo:t,chainId:n})=>{let{initiaAddress:r,hexAddress:i}=Pa(),a=tt(n),{simulateTx:o}=oa(),{data:s}=(0,u.useSuspenseQuery)({queryKey:kl.simulate({messages:e,memo:t,chainId:n}).queryKey,queryFn:()=>o({messages:e,memo:t,chainId:n}),staleTime:B.SECOND}),c=e=>(0,y.jsxs)(`div`,{className:wl.root,children:[(0,y.jsx)(`h2`,{className:wl.title,children:`Estimated changes`}),(0,y.jsx)(`div`,{className:wl.changes,children:e})]});if(!s)return null;let l=s.result?.events??[];if(l.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type===`minimove`){let[e]=jl(Sl(l,i));return e.length===0?null:c((0,y.jsx)(Dl,{changes:e,chain:a}))}let[d]=jl(xl(l,r));return d.length===0?null:c((0,y.jsx)(El,{changes:d,chain:a}))};function jl(e){return(0,p.partition)(e=>(0,f.default)(e.amount||0).isNegative(),e)}var Ml={title:`_title_1d032_1`,meta:`_meta_1d032_7`,footer:`_footer_1d032_14`,rejectButton:`_rejectButton_1d032_19`},Nl=()=>{let{txRequest:e,resolve:t,reject:n}=aa(),{messages:r,memo:i,chainId:a,gas:o,gasAdjustment:s,spendCoins:c}=e,l=tt(a),d=Rt(l),p=Wi(l),m=Gi(l),h=pt(l),_=ia(),v=Jr(a),b=(e.gasPrices??p).map(({amount:e,denom:t})=>(0,M.calculateFee)(Math.ceil(o*s),M.GasPrice.fromString(e+t))),x=b.map(e=>e.amount[0]),S=e=>{let t=d.find(t=>t.denom===e)?.amount||`0`,n=x.find(t=>t.denom===e)?.amount||`0`,r=c.filter(t=>t.denom===e).reduce((e,t)=>e.plus(t.amount||0),(0,f.default)(0)),i=(0,f.default)(n).plus(r),a=(0,f.default)(t).gte(i),{symbol:o,decimals:s}=h(e);return{symbol:o,decimals:s,spend:r.gt(0)?r.toFixed():null,fee:n,total:i.toFixed(),balance:t,isSufficient:a}},[C,w]=(0,g.useState)(()=>{if(m&&S(m).isSufficient)return m;for(let{denom:e}of x)if(S(e).isSufficient)return e;return x[0]?.denom}),{mutate:T,isPending:E}=(0,u.useMutation)({mutationKey:[Ki],mutationFn:async()=>{let n=b.find(e=>e.amount[0].denom===C);if(!n)throw Error(`Fee not found`);await t(await _({chainId:a,messages:r,memo:i||``,fee:n,preferredFeeDenom:C,allowAutoSign:!e.internal,allowWalletDerivation:!0,accountSequence:Xr(v)}))},onError:async e=>{n(e)}}),D=S(C),O=!D.isSufficient;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(gc,{children:[(0,y.jsx)(`h1`,{className:Ml.title,children:`Confirm tx`}),(0,y.jsxs)(`section`,{className:Ml.meta,"aria-label":`Transaction metadata`,children:[(0,y.jsx)(yl,{title:`Chain`,content:a}),(0,y.jsx)(yl,{title:`Tx fee`,content:(0,y.jsx)(cl,{options:b,value:C,onChange:w})}),i&&(0,y.jsx)(yl,{title:`Memo`,content:i}),O&&(0,y.jsx)(el,{level:`error`,children:(0,y.jsx)(ul,{...D})})]}),(0,y.jsx)(Al,{messages:r,memo:i,chainId:a}),(0,y.jsx)(nl,{list:r,renderHeader:({typeUrl:e})=>(0,me.sentenceCase)(e.split(`.`).pop().replace(/^Msg/,``)),renderContent:e=>(0,y.jsx)(_l,{message:e,chainId:a})})]}),(0,y.jsxs)(mc,{className:Ml.footer,children:[(0,y.jsx)(G.Outline,{onClick:()=>n(Error(`User rejected`)),disabled:E,className:Ml.rejectButton,"aria-label":`Reject`,children:(0,y.jsx)(L.IconClose,{size:16})}),(0,y.jsx)(G.White,{onClick:()=>T(),disabled:O||v.isFetching,loading:E,children:`Approve`})]})]})},Pl=({children:e})=>{let[{title:t,content:n,path:r},i]=(0,g.useState)({}),[a,o]=(0,g.useState)(!1),s=(0,b.useAtomValue)(qi),c=(0,g.useCallback)(e=>{i(e),o(!0)},[]),l=(0,g.useCallback)(()=>{i({}),o(!1)},[]),u=(0,g.useCallback)(e=>{e||(s?.reject(Error(`User rejected`)),i({})),o(e)},[s]);return(0,y.jsxs)(Oi.Provider,{value:{openModal:c,closeModal:l},children:[e,(0,y.jsx)(Jc,{title:t,open:a,onOpenChange:u,children:(0,y.jsx)(W,{children:r===`/tx`?(0,y.jsx)(Nl,{}):n})})]})},Fl={container:`_container_1w1hx_1`,toast:`_toast_1w1hx_11`,info:`_info_1w1hx_24`,success:`_success_1w1hx_28`,error:`_error_1w1hx_32`,icon:`_icon_1w1hx_37`,content:`_content_1w1hx_45`,title:`_title_1w1hx_48`,description:`_description_1w1hx_53`,close:`_close_1w1hx_75`},Il=({notification:e,onClose:t,...n})=>{let r=(0,pe.useTransition)(e,{keys:e=>e?.id||`empty`,from:{transform:`translateY(-52px)`,opacity:0},enter:{transform:`translateY(0px)`,opacity:1},leave:{transform:`translateY(-52px)`,opacity:0},config:{tension:500,friction:30,clamp:!0}}),i=e=>{switch(e){case`loading`:return(0,y.jsx)(uc,{size:16});case`info`:case`success`:return(0,y.jsx)(L.IconCheckCircleFilled,{size:16});case`error`:return(0,y.jsx)(L.IconCloseCircleFilled,{size:16});default:return null}};return r((e,r)=>{if(!r)return null;let{type:a,title:o,description:s}=r,c=i(a);return(0,y.jsx)(pe.animated.div,{style:e,className:Fl.container,children:(0,y.jsxs)(`div`,{className:(0,F.default)(Fl.toast,a&&Fl[a]),role:`alert`,...n,children:[c&&(0,y.jsx)(`div`,{className:Fl.icon,"aria-hidden":`true`,children:c}),(0,y.jsxs)(`div`,{className:Fl.content,children:[(0,y.jsx)(`p`,{className:Fl.title,children:o}),s&&(0,y.jsx)(`div`,{className:Fl.description,children:s})]}),(0,y.jsx)(`button`,{className:Fl.close,onClick:t,"aria-label":`Dismiss notification`,children:(0,y.jsx)(L.IconClose,{size:14,"aria-hidden":`true`})})]})})})},Ll=5e3,Rl=({children:e})=>{let t=Ec(),[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(!1),o=()=>{i.current&&=(clearTimeout(i.current),null)},s=(0,g.useCallback)(()=>{o(),r(null)},[]),c=(0,g.useCallback)(e=>{o(),r({...e,id:(0,ge.nanoid)()}),e.autoHide&&!a.current&&(i.current=setTimeout(()=>s(),Ll))},[s]),l=(0,g.useCallback)(e=>{o(),r(t=>t?{...t,...e}:{...e,id:(0,ge.nanoid)()}),e.autoHide&&!a.current&&(i.current=setTimeout(()=>s(),Ll))},[s]);return(0,g.useEffect)(()=>()=>o(),[]),(0,y.jsxs)(Pc.Provider,{value:{showNotification:c,updateNotification:l,hideNotification:s},children:[e,t&&(0,_e.createPortal)((0,y.jsx)(Il,{notification:n,onClose:s,onMouseEnter:()=>{o(),a.current=!0},onMouseLeave:()=>{o(),a.current=!1,n?.autoHide&&(i.current=setTimeout(()=>s(),Ll))}}),t)]})},zl=({children:e})=>{let[t,n]=(0,g.useState)(null);return(0,y.jsx)(Tc.Provider,{value:{container:t,setContainer:n},children:e})};function Bl(e){let t=e.split(`.`);return t.length===4?t.every(e=>{if(!/^\d+$/.test(e))return!1;let t=Number(e);return t>=0&&t<=255}):!1}function Vl(e){return Bl(e)||e.includes(`:`)}function Hl(e){let t=(0,ve.parse)(e);return`error`in t?null:t.domain}function Ul(e,t){return e===t||e===`www.${t}`}function Wl(e){if(e.protocol!==`https:`)return!1;let t=e.hostname.toLowerCase();return!t||!t.includes(`.`)||t===`localhost`||Vl(t)?!1:Hl(t)!==null}function Gl(e,t){try{let n=new URL(e);if(!Wl(n))return!1;let r=n.hostname.toLowerCase(),i=t.toLowerCase();if(!r||!i||Vl(i)||i===`localhost`)return!1;let a=Hl(r);if(!a)return!1;let o=Hl(i);return!o||o!==a?!1:Ul(r,a)?i===a||i.endsWith(`.${a}`):i===r||i.endsWith(`.${r}`)}catch{return!1}}var J={container:`_container_1422v_1`,title:`_title_1422v_7`,description:`_description_1422v_14`,sectionTitle:`_sectionTitle_1422v_20`,websiteInfo:`_websiteInfo_1422v_27`,favicon:`_favicon_1422v_37`,websiteTitle:`_websiteTitle_1422v_42`,websiteHost:`_websiteHost_1422v_48`,warningContent:`_warningContent_1422v_54`,ignoreButton:`_ignoreButton_1422v_61`,infoList:`_infoList_1422v_65`,infoItem:`_infoItem_1422v_75`,label:`_label_1422v_84`,value:`_value_1422v_90`,infoValue:`_infoValue_1422v_94`,durationTrigger:`_durationTrigger_1422v_100`,durationItem:`_durationItem_1422v_101`,featureList:`_featureList_1422v_105`,featureItem:`_featureItem_1422v_113`,checkIcon:`_checkIcon_1422v_123`,learnMoreLink:`_learnMoreLink_1422v_127`,feedbackContainer:`_feedbackContainer_1422v_140`,footer:`_footer_1422v_146`};function Kl(e){return e instanceof h.HTTPError&&e.response.status===404}var ql=(0,m.createQueryKeys)(`interwovenkit:account`,{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{let n=h.default.create({prefixUrl:e}),r=`cosmos/auth/v1beta1/account_info/${t}`;try{return await n.get(r).json(),!0}catch(e){if(Kl(e))return!1;throw e}}})}),Jl=()=>{let[e,t]=(0,b.useAtom)(Jn),[n,r]=(0,g.useState)(()=>e?.defaultDuration??va),[i,a]=(0,g.useState)(!1),o=et(),s=Ze(),{address:c,initiaAddress:l,username:f}=Pa(),{mutate:p,isPending:m}=ha(),{closeDrawer:h}=Or();if(!e)throw Error(`Pending request not found`);let{logoUrl:_,name:v,restUrl:x}=o(e.chainId),{data:S,isLoading:C,isError:w}=(0,u.useQuery)(ql.info(x,l)),T={favicon:document.querySelector(`link[rel="icon"]`)?.getAttribute(`href`)||``,title:document.title,hostname:window.location.hostname},E=s.find(t=>t.chainId===e.chainId),D=E?.website?Gl(E.website,window.location.hostname):!1,O=()=>{p(n)},k=()=>{e?.reject(Error(`User cancelled`)),t(null),h()},A=!D&&!i,j=!C&&!w&&S===!1,M=!C&&w,ee=A||C||w||S===!1;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(gc,{className:J.container,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`h1`,{className:J.title,children:`Enable auto-signing`}),(0,y.jsx)(`p`,{className:J.description,children:`An application is requesting to enable auto-signing`})]}),(0,y.jsxs)(`section`,{children:[(0,y.jsx)(`h2`,{className:J.sectionTitle,children:`Requested by`}),(0,y.jsxs)(`div`,{className:J.websiteInfo,children:[(0,y.jsx)(`img`,{src:T.favicon,alt:``,className:J.favicon}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:J.websiteTitle,children:T.title}),(0,y.jsx)(`div`,{className:J.websiteHost,children:T.hostname})]})]})]}),(0,y.jsxs)(`section`,{children:[(0,y.jsx)(`h2`,{className:J.sectionTitle,children:`Applies to`}),(0,y.jsxs)(`div`,{className:J.infoList,children:[(0,y.jsxs)(`div`,{className:J.infoItem,children:[(0,y.jsx)(`div`,{className:J.label,children:`Address`}),(0,y.jsxs)(`div`,{className:J.infoValue,children:[(0,y.jsx)(L.IconWallet,{size:14}),(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(f??c)})]})]}),(0,y.jsxs)(`div`,{className:J.infoItem,children:[(0,y.jsx)(`div`,{className:J.label,children:`Chain`}),(0,y.jsxs)(`div`,{className:J.infoValue,children:[(0,y.jsx)(K,{src:_,width:14,height:14,logo:!0}),(0,y.jsx)(`span`,{children:v})]})]}),(0,y.jsxs)(`div`,{className:J.infoItem,children:[(0,y.jsx)(`div`,{className:J.label,children:`Duration`}),(0,y.jsx)(il,{options:_a,value:n,onChange:r,classNames:{trigger:J.durationTrigger,item:J.durationItem}})]})]})]}),(0,y.jsxs)(`section`,{children:[(0,y.jsx)(`h2`,{className:J.sectionTitle,children:`About auto-signing`}),(0,y.jsx)(`ul`,{className:J.featureList,children:[`Send transactions without confirmation pop-ups`,`Secured by your wallet signature`,`Revoke permissions any time in settings`].map(e=>(0,y.jsxs)(`li`,{className:J.featureItem,children:[(0,y.jsx)(L.IconCheckCircle,{size:12,className:J.checkIcon}),(0,y.jsx)(`span`,{children:e})]},e))}),(0,y.jsxs)(`a`,{href:`https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction`,target:`_blank`,rel:`noopener noreferrer`,className:J.learnMoreLink,children:[`Learn more `,(0,y.jsx)(L.IconExternalLink,{size:12})]})]})]}),(0,y.jsxs)(mc,{className:J.footer,extra:(0,y.jsxs)(`div`,{className:J.feedbackContainer,children:[j&&(0,y.jsx)(el,{level:`error`,children:`Insufficient balance for fee`}),M&&(0,y.jsx)(el,{level:`warning`,children:`Unable to verify account status. Try again.`}),!D&&!i&&(0,y.jsx)(el,{level:`warning`,children:(0,y.jsxs)(`div`,{className:J.warningContent,children:[(0,y.jsx)(`span`,{children:`You are on an unverified website`}),(0,y.jsx)(`button`,{onClick:()=>a(!0),className:J.ignoreButton,children:`Ignore`})]})})]}),children:[(0,y.jsx)(G.Outline,{onClick:k,children:`Cancel`}),(0,y.jsx)(G.White,{onClick:O,disabled:ee,loading:m,children:`Enable`})]})]})},Yl=()=>{let e=(0,b.useAtomValue)(Jn);return e?(0,y.jsx)(Jl,{},`${e.chainId}:${e.defaultDuration}`):null},Xl={container:`_container_mqvhs_1`,badge:`_badge_mqvhs_5`},Zl=e=>{let{offset:t=-4,disabled:n,children:r,className:i}=e;return(0,y.jsxs)(`div`,{className:(0,F.default)(Xl.container,i),children:[r,!n&&(0,y.jsx)(`div`,{className:Xl.badge,style:{right:t,top:t},"aria-hidden":`true`})]})},Ql={header:`_header_s7mee_1`,back:`_back_s7mee_12`,title:`_title_s7mee_24`},$l=({title:e,backButton:t,extra:n,children:r})=>{let i=Xt();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`header`,{className:Ql.header,children:[(0,y.jsx)($t,{to:t??(i.length>1?-1:`/`),className:Ql.back,shouldReset:!!t,"aria-label":`Go back`,children:(0,y.jsx)(L.IconBack,{size:16,"aria-hidden":`true`})}),(0,y.jsx)(`h1`,{className:Ql.title,children:e}),n]}),(0,y.jsx)(gc,{children:r})]})};function eu(){let e=Ze();return t=>e.some(e=>e.chain_id===t)}function tu(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!==`initia`}function nu(){let e=eu();return t=>e(t.chain_id)?`initia`:t.chain_type}function ru(e){return nu()(e)}function iu(){let e=an(),{data:t}=(0,u.useSuspenseQuery)({queryKey:rn.chains.queryKey,queryFn:()=>e.get(`v2/info/chains`).json(),select:({chains:e})=>(0,p.sortWith)([(0,p.descend)(({chain_name:e})=>e===`initia`),(0,p.ascend)(({pretty_name:e})=>e)],e),staleTime:B.MINUTE});return t}function au(){let e=iu(),t=$e();return n=>{let r=e.find(e=>e.chain_id===n);if(r)return r;let i=t.find(e=>e.chain_id===n);if(!i)throw Error(`Chain not found: ${n}`);return{chain_id:i.chain_id,chain_name:i.name,pretty_name:i.pretty_name,logo_uri:i.logo,chain_type:`cosmos`,rpc:``,rest:``}}}function ou(e){return au()(e)}function su(e,t){try{return(0,_.fromBech32)(e).prefix===t}catch{return!1}}function cu(){let{initiaAddress:e,hexAddress:t}=Pa(),n=au(),r=nu();return i=>{switch(r(n(i))){case`initia`:return e;case`evm`:return t;default:return``}}}function lu(){let e=au(),t=nu();return(n,r)=>{let i=e(r);switch(t(i)){case`initia`:return d.InitiaAddress.validate(n);case`evm`:return(0,w.isAddress)(n);case`cosmos`:return i.bech32_prefix?su(n,i.bech32_prefix):!1;default:return!1}}}function uu(){let e=au(),t=nu();return({initialAddress:n,initialChainId:r,chainId:i,fallbackAddress:a})=>{let o=t(e(r)),s=t(e(i));if(o===`evm`&&s===`initia`)return(0,d.InitiaAddress)(n).bech32;if(o===`initia`&&s===`evm`)return(0,d.InitiaAddress)(n).hex;if(o===s)return n;if(a){if(s===`initia`)return(0,d.InitiaAddress)(a).bech32;if(s===`evm`)return(0,d.InitiaAddress)(a).hex}return``}}function du(e){return!e.hidden}function fu(e,t){return e.find(e=>e.denom===t&&du(e))}function pu(e){return e.find(du)}function mu(){let e=an();return(0,u.useSuspenseQuery)({queryKey:rn.allAssets().queryKey,queryFn:()=>e.get(`v2/fungible/assets`).json(),staleTime:B.MINUTE})}function hu(){let{data:{chain_to_assets_map:e}}=mu(),t=iu(),n=(0,u.useQueryClient)();return(0,g.useMemo)(()=>{let r=[];for(let i in e){if(!t.some(e=>e.chain_id===i))continue;let{assets:a}=e[i]??{assets:[]};n.setQueryData(rn.assets(i).queryKey,{chain_to_assets_map:{[i]:e[i]}});for(let e of a)n.setQueryData(rn.asset(i,e.denom).queryKey,e);r.push(...a)}return r},[e,t,n])}function gu(e){let t=an(),n=(0,u.useQueryClient)(),{data:r}=(0,u.useSuspenseQuery)({queryKey:rn.assets(e).queryKey,queryFn:()=>t.get(`v2/fungible/assets`,{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:t})=>{let{assets:r}=t[e]??{assets:[]};for(let t of r)n.setQueryData(rn.asset(e,t.denom).queryKey,t);return[...r].sort((0,p.ascend)(e=>jt(e.symbol)))},staleTime:B.MINUTE});return r}function _u(e){let t=gu(e);return e=>{let n=t.find(t=>t.denom===e);if(!n)throw Error(`Asset not found: ${e}`);return n}}function vu(e,t){return _u(t)(e)}var yu={root:`_root_ekn9t_1`,header:`_header_ekn9t_6`,title:`_title_ekn9t_12`,warning:`_warning_ekn9t_18`,content:`_content_ekn9t_22`,footer:`_footer_ekn9t_26`,secondary:`_secondary_ekn9t_36`},bu=e=>{let{type:t,icon:n,title:r,children:i,primaryButton:a,secondaryButton:o}=e;return(0,y.jsxs)(gc,{className:yu.root,children:[(0,y.jsxs)(`header`,{className:(0,F.default)(yu.header,t&&yu[t]),children:[n,(0,y.jsx)(`h1`,{className:yu.title,children:r})]}),(0,y.jsx)(`div`,{className:yu.content,children:i}),(0,y.jsxs)(`footer`,{className:yu.footer,children:[(0,y.jsx)(G.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),(0,y.jsxs)(`button`,{className:yu.secondary,onClick:o.onClick,children:[(0,y.jsx)(`span`,{children:o.label}),(0,y.jsx)(L.IconChevronRight,{size:14,"aria-hidden":`true`})]})]})]})},xu={list:`_list_k4n3k_1`,row:`_row_k4n3k_9`,dt:`_dt_k4n3k_20`,asset:`_asset_k4n3k_26`},Su=({list:e,onNavigate:t,onDismiss:n})=>{let r=V(),i=et(),a=pt(r);return(0,y.jsx)(bu,{title:`Ready to claim`,primaryButton:{label:`View withdrawal status`,onClick:t},secondaryButton:{label:`Do not show again`,onClick:n},children:(0,y.jsx)(`div`,{className:xu.list,children:[...e].sort((e,t)=>e.chainId.localeCompare(t.chainId)).map(({txHash:e,chainId:t,amount:n,denom:r})=>{let o=i(t),{decimals:s,symbol:c}=a(r),l=(0,d.formatAmount)(n,{decimals:s});return(0,y.jsxs)(`div`,{className:xu.row,children:[(0,y.jsxs)(`div`,{className:xu.dt,children:[(0,y.jsx)(K,{src:o.logoUrl,width:16,height:16,logo:!0}),(0,y.jsx)(`span`,{children:o.name})]}),(0,y.jsxs)(`span`,{className:xu.asset,children:[l,` `,c]})]},e)})})})};function Cu(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}var wu=({chainId:e,txHash:t})=>`${H.OP_REMINDER}:${e}:${t}`,Tu=(0,ye.atomWithStorage)(H.OP_REMINDER,[]);function Eu(){let e=U(),[t=[],n]=(0,b.useAtom)(Tu);return{reminders:(0,g.useMemo)(()=>t.map(e=>{let t=localStorage.getItem(wu(e));return t?JSON.parse(t):null}).filter(t=>{if(!t)return!1;let{recipient:n,claimableAt:r}=t;return n===e?(0,oe.isPast)(r):!1}),[e,t]),addReminder:(0,g.useCallback)((e,r)=>{t.some(t=>Cu(t,e))||(n((t=[])=>[...t,e]),localStorage.setItem(wu(e),JSON.stringify(r)))},[t,n]),removeReminder:(0,g.useCallback)(e=>{n((t=[])=>t.filter(t=>!Cu(t,e))),localStorage.removeItem(wu(e))},[n]),syncReminders:(0,g.useCallback)(e=>{let r=e.filter(e=>!t.some(t=>Cu(t,e)));r.length!==0&&n((e=[])=>[...e,...r])},[t,n]),setReminder:(0,g.useCallback)((e,t)=>{localStorage.setItem(wu(e),JSON.stringify(t)),n((e=[])=>[...e])},[n])}}function Du(){let e=Zt(),{openModal:t,closeModal:n}=ki(),{reminders:r,setReminder:i}=Eu();(0,g.useEffect)(()=>{let a=r.filter(e=>!e.dismissed);if(a.length===0)return;let o=()=>{e(`/op/withdrawals`,{chainId:a.every(e=>e.chainId===a[0].chainId)?a[0].chainId:void 0}),s()},s=()=>{n();for(let e of a)i(e,{...e,dismissed:!0})};t({content:(0,g.createElement)(Su,{list:a,onNavigate:o,onDismiss:s})})},[r,n,e,t,i])}var Ou={wrapper:`_wrapper_5ssm8_1`,balance:`_balance_5ssm8_11`,button:`_button_5ssm8_15`},ku=({onClick:e,children:t,disabled:n})=>(0,y.jsxs)(`div`,{className:Ou.wrapper,children:[(0,y.jsx)(L.IconWallet,{size:16,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:Ou.balance,children:t}),(0,y.jsx)(`button`,{type:`button`,tabIndex:-1,className:Ou.button,onClick:()=>e(),disabled:n,"aria-label":`Use maximum balance`,children:`MAX`})]}),Au={fieldset:`_fieldset_up6fh_1`,upper:`_upper_up6fh_9`,select:`_select_up6fh_14`,account:`_account_up6fh_20`,lower:`_lower_up6fh_25`,wrapper:`_wrapper_up6fh_26`,balance:`_balance_up6fh_33`,value:`_value_up6fh_37`,error:`_error_up6fh_50`},ju=e=>{let{selectButton:t,accountButton:n,quantityInput:r,balanceButton:i,value:a,errorMessage:o,hideNumbers:s}=e;return(0,y.jsxs)(`div`,{className:Au.fieldset,children:[(0,y.jsxs)(`div`,{className:Au.upper,children:[(0,y.jsx)(`div`,{className:Au.select,children:t}),(0,y.jsx)(`div`,{className:Au.account,children:n})]}),!s&&(0,y.jsxs)(`div`,{className:Au.lower,children:[r,(0,y.jsxs)(`div`,{className:Au.wrapper,children:[(0,y.jsx)(`div`,{className:Au.balance,children:i}),a&&(0,y.jsx)(`div`,{className:Au.value,children:a})]}),o&&(0,y.jsxs)(`footer`,{className:Au.error,children:[(0,y.jsx)(L.IconWarningFilled,{size:12,"aria-hidden":`true`}),(0,y.jsx)(`p`,{role:`alert`,children:o})]})]})]})};function Mu(){let e=(0,g.useRef)(null),t=bc();return(0,g.useEffect)(()=>{t||e.current?.focus()},[t]),e}var Nu={input:`_input_h8073_1`};function Pu(e){let{name:t,control:n,dp:r=6,className:i,rules:a,...o}=e,s=Mu();return(0,y.jsx)(I.Controller,{name:t,control:n,rules:a,render:({field:e})=>(0,y.jsx)(xe.NumericFormat,{value:e.value,getInputRef:(0,be.mergeRefs)([e.ref,s]),className:(0,F.default)(Nu.input,i),onValueChange:t=>{e.onChange(t.value)},onBlur:e.onBlur,decimalScale:r,allowNegative:!1,placeholder:`0`,inputMode:`decimal`,autoComplete:`off`,...o})})}var Fu={input:`_input_19r9r_1`,placeholder:`_placeholder_19r9r_18`},Iu=({children:e})=>{let t=tn(e.replace(/,/g,``)),n=!t||t.isZero();return(0,y.jsx)(`p`,{className:(0,F.default)(Fu.input,{[Fu.placeholder]:n}),children:e})},Lu=({balance:e,decimals:t,className:n})=>{let{control:r}=(0,I.useFormContext)();return(0,y.jsx)(Pu,{name:`quantity`,control:r,className:(0,F.default)(Fu.input,n),rules:{required:`Enter amount`,validate:n=>{let r=tn(n);return!r||r.lte(0)?`Enter amount`:nn({quantity:n,balance:e,decimals:t})?`Insufficient balance`:!0}},"aria-label":`Amount`})};Lu.ReadOnly=Iu;var Ru=({title:e,content:t,children:n,className:r})=>{let[i,a]=(0,g.useState)(!1);return(0,y.jsx)(Jc,{title:e,trigger:n,className:r,open:i,onOpenChange:a,children:t(()=>a(!1))})},zu={tooltip:`_tooltip_19kvs_1`,small:`_small_19kvs_14`,fadeIn:`_fadeIn_19kvs_1`,fadeOut:`_fadeOut_19kvs_1`,arrow:`_arrow_19kvs_44`},Bu=({label:e,children:t,small:n,...r})=>(0,y.jsxs)(P.Tooltip.Root,{...r,children:[(0,y.jsx)(P.Tooltip.Trigger,{asChild:!0,children:t}),(0,y.jsx)(P.Tooltip.Portal,{container:Ec(),children:(0,y.jsxs)(P.Tooltip.Content,{className:(0,F.default)(zu.tooltip,{small:n}),collisionBoundary:Ec(),collisionPadding:8,sideOffset:4,children:[e,(0,y.jsx)(P.Tooltip.Arrow,{className:zu.arrow})]})})]});function Vu(e,t){let n=an(),r=lu(),i=!!t&&!!e&&r(e,t);return(0,u.useQuery)({queryKey:rn.balances(t,e).queryKey,queryFn:()=>n.post(`v2/info/balances`,{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:e})=>!i||!e?{}:e[t]?.denoms??{},enabled:i,staleTime:B.SECOND})}function Hu(e,t,n){let{data:r={}}=Vu(e,t);return(0,p.path)([n],r)}function Uu({sourceDenom:e,sourceBalance:t,amountIn:n,feeTokenDenoms:r,balancesByDenom:i,additionalFees:a=[]}){if(!r.includes(e)||t===void 0||n===void 0||i===void 0)return!1;let o=a.reduce((e,t)=>{if(t.amount===void 0||t.amount===``)return e;let n=t.origin_asset.denom,r=e.get(n)??(0,f.default)(0);return e.set(n,r.plus(t.amount)),e},new Map);if(r.some(t=>{if(t===e)return!1;let n=(0,f.default)(i[t]?.amount||0),r=o.get(t);return r?n.gte(r):n.gt(0)}))return!1;let s=o.get(e)??(0,f.default)(0);return s.isZero()?!1:(0,f.default)(t||0).lt((0,f.default)(n||0).plus(s))}var Wu=[[`d`,1440*60],[`h`,3600],[`m`,60],[`s`,1]];function Gu(e){if(!e)return;let{formattedParts:t}=Wu.reduce(({remainingSeconds:e,formattedParts:t},[n,r])=>{let i=Math.floor(e/r);return{remainingSeconds:e-i*r,formattedParts:i>0?[...t,`${i}${n}`]:t}},{remainingSeconds:e,formattedParts:[]});return t.join(` `)}function Ku(e,t){let n=tn(e)??(0,f.default)(0),r=tn(t)??(0,f.default)(0);return n.times((0,f.default)(100).minus(r)).div(100).integerValue(f.default.ROUND_FLOOR).toFixed(0)}function qu(e){return e?.map(e=>{let{amount:t,origin_asset:n}=e;return`${(0,d.formatAmount)(t,{decimals:n.decimals??0})} ${n.symbol}`}).join(`, `)}function Ju(e,t,n,r){let{srcChainId:i,srcDenom:a,quantity:o,dstChainId:s,dstDenom:c}=n,l=t.getQueryData(rn.asset(i,a).queryKey);if(!l||l.decimals==null)throw Error(`Failed to refresh route: source asset metadata is unavailable.`);let u=l.decimals;return e.post(`v2/fungible/route`,{signal:r?.signal,json:{amount_in:(0,d.toBaseUnit)(o,{decimals:u}),source_asset_chain_id:i,source_asset_denom:a,dest_asset_chain_id:s,dest_asset_denom:c,is_op_withdraw:r?.isOpWithdraw}}).json()}function Yu(e,t){let{watch:n}=Ks(),r=n(),i=an(),a={srcChainId:r.srcChainId,srcDenom:r.srcDenom,dstChainId:r.dstChainId,dstDenom:r.dstDenom,quantity:e},o=!a.srcChainId||!a.srcDenom||!a.dstChainId||!a.dstDenom,s=!!tn(a.quantity)?.gt(0),c=t?.refreshMs??1e4,l=s&&!t?.disabled&&!o,d=(0,u.useQueryClient)();return(0,u.useQuery)({queryKey:rn.route(a,t?.isOpWithdraw).queryKey,queryFn:async({signal:e})=>Ju(i,d,a,{isOpWithdraw:t?.isOpWithdraw,signal:e}),enabled:l,staleTime:c,refetchInterval:l?c:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:`always`})}function Xu(e){return(0,u.useQuery)({queryKey:rn.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof h.HTTPError))return null;let{response:t}=e;return(t.headers.get(`content-type`)??``).includes(`application/json`)?(await t.json()).info??null:null},enabled:!!e})}function Zu(){let{watch:e}=Ks(),{srcChainId:t,srcDenom:n,dstChainId:r,dstDenom:i}=e(),a=ru(ou(t)),o=vu(n,t),s=vu(i,r),c=V(),l=Ze();return a===`initia`&&r===c.chainId&&o.symbol===s.symbol&&l.find(e=>e.chainId===t)?.metadata?.op_denoms?.includes(s.denom)}var Qu={label:`_label_t93ix_1`,wrapper:`_wrapper_t93ix_7`,input:`_input_t93ix_10`,clear:`_clear_t93ix_18`},$u=({mode:e=`onChange`,myAddress:t,...n})=>{let{validate:r=d.InitiaAddress.validate,chainType:i=`initia`,onApply:a,ref:o}=n,s=Mu(),{control:c,getValues:l,setValue:f,formState:p}=(0,I.useFormContext)(),[m,h]=(0,g.useState)(l(`recipient`)),_=It(),{data:v,isLoading:b,error:x}=(0,u.useQuery)({queryKey:Ft.address(_.restUrl,m).queryKey,queryFn:()=>_.getAddress(m),staleTime:B.MINUTE,enabled:_.validateUsername(m)}),S=v??(r(m)?m:``),C=t&&d.InitiaAddress.equals(S,t);return(0,g.useEffect)(()=>{e===`onChange`&&(!m&&!p.dirtyFields.recipient||f(`recipient`,v??m,{shouldValidate:!0,shouldDirty:!0}))},[p.dirtyFields.recipient,m,e,f,v]),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`label`,{htmlFor:`recipient`,className:Qu.label,children:[(0,y.jsx)(`span`,{children:`Recipient`}),(0,y.jsx)(G.Small,{type:`button`,tabIndex:-1,onClick:async()=>{try{h((await navigator.clipboard.readText()).trim())}catch{}},children:`Paste`})]}),(0,y.jsxs)(`div`,{className:Qu.wrapper,children:[(0,y.jsx)(I.Controller,{name:`recipient`,control:c,rules:{required:`Recipient address is required`,validate:e=>r(e)||`Invalid address`},render:()=>(0,y.jsx)(`input`,{id:`recipient`,className:(0,F.default)(Qu.input,`monospace`),value:m,onChange:e=>h(e.target.value.trim()),placeholder:i===`initia`?`Address or username`:`Enter address`,autoComplete:`off`,"data-has-value":m?`true`:void 0,ref:e===`onSubmit`?(0,be.mergeRefs)([o,s]):o})}),!!m&&(0,y.jsx)(`button`,{type:`button`,className:Qu.clear,onClick:()=>h(``),"aria-label":`Clear recipient`,children:(0,y.jsx)(L.IconCloseCircleFilled,{size:16})})]}),(()=>{if(b)return(0,y.jsx)(Zc,{level:`loading`,children:`Resolving username...`});if(x)return(0,y.jsx)(Zc,{level:`error`,children:x.message});if(v)return(0,y.jsx)(Zc,{level:`success`,className:`monospace`,children:v});if(e===`onSubmit`&&m&&!S)return(0,y.jsx)(Zc,{level:`error`,children:`Invalid address`})})(),C&&(0,y.jsx)(Zc,{children:`This is my address`}),e===`onSubmit`&&(0,y.jsx)(mc,{extra:(!t||!!S&&!C)&&(0,y.jsx)(el,{level:`warning`,children:`Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable.`}),children:(0,y.jsx)(G.White,{type:`button`,onClick:()=>{b||x||(f(`recipient`,S,{shouldValidate:!0,shouldDirty:!0}),a?.())},disabled:b||!!x||!S,children:`Apply`})})]})},ed={scrollable:`_scrollable_vgj3r_1`,list:`_list_vgj3r_5`,item:`_item_vgj3r_9`,name:`_name_vgj3r_22`};function td({onSelect:e,list:t,...n}){let{getImage:r,getName:i,getKey:a,getIsLoading:o,getDisabled:s}=n;return(0,y.jsx)(gc,{className:ed.scrollable,children:(0,y.jsx)(`div`,{className:ed.list,children:t.map(t=>(0,y.jsxs)(`button`,{className:ed.item,onClick:()=>e(t),disabled:o?.(t)||s?.(t),"aria-busy":!!o?.(t),children:[(0,y.jsx)(K,{src:r(t),width:28,height:28}),(0,y.jsx)(`span`,{className:ed.name,children:i(t)}),o?.(t)&&(0,y.jsx)(uc,{size:16})]},a(t)))})})}function nd(){let{cosmosWallets:e=[]}=z(),t=(0,g.useMemo)(()=>{let t=[{name:`Keplr`,image:`https://assets.initia.xyz/images/wallets/Keplr.webp`,getProvider:()=>window.keplr,fallbackUrl:`https://keplr.app/get`}].filter(t=>!e.some(e=>e.name===t.name));return[...e,...t]},[e]);return{list:t,find:e=>t.find(t=>t.name===e)}}var rd={wrapper:`_wrapper_h04x1_1`,account:`_account_h04x1_8`,clear:`_clear_h04x1_28`,white:`_white_h04x1_39`,warning:`_warning_h04x1_52`},id=({type:e})=>{let{watch:t,setValue:n}=Ks(),{srcChainId:r,dstChainId:i,cosmosWalletName:a}=t(),o=t(e===`src`?`sender`:`recipient`),s=ru(ou(i)),{showNotification:c}=Fc(),{list:l,find:u}=nd(),f=u(a),p=cu(),m=lu(),h=p(i),g=d.InitiaAddress.equals(o,h),_=()=>(0,y.jsx)(Ru,{title:`Connect wallet`,content:e=>(0,y.jsx)(td,{onSelect:async t=>{let i=t.getProvider();if(!i){t.fallbackUrl?window.open(t.fallbackUrl,`_blank`,`noopener,noreferrer`):c({type:`error`,title:`${t.name} not available`,description:`Please install the wallet extension and try again.`});return}try{let a=await i.getOfflineSigner(r).getAccounts();if(a.length===0)throw Error(`No accounts found`);n(`sender`,a[0].address),n(`cosmosWalletName`,t.name),e()}catch(e){let n=e instanceof Error?e.message:`Unknown error`;c({type:`error`,title:`Failed to connect ${t.name}`,description:n})}},list:l,getImage:e=>e.image,getName:e=>e.name,getKey:e=>e.name}),className:(0,F.default)(rd.account,{[rd.white]:!o}),children:o?(0,y.jsxs)(y.Fragment,{children:[f&&(0,y.jsx)(K,{src:f.image,width:18,height:18}),(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{children:`Connect wallet`}),(0,y.jsx)(L.IconChevronRight,{size:14,"aria-hidden":`true`})]})}),v=e=>(0,y.jsx)(Ru,{title:`Recipient`,content:e=>(0,y.jsx)(gc,{children:(0,y.jsx)($u,{mode:`onSubmit`,myAddress:h,chainType:s,validate:e=>m(e,i),onApply:e})}),className:rd.account,children:e}),b=()=>{switch(s){case`initia`:case`evm`:return g?v((0,y.jsx)(L.IconWallet,{size:14})):(0,y.jsxs)(`div`,{className:rd.account,children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)}),(0,y.jsx)(`button`,{type:`button`,className:rd.clear,onClick:()=>n(`recipient`,h,{shouldValidate:!0}),"aria-label":`Reset to my address`,children:(0,y.jsx)(L.IconCloseCircleFilled,{size:14})})]});case`cosmos`:return v((0,y.jsxs)(y.Fragment,{children:[o?(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)}):(0,y.jsx)(`span`,{children:`Recipient`}),(0,y.jsx)(L.IconEdit,{size:14,"aria-hidden":`true`})]}))}};switch(e){case`src`:return _();case`dst`:return b()}},ad={images:`_images_cj4xz_1`},od=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:i=6,className:a})=>(0,y.jsxs)(`div`,{className:(0,F.default)(ad.images,a),style:{position:`relative`},"aria-hidden":`true`,children:[(0,y.jsx)(K,{src:e,width:t,height:t,className:ad.asset,logo:!0}),(0,y.jsx)(K,{src:n,width:r,height:r,className:ad.chain,style:{position:`absolute`,bottom:0,right:-1*i},logo:!0})]}),sd={root:`_root_6187w_1`,content:`_content_6187w_10`,details:`_details_6187w_20`,symbol:`_symbol_6187w_26`,chain:`_chain_6187w_34`,chevron:`_chevron_6187w_43`},cd=({asset:e,chain:t,readOnly:n})=>{let r=(0,y.jsxs)(`div`,{className:sd.content,children:[(0,y.jsx)(od,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),(0,y.jsxs)(`div`,{className:sd.details,children:[(0,y.jsx)(`div`,{className:sd.symbol,children:e.symbol||e.denom}),(0,y.jsxs)(`div`,{className:sd.chain,children:[`on `,t.name]})]})]});return n?(0,y.jsx)(`div`,{className:sd.root,children:r}):(0,y.jsxs)(`div`,{className:sd.root,children:[r,(0,y.jsx)(L.IconChevronDown,{size:16,className:sd.chevron,"aria-hidden":`true`})]})};function ld(e,t,n){let r=t.toLowerCase();return n.filter(t=>e.some(e=>String(t[e]??``).toLowerCase().includes(r)))}var ud={root:`_root_1sh27_1`,label:`_label_1sh27_8`,input:`_input_1sh27_21`,hasValue:`_hasValue_1sh27_31`,clear:`_clear_1sh27_35`},dd=e=>{let{rootClassName:t,padding:n=16,iconSize:r=16,onClear:i,ref:a,...o}=e;return(0,y.jsxs)(`div`,{className:(0,F.default)(ud.root,t,{[ud.hasValue]:o.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[(0,y.jsx)(`label`,{htmlFor:`search`,className:ud.label,children:(0,y.jsx)(L.IconSearch,{size:r})}),(0,y.jsx)(`input`,{className:ud.input,id:`search`,type:`text`,maxLength:100,ref:a,...o}),o.value&&(0,y.jsx)(`button`,{type:`button`,className:ud.clear,"aria-label":`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:i,children:(0,y.jsx)(L.IconCloseCircleFilled,{size:r})})]})},fd={container:`_container_cd7o8_1`,search:`_search_cd7o8_7`,list:`_list_cd7o8_11`,item:`_item_cd7o8_15`,logo:`_logo_cd7o8_37`,fallback:`_fallback_cd7o8_44`,info:`_info_cd7o8_51`,symbol:`_symbol_cd7o8_57`,name:`_name_cd7o8_66`,balance:`_balance_cd7o8_72`,value:`_value_cd7o8_79`},pd=[`symbol`],md=(e,t)=>t(e),hd=(0,g.memo)(function(e){let{assets:t,onSelect:n,renderAsset:r,listClassName:i}=e;return(0,y.jsx)(`div`,{className:(0,F.default)(fd.list,i),children:t.map(e=>(0,y.jsx)(`button`,{type:`button`,className:fd.item,onClick:()=>n(e.denom),children:r(e,e=>{let{denom:t,logoUrl:n,symbol:r,name:i,balance:a,decimals:o,value:s=0}=e;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(K,{src:n,width:32,height:32,className:fd.logo,classNames:{placeholder:fd.fallback},logo:!0}),(0,y.jsxs)(`div`,{className:fd.info,children:[(0,y.jsx)(`div`,{className:fd.symbol,children:r||t}),(0,y.jsx)(`div`,{className:fd.name,children:i})]}),(0,y.jsxs)(`div`,{className:fd.balance,children:[a&&(0,y.jsx)(`div`,{children:(0,d.formatAmount)(a,{decimals:o})}),s>0&&(0,y.jsx)(`div`,{className:fd.value,children:q(s)})]})]})})},e.denom))})}),gd=e=>{let{assets:t,onSelect:n,renderAsset:r=md,searchKeys:i=pd,placeholder:a=`Search by symbol`,emptyMessage:o=`No assets`,listClassName:s}=e,[c,l]=(0,g.useState)(``),u=(0,g.useDeferredValue)(c),d=(0,g.useMemo)(()=>ld(i,u,t),[i,u,t]);return(0,y.jsxs)(`div`,{className:fd.container,children:[(0,y.jsx)(dd,{value:c,onChange:e=>l(e.target.value),onClear:()=>l(``),placeholder:a,rootClassName:fd.search,padding:20,ref:Mu()}),d.length===0?(0,y.jsx)(Ia,{children:o}):(0,y.jsx)(hd,{assets:d,onSelect:n,renderAsset:r,listClassName:s})]})};gd.Placeholder=()=>(0,y.jsxs)(`div`,{className:fd.container,children:[(0,y.jsx)(dd,{rootClassName:fd.search,padding:20,placeholder:`Search by symbol`,readOnly:!0}),(0,y.jsx)(Ia,{children:`Loading...`})]});var _d={stack:`_stack_16oqn_1`,title:`_title_16oqn_9`,grid:`_grid_16oqn_16`,item:`_item_16oqn_22`,button:`_button_16oqn_26`,active:`_active_16oqn_44`},vd=({label:e,chains:t,value:n,onSelect:r,getShowIndicator:i})=>(0,y.jsxs)(`div`,{children:[e&&(0,y.jsx)(`h2`,{className:_d.title,children:e}),(0,y.jsx)(`div`,{className:_d.grid,children:t.map(({chainId:e,name:t,logoUrl:a})=>(0,y.jsx)(Zl,{offset:-2,disabled:!i?.(e),className:_d.item,children:(0,y.jsx)(Bu,{label:t,disableHoverableContent:!0,children:(0,y.jsx)(`button`,{type:`button`,"aria-label":t,className:(0,F.default)(_d.button,{[_d.active]:e===n}),onClick:()=>r(e),children:(0,y.jsx)(K,{src:a,width:28,height:28,logo:!0})})})},e))})]});vd.Stack=({children:e})=>(0,y.jsx)(`div`,{className:_d.stack,children:e});var yd=({address:e,chain:t,onSelect:n})=>{let r=gu(t.chain_id),{data:i={}}=Vu(e,t.chain_id);return(0,y.jsx)(gd,{assets:(0,p.sortWith)([(0,p.ascend)(e=>jt(e.symbol)),(0,p.descend)(e=>e.value),({balance:e=`0`},{balance:t=`0`})=>(0,f.default)(t||0).comparedTo(e||0)??0,(0,p.ascend)(e=>e.symbol.toLowerCase())],r.filter(du).map(e=>{let{denom:t,symbol:n=(0,d.truncate)(t),logo_uri:r}=e,a=i[t]??{};return{...e,symbol:n,decimals:e.decimals??0,logoUrl:r??``,name:e.name??``,balance:a.amount,value:Number(a.value_usd??0)}})),onSelect:n})},bd=({type:e,afterSelect:t})=>{let n=e===`src`?`srcChainId`:`dstChainId`,r=e===`src`?`srcDenom`:`dstDenom`,i=e===`src`?`sender`:`recipient`,a=Ma(),o=iu(),{watch:s,setValue:c}=Ks(),l=s(i),u=s(n),d=s(r),[f,m]=(0,g.useState)(u),h=ou(f),_=uu(),v=eu(),[b,x]=(0,p.partition)(e=>v(e.chain_id),o.filter(e=>!e.hidden));return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(vd.Stack,{children:[(0,y.jsx)(vd,{label:`Interwoven Economy`,chains:b.map(({chain_id:e,chain_name:t,pretty_name:n,logo_uri:r})=>({chainId:e,name:n||t,logoUrl:r??``})),value:f,onSelect:m}),(0,y.jsx)(vd,{label:`Chains`,chains:x.map(({chain_id:e,chain_name:t,pretty_name:n,logo_uri:r})=>({chainId:e,name:n||t,logoUrl:r??``})),value:f,onSelect:m})]}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gd.Placeholder,{}),children:(0,y.jsx)(yd,{address:_({initialAddress:l,initialChainId:u,chainId:f,fallbackAddress:e===`src`?a:void 0}),chain:h,onSelect:e=>{if(u===f&&d===e){t();return}c(n,f),c(r,e),t()}})},f)]})},xd=({type:e})=>{let t=e===`src`?`srcChainId`:`dstChainId`,n=e===`src`?`srcDenom`:`dstDenom`,r=e===`src`?`Select source chain and asset`:`Select destination chain and asset`,{watch:i}=Ks(),a=i(t),o=i(n),s=ou(a),c=vu(o,a);return(0,y.jsx)(Ru,{title:r,content:t=>(0,y.jsx)(bd,{type:e,afterSelect:t}),children:(0,y.jsx)(cd,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??``},chain:{chainId:s.chain_id,name:s.pretty_name||s.chain_name,logoUrl:s.logo_uri??``}})})},Sd={skeleton:`_skeleton_1l4jn_1`,pulse:`_pulse_1l4jn_1`},Cd=({width:e=`100%`,height:t})=>(0,y.jsx)(`div`,{className:Sd.skeleton,style:{width:e,height:t},"aria-hidden":`true`}),wd={stack:`_stack_oq1ir_1`,button:`_button_oq1ir_6`,isLoading:`_isLoading_oq1ir_19`,disabled:`_disabled_oq1ir_19`,checked:`_checked_oq1ir_23`,header:`_header_oq1ir_37`,title:`_title_oq1ir_43`,duration:`_duration_oq1ir_52`,warning:`_warning_oq1ir_62`,amount:`_amount_oq1ir_66`,value:`_value_oq1ir_67`},Td=({children:e})=>(0,y.jsx)(`div`,{className:wd.stack,role:`radiogroup`,"aria-label":`Route options`,children:e}),Ed=({label:e,query:t,value:n,onSelect:r,...i})=>{let{data:a,isLoading:o}=t,{watch:s}=Ks(),{dstChainId:c,dstDenom:l}=s(),u=vu(l,c),f=!o&&i.checked,p=!o&&!a;return(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(wd.button,{[wd.isLoading]:o,[wd.disabled]:p,[wd.checked]:f}),onClick:()=>{o||p||r(n)},role:`radio`,"aria-checked":f,"aria-disabled":p,children:[(0,y.jsxs)(`div`,{className:wd.header,children:[(0,y.jsxs)(`div`,{className:wd.title,children:[(0,y.jsx)(`span`,{children:e}),f&&(0,y.jsx)(L.IconCheck,{size:14,"aria-hidden":`true`})]}),o?(0,y.jsx)(Cd,{width:80,height:16}):a?(0,y.jsxs)(`div`,{className:(0,F.default)(wd.duration,{[wd.warning]:n===`op`}),children:[(0,y.jsx)(L.IconClockFilled,{size:12,"aria-hidden":`true`}),(0,y.jsx)(`span`,{children:Gu(a.estimated_route_duration_seconds)})]}):(0,y.jsx)(`div`,{className:wd.duration,children:`Not available`})]}),(o||a)&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:wd.amount,children:o?(0,y.jsx)(Cd,{width:260,height:40}):a?(0,d.formatAmount)(a.amount_out,{decimals:u.decimals}):null}),(0,y.jsx)(`div`,{className:wd.value,children:o?(0,y.jsx)(Cd,{width:120,height:16}):a?a.usd_amount_out?q(a.usd_amount_out):`$-`:null})]})]})};Ed.Stack=Td;function Dd(e){let t=tn(e);return t?t.lte(0)?{type:`error`,text:`Slippage must be greater than 0`}:t.gt(100)?{type:`error`,text:`Slippage must be less than 100%`}:t.gt(5)?{type:`warning`,text:`Your transaction may be frontrun`}:t.lt(.1)?{type:`warning`,text:`Your transaction may fail`}:null:{type:`error`,text:`Enter a slippage value`}}var Od={description:`_description_nuyvt_1`,presets:`_presets_nuyvt_8`,preset:`_preset_nuyvt_8`,active:`_active_nuyvt_29`,custom:`_custom_nuyvt_40`,wrapper:`_wrapper_nuyvt_47`,percent:`_percent_nuyvt_58`},kd=[`0.1`,`0.5`,`1.0`],Ad=({afterConfirm:e})=>{let t=Ks(),n=t.getValues(`slippagePercent`),[r,i]=(0,g.useState)(null),{control:a,watch:o,getValues:s,setValue:c}=(0,I.useForm)({defaultValues:{value:n}}),l=o(`value`);(0,g.useEffect)(()=>{let e=kd.findIndex(e=>e===n);i(e>=0?e:null)},[n]);let u=(e,t)=>{c(`value`,e),i(t)},d=()=>{i(null)},f=(0,g.useMemo)(()=>Dd(l),[l]),p=f?.type===`error`,m=({value:n})=>{t.setValue(`slippagePercent`,n),e()};return(0,y.jsxs)(gc,{children:[(0,y.jsx)(`p`,{className:Od.description,children:`Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed.`}),(0,y.jsxs)(`div`,{className:Od.presets,role:`radiogroup`,"aria-label":`Slippage presets`,children:[kd.map((e,t)=>(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(Od.preset,{[Od.active]:r===t}),onClick:()=>u(e,t),role:`radio`,"aria-checked":r===t,children:[e,`%`]},e)),r===null?(0,y.jsxs)(`div`,{className:Od.wrapper,children:[(0,y.jsx)(Pu,{name:`value`,control:a,dp:2,onFocus:d,placeholder:``,className:(0,F.default)(Od.preset,Od.active),"aria-label":`Slippage percent`}),(0,y.jsx)(`span`,{className:Od.percent,children:`%`})]}):(0,y.jsx)(`button`,{type:`button`,className:(0,F.default)(Od.preset,Od.custom),onClick:()=>i(null),role:`radio`,"aria-checked":r===null,children:`Custom`})]}),f&&(0,y.jsx)(el,{level:f.type,children:f.text}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{type:`button`,onClick:()=>m(s()),disabled:p,children:`Confirm`})})]})},jd={form:`_form_1owk5_1`,arrow:`_arrow_1owk5_5`,divider:`_divider_1owk5_14`,flip:`_flip_1owk5_23`,meta:`_meta_1owk5_41`,row:`_row_1owk5_54`,title:`_title_1owk5_60`,description:`_description_1owk5_64`,icon:`_icon_1owk5_71`,edit:`_edit_1owk5_76`,link:`_link_1owk5_94`,warning:`_warning_1owk5_99`};function Md({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}function Nd({srcChainType:e,chainFeeAssets:t,srcDenom:n}){switch(e){case`initia`:case`cosmos`:return t.map(({denom:e})=>e);case`evm`:return(0,w.isAddress)(n)?[]:[n];default:return[]}}var Pd=(0,f.default)(1),Fd=()=>{let e=Zt(),t=bc(),n=Fn(),[r,i]=(0,g.useState)(void 0),[a,o]=(0,g.useState)(!1),[s,c]=(0,le.useLocalStorage)(H.BRIDGE_ROUTE_TYPE,`default`),{watch:l,setValue:u,handleSubmit:p,formState:m}=Ks(),h=l(),{srcChainId:_,srcDenom:v,dstChainId:b,dstDenom:x,quantity:S,sender:C,slippagePercent:w}=h,T=V(),E=ou(_),D=ru(E),O=ru(ou(b)),k=vu(v,_),A=vu(x,b),{data:j,isError:M}=Vu(C,_),ee=Hu(C,_,v),te=j!==void 0,N=ee?.amount??(j?`0`:void 0),ne=!N||(0,f.default)(N||0).isZero(),[re]=(0,le.useDebounceValue)(S,300),ie=nn({quantity:re,balance:N,decimals:k?.decimals}),ae=_===b,oe=ae&&_===T.chainId,se=Md({isLayer1Swap:oe,isL2Swap:ae&&D===`initia`&&!oe}),ce=D!==`initia`&&O!==`initia`,P=Zu(),ue=Yu(re,{disabled:ce,refreshMs:se}),F=Yu(re,{isOpWithdraw:!0,disabled:!P,refreshMs:se}),I=P&&s===`op`,de=I?F:ue,fe=I?ue:F,pe=I?!ce:P,he=de.error&&pe?fe:de,{data:R,isLoading:ge,error:_e}=he,{data:ve}=Xu(_e),ye=re&&ge&&!a,be=()=>{u(`srcChainId`,b),u(`srcDenom`,x),u(`dstChainId`,_),u(`dstDenom`,v),u(`quantity`,``,{shouldTouch:!1,shouldDirty:!1})},{openModal:xe,closeModal:Se}=ki(),Ce=p(async t=>{i(void 0),o(!0);try{let r=await he.refetch();if(r.error||!r.data||!r.dataUpdatedAt){i(r.error instanceof Error?r.error.message:`Failed to refresh route. Please try again.`);return}let a=r.data,o=r.dataUpdatedAt;if(n(`Bridge Simulation Success`,{quantity:t.quantity,srcChainId:t.srcChainId,srcDenom:t.srcDenom,dstChainId:t.dstChainId,dstDenom:t.dstDenom}),a.warning){let{type:n=``,message:r}=a.warning??{};xe({content:(0,y.jsx)(bu,{type:`warning`,icon:(0,y.jsx)(L.IconWarningFilled,{size:40}),title:(0,me.sentenceCase)(n),primaryButton:{label:`Cancel`,onClick:Se},secondaryButton:{label:`Proceed anyway`,onClick:()=>{e(`/bridge/preview`,{route:a,values:t,quoteVerifiedAt:o}),Se()}},children:(0,y.jsx)(`p`,{className:jd.warning,children:r})})});return}e(`/bridge/preview`,{route:a,values:t,quoteVerifiedAt:o})}finally{o(!1)}}),we=(0,g.useMemo)(()=>R?.estimated_fees?.filter(({fee_behavior:e})=>e===`FEE_BEHAVIOR_DEDUCTED`)??[],[R]),Te=(0,g.useMemo)(()=>R?.estimated_fees?.filter(({fee_behavior:e})=>e===`FEE_BEHAVIOR_ADDITIONAL`)??[],[R]),Ee=(0,g.useMemo)(()=>{if(te)for(let e of Te){let t=j?.[e.origin_asset.denom]?.amount||`0`,n=(R?.source_asset_denom===e.origin_asset.denom?R.amount_in:`0`)||`0`,r=e.amount||`0`;if((0,f.default)(t).lt((0,f.default)(n).plus(r)))return`Insufficient ${e.origin_asset.symbol} for fees`}},[Te,j,te,R]),De=!!R&&Te.length>0&&!te,Oe=R?(0,d.formatAmount)(R.amount_out,{decimals:A.decimals}):`0`,ke=(0,g.useMemo)(()=>E.fee_assets??[],[E.fee_assets]),Ae=(0,g.useCallback)((e,t)=>{let n=(0,f.default)(j?.[e]?.amount||0),r=e===(t?.sourceDenom??v)?(0,f.default)(t?.amountIn||R?.amount_in||0):(0,f.default)(0);return n.minus(r)},[j,R?.amount_in,v]),je=(0,g.useMemo)(()=>Nd({srcChainType:D,chainFeeAssets:ke,srcDenom:v}),[ke,D,v]),Me=Uu({sourceDenom:v,sourceBalance:N,amountIn:R?.amount_in,feeTokenDenoms:je,balancesByDenom:j,additionalFees:Te}),Ne=je.some(e=>Ae(e).gt(Pd)),Pe=te&&R&&je.length>0&&!Ne||Me?`Insufficient balance for fees`:void 0,Fe=!!r,Ie=(0,g.useMemo)(()=>{if(!h.sender)return`Connect wallet`;if(!h.quantity||!re)return`Enter amount`;if(!h.recipient)return`Enter recipient address`;if(m.errors.quantity)return m.errors.quantity.message;if(M)return`Failed to load balance`;if(ie)return`Insufficient balance`;if(!R)return`Route not found`;if(De)return`Loading balances...`;if(Ee)return Ee},[re,Ee,m,De,M,ie,R,h]),Le=(0,g.useMemo)(()=>a?`Refreshing route...`:ye?`Simulating...`:!1,[ye,a]),Re=(0,g.useCallback)((e,n)=>e.length?(0,y.jsxs)(`div`,{className:jd.description,children:[qu(e),!t&&(0,y.jsx)(Bu,{label:n,children:(0,y.jsx)(`span`,{className:jd.icon,children:(0,y.jsx)(L.IconInfoFilled,{size:12,"aria-hidden":`true`})})})]}):null,[t]),ze=!!tn(S)?.gt(0)&&P&&ue.data&&F.data&&F.data.estimated_route_duration_seconds>ue.data.estimated_route_duration_seconds,Be=(0,g.useMemo)(()=>{if(!R)return[];let e=Ku(R.amount_out,w);return[{condition:!!R.estimated_fees?.length,title:`Fees`,content:(0,y.jsxs)(`div`,{children:[Re(we,`Fee deducted from the amount you receive`),Re(Te,`Fee charged in addition to the amount you enter`)]})},{condition:!ze&&!!Gu(R.estimated_route_duration_seconds),title:`Estimated time`,content:(0,y.jsx)(`span`,{className:jd.description,children:Gu(R.estimated_route_duration_seconds)})},{condition:R.does_swap,title:`Slippage`,content:(0,y.jsxs)(`span`,{className:jd.description,children:[(0,y.jsxs)(`span`,{children:[w,`%`]}),(0,y.jsx)(Ru,{title:`Slippage tolerance`,content:e=>(0,y.jsx)(Ad,{afterConfirm:e}),className:jd.edit,children:(0,y.jsx)(L.IconSettingFilled,{size:12,"aria-hidden":`true`})})]})},{condition:R.does_swap,title:`Minimum received`,content:(0,y.jsxs)(`span`,{className:jd.description,children:[(0,y.jsx)(`img`,{src:A.logo_uri,alt:A.symbol,width:12,height:12}),(0,d.formatAmount)(e,{decimals:A.decimals}),` `,A.symbol]})}].filter(e=>e.condition)},[Te,we,A,Re,R,ze,w]);return(0,y.jsxs)(`form`,{className:jd.form,onSubmit:Ce,"aria-label":`Bridge and swap form`,children:[(0,y.jsx)(ju,{selectButton:(0,y.jsx)(xd,{type:`src`}),accountButton:D===`cosmos`&&(0,y.jsx)(id,{type:`src`}),quantityInput:(0,y.jsx)(Lu,{balance:N,decimals:k?.decimals}),balanceButton:(0,y.jsx)(ku,{onClick:()=>u(`quantity`,(0,d.fromBaseUnit)(ee?.amount,{decimals:k?.decimals??0}),{shouldValidate:!0}),disabled:ne,children:(0,d.formatAmount)(N??`0`,{decimals:k.decimals})}),value:R?.usd_amount_in?q(R.usd_amount_in):`$-`}),(0,y.jsxs)(`div`,{className:jd.arrow,children:[(0,y.jsx)(`div`,{className:jd.divider}),(0,y.jsx)(`button`,{type:`button`,className:jd.flip,onClick:()=>be(),"aria-label":`Swap source and destination`,children:(0,y.jsx)(L.IconChevronDown,{size:16,"aria-hidden":`true`})})]}),(0,y.jsx)(ju,{selectButton:(0,y.jsx)(xd,{type:`dst`}),accountButton:(0,y.jsx)(id,{type:`dst`}),quantityInput:(0,y.jsx)(Lu.ReadOnly,{children:Oe}),value:R?.usd_amount_out?q(R.usd_amount_out):`$-`,hideNumbers:ze}),(0,y.jsx)(Yc,{children:ze?(0,y.jsxs)(Ed.Stack,{children:[(0,y.jsx)(Ed,{label:`Fast`,query:ue,value:`default`,onSelect:c,checked:s===`default`}),(0,y.jsx)(Ed,{label:`Lossless`,query:F,value:`op`,onSelect:c,checked:s===`op`})]}):null}),(0,y.jsx)(mc,{extra:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(el.Stack,{children:[M&&(0,y.jsx)(el,{level:`error`,children:`Failed to load balance`}),Fe&&(0,y.jsx)(el,{level:`error`,children:r}),R?.extra_infos?.map(e=>(0,y.jsx)(el,{level:`info`,children:e},e)),ve&&(0,y.jsx)(el,{level:`info`,children:ve}),Pe&&(0,y.jsx)(el,{level:`warning`,children:Pe}),R?.warning&&(0,y.jsx)(el,{level:`warning`,children:R.warning.message}),R?.extra_warnings?.map(e=>(0,y.jsx)(el,{level:`warning`,children:e},e))]}),(0,y.jsx)(Yc,{children:Be.length>0&&(0,y.jsx)(`section`,{className:jd.meta,"aria-label":`Route details`,children:Be.map((e,t)=>(0,y.jsxs)(`div`,{className:jd.row,children:[(0,y.jsx)(`span`,{className:jd.title,children:e.title}),e.content]},t))})})]}),children:(0,y.jsx)(G.White,{loading:Le,disabled:!!Ie||a,children:Ie??`Preview route`})})]})},Id=()=>{Du();let e=Xt(),t=Zt(),n=Ma(),r=(0,I.useForm)({mode:`onChange`,defaultValues:Js()}),{watch:i,setValue:a}=r,{srcChainId:o,dstChainId:s,srcDenom:c,dstDenom:l,quantity:u,slippagePercent:d,recipient:f}=i();i((e,{name:t})=>{(t===`srcChainId`||t===`srcDenom`)&&a(`quantity`,``,{shouldTouch:!1,shouldDirty:!1})});let p=cu(),m=p(o),h=p(s),_=lu()(f,s);(0,g.useEffect)(()=>{a(`cosmosWalletName`,void 0),a(`sender`,m)},[o,m,a]),(0,g.useEffect)(()=>{_||a(`recipient`,h)},[h,_,a]);let{showNotification:v}=Fc(),b=ou(o),x=ou(s),S=gu(o),C=gu(s),w=pu(S),T=pu(C),E=!!fu(S,c),D=!!fu(C,l);(0,g.useEffect)(()=>{w&&!E&&(a(`srcDenom`,w.denom),v({type:`info`,title:`Switched to ${w.symbol}`,description:`The selected asset is not available on ${b.pretty_name}.`,autoHide:!0}))},[w,E,a,v,b.pretty_name]),(0,g.useEffect)(()=>{T&&!D&&(a(`dstDenom`,T.denom),v({type:`info`,title:`Switched to ${T.symbol}`,description:`The selected asset is not available on ${x.pretty_name}.`,autoHide:!0}))},[T,D,a,v,x.pretty_name]),(0,g.useEffect)(()=>{!E||!D||(localStorage.setItem(H.BRIDGE_SRC_CHAIN_ID,o),localStorage.setItem(H.BRIDGE_SRC_DENOM,c),localStorage.setItem(H.BRIDGE_DST_CHAIN_ID,s),localStorage.setItem(H.BRIDGE_DST_DENOM,l),localStorage.setItem(H.BRIDGE_QUANTITY,u),localStorage.setItem(H.BRIDGE_SLIPPAGE_PERCENT,d))},[o,c,s,l,u,d,E,D]);let O=e[0].path===`/bridge`,{reminders:k}=Eu();return(0,y.jsx)($l,{title:`Bridge/Swap`,backButton:O?`/`:void 0,extra:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(G.Small,{onClick:()=>t(`/bridge/history`),unpadded:!0,"aria-label":`Bridge/Swap history`,children:(0,y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,width:`12`,height:`12`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z`}),(0,y.jsx)(`path`,{d:`M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z`})]})}),(0,y.jsx)(Zl,{offset:0,disabled:k.length===0,children:(0,y.jsx)(G.Small,{onClick:()=>t(`/op/withdrawals`),disabled:!n,children:(0,y.jsx)(`span`,{children:`Withdrawal status`})})})]}),children:E&&D&&(0,y.jsx)(I.FormProvider,{...r,children:(0,y.jsx)(W,{children:(0,y.jsx)(Fd,{})})})})},Ld={button:`_button_1crvp_1`,checkbox:`_checkbox_1crvp_11`,checked:`_checked_1crvp_25`},Rd=({checked:e,onClick:t,label:n,className:r})=>(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(Ld.button,r),onClick:t,role:`checkbox`,"aria-checked":e,children:[(0,y.jsx)(`div`,{className:(0,F.default)(Ld.checkbox,{[Ld.checked]:e}),children:e&&(0,y.jsx)(L.IconCheck,{size:12,"aria-hidden":`true`})}),(0,y.jsx)(`span`,{className:Ld.label,children:n})]}),zd={button:`_button_aoxv2_1`},Bd=({onClick:e,disabled:t})=>{let{ref:n,inView:r}=(0,Se.useInView)();return(0,g.useEffect)(()=>{r&&e()},[r,e]),(0,y.jsxs)(`button`,{className:zd.button,onClick:e,disabled:t,ref:n,children:[(0,y.jsx)(`span`,{children:`Load more`}),(0,y.jsx)(L.IconChevronDown,{size:12,"aria-hidden":`true`})]})};function Vd(e,t){return e.reduce((e,n)=>{let r=t(n);if(!r)return e;let i=r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),a=e[i]||[];return{...e,[i]:[...a,n]}},{})}var Hd=({chainId:e,txHash:t})=>`${H.BRIDGE_HISTORY}:${e}:${t}`;function Ud(){let[e,t]=(0,le.useLocalStorage)(H.BRIDGE_HISTORY,[]);return{history:e,addHistoryItem:(0,g.useCallback)((n,r)=>{localStorage.setItem(Hd(n),JSON.stringify(r));for(let t of e.slice(99))localStorage.removeItem(Hd(t));t((e=[])=>[n,...e.slice(0,99)])},[e,t]),getHistoryDetails:(0,g.useCallback)(e=>{let t=localStorage.getItem(Hd(e));return t?JSON.parse(t):null},[])}}function Wd(e){return(0,le.useLocalStorage)(Hd(e),null)}var Gd=(0,m.createQueryKeys)(`interwovenkit:op`,{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function Kd(){let{restUrl:e}=V();return(0,g.useMemo)(()=>h.default.create({prefixUrl:e}),[e])}function qd(e){let t=Kd(),{data:n}=(0,u.useSuspenseQuery)({queryKey:Gd.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:B.INFINITY});return n}var Jd=20;function Yd(e){let t=U();return(0,u.useSuspenseInfiniteQuery)({queryKey:Gd.withdrawals(e,t).queryKey,queryFn:async({pageParam:n})=>{if(!t)return[];let r={limit:Jd,offset:n,order:`desc`},{withdrawals:i}=await h.default.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:r}).json();return i},getNextPageParam:e=>{let t=(0,p.last)(e)?.sequence;return e.length<Jd||!t||t<=1?null:t-1},initialPageParam:0,staleTime:B.SECOND})}function Xd(e){let t=Kd(),{data:n}=(0,u.useSuspenseQuery)({queryKey:Gd.latestOutput(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:e})=>{let[t]=e;return t||null},staleTime:B.SECOND});return n}function Zd({bridge_id:e,output_index:t}){let n=Kd(),{data:r}=(0,u.useSuspenseQuery)({queryKey:Gd.output(e,t).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:B.SECOND});return r}function Qd({bridge_id:e,sequence:t}){let n=Ze().find(({metadata:t})=>t?.op_bridge_id===e.toString())?.chain_id;if(!n)throw Error(`Chain not found for bridge_id: ${e}`);let r=et()(n);if(!r)throw Error(`Chain not found: ${n}`);let i=r.metadata?.executor_uri;if(!i)throw Error(`Executor URL not found: ${n}`);let{data:a}=(0,u.useSuspenseQuery)({queryKey:Gd.outputResponse(i,t).queryKey,queryFn:()=>h.default.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:B.SECOND});return a}function $d(e,t){let{bridge_id:n}=e,r=Kd(),{data:i}=(0,u.useSuspenseQuery)({queryKey:Gd.withdrawalClaimed(n,t).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:e})=>e,staleTime:({state:{data:e}})=>e?.claimed?1/0:B.SECOND});return i}function ef(e){return Ce.sha3_256.create().update(e).digest()}function tf(e,t){let n=new ArrayBuffer(t);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function nf(e){let{bridge_id:t,sequence:n,amount:r,from:i,to:a}=e,o=tf(t.toString(),8),s=tf(n.toString(),8),c=tf(r.amount,8);return ef(ef((0,we.concatBytes)(o,s,ef((0,we.utf8ToBytes)(i)),ef((0,we.utf8ToBytes)(a)),ef((0,we.utf8ToBytes)(r.denom)),c)))}async function rf(e,t,n){try{return await h.default.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:n}}).json(),!0}catch{return!1}}async function af(e,t){let n=h.default.create({prefixUrl:t}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let e=1;e<=24;e++)try{return await n.get(r).json()}catch{await new Promise(e=>setTimeout(e,5e3))}throw Error(`Timeout: ${e} not found`)}function of({addressList:e,route:t,slippagePercent:n,signedOpHook:r}){return{address_list:e,amount_in:t.amount_in,amount_out:t.amount_out,source_asset_chain_id:t.source_asset_chain_id,source_asset_denom:t.source_asset_denom,dest_asset_chain_id:t.dest_asset_chain_id,dest_asset_denom:t.dest_asset_denom,slippage_tolerance_percent:n,operations:t.operations,signed_op_hook:r}}async function sf(e,t){let n=of(t),{txs:r}=await e.post(`v2/fungible/msgs`,{json:n}).json();if(!r||r.length===0)throw Error(`No transaction data found`);return r}function cf(e,t){if(!e?.length)throw Error(`Invalid transaction data`);return e.map(({msg_type_url:e,msg:n})=>{if(!(e&&n))throw Error(`Invalid transaction data`);let r=t.converters[e];if(!r)throw Error(`Unsupported message type: ${e}`);return t.fromAmino({type:r.aminoType,value:JSON.parse(n)})})}function lf({gas:e,gasPrices:t,gasAdjustment:n=Ne}){return t.reduce((t,{amount:r,denom:i})=>(t[i]=(0,f.default)(e).times(n).times(r||0).integerValue(f.default.ROUND_CEIL).toFixed(0),t),{})}function uf({balances:e,requiredFeeByDenom:t,sourceDenom:n,amountIn:r}){let i=Object.keys(t);return i.length===0?!0:i.some(i=>{let a=(0,f.default)(e[i]?.amount||0),o=i===n?(0,f.default)(r||0):(0,f.default)(0),s=(0,f.default)(t[i]||0);return a.minus(o).gte(s)})}async function df(e,t){let{chain_type:n,chain_id:r,chain_name:i,evm_fee_asset:a,rpc:o}=t;if(n!==`evm`)throw Error(`Chain is not an EVM chain: ${i}`);try{await e.send(`wallet_switchEthereumChain`,[{chainId:`0x${Number(r).toString(16)}`}])}catch(t){if((0,p.path)([`error`,`code`],t)!==4902)throw t;if(!a)throw Error(`Fee asset is not defined for chain: ${i}`);await e.send(`wallet_addEthereumChain`,[{chainId:`0x${Number(r).toString(16)}`,chainName:i,nativeCurrency:a,rpcUrls:[o]}]),await e.send(`wallet_switchEthereumChain`,[{chainId:`0x${Number(r).toString(16)}`}])}}function ff(){return Yt()}function pf(e,t){let{customFee:n,onCompleted:r}=t??{},i=Zt(),{showNotification:a,updateNotification:o,hideNotification:s}=Fc(),{addHistoryItem:c}=Ud(),l=Fn(),{route:p,values:m}=ff(),{srcChainId:h,sender:g,recipient:_,cosmosWalletName:v}=m,y=oi(),{requestTxSync:b,submitTxSync:x,waitForTxConfirmation:S}=Pa(),{find:C}=nd(),w=Wr(),T=Gr(),E=Kr(),D=ou(h),O=ru(D),k=_u(h),A=(0,u.useQueryClient)(),{registryUrl:j}=z(),ee=et(),te=V(),{addReminder:N}=Eu(),ne=an();return(0,u.useMutation)({mutationFn:async()=>{try{if(`cosmos_tx`in e){if(!e.cosmos_tx.msgs)throw Error(`Invalid transaction data`);let t=cf(e.cosmos_tx.msgs,{converters:T,fromAmino:E.fromAmino.bind(E)});if(O===`initia`){let{srcDenom:e,quantity:r}=m,{decimals:i}=k(e),a=n?await x({messages:t,chainId:h,fee:n}):await b({messages:t,chainId:h,internal:1,spendCoins:[{denom:e,amount:(0,d.toBaseUnit)(r,{decimals:i})}]});return{txHash:a,wait:S({txHash:a,chainId:h})}}let r=C(v)?.getProvider();if(!r)throw Error(`Wallet not connected`);let i=r.getOfflineSignerOnlyAmino(h),a=await M.SigningStargateClient.connectWithSigner(D.rpc,i,{registry:w,aminoTypes:E}),o=await a.getAllBalances(g),s=D.fee_assets.find(e=>o.some(t=>t.denom===e.denom&&(0,f.default)(t.amount||0).gt(0)));if(!s){let e=[`Insufficient balance for fees.`,`Available fee assets: ${D.fee_assets.map(e=>k(e.denom).symbol).join(`, `)}`,`(note: asset symbols may refer to different tokens across chains)`].join(` `);throw Error(e)}let{denom:c,gas_price:l}=s;if(!l)throw Error(`Gas price not found for ${c}`);let u=await a.simulate(g,t,``),p=M.GasPrice.fromString(l.average+c),_=(0,M.calculateFee)(Math.ceil(u*Ne),p),y=await a.signAndBroadcastSync(g,t,_);return{txHash:y,wait:sa({txHash:y,client:a})}}if(`evm_tx`in e){let{chain_id:t,to:n,value:r,data:i}=e.evm_tx,a=await y(),o=await a.getSigner();await df(a,D);let s=await o.sendTransaction({chainId:t,to:n,value:r,data:`0x${i}`}),c=ci(s.wait(),3e4,`Transaction was not confirmed in time. It may still be processing.`);return{txHash:s.hash,wait:c}}throw Error(`Unlisted chain type`)}catch(e){throw e instanceof si?e:await Ge(e)}},onSuccess:async({txHash:e,wait:t})=>{localStorage.removeItem(H.BRIDGE_QUANTITY),A.removeQueries({queryKey:rn.route._def}),A.removeQueries({queryKey:rn.routeErrorInfo._def}),r?r({txhash:e,chainId:h,timestamp:Date.now(),success:!0,route:p,values:m}):(i(-1),a({type:`loading`,title:`Transaction is pending...`}));try{await t;let n=wf(p)===Cf.OP_WITHDRAW,i=n?{success:!0,error:null}:await bf(ne,e,h);!r&&!i.success&&i.error&&a({type:`error`,title:`Transaction tracking failed`,description:`Failed to track transaction: ${i.error instanceof Error?i.error.message:String(i.error)}. The transaction may still be processing.`,autoHide:!0});let u=i.success,d=vf({txHash:e,srcChainId:h,route:p,values:m,recipient:_},u);if(c(d.tx,d.details),r||o(hf(s)),l(`Bridge Transaction Success`,_f(m,e)),n){let e=ee(h).metadata?.op_bridge_id;if(e&&!await rf(te.restUrl,Number(e),p.dest_asset_denom)){let e=yf(d.tx,p,_);N(d.tx,e)}}}catch(t){let n=t instanceof Error?t.message:String(t);if(t instanceof si){let t=vf({txHash:e,srcChainId:h,route:p,values:m,recipient:_},!1);c(t.tx,t.details),r||o(gf(s))}else r?r({success:!1,error:n,route:p,values:m}):o({type:`error`,title:`Transaction not confirmed`,description:n});l(`Bridge Confirmation Failed`,{..._f(m,e),error:n,type:t instanceof si?`timeout`:`error`})}finally{A.invalidateQueries({queryKey:rn.balances(h,g).queryKey})}},onError:async e=>{let t=O===`initia`?await Ii(e,ee(h),j):e;r?r({success:!1,error:t.message,route:p,values:m}):a({type:`error`,title:`Transaction failed`,description:t.message}),l(`Bridge Transaction Failed`,{..._f(m),error:t.message})}})}function mf(){let e=an(),t=U(),n=Zr(),{route:r,values:i}=ff(),a=au(),o=Gr(),s=Kr();return(0,u.useMutation)({mutationFn:async()=>{try{let{chain_id:c,hook:l}=await e.post(`op-hook`,{json:{source_address:t,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:(0,d.InitiaAddress)(i.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await af(t,a(r.dest_asset_chain_id).rest);let u=await n(c,t,cf(l,{converters:o,fromAmino:s.fromAmino.bind(s)}),{amount:[],gas:`1`},``,{incrementSequence:c===i.srcChainId?2:0}),f=N.Tx.fromPartial({body:N.TxBody.decode(u.bodyBytes),authInfo:N.AuthInfo.decode(u.authInfoBytes),signatures:u.signatures});return{signer:t,hook:(0,_.toBase64)(N.Tx.encode(f).finish())}}catch(e){throw await Ge(e)}}})}function hf(e){return{type:`info`,title:`Transaction submitted`,description:(0,g.createElement)(g.Fragment,null,`Check `,(0,g.createElement)($t,{to:`/bridge/history`,onClick:e},`the activity page`),` for transaction status`),autoHide:!0}}function gf(e){return{type:`info`,title:`Transaction pending`,description:(0,g.createElement)(g.Fragment,null,`Confirmation is taking longer than expected. Check `,(0,g.createElement)($t,{to:`/bridge/history`,onClick:e},`the activity page`),` for updates`),autoHide:!0}}function _f(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function vf(e,t){let{txHash:n,srcChainId:r,route:i,values:a}=e,o={chainId:r,txHash:n},s=wf(i)===Cf.OP_WITHDRAW;return{tx:o,details:{...o,timestamp:Date.now(),route:i,values:a,state:s?`success`:void 0,tracked:t},isOpWithdraw:s}}function yf(e,t,n){return{...e,recipient:(0,d.InitiaAddress)(n).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function bf(e,t,n){for(let r=0;r<=30;r++)try{return await e.post(`v2/tx/track`,{json:{tx_hash:t,chain_id:n}}).json(),{success:!0,error:null}}catch(e){if(r===30)return{success:!1,error:await Ge(e)};await new Promise(e=>setTimeout(e,1e3))}return{success:!1,error:Error(`Maximum retries exceeded`)}}function xf(e){let{chainId:t,txHash:n,tracked:r}=e,i=an();return(0,u.useQuery)({queryKey:rn.txTrack(t,n).queryKey,queryFn:async()=>{try{return await i.post(`v2/tx/track`,{json:{tx_hash:n,chain_id:t}}).json()}catch(e){throw await Ge(e)}},select:({tx_hash:e})=>e,retry:6,retryDelay:5e3,staleTime:B.INFINITY,enabled:!r&&!!t&&!!n})}function Sf(e){let{timestamp:t,chainId:n,txHash:r,tracked:i,state:a}=e,o=an();return(0,u.useQuery)({queryKey:rn.txStatus(n,r).queryKey,queryFn:()=>o.get(`v2/tx/status`,{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&i&&!a,refetchInterval:({state:{data:n}})=>{if(!n)return!1;let{status:r}=n;if(r===`STATE_COMPLETED`)return!1;let i=t+e.route.estimated_route_duration_seconds*1e3,a=Math.floor((i-Date.now())/1e3);return a<=0?1e3:a<=300?5e3:60*1e3},staleTime:B.INFINITY})}var Cf=function(e){return e.OP_WITHDRAW=`OP Bridge withdrawal`,e.SKIP=`Skip`,e}({});function wf(e){let{operations:t,dest_asset_denom:n}=e;return(0,p.has)(`op_init_transfer`,(0,p.head)(t))&&n===`uinit`?Cf.OP_WITHDRAW:Cf.SKIP}var Tf={success:`_success_t4dfk_1`,error:`_error_t4dfk_5`},Ef=({tx:e})=>{let[t,n]=Wd(e);if(!t)throw Error(`Bridge history details not found`);let{data:r}=Sf(t),i=t.state??Df(r);switch((0,g.useEffect)(()=>{i!==`loading`&&n(e=>{if(!e)throw Error(`Bridge history details not found`);return{...e,tracked:!0,state:i}})},[n,i]),i){case`error`:return(0,y.jsx)(`div`,{className:Tf.error,children:(0,y.jsx)(L.IconCloseCircleFilled,{size:14})});case`success`:return(0,y.jsx)(`div`,{className:Tf.success,children:(0,y.jsx)(L.IconCheckCircleFilled,{size:14})});default:return(0,y.jsx)(uc,{size:14})}};function Df(e){if(!e)return`loading`;switch(e.state){case`STATE_ABANDONED`:case`STATE_COMPLETED_ERROR`:case`STATE_PENDING_ERROR`:return`error`;case`STATE_COMPLETED_SUCCESS`:return`success`;default:return`loading`}}var Of={link:`_link_104m3_1`,header:`_header_104m3_23`,title:`_title_104m3_31`,date:`_date_104m3_37`,explorer:`_explorer_104m3_41`,divider:`_divider_104m3_49`,fees:`_fees_104m3_57`,label:`_label_104m3_65`,content:`_content_104m3_69`,route:`_route_104m3_75`,row:`_row_104m3_80`,asset:`_asset_104m3_86`,amount:`_amount_104m3_94`,chain:`_chain_104m3_99`,account:`_account_104m3_108`,arrow:`_arrow_104m3_115`},kf=({tx:e})=>{let[t,n]=Wd(e);if(!t)throw Error(`Bridge history details not found`);let{chainId:r,txHash:i,route:a,values:o,timestamp:s,tracked:c}=t,{data:u}=xf(t),{address:f=``,connector:p}=(0,l.useAccount)(),{find:m}=nd();(0,g.useEffect)(()=>{u&&n(e=>{if(!e)throw Error(`Bridge history details not found`);return{...e,tracked:!0}})},[n,u]);let{amount_in:h,amount_out:_,source_asset_chain_id:v,source_asset_denom:b,dest_asset_chain_id:x,dest_asset_denom:S,estimated_fees:C=[]}=a,w=ou(v),T=ou(x),E=vu(b,v),D=vu(S,x),O=(e,t)=>t?(0,y.jsx)(K,{src:t,width:12,height:12}):d.InitiaAddress.equals(e,f)?(0,y.jsx)(K,{src:p?.icon,width:12,height:12}):(0,y.jsx)(L.IconWallet,{size:12}),k=(e,{symbol:t,decimals:n,logo_uri:r},{chain_name:i,pretty_name:a,...o},s,c)=>(0,y.jsxs)(`div`,{className:Of.row,children:[(0,y.jsx)(od,{assetLogoUrl:r,chainLogoUrl:o.logo_uri??void 0}),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:Of.asset,children:[(0,y.jsx)(`span`,{className:Of.amount,children:(0,d.formatAmount)(e,{decimals:n})}),(0,y.jsx)(`span`,{children:t})]}),(0,y.jsxs)(`div`,{className:Of.chain,children:[(0,y.jsxs)(`span`,{children:[`on `,a||i]}),(0,y.jsxs)(`div`,{className:Of.account,children:[c,(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(s)})]})]})]})]}),A=wf(a),j=(0,g.useMemo)(()=>{switch(A){case Cf.SKIP:return`Skip Explorer`;case Cf.OP_WITHDRAW:return`Initia Scan`}},[A]),M=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`header`,{className:Of.header,children:[(0,y.jsxs)(`div`,{className:Of.title,children:[c?(0,y.jsx)(Ef,{tx:e}):(0,y.jsx)(uc,{size:14}),(0,y.jsx)(`div`,{className:Of.date,children:(0,oe.format)(new Date(s),`h:mm a`)})]}),(0,y.jsxs)(`div`,{className:Of.explorer,children:[(0,y.jsx)(`span`,{children:j}),(0,y.jsx)(L.IconExternalLink,{size:12,"aria-hidden":`true`})]})]}),(0,y.jsxs)(`div`,{className:Of.route,children:[k(h,E,w,o.sender,O(o.sender,m(o.cosmosWalletName)?.image)),(0,y.jsx)(`div`,{className:Of.arrow,children:(0,y.jsx)(L.IconArrowDown,{size:12,"aria-hidden":`true`})}),k(_,D,T,o.recipient,O(o.recipient))]}),C.length>0&&(0,y.jsxs)(`div`,{className:Of.fees,children:[(0,y.jsx)(`span`,{className:Of.label,children:`Fees`}),(0,y.jsx)(`span`,{className:Of.content,children:qu(C)})]})]});if(A===Cf.OP_WITHDRAW)return(0,y.jsx)(Nc,{chainId:r,txHash:i,className:Of.link,children:M});let ee=new URLSearchParams({tx_hash:i,chain_id:r});return(0,y.jsx)(`a`,{href:new URL(`?${ee.toString()}`,`https://explorer.skip.build`).toString(),className:Of.link,target:`_blank`,rel:`noopener noreferrer`,children:M})},Af={history:`_history_13u9z_1`,header:`_header_13u9z_5`,checkbox:`_checkbox_13u9z_9`,groups:`_groups_13u9z_13`,dateGroup:`_dateGroup_13u9z_21`,dateHeader:`_dateHeader_13u9z_26`,list:`_list_13u9z_32`},jf=()=>{let{initiaAddress:e,hexAddress:t}=Pa(),{history:n,getHistoryDetails:r}=Ud(),i=n.filter(e=>r(e)),a=i.filter(n=>{let i=r(n);if(!i)return!1;let{values:a}=i,{sender:o,recipient:s}=a;return[o,s].some(n=>[e,t].includes(n))}),[o,s]=(0,g.useState)(1),[c,l]=(0,le.useToggle)(!a.length),u=c?i:a,d=u.slice(0,o*10),f=(0,g.useMemo)(()=>Vd(d,e=>{let t=r(e);if(t)return new Date(t.timestamp)}),[d,r]);return(0,y.jsx)($l,{title:`Bridge/Swap activity`,children:(0,y.jsxs)(`div`,{className:Af.history,children:[i.length>0&&i.length!==a.length&&(0,y.jsx)(`header`,{className:Af.header,children:(0,y.jsx)(Rd,{checked:c,onClick:l,label:`Show all transactions stored in this browser`,className:Af.checkbox})}),u.length===0?(0,y.jsx)(Ia,{children:`No bridge/swap activity`}):(0,y.jsx)(`div`,{className:Af.groups,children:Object.entries(f).map(([e,t])=>(0,y.jsxs)(`div`,{className:Af.dateGroup,children:[(0,y.jsx)(`div`,{className:Af.dateHeader,children:e}),(0,y.jsx)(`div`,{className:Af.list,children:t.map(e=>(0,y.jsx)(W,{children:(0,y.jsx)(kf,{tx:e})},e.txHash))})]},e))}),u.length>o*10?(0,y.jsx)(Bd,{onClick:()=>s(e=>e+1)}):n.length>=100&&(0,y.jsxs)(Ia,{children:[`Only the latest `,100,` items are stored. Older entries will be removed automatically.`]})]})})};function Mf({currentState:e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:i}){return{...e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:i}}function Nf({currentState:e,route:t,values:n,quoteVerifiedAt:r}){return Mf({currentState:e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:!0})}function Pf({currentState:e,route:t,values:n,quoteVerifiedAt:r}){return Mf({currentState:e,route:t,values:n,quoteVerifiedAt:r,requiresReconfirm:!1})}var Ff=1e4;function If(e){return e===void 0?`undefined`:typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(If).join(`,`)}]`:`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${If(t)}`).join(`,`)}}`}function Lf(e){return If({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Rf(e,t,n){let r=Zt(),i=Yt(),a=(0,u.useQueryClient)(),o=an(),[s,c]=(0,g.useState)(!1),[l,d]=(0,g.useState)(void 0),[f,p]=(0,g.useState)(n??0),m=(0,g.useRef)(null);return(0,g.useEffect)(()=>{p(n??0)},[n]),(0,g.useEffect)(()=>()=>{m.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{let s=Math.max(n??0,f);if(Date.now()-s<=Ff)return!1;c(!0),d(void 0);let l=new AbortController;m.current=l;try{let n=await Ju(o,a,t,{isOpWithdraw:wf(e)===Cf.OP_WITHDRAW,signal:l.signal});if(l.signal.aborted)return!0;let s=Lf(n)!==Lf(e),c=Date.now();return s?(r(0,Nf({currentState:i,route:n,values:t,quoteVerifiedAt:c})),!0):(p(c),!1)}catch(e){return e instanceof DOMException&&e.name===`AbortError`||l.signal.aborted||d((await Ge(e)).message),!0}finally{m.current===l&&(m.current=null),l.signal.aborted||c(!1)}},isRefreshing:s,refreshError:l,clearRefreshError:()=>d(void 0)}}function zf(e,t){return t?`Confirm updated route`:e||`Confirm`}function Bf({error:e,warning:t,messageRefreshError:n,refreshError:r,requiresReconfirm:i}){if(e)return{level:`error`,text:e};if(n)return{level:`error`,text:n};if(r)return{level:`error`,text:r};if(t)return{level:`warning`,text:t};if(i)return{level:`info`,text:`Route updated. Please review and confirm again.`}}function Vf({isCheckingApprovals:e,isCheckingFeeBalance:t,isFetchingMessages:n,isEstimatingGas:r,isRouteTransitioning:i}){return i?`Refreshing route...`:n?`Fetching messages...`:t?`Checking fee balance...`:e?`Checking approvals...`:r?`Estimating gas...`:!1}function Hf({isRefreshing:e,isPending:t,backgroundLoadingText:n}){return e?`Refreshing route...`:t?`Signing transaction...`:n}var Uf=({tx:e,fee:t,onCompleted:n,confirmMessage:r,error:i,warning:a,isCheckingApprovals:o,isCheckingFeeBalance:s,messageRefreshError:c,isRouteTransitioning:l,isFetchingMessages:u,isEstimatingGas:d})=>{let f=Zt(),p=Yt(),{route:m,values:h,quoteVerifiedAt:g,requiresReconfirm:_}=ff(),{mutate:v,isPending:b}=pf(e,{customFee:t,onCompleted:n}),{refreshRouteIfNeeded:x,isRefreshing:S,refreshError:C,clearRefreshError:w}=Rf(m,h,g),T=Vf({isCheckingApprovals:o,isCheckingFeeBalance:s,isFetchingMessages:u,isEstimatingGas:d,isRouteTransitioning:l}),E=async()=>{if(!(b||S||T||c)){if(_){f(0,Pf({currentState:p,route:m,values:h,quoteVerifiedAt:g??Date.now()}));return}await x()||(w(),v())}},D=Bf({error:i,warning:a,messageRefreshError:c,refreshError:C,requiresReconfirm:_}),O=Hf({isRefreshing:S,isPending:b,backgroundLoadingText:T}),k=b||S||!!T||!!c;return(0,y.jsx)(mc,{extra:D&&(0,y.jsx)(el,{level:D.level,children:D.text}),children:(0,y.jsx)(G.White,{onClick:E,loading:O,disabled:!!i||!!a||k,children:zf(r,!!_)})})};function Wf({approvalError:e,approveTokens:t,exactFeeCheckError:n,isApproving:r,isCheckingApprovals:i,isCheckingFeeBalance:a,isFetchingMessages:o,messageRefreshError:s,requiresApproval:c}){return o||s?{kind:`preview`,isFetchingMessages:o,messageRefreshError:s}:a?{kind:`preview`,isCheckingFeeBalance:!0}:n?{kind:`preview`,error:n}:i?{kind:`preview`,isCheckingApprovals:!0}:c&&t?{kind:`approval`,approvalError:e,approveTokens:t,isApproving:!!r}:{kind:`preview`}}var Gf={content:`_content_1hzj2_1`,info:`_info_1hzj2_6`,arrow:`_arrow_1hzj2_11`,divider:`_divider_1hzj2_19`,type:`_type_1hzj2_27`,asset:`_asset_1hzj2_47`,amount:`_amount_1hzj2_55`,lower:`_lower_1hzj2_60`,chain:`_chain_1hzj2_66`,address:`_address_1hzj2_72`},Kf=e=>{let{source:t,label:n,amount:r,denom:i,chainId:a,address:o,walletIcon:s}=e,{symbol:c=(0,d.truncate)(i),decimals:l=0,logo_uri:u=st}=e,{chain_name:f,pretty_name:p,...m}=ou(a);return(0,y.jsxs)(`div`,{children:[!t&&(0,y.jsxs)(`div`,{className:Gf.arrow,children:[(0,y.jsx)(`div`,{className:Gf.divider}),n?(0,y.jsx)(Bu,{label:n,children:(0,y.jsx)(`button`,{className:Gf.type,"aria-label":n,children:(0,y.jsx)(L.IconArrowDown,{size:12})})}):(0,y.jsx)(`span`,{className:Gf.type,children:(0,y.jsx)(L.IconArrowDown,{size:12})}),(0,y.jsx)(`div`,{className:Gf.divider})]}),(0,y.jsxs)(`div`,{className:Gf.content,children:[(0,y.jsx)(od,{assetLogoUrl:u,chainLogoUrl:m.logo_uri??void 0}),(0,y.jsxs)(`div`,{className:Gf.info,children:[(0,y.jsxs)(`div`,{className:Gf.asset,children:[(0,y.jsx)(`span`,{className:Gf.amount,children:(0,d.formatAmount)(r,{decimals:l})}),(0,y.jsx)(`span`,{children:c})]}),(0,y.jsxs)(`div`,{className:Gf.lower,children:[(0,y.jsxs)(`div`,{className:Gf.chain,children:[`on `,p||f]}),o&&(0,y.jsx)(Lc,{value:o,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{className:Gf.address,onClick:e,children:[s,t?(0,y.jsx)(`span`,{children:`Copied!`}):(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.truncate)(o)})]})})]})]})]})]})},qf=e=>{let t=vu(e.denom,e.chainId);return(0,y.jsx)(Kf,{...e,...t})};qf.Placeholder=Kf;var Jf={root:`_root_1hbar_1`,flexEnd:`_flexEnd_1hbar_6`,toggle:`_toggle_1hbar_11`,route:`_route_1hbar_36`,content:`_content_1hbar_43`,slideDown:`_slideDown_1hbar_1`,slideUp:`_slideUp_1hbar_1`};function Yf(e){let t=({name:e})=>e===`initia-dex`?`Initia DEX`:(0,me.capitalCase)((0,p.head)(e?.split(`-`)??[])??``);if(`transfer`in e)return{label:`Bridge via IBC`,...e,...e.transfer};if(`bank_send`in e)return{label:`Send`,...e,...e.bank_send};if(`swap`in e){let n=e.swap?.swap_venues?.map(t).join(`, `);return{label:n?`Swap on ${n}`:`Swap`,...e,...e.swap}}if(`axelar_transfer`in e)return{label:`Bridge via Axelar`,...e,...e.axelar_transfer};if(`cctp_transfer`in e)return{label:`Bridge via CCTP`,...e,...e.cctp_transfer};if(`hyperlane_transfer`in e)return{label:`Bridge via Hyperlane`,...e,...e.hyperlane_transfer};if(`evm_swap`in e){let n=e.evm_swap?.swap_venues?.map(t).join(`, `);return{label:n?`Swap on ${n}`:`Swap`,...e,...e.evm_swap}}if(`op_init_transfer`in e)return{label:`Bridge via OP Bridge`,...e,...e.op_init_transfer};if(`go_fast_transfer`in e)return{label:`Bridge via Go Fast`,...e,...e.go_fast_transfer};if(`eureka_transfer`in e)return{label:`Bridge via Eureka`,...e,...e.eureka_transfer};if(`stargate_transfer`in e)return{label:`Bridge via Stargate`,...e,...e.stargate_transfer};if(`layer_zero_transfer`in e)return{label:`Bridge via LayerZero`,...e,...e.layer_zero_transfer};throw Error(`Unknown operation type`)}var Xf=({addressList:e})=>{let{values:t,route:n}=ff(),{source_asset_denom:r,source_asset_chain_id:i,amount_in:a,operations:o}=n,s=(0,p.zipObj)(n.required_chain_addresses,e),{find:c}=nd(),{connector:u,address:f=``}=(0,l.useAccount)(),[m,h]=(0,le.useToggle)(!1),g=o.length>1,_=(0,y.jsx)(K,{src:t.cosmosWalletName?c(t.cosmosWalletName)?.image:u?.icon,width:12,height:12}),v={amount:a,denom:r,chainId:i,address:t.sender,walletIcon:_},b=e=>d.InitiaAddress.equals(e,f)?_:(0,y.jsx)(L.IconWallet,{size:11}),x=o.map(Yf).map(e=>{let{label:t,amount_out:n,denom:r,denom_out:i=r,chain_id:a,from_chain_id:o,to_chain_id:c=a??o}=e,l=s[c];return{label:g&&!m?void 0:t,amount:n,denom:i,chainId:c,address:l,walletIcon:b(l)}}),S=x.slice(0,-1),C=x[x.length-1];return(0,y.jsxs)(P.Collapsible.Root,{className:Jf.root,open:m,onOpenChange:h,children:[g&&(0,y.jsx)(`div`,{className:Jf.flexEnd,children:(0,y.jsx)(P.Collapsible.Trigger,{className:Jf.toggle,children:m?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(L.IconMinus,{size:12}),(0,y.jsx)(`span`,{children:`Hide details`})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(L.IconList,{size:12}),(0,y.jsx)(`span`,{children:`Show details`})]})})}),(0,y.jsxs)(`div`,{className:Jf.route,children:[(0,y.jsx)(qf,{...v,source:!0}),(0,y.jsx)(P.Collapsible.Content,{className:Jf.content,children:S.map((e,t)=>(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(qf.Placeholder,{...e}),errorBoundaryProps:{fallback:(0,y.jsx)(qf.Placeholder,{...e})},children:(0,y.jsx)(qf,{...e})},t))}),(0,y.jsx)(qf,{...C})]})]})},Zf=({error:e})=>{let t=Zt();return(0,y.jsx)(mc,{extra:(0,y.jsx)(el,{level:`error`,children:e.message}),children:(0,y.jsx)(G.White,{onClick:()=>t(`/bridge`),children:`Home`})})},Qf=({children:e})=>{let{route:t,values:n}=ff(),{required_chain_addresses:r}=t,{srcChainId:i,dstChainId:a,sender:o,recipient:s}=n,{initiaAddress:c,hexAddress:l}=Pa(),u=ei(),f=au(),p=nu(),m=p(f(i)),h=r.slice(0,-1).some(e=>p(f(e))===`cosmos`)&&m!==`cosmos`,[v,b]=(0,g.useState)(void 0),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let e=!1;return(async()=>{try{if(b(void 0),w(null),!h)return;if(!u)throw Error(`Wallet not connected`);S(!0);let[{pubkey:t}]=await u.getAccounts();if(e)return;b(t)}catch(t){let n=await Ge(t);if(e)return;w(n)}finally{e||S(!1)}})(),()=>{e=!0}},[h,u]),C?(0,y.jsx)(Zf,{error:C}):x?(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{loading:x&&`Generating intermediary addresses...`})}):!h||v?e(r.map((e,t)=>{if(t===r.length-1)return p(f(a))===`initia`?(0,d.InitiaAddress)(s).bech32:s;let n=f(e),u=p(n),m=p(f(i));switch(u){case`initia`:return c;case`evm`:return l;case`cosmos`:if(m===`cosmos`)return(0,_.toBech32)(n.bech32_prefix,(0,_.fromBech32)(o).data);if(!v)throw Error(`Pubkey not found`);return(0,E.pubkeyToAddress)((0,E.encodeSecp256k1Pubkey)(v),n.bech32_prefix);default:throw Error(`Unlisted chain type`)}})):null};function $f(e){return`evm_tx`in e?JSON.stringify({approvals:e.evm_tx.required_erc20_approvals??[],chainId:e.evm_tx.chain_id,signerAddress:e.evm_tx.signer_address}):`non-evm`}function ep({currentKey:e,isPending:t,nextKey:n}){return!t&&e!==n}function tp(e,t){return typeof e==`function`?e(t):t.isCheckingApprovals?(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{loading:`Checking approvals...`})}):t.requiresApproval&&t.approveTokens?(0,y.jsx)(mc,{extra:(0,y.jsx)(el,{level:`error`,children:t.approvalError}),children:(0,y.jsx)(G.White,{onClick:t.approveTokens,loading:t.isApproving&&`Approving tokens...`,children:`Approve tokens`})}):e}var np=({tx:e,children:t})=>{let n=oi(),r=au(),i=(0,u.useQueryClient)(),a=$f(e),o=(0,g.useRef)(a),{data:s,isLoading:c}=(0,u.useQuery)({queryKey:[`interwovenkit:erc20-approvals-needed`,e],queryFn:async()=>{if(!(`evm_tx`in e)||!e.evm_tx.required_erc20_approvals)return[];let{chain_id:t,signer_address:i}=e.evm_tx,a=await n();await df(a,r(t));let o=[`function allowance(address owner, address spender) view returns (uint256)`];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async e=>{let{token_contract:t,spender:n}=e,r=await new w.ethers.Contract(t,o,a).allowance(i,n);return{approval:e,currentAllowance:BigInt(r.toString())}}))).filter(({approval:e,currentAllowance:t})=>t<BigInt(e.amount)).map(({approval:e})=>e)},enabled:!!e&&`evm_tx`in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:l,data:d,isPending:f,error:p,reset:m}=(0,u.useMutation)({mutationFn:async()=>{try{if(!(`evm_tx`in e))throw Error(`Transaction is not EVM`);if(!s||s.length===0)throw Error(`No approvals needed`);let{chain_id:t}=e.evm_tx,i=await n(),a=await i.getSigner();await df(i,r(t));for(let e of s){let{token_contract:t,spender:n,amount:r}=e;await ci((await new w.ethers.Contract(t,[`function approve(address spender, uint256 amount) external returns (bool)`],a).approve(n,r)).wait(),3e4,`Approval was not confirmed in time. It may still be processing.`)}return!0}catch(t){throw t instanceof si?(i.invalidateQueries({queryKey:[`interwovenkit:erc20-approvals-needed`,e]}),t):await Ge(t)}}});return(0,g.useEffect)(()=>{let e=o.current;ep({currentKey:e,isPending:f,nextKey:a})&&(o.current=a,m())},[a,f,m]),tp(t,{approvalError:p?.message,approveTokens:s&&s.length>0&&!d?()=>l():void 0,isApproving:f,isCheckingApprovals:c,requiresApproval:!!s&&s.length>0&&!d})};function rp({route:e,tx:t,isSrcInitia:n,isDstInitia:r,sender:i,recipient:a}){return!!e&&`cosmos_tx`in t&&!!t.cosmos_tx.msgs?.length&&!e.required_op_hook&&n&&r&&!!i&&!!a}function ip({hasBalances:e,hasChain:t,requiresExactFeeCheck:n}){return n&&e&&t}function ap({balances:e,feeDenoms:t}){return e?[...t].sort().map(t=>`${t}:${e[t]?.amount??`0`}`).join(`|`):``}function op({tx:e,children:t}){let{route:n,values:r}=ff(),{sender:i,recipient:a,srcChainId:o,srcDenom:s,dstChainId:c}=r,l=ou(o),d=ou(c),f=ru(l),p=ru(d),{data:m,isLoading:h,error:g}=Vu(i,o),_=Gr(),v=Kr(),y=ai(),b=rp({route:n,tx:e,isSrcInitia:f===`initia`,isDstInitia:p===`initia`,sender:i,recipient:a}),{chain:x,error:S,isLoading:C}=nt(o,b),w=ap({balances:m,feeDenoms:x?Array.from(new Set([s,...x.fees.fee_tokens.map(({denom:e})=>e)])):[]}),T=ip({hasBalances:m!==void 0,hasChain:!!x,requiresExactFeeCheck:b}),{data:E,error:D,isLoading:O}=(0,u.useQuery)({queryKey:[`interwovenkit:bridge-preview-fee-check`,e,i,o,s,n.amount_in,w],queryFn:async()=>{try{if(!(b&&x&&`cosmos_tx`in e&&e.cosmos_tx.msgs?.length&&m))throw Error(`Invalid transaction data`);let t=cf(e.cosmos_tx.msgs,{converters:_,fromAmino:v.fromAmino.bind(v)});return uf({balances:m,requiredFeeByDenom:lf({gas:await(await y(o)).simulate(i,t,``),gasPrices:await Ui(x)}),sourceDenom:s,amountIn:n.amount_in})}catch(e){throw await Ge(e)}},enabled:T,retry:!1});return t(b?S?{exactFeeCheckError:S.message,isCheckingFeeBalance:!1}:g?{exactFeeCheckError:g instanceof Error?g.message:`Failed to load balances`,isCheckingFeeBalance:!1}:C||h||m===void 0||O?{isCheckingFeeBalance:!0}:D?{exactFeeCheckError:D.message,isCheckingFeeBalance:!1}:E?{isCheckingFeeBalance:!1}:{exactFeeCheckError:`Insufficient balance for fees`,isCheckingFeeBalance:!1}:{isCheckingFeeBalance:!1})}function sp({addressList:e,operations:t,signedOpHook:n}){return JSON.stringify({addressList:e,operations:t,signedOpHook:n??null})}function cp({previousQuoteVerifiedAt:e,quoteVerifiedAt:t,hasValue:n,hasMessageRefreshError:r}){return n&&r&&e!==void 0&&t!==void 0&&t!==e}function lp({error:e,loading:t,value:n}){let r=n!==void 0;return{isFetchingMessages:t,messageRefreshError:!t&&r&&e?e.message:void 0,shouldRenderError:!!e&&!r,shouldRenderLoading:!r}}var up=({addressList:e,signedOpHook:t,children:n})=>{let r=an(),{route:i,values:a,quoteVerifiedAt:o}=ff(),[s,c]=(0,g.useState)(void 0),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(0),h=(0,g.useRef)(o),_=sp({addressList:e,operations:i.operations,signedOpHook:t});(0,g.useEffect)(()=>{let e=h.current;cp({previousQuoteVerifiedAt:e,quoteVerifiedAt:o,hasValue:s!==void 0,hasMessageRefreshError:d!==null})&&m(e=>e+1),h.current=o},[o,s,d]),(0,g.useEffect)(()=>{let n=!1;return(async()=>{try{if(u(!0),f(null),i.required_op_hook&&!t)throw Error(`Op hook is required`);let o=await sf(r,{addressList:e,route:{amount_in:i.amount_in,amount_out:i.amount_out,source_asset_chain_id:i.source_asset_chain_id,source_asset_denom:i.source_asset_denom,dest_asset_chain_id:i.dest_asset_chain_id,dest_asset_denom:i.dest_asset_denom,operations:i.operations},slippagePercent:String(a.slippagePercent),signedOpHook:t});if(n)return;let[s]=o;c(s)}catch(e){let t=await Ge(e);if(n)return;f(t)}finally{n||u(!1)}})(),()=>{n=!0}},[_,p,i.amount_in,i.amount_out,i.source_asset_chain_id,i.source_asset_denom,i.dest_asset_chain_id,i.dest_asset_denom,i.required_op_hook,a.slippagePercent,r]);let v=lp({error:d,loading:l,value:s});return v.shouldRenderError&&d?(0,y.jsx)(Zf,{error:d}):v.shouldRenderLoading?(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{loading:`Fetching messages...`})}):n(s,{isFetchingMessages:v.isFetchingMessages,messageRefreshError:v.messageRefreshError})},dp=({children:e})=>{let{route:t}=ff(),n=mf();return t.required_op_hook&&!n.data?(0,y.jsx)(mc,{extra:(0,y.jsx)(el,{level:`error`,children:n.error?.message}),children:(0,y.jsx)(G.White,{onClick:()=>n.mutate(),loading:n.isPending&&`Awaiting signature...`,children:`Authorize conversion`})}):e(n.data)};function fp({approvalError:e,approveTokens:t,isApproving:n}){return(0,y.jsx)(mc,{extra:e&&(0,y.jsx)(el,{level:`error`,children:e}),children:(0,y.jsx)(G.White,{onClick:t,loading:n&&`Approving tokens...`,children:`Approve tokens`})})}var pp=()=>(0,y.jsx)($l,{title:`Route preview`,children:(0,y.jsx)(Qf,{children:e=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Xf,{addressList:e}),(0,y.jsx)(dp,{children:t=>(0,y.jsx)(up,{addressList:e,signedOpHook:t,children:(e,{isFetchingMessages:t,messageRefreshError:n})=>(0,y.jsx)(op,{tx:e,children:({exactFeeCheckError:r,isCheckingFeeBalance:i})=>(0,y.jsx)(np,{tx:e,children:({approvalError:a,approveTokens:o,isApproving:s,isCheckingApprovals:c,requiresApproval:l})=>{let u=Wf({approvalError:a,approveTokens:o,exactFeeCheckError:r,isApproving:s,isCheckingApprovals:c,isCheckingFeeBalance:i,isFetchingMessages:t,messageRefreshError:n,requiresApproval:l});return u.kind===`approval`?fp({approvalError:u.approvalError,approveTokens:u.approveTokens,isApproving:u.isApproving}):(0,y.jsx)(Uf,{tx:e,error:u.error,isCheckingApprovals:u.isCheckingApprovals,isCheckingFeeBalance:u.isCheckingFeeBalance,isFetchingMessages:u.isFetchingMessages,messageRefreshError:u.messageRefreshError})}})})})})]})})}),mp=(0,g.createContext)(null);function hp(){return(0,g.useContext)(mp)}var gp={button:`_button_17r1o_1`,claimed:`_claimed_17r1o_24`},_p=()=>{let{withdrawalTx:e}=hp(),{bridge_id:t,sequence:n,amount:r,output_index:i,withdrawal_proofs:a,storage_root:o,from:s,to:c,version:l}=e,d=V(),f=U(),{requestTxSync:p,waitForTxConfirmation:m}=Pa(),h=Qd(e),g=(0,_.toBase64)(nf(e)),v=$d(e,g),b=(0,u.useQueryClient)(),{mutate:x,isPending:S}=(0,u.useMutation)({mutationFn:async()=>{if(!h)throw Error(`Output not found`);let{last_block_hash:e}=h;return p({chainId:d.chain_id,messages:[{typeUrl:`/opinit.ophost.v1.MsgFinalizeTokenWithdrawal`,value:{sender:f,bridgeId:BigInt(t),outputIndex:BigInt(i),withdrawalProofs:a.map(_.fromBase64),from:s,to:c,sequence:BigInt(n),amount:r,version:(0,_.fromBase64)(l),storageRoot:(0,_.fromBase64)(o),lastBlockHash:(0,_.fromBase64)(e)}}],internal:!0})},onSuccess:async e=>{await m({chainId:d.chain_id,txHash:e}),b.invalidateQueries({queryKey:Gd.withdrawalClaimed(t,g).queryKey})}});return v?(0,y.jsxs)(`div`,{className:gp.claimed,children:[(0,y.jsx)(L.IconCheckCircleFilled,{size:14}),(0,y.jsx)(`span`,{children:`Claimed`})]}):(0,y.jsx)(`button`,{className:gp.button,onClick:()=>x(),disabled:S,children:`Claim`})},vp=({children:e})=>{let{withdrawalTx:t}=hp(),n=qd(t.bridge_id),r=Zd(t);return e((0,g.useMemo)(()=>{if(!r)return null;let{bridge_config:e}=n,{output_proposal:t}=r;return(0,oe.addSeconds)(new Date(t.l1_block_time),parseFloat(e.finalization_period))},[n,r]))},yp=1e3,bp=60,xp=60,Sp=24,Cp=yp*bp,wp=Cp*xp,Tp=wp*Sp,Ep=({date:e})=>{let t=(0,g.useCallback)(()=>{let t=new Date().getTime(),n=e.getTime()-t;return n<=0?{days:0,hours:0,minutes:0,seconds:0}:{days:Math.floor(n/Tp),hours:Math.floor(n%Tp/wp),minutes:Math.floor(n%wp/Cp),seconds:Math.floor(n%Cp/yp)}},[e]),[n,r]=(0,g.useState)(t());(0,g.useEffect)(()=>{let e=window.setInterval(()=>{r(t())},1e3);return()=>window.clearInterval(e)},[t,e]);let i=e=>e.toString().padStart(2,`0`),{days:a,hours:o,minutes:s,seconds:c}=n;return(0,y.jsx)(Bu,{label:e.toLocaleString(),children:(0,y.jsxs)(`span`,{className:`monospace`,children:[a,`d `,i(o),`h `,i(s),`m `,i(c),`s`]})})},Dp={container:`_container_1lz3w_1`,title:`_title_1lz3w_5`},Op=({date:e})=>(0,y.jsxs)(`div`,{className:Dp.container,children:[(0,y.jsx)(`div`,{className:Dp.title,children:`Claimable in`}),(0,y.jsx)(Ep,{date:e})]}),kp={container:`_container_1oldz_1`,icon:`_icon_1oldz_7`},Ap=`Withdrawal will begin within an hour`,jp=()=>{let e=bc();return(0,y.jsxs)(`div`,{className:kp.container,children:[(0,y.jsx)(`span`,{children:`In progress`}),!e&&(0,y.jsx)(Bu,{label:Ap,children:(0,y.jsx)(`span`,{className:kp.icon,children:(0,y.jsx)(L.IconInfoFilled,{size:12})})})]})},Mp=({children:e})=>{let{withdrawalTx:t}=hp(),n=Xd(t.bridge_id);return e(t.output_index>Number(n?.output_index))},Np=({date:e,children:t})=>{let{chainId:n,withdrawalTx:r}=hp(),i=$d(r,(0,_.toBase64)(nf(r))),{setReminder:a,removeReminder:o}=Eu();return(0,g.useEffect)(()=>{let t={chainId:n,txHash:r.tx_hash};i?o(t):a(t,{...t,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:(0,oe.isPast)(e.getTime())?!0:void 0})},[n,i,e,o,a,r]),t},Pp=()=>(0,y.jsx)(Mp,{children:e=>e?(0,y.jsx)(jp,{}):(0,y.jsx)(vp,{children:e=>e?(0,y.jsx)(Np,{date:e,children:(0,oe.isFuture)(e)?(0,y.jsx)(Op,{date:e}):(0,y.jsx)(_p,{})}):(0,y.jsx)(jp,{})})}),Fp={asset:`_asset_6h8u2_1`,info:`_info_6h8u2_7`,symbol:`_symbol_6h8u2_11`},Ip=({amount:e,denom:t})=>{let{symbol:n,logoUrl:r,decimals:i}=mt(t,V());return(0,y.jsxs)(`div`,{className:Fp.asset,children:[(0,y.jsx)(K,{src:r,width:32,height:32,logo:!0}),(0,y.jsxs)(`div`,{className:Fp.info,children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.formatAmount)(e,{decimals:i})}),(0,y.jsx)(`span`,{className:Fp.symbol,children:n})]})]})},Lp={item:`_item_km5w2_1`,more:`_more_km5w2_12`},Rp=({chain:e})=>{let t=e.metadata?.executor_uri;if(!t)throw Error(`Executor URL is not defined`);let{data:n,fetchNextPage:r,hasNextPage:i,isFetching:a}=Yd(t),o=(0,g.useMemo)(()=>n?.pages.flat()??[],[n]),{syncReminders:s}=Eu();return(0,g.useEffect)(()=>{s(o.map(t=>({chainId:e.chainId,txHash:t.tx_hash})))},[e.chainId,o,s]),o.length?(0,y.jsxs)(y.Fragment,{children:[o.map(t=>{let{amount:n}=t;return(0,y.jsxs)(`div`,{className:Lp.item,children:[(0,y.jsx)(Ip,{...n}),(0,y.jsx)(W,{suspenseFallback:null,children:(0,y.jsx)(mp.Provider,{value:{chainId:e.chainId,withdrawalTx:t},children:(0,y.jsx)(Pp,{})})})]},t.sequence)}),i&&(0,y.jsx)(Bd,{onClick:()=>r(),disabled:a})]}):(0,y.jsx)(Ia,{children:`No withdrawals`})},zp={content:`_content_dj1qm_1`,title:`_title_dj1qm_5`},Bp=()=>{let{chainId:e}=Yt(),t=Ze(),n=rt(),[r,i]=(0,g.useState)(e??(n.metadata?.is_l1?``:n.chainId)),a=et(),{reminders:o}=Eu(),s=r?a(r):void 0;return(0,y.jsxs)($l,{title:`OP Bridge withdrawals`,children:[(0,y.jsx)(vd,{chains:t.filter(({metadata:e})=>!e?.is_l1&&e?.op_denoms?.length),value:r,onSelect:i,getShowIndicator:e=>o.some(t=>t.chainId===e)}),(0,y.jsx)(`div`,{className:zp.content,children:s?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`h2`,{className:zp.title,children:s.name}),(0,y.jsx)(W,{children:(0,y.jsx)(Rp,{chain:s})},r)]}):(0,y.jsx)(el,{level:`info`,children:`Select a chain to display your OP Bridge withdrawals`})})]})},Vp=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,``),Hp=`https://explorer-api.walletconnect.com/v3/wallets?projectId=5722e7dffb709492cf5312446ceeff73`,Up=[`interwovenkit:walletconnect-wallets`],Wp=e=>typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`string`&&`name`in e&&typeof e.name==`string`,Gp=async e=>{let t=await h.default.get(Hp,{signal:e}).json(),n=typeof t==`object`&&t&&`listings`in t?t.listings:t;return Object.values(n??{}).filter(Wp)},Kp=()=>(0,u.useQuery)({queryKey:Up,queryFn:({signal:e})=>Gp(e),staleTime:B.INFINITY,gcTime:B.INFINITY,retry:2}),qp=new Set([`io.leapwallet`]),Jp=new Set([`leap`]),Yp=e=>qp.has(e.id)||Jp.has(Vp(e.name)),Y={page:`_page_13y8q_1`,slideFromLeft:`_slideFromLeft_13y8q_1`,pageTop:`_pageTop_13y8q_19`,slideFromRight:`_slideFromRight_13y8q_1`,backButtonFixed:`_backButtonFixed_13y8q_63`,listItem:`_listItem_13y8q_64`,socialButton:`_socialButton_13y8q_65`,arrowIcon:`_arrowIcon_13y8q_66`,searchInputUnderline:`_searchInputUnderline_13y8q_67`,header:`_header_13y8q_72`,title:`_title_13y8q_81`,headerSpacer:`_headerSpacer_13y8q_116`,icon:`_icon_13y8q_120`,installedText:`_installedText_13y8q_124`,divider:`_divider_13y8q_131`,dividerText:`_dividerText_13y8q_152`,loading:`_loading_13y8q_193`,socialIcons:`_socialIcons_13y8q_198`,socialText:`_socialText_13y8q_204`,searchWrapper:`_searchWrapper_13y8q_214`,scrollable:`_scrollable_13y8q_248`,list:`_list_13y8q_64`,listIconWrapper:`_listIconWrapper_13y8q_332`,moreIconSmall:`_moreIconSmall_13y8q_342`,externalLinkIcon:`_externalLinkIcon_13y8q_364`,listName:`_listName_13y8q_368`,listNameMuted:`_listNameMuted_13y8q_381`,recentBadge:`_recentBadge_13y8q_394`,learnMoreLink:`_learnMoreLink_13y8q_408`},Xp=e=>{try{let t=new URL(e.trim());return t.protocol===`https:`&&!t.username&&!t.password}catch{return!1}},Zp=({walletConnectors:e,isPending:t,pendingConnectorId:n,recentConnectorId:r,onConnect:i,onBack:a})=>{let[o,s]=(0,g.useState)(``),{data:c=[],isError:l,isLoading:u,isFetching:d}=Kp(),f=u||d&&c.length===0,p=(0,g.useMemo)(()=>{if(!o)return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[e,o]),m=(0,g.useMemo)(()=>{let t=new Set(e.map(e=>Vp(e.name))),n=o.toLowerCase();return c.filter(e=>!Yp(e)).filter(e=>!t.has(Vp(e.name))).filter(e=>!o||e.name.toLowerCase().includes(n)).sort((e,t)=>e.name.localeCompare(t.name))},[c,e,o]);return(0,y.jsxs)(`div`,{className:Y.pageTop,children:[(0,y.jsx)(`button`,{type:`button`,className:Y.backButtonFixed,onClick:a,"aria-label":`Back`,children:(0,y.jsx)(L.IconBack,{size:16,"aria-hidden":`true`})}),(0,y.jsxs)(`header`,{className:Y.header,children:[(0,y.jsx)(`div`,{className:Y.headerSpacer}),(0,y.jsx)(`h1`,{className:Y.title,children:`All Wallets`}),(0,y.jsx)(`div`,{className:Y.headerSpacer})]}),(0,y.jsx)(`div`,{className:Y.searchWrapper,children:(0,y.jsx)(dd,{rootClassName:Y.searchInputUnderline,placeholder:`Search Wallet`,"aria-label":`Search wallets`,value:o,onChange:e=>s(e.target.value),onClear:()=>s(``)})}),(0,y.jsx)(gc,{className:Y.scrollable,children:(0,y.jsxs)(`div`,{className:Y.list,children:[p.map(e=>{let{name:a,icon:o,id:s}=e,c=r===s,l=n===s,u=`ready`in e?!!e.ready:!0;return(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(Y.listItem,{[Y.loading]:l}),onClick:()=>i(e),disabled:t||!u,"aria-busy":l,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(K,{src:o,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listName,children:a}),l?(0,y.jsx)(uc,{size:16}):c?(0,y.jsx)(`span`,{className:Y.recentBadge,children:`Recent`}):u?(0,y.jsx)(`span`,{className:Y.installedText,children:`Installed`}):null]},`connector:${s}`)}),f&&(0,y.jsxs)(`div`,{className:(0,F.default)(Y.listItem,Y.loading),role:`status`,"aria-live":`polite`,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(uc,{size:16})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:`Loading more wallets...`})]}),m.map(e=>{let t=e.image_url?.sm||e.image_url?.md||e.image_url?.lg,n=t&&Xp(t)?t:void 0;return(0,y.jsxs)(`button`,{type:`button`,className:Y.listItem,disabled:!0,"aria-label":`${e.name} (not installed)`,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:n&&(0,y.jsx)(K,{src:n,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:e.name})]},`wc:${e.id}`)}),l&&(0,y.jsx)(el,{level:`error`,children:`Couldn't load additional wallets.`})]})})]})},Qp=(e,t,n,r)=>{if(n<=0)return[];if(e.length<=n)return[...e];let i=r?e.findIndex(e=>e.id===r):-1,a=i>=0?e[i]:void 0,o=i>=0?e.filter((e,t)=>t!==i):e,s=new Set(t.map(e=>e.id)),c=new Set(t.map(e=>Vp(e.name))),l=[],u=[];for(let e of o)s.has(e.id)||c.has(Vp(e.name))?l.push(e):u.push(e);return a?[a,...l,...u].slice(0,n):l.concat(u).slice(0,n)},$p=()=>(0,y.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,y.jsx)(`circle`,{cx:`4`,cy:`8`,r:`1.5`}),(0,y.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.5`}),(0,y.jsx)(`circle`,{cx:`12`,cy:`8`,r:`1.5`})]}),em=()=>(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{fill:`#4285F4`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,y.jsx)(`path`,{fill:`#34A853`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,y.jsx)(`path`,{fill:`#FBBC05`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,y.jsx)(`path`,{fill:`#EA4335`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]}),tm=()=>(0,y.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,y.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),nm=()=>(0,y.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,"aria-hidden":`true`,children:[(0,y.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`}),(0,y.jsx)(`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`})]}),rm=[{id:`io.rabby`,name:`Rabby`,icon:`https://assets.initia.xyz/images/wallets/Rabby.webp`,url:`https://rabby.io`},{id:`app.phantom`,name:`Phantom`,icon:`https://assets.initia.xyz/images/wallets/Phantom.webp`,url:`https://phantom.com`},{id:`app.keplr`,name:`Keplr`,icon:`https://assets.initia.xyz/images/wallets/Keplr.webp`,url:`https://keplr.app`},{id:`io.metamask`,name:`MetaMask`,icon:`https://assets.initia.xyz/images/wallets/MetaMask.webp`,url:`https://metamask.io`}],im=5,am=({walletConnectors:e,privyConnector:t,isPending:n,pendingConnectorId:r,recentConnectorId:i,onConnect:a,onShowAll:o,onPrefetchWallets:s})=>{let c=e.filter(e=>!(`ready`in e)||!!e.ready),l=Qp(c,rm,im,i),u=new Set(c.map(e=>e.id)),d=new Set(c.map(e=>Vp(e.name))),f=Math.max(0,im-l.length),p=rm.filter(e=>!u.has(e.id)&&!d.has(Vp(e.name))).slice(0,f);return(0,y.jsxs)(`div`,{className:Y.page,children:[(0,y.jsxs)(`header`,{className:Y.header,children:[(0,y.jsx)(`div`,{className:Y.headerSpacer}),(0,y.jsx)(`h1`,{className:Y.title,children:`Sign In`}),(0,y.jsx)(`div`,{className:Y.headerSpacer})]}),t&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(Y.socialButton,{[Y.loading]:r===t.id}),onClick:()=>a(t),disabled:n,"aria-busy":r===t.id,children:[(0,y.jsx)(`span`,{className:Y.socialText,children:`Email / Socials`}),r===t.id?(0,y.jsx)(uc,{size:16}):(0,y.jsxs)(`div`,{className:Y.socialIcons,children:[(0,y.jsx)(em,{}),(0,y.jsx)(nm,{}),(0,y.jsx)(tm,{})]})]}),(0,y.jsx)(`div`,{className:Y.divider,children:(0,y.jsx)(`span`,{className:Y.dividerText,children:`or`})})]}),(0,y.jsx)(gc,{className:Y.scrollable,children:(0,y.jsxs)(`div`,{className:Y.list,children:[l.map(e=>{let{icon:t,id:o,name:s,uid:c}=e,l=r===o,u=i===o;return(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(Y.listItem,{[Y.loading]:l}),onClick:()=>a(e),disabled:n,"aria-busy":l,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(K,{src:t,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listName,children:s}),l?(0,y.jsx)(uc,{size:16}):u?(0,y.jsx)(`span`,{className:Y.recentBadge,children:`Recent`}):(0,y.jsx)(`span`,{className:Y.installedText,children:`Installed`})]},c)}),p.map(e=>(0,y.jsxs)(`a`,{className:Y.listItem,href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`${e.name} (opens in new tab)`,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(K,{src:e.icon,width:26,height:26,alt:``,className:Y.icon})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:e.name}),(0,y.jsx)(L.IconExternalLink,{size:10,className:Y.externalLinkIcon,"aria-hidden":`true`})]},e.id)),(0,y.jsxs)(`button`,{type:`button`,className:Y.listItem,onClick:o,onMouseEnter:s,onFocus:s,disabled:n,children:[(0,y.jsx)(`div`,{className:Y.listIconWrapper,children:(0,y.jsx)(`div`,{className:Y.moreIconSmall,children:(0,y.jsx)($p,{})})}),(0,y.jsx)(`span`,{className:Y.listNameMuted,children:`More wallets`}),(0,y.jsx)(`span`,{className:Y.arrowIcon,"aria-hidden":`true`,children:`→`})]})]})}),(0,y.jsxs)(`a`,{className:Y.learnMoreLink,href:`https://docs.initia.xyz/home/tools/wallet`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Learn more (opens in new tab)`,children:[`Learn more`,(0,y.jsx)(L.IconExternalLink,{size:14,"aria-hidden":`true`})]})]})},om=({onSuccess:e})=>{let{connectors:t,connectAsync:n}=(0,l.useConnect)(),r=(0,le.useReadLocalStorage)(`wagmi.recentConnectorId`),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(`signin`),c=(0,u.useQueryClient)(),d=()=>c.prefetchQuery({queryKey:Up,queryFn:({signal:e})=>Gp(e),staleTime:B.INFINITY,gcTime:B.INFINITY}),{mutate:f,isPending:p}=(0,u.useMutation)({mutationFn:async e=>{try{await n({connector:e})}catch(e){throw await Ge(e)}},onMutate:e=>{a(e.id)},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}}),m=(0,g.useMemo)(()=>[...t].sort((e,t)=>e.id===r?-1:t.id===r?1:e.name.localeCompare(t.name)),[t,r]),h=(0,g.useMemo)(()=>m.find(e=>e.id===Re.id),[m]),_=(0,g.useMemo)(()=>m.filter(e=>e.id!==Re.id&&!Yp(e)),[m]);return o===`all`?(0,y.jsx)(Zp,{walletConnectors:_,isPending:p,pendingConnectorId:i,recentConnectorId:r,onConnect:f,onBack:()=>s(`signin`)}):(0,y.jsx)(am,{walletConnectors:_,privyConnector:h,isPending:p,pendingConnectorId:i,recentConnectorId:r,onConnect:f,onShowAll:()=>s(`all`),onPrefetchWallets:d})},sm={button:`_button_69xmz_1`,content:`_content_69xmz_18`},cm=({title:e,defaultOpen:t=!1,children:n})=>{let[r,i]=(0,le.useToggle)(t),a=(0,g.useId)();return(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`button`,{type:`button`,className:sm.button,onClick:i,"aria-expanded":r,"aria-controls":a,children:[e,` `,(0,y.jsx)(L.IconChevronDown,{size:12,style:{transform:r?`rotate(180deg)`:`rotate(0deg)`},"aria-hidden":`true`})]}),(0,y.jsx)(Yc,{children:(0,y.jsx)(`div`,{id:a,children:r&&(0,y.jsx)(`div`,{className:sm.content,children:n})})})]})},lm={row:`_row_70qmb_1`,value:`_value_70qmb_13`,emphasized:`_emphasized_70qmb_23`},um=({label:e,children:t,emphasized:n,valueStyle:r})=>(0,y.jsxs)(`div`,{className:(0,F.default)(lm.row,n&&lm.emphasized),children:[(0,y.jsx)(`p`,{children:e}),(0,y.jsx)(`div`,{className:lm.value,style:r,children:t})]}),dm=/^0x[0-9a-fA-F]{40}$/;function fm(e,t){if(!e||typeof e!=`object`)throw Error(`Deposit address response is not an object`);let{deposit_address:n,chain_id:r,asset_denom:i,wallet_address:a,cursor:o}=e;if(typeof n!=`string`||!dm.test(n))throw Error(`Deposit address response has an invalid deposit address: ${String(n)}`);if(r!==t.chainId)throw Error(`Deposit address response chain_id mismatch: ${String(r)}`);if(typeof i!=`string`||on(i)!==on(t.assetDenom))throw Error(`Deposit address response asset_denom mismatch: ${String(i)}`);if(typeof a!=`string`||a.toLowerCase()!==t.walletAddress.toLowerCase())throw Error(`Deposit address response wallet_address mismatch: ${String(a)}`);if(typeof o!=`string`||!o)throw Error(`Deposit address response is missing the cursor`);return{deposit_address:n,chain_id:r,asset_denom:i,wallet_address:a,cursor:o}}function pm(e,t){let{walletAddress:n,chainId:r,assetDenom:i}=t;return{queryKey:Vt.depositAddress(n,r,i).queryKey,queryFn:async()=>{try{return fm(await e.post(`v1/deposit-address`,{json:{wallet_address:n,chain_id:r,asset_denom:i}}).json(),t)}catch(e){throw await Ge(e)}}}}function mm(e){let{depositApiUrl:t}=z(),n=Ht(),{walletAddress:r,chainId:i,assetDenom:a}=e;return(0,u.useQuery)({...pm(n,e),enabled:!!t&&!!r&&!!i&&!!a,staleTime:B.INFINITY})}function hm({data:e,isFetchedAfterMount:t,isSuccess:n}){return e&&t&&n?e:void 0}function gm(e){let{depositApiUrl:t}=z(),n=Ht(),{walletAddress:r,chainId:i,assetDenom:a}=e,o=(0,u.useQuery)({...pm(n,e),enabled:!!t&&!!r&&!!i&&!!a,staleTime:1/0,refetchOnMount:`always`,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),s=hm({data:o.data,isFetchedAfterMount:o.isFetchedAfterMount,isSuccess:o.isSuccess});return{query:o,data:s,freshCursor:s?.cursor??``}}var _m=e=>!gn.includes(e),vm=e=>vn.includes(e);function ym(e){return e?vm(e.bucket)?e.bucket:`failed`:`waiting`}var bm=3e3,xm=15e3,Sm=5*6e4,Cm=e=>e<Sm?bm:xm;function wm(){let[e]=(0,g.useState)(()=>Date.now());return e}var Tm=(e,t)=>e&&_m(e.bucket)?!1:Cm(t);function Em(e){let{depositApiUrl:t}=z(),n=Ht(),r=wm();return(0,u.useQuery)({queryKey:Vt.deposit(e).queryKey,queryFn:async()=>{try{return await n.get(`v1/deposits/${e}`).json()}catch(e){throw await Ge(e)}},enabled:!!t&&!!e,refetchInterval:e=>Tm(e.state.data,Date.now()-r)})}var Dm=class extends Error{};function Om(e,t){let n=t.toLowerCase(),r=e.find(e=>e.deposit_address.toLowerCase()!==n);if(r)throw new Dm(`Deposit ${r.id} belongs to ${r.deposit_address}, not the requested ${t}`);return e}function km({depositAddress:e,after:t}){let{depositApiUrl:n}=z(),r=Ht(),i=wm();return(0,u.useQuery)({queryKey:Vt.newDeposits(e,t).queryKey,queryFn:async()=>{try{let{deposits:n}=await r.get(`v1/deposits`,{searchParams:{deposit_address:e,after:t,limit:`1`}}).json();return Om(n,e)}catch(e){throw e instanceof Dm?e:await Ge(e)}},enabled:!!n&&!!e&&!!t,refetchInterval:()=>Cm(Date.now()-i)})}function Am(e){let{depositApiUrl:t}=z(),n=Ht();return(0,u.useQuery)({queryKey:Vt.activeDeposits(e).queryKey,queryFn:async()=>{try{let{deposits:t}=await n.get(`v1/deposits`,{searchParams:{deposit_address:e,active:`true`,limit:`1`}}).json();return Om(t,e)}catch(e){throw e instanceof Dm?e:await Ge(e)}},enabled:!!t&&!!e,refetchInterval:xm})}function jm(e,t,n){let r=e&&t&&e.deposit_address.toLowerCase()!==t.toLowerCase()?new Dm(`Deposit ${e.id} belongs to ${e.deposit_address}, not the requested ${t}`):null;return{deposit:r?null:e??null,isError:!!n||!!r,error:r??n}}function Mm({depositAddress:e,depositId:t}){let n=Em(t);return jm(n.data,e,n.error??null)}function Nm(e){let t=(t,n)=>{let r=on(n);return e[t]?.assets.find(e=>on(e.denom)===r)};return{symbol:(e,n)=>t(e,n)?.symbol??cn(n),logoUrl:(e,n)=>t(e,n)?.logo_uri??``}}function Pm(){let{data:{chain_to_assets_map:e}}=mu();return(0,g.useMemo)(()=>Nm(e),[e])}function Fm(e,t){let n=An(e,t),r=Pm();return(0,g.useMemo)(()=>{let e=new Map;for(let t of n){let n=r.symbol(t.src_chain_id,t.src_denom),i=e.get(n);i?i.routes.push(t):e.set(n,{symbol:n,logoUrl:r.logoUrl(t.src_chain_id,t.src_denom),routes:[t]})}return[...e.values()]},[n,r])}function Im(e,t){return e.find(e=>e.symbol===t)??e[0]}function Lm(){return(0,I.useFormContext)()}function Rm(){let{setValue:e}=Lm();return(0,g.useCallback)(t=>e(`page`,t),[e])}function zm(){let{setValue:e}=Lm(),t=Rm();return(0,g.useCallback)(n=>{e(`trackedDepositId`,n),t(`track`)},[e,t])}function Bm(){let{setValue:e}=Lm(),t=Rm();return(0,g.useCallback)(n=>{e(`method`,n),t(n)},[e,t])}var Vm={back:`_back_7ercl_6`},Hm=({onClick:e})=>{let t=Ec(),n=(0,y.jsx)(`button`,{type:`button`,className:Vm.back,onClick:e,"aria-label":`Go back`,children:(0,y.jsx)(L.IconBack,{size:20,"aria-hidden":`true`})});return t?(0,_e.createPortal)(n,t):n},Um={title:`_title_ld663_1`,list:`_list_ld663_12`,scroll:`_scroll_ld663_22`,row:`_row_ld663_30`,activeRow:`_activeRow_ld663_48`},Wm=({title:e,onBack:t,children:n})=>(0,y.jsxs)(y.Fragment,{children:[t&&(0,y.jsx)(Hm,{onClick:t}),(0,y.jsx)(`h2`,{className:Um.title,children:e}),n]});Wm.List=e=>{let{className:t,maxHeight:n,scroll:r=!0,children:i}=e;return(0,y.jsx)(`div`,{className:(0,F.default)(Um.list,r&&Um.scroll,t),style:n?{maxHeight:n}:void 0,children:i})},Wm.Row=({onClick:e,isActive:t,children:n})=>(0,y.jsx)(`button`,{type:`button`,className:(0,F.default)(Um.row,t&&Um.activeRow),onClick:e,children:n});var Gm={unavailable:`_unavailable_707tc_1`},Km=`We couldn't fetch a processing time estimate right now. Deposits are unaffected and will be processed normally.`,qm=({estimate:e})=>{switch(e.status){case`ready`:return fn(e.seconds);case`estimating`:return`Estimating…`;case`unavailable`:return(0,y.jsx)(Bu,{label:Km,children:(0,y.jsxs)(`span`,{className:Gm.unavailable,children:[(0,y.jsx)(L.IconWarningFilled,{size:12,"aria-hidden":`true`}),`Unavailable`]})})}},Jm={trigger:`_trigger_u1d1r_1 _field_a687c_4`,staticField:`_staticField_u1d1r_15 _field_a687c_4`,triggerValue:`_triggerValue_u1d1r_19`,triggerLabel:`_triggerLabel_u1d1r_27`,logo:`_logo_u1d1r_33`,icon:`_icon_u1d1r_39`,positioner:`_positioner_u1d1r_50`,popup:`_popup_u1d1r_54`,item:`_item_u1d1r_63`,itemText:`_itemText_u1d1r_80`,itemMin:`_itemMin_u1d1r_92`,itemIndicator:`_itemIndicator_u1d1r_101`,active:`_active_u1d1r_107`},Ym=({label:e,options:t,value:n,onChange:r})=>{let i=Ec(),a=t.find(e=>e.value===n);if(t.length<=1){let e=t[0];return(0,y.jsx)(`div`,{className:Jm.staticField,children:(0,y.jsxs)(`span`,{className:Jm.triggerValue,children:[e&&(0,y.jsx)(K,{src:e.logoUrl,width:24,height:24,className:Jm.logo,classNames:{placeholder:Jm.logo}}),(0,y.jsx)(`span`,{className:Jm.triggerLabel,children:e?.label})]})})}return(0,y.jsxs)(he.Select.Root,{value:n,onValueChange:e=>{if(e===null)return;let n=t.find(t=>t.value===e);n&&r(n.value)},modal:!1,children:[(0,y.jsxs)(he.Select.Trigger,{className:Jm.trigger,"aria-label":e,children:[(0,y.jsxs)(`span`,{className:Jm.triggerValue,children:[a&&(0,y.jsx)(K,{src:a.logoUrl,width:24,height:24,className:Jm.logo,classNames:{placeholder:Jm.logo}}),(0,y.jsx)(`span`,{className:Jm.triggerLabel,children:a?.label??`Select`})]}),(0,y.jsx)(he.Select.Icon,{className:Jm.icon,children:(0,y.jsx)(L.IconChevronDown,{size:16,"aria-hidden":`true`})})]}),(0,y.jsx)(he.Select.Portal,{container:i,children:(0,y.jsx)(he.Select.Positioner,{className:Jm.positioner,alignItemWithTrigger:!1,sideOffset:6,align:`end`,children:(0,y.jsx)(he.Select.Popup,{className:Jm.popup,children:t.map(e=>(0,y.jsxs)(he.Select.Item,{className:Jm.item,value:e.value,children:[(0,y.jsx)(K,{src:e.logoUrl,width:20,height:20,className:Jm.logo,classNames:{placeholder:Jm.logo}}),(0,y.jsx)(he.Select.ItemText,{className:Jm.itemText,children:e.label}),e.minLabel&&(0,y.jsx)(`span`,{className:Jm.itemMin,children:e.minLabel}),(0,y.jsx)(L.IconCheck,{size:12,className:(0,F.default)(Jm.itemIndicator,{[Jm.active]:e.value===n}),"aria-hidden":`true`})]},e.value))})})})]})},Xm={root:`_root_1ogu0_5`,selectors:`_selectors_1ogu0_12`,"selector-group":`_selector-group_1ogu0_19`,"selector-label":`_selector-label_1ogu0_29`,"qr-section":`_qr-section_1ogu0_35`,"min-group":`_min-group_1ogu0_44`,min:`_min_1ogu0_44`,warning:`_warning_1ogu0_57`,qr:`_qr_1ogu0_35`,"qr-loading":`_qr-loading_1ogu0_82`,"address-group":`_address-group_1ogu0_87`,address:`_address_1ogu0_87`,copy:`_copy_1ogu0_111`,"label-wrapper":`_label-wrapper_1ogu0_130`,"label-copy":`_label-copy_1ogu0_138`,"label-copied":`_label-copied_1ogu0_142`,copied:`_copied_1ogu0_150`,resume:`_resume_1ogu0_161`,details:`_details_1ogu0_189`,error:`_error_1ogu0_193`},Zm=()=>{let e=Rm(),t=zm(),{watch:n}=Lm(),r=U(),i=n(`receiveSymbol`),a=n(`receiveDenom`),o=n(`receiveChainId`),s=Fm(o,a),[c,l]=(0,g.useState)(``),u=Im(s,c),d=u?.symbol??``,f=u?.routes??[],[p,m]=(0,g.useState)(f[0]?.src_chain_id??``),h=f.find(e=>e.src_chain_id===p)??f[0],_=h?.src_chain_id??``,v=e=>{let t=Im(s,e);l(e),m(t?.routes[0]?.src_chain_id??``)},b=h?un(h.min_deposit_amount,h.src_decimals,u?.symbol??``):``,x=En(h,o,a),S=iu(),C=S.find(e=>e.chain_id===_)?.logo_uri??``,w=f.map(e=>{let t=S.find(t=>t.chain_id===e.src_chain_id);return{value:e.src_chain_id,label:t?.pretty_name??ln(e.src_chain_id),logoUrl:t?.logo_uri??``,minLabel:`Min ${un(e.min_deposit_amount,e.src_decimals,u?.symbol??``)}`}}),T=s.map(e=>({value:e.symbol,label:e.symbol,logoUrl:e.logoUrl})),{query:E,data:D,freshCursor:O}=gm({walletAddress:r,chainId:o,assetDenom:a}),{isError:k,error:A}=E,j=D?.deposit_address??``,M=km({depositAddress:j,after:O}),ee=M.data?.[0]?.id??``;(0,g.useEffect)(()=>{ee&&t(ee)},[ee,t]);let te=Am(j),N=te.data?.[0]?.id??``,ne=[M.error,te.error].find(e=>e instanceof Dm),re=(M.isError||te.isError)&&!ne,ie=(k?A:null)??ne??null,ae=(0,g.useRef)(null),oe=(0,g.useRef)(null),se=Dc(`--gray-0`);return(0,g.useEffect)(()=>{!ae.current||!j||(oe.current?oe.current.update({data:j,image:C,dotsOptions:{color:se},cornersSquareOptions:{color:se},cornersDotOptions:{color:se}}):(oe.current=new Te.default({type:`canvas`,width:400,height:400,margin:0,data:j,image:C,qrOptions:{mode:`Byte`,errorCorrectionLevel:`H`},dotsOptions:{type:`dots`,color:se},cornersSquareOptions:{type:`extra-rounded`,color:se},cornersDotOptions:{type:`dot`,color:se},backgroundOptions:{color:`transparent`},imageOptions:{hideBackgroundDots:!0,imageSize:.25,margin:8}}),oe.current.append(ae.current)))},[j,C,se]),(0,y.jsx)(Wm,{title:`Deposit ${i} via address`,onBack:()=>e(`select-method`),children:(0,y.jsxs)(`div`,{className:Xm.root,children:[(0,y.jsxs)(`div`,{className:Xm.selectors,children:[(0,y.jsxs)(`div`,{className:Xm[`selector-group`],children:[(0,y.jsx)(`span`,{className:Xm[`selector-label`],children:`Source asset`}),(0,y.jsx)(Ym,{label:`Source asset`,options:T,value:d,onChange:v})]}),(0,y.jsxs)(`div`,{className:Xm[`selector-group`],children:[(0,y.jsx)(`span`,{className:Xm[`selector-label`],children:`Supported network`}),(0,y.jsx)(Ym,{label:`Supported network`,options:w,value:_,onChange:m})]})]}),(0,y.jsxs)(`div`,{className:Xm[`qr-section`],children:[(0,y.jsxs)(`div`,{className:Xm[`min-group`],children:[b&&(0,y.jsxs)(`p`,{className:Xm.min,children:[`Minimum deposit: `,b]}),(0,y.jsxs)(`p`,{className:Xm.warning,role:`alert`,children:[(0,y.jsx)(L.IconWarningFilled,{size:12,"aria-hidden":`true`}),`Deposits below minimum or with unsupported assets will be lost.`]})]}),ie?(0,y.jsx)(`p`,{className:Xm.error,role:`alert`,children:ie.message}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:(0,F.default)(Xm.qr,{[Xm[`qr-loading`]]:!j}),ref:ae}),(0,y.jsxs)(`div`,{className:Xm[`address-group`],children:[(0,y.jsx)(`span`,{className:Xm.address,children:j||`Generating your deposit address…`}),(0,y.jsx)(Lc,{value:j,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(Xm.copy,{[Xm.copied]:t}),onClick:e,disabled:!j,"aria-label":t?`Copied`:`Copy deposit address`,children:[(0,y.jsx)(L.IconCopy,{size:12,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Xm[`label-wrapper`],children:[(0,y.jsx)(`span`,{className:Xm[`label-copy`],children:`Copy address`}),(0,y.jsx)(`span`,{className:Xm[`label-copied`],children:`Copied!`})]})]})})]}),re&&(0,y.jsx)(`p`,{className:Xm.error,role:`alert`,children:`Deposit detection is temporarily unavailable. Your transfer is unaffected; it will appear once the connection recovers.`})]})]}),!ie&&N&&(0,y.jsx)(`button`,{type:`button`,className:Xm.resume,onClick:()=>t(N),children:`View the transfer detected at this address`}),(0,y.jsx)(`div`,{className:Xm.details,children:(0,y.jsxs)(cm,{title:`Transaction details`,defaultOpen:!0,children:[h&&(0,y.jsx)(um,{label:`Max slippage`,children:dn(h.max_slippage_percent)}),(0,y.jsx)(um,{label:`Processing time`,children:(0,y.jsx)(qm,{estimate:x})})]})})]})})},Qm=1,$m=`0x0000000000000000000000000000000000000000`;function eh(e){if(e.fiat.length===0||e.crypto.length===0)throw Error(`Onramper returned no supported currencies. onramperApiKey or onramperApiUrl is likely misconfigured.`);return e}function th(e,t,n){if(t!==String(Qm))return;let r=n.endsWith(`-native`)?$m:n.toLowerCase();return e.find(e=>e.chainId===Qm&&e.address.toLowerCase()===r)}function nh(e,{presetCurrency:t,persistedId:n,recommendedCode:r,defaultId:i}){let a=t=>t?e.find(e=>e.id===t):void 0,o=t=>{if(!t)return;let n=t.toLowerCase();return e.find(e=>e.code.toLowerCase()===n)??e.find(e=>e.id===n)};return o(t)??a(n)??o(r)??a(i)??e[0]}var rh=`applepay`;function ih(){if(typeof window>`u`)return!1;let e=window.ApplePaySession;if(!e)return!1;try{return e.canMakePayments()}catch{return!1}}function ah(e,t){return t?e:e.filter(e=>e.paymentTypeId!==rh)}function oh(e,t){return e.length>0&&ah(e,t).length===0}function sh(e){let t=e.map(e=>e.details?.limits?.aggregatedLimit?.max).filter(e=>typeof e==`number`&&Number.isFinite(e));if(t.length!==0)return Math.max(...t)}function ch(e,t){return`${t}${(0,f.default)(String(e)).toFormat()}`}function lh(e,t){return`Up to ${ch(e,t)}`}function uh(e,t){return e.find(e=>e.paymentTypeId===t)?.details?.limits?.aggregatedLimit}function dh(e,t,n,r){if(!t)return``;let i=Number(e);if(!(i>0))return``;let a=r?` with ${r}`:``;return t.min!==void 0&&i<t.min?`Minimum purchase${a} is ${ch(t.min,n)}`:t.max!==void 0&&i>t.max?`Maximum purchase${a} is ${ch(t.max,n)}`:``}function fh(e,t){return(0,f.default)((0,d.toBaseUnit)(String(e),{decimals:t.src_decimals})||`0`).lt(t.min_deposit_amount)}function ph(e){return e.charAt(0).toUpperCase()+e.slice(1)}function mh(e,t){return e.find(e=>e.id===t)?.displayName??ph(t)}function hh(e){let t=e.filter(e=>typeof e.payout==`number`&&!!e.ramp);if(!t.length)return[];let n=Math.max(...t.map(e=>e.payout));return[...t].sort((e,t)=>t.payout-e.payout).map(e=>{let t=e.payout===n,r=n?(e.payout-n)/n*100:0;return{quote:e,ramp:e.ramp,payout:e.payout,isBest:t,diffLabel:t?``:`${r.toFixed(2)}%`}})}function gh(e,t){return e.find(e=>e.ramp===t)??e[0]??null}function _h(e){return(e.networkFee??0)+(e.transactionFee??0)}var vh=6101,yh=6200,bh=6403,xh=`Providers are temporarily unavailable. Try again in a moment.`,Sh=`No provider currently supports this combination. Try a different payment method or currency.`;function Ch(e){let t=e.flatMap(e=>e.errors??[]),n=t.find(e=>e.errorId===vh);if(n)return n.message;let r=t.filter(e=>e.errorId!==bh);return r.length>0&&r.every(e=>e.errorId===yh)?xh:Sh}function wh(e){if(hh(e).length>0)return;let t=e.flatMap(e=>e.errors??[]);t.length!==0&&console.warn(`[onramp] provider quote errors:`,t)}function Th(e){let t=``;try{t=new URL(e).protocol}catch{}if(t!==`https:`)throw Error(`Unexpected checkout URL from the provider: ${e}`)}function Eh(e){return{queryKey:Vt.onramperSupported.queryKey,queryFn:async()=>{try{let{message:t}=await e.get(`supported`,{searchParams:{type:`buy`}}).json();return eh(t)}catch(e){throw await Ge(e)}},staleTime:B.INFINITY}}function Dh(){let{data:e}=(0,u.useSuspenseQuery)(Eh(Ut()));return e}function Oh(){let e=Wt(),{data:t}=(0,u.useQuery)({...Eh(Ut()),enabled:e});return t?.crypto}function kh(){let e=Ut(),{data:t}=(0,u.useSuspenseQuery)({queryKey:Vt.onramperOnramps.queryKey,queryFn:async()=>{try{let{message:t}=await e.get(`supported/onramps/all`,{searchParams:{type:`buy`}}).json();return t}catch(e){throw await Ge(e)}},staleTime:B.INFINITY});return t}function Ah(e){return{queryKey:Vt.onramperGeoDefaults.queryKey,queryFn:async()=>{try{return(await e.get(`supported/defaults/all`,{searchParams:{type:`buy`}}).json())?.message?.recommended?.source??null}catch(e){return console.warn(`[onramp] geo defaults lookup failed:`,e),null}},staleTime:B.INFINITY}}function jh(){let{data:e}=(0,u.useSuspenseQuery)(Ah(Ut()));return e}function Mh(){let e=Wt(),t=Ut(),n=(0,u.useQueryClient)();(0,g.useEffect)(()=>{e&&n.prefetchQuery(Ah(t))},[e,t,n])}function Nh(e){let t=kh();return(0,g.useMemo)(()=>t.find(t=>t.id===e),[t,e])}function Ph(e){let{fiat:t}=Dh();return(0,g.useMemo)(()=>t.find(t=>t.id===e),[t,e])}function Fh(e){return Ph(e)?.code??e.toUpperCase()}function Ih(e,t){let n=An(e,t),{crypto:r}=Dh(),i=(0,g.useMemo)(()=>n.find(e=>th(r,e.src_chain_id,e.src_denom)),[n,r]);return(0,g.useMemo)(()=>{if(!i)return null;let e=th(r,i.src_chain_id,i.src_denom);return e?{route:i,crypto:e}:null},[i,r])}function Lh(e,t){return Ih(e,t)?.crypto??null}function Rh(e,t,n){let r=Wt(),i=Ut();return(0,u.useQuery)({queryKey:Vt.onramperPaymentTypes(e,t).queryKey,queryFn:async()=>{try{let{message:n}=await i.get(`supported/payment-types/${e}`,{searchParams:{destination:t,type:`buy`}}).json();return n}catch(e){throw await Ge(e)}},enabled:r&&!!e&&!!t,staleTime:B.MINUTE,select:n})}var zh=e=>ah(e,ih()),Bh=e=>oh(e,ih());function Vh(e,t){return Rh(e,t,zh)}function Hh(e,t){return Rh(e,t,Bh).data??!1}var Uh=B.SECOND*30;function Wh({fiat:e,crypto:t,amount:n,paymentMethod:r,enabled:i=!0}){let a=Wt(),o=Ut();return(0,u.useQuery)({queryKey:Vt.onramperQuotes(e,t,n,r).queryKey,queryFn:async({signal:i})=>{try{let a={type:`buy`,amount:n,paymentMethod:r},s=await o.get(`quotes/${e}/${t}`,{searchParams:a,signal:i}).json();return wh(s),s}catch(e){throw await Ge(e)}},enabled:i&&a&&!!e&&!!t&&Number(n)>0&&!!r,staleTime:Uh,refetchInterval:Uh})}async function Gh(e,t){try{return await e.post(`v1/onramper/checkout`,{json:{wallet_address:t.walletAddress,chain_id:t.chainId,asset_denom:t.assetDenom,onramp:t.onramp,fiat:t.fiat,crypto:t.crypto,network:t.network,amount:t.amount,payment_method:t.paymentMethod,uuid:t.uuid}}).json()}catch(e){throw await Ge(e)}}function Kh(){let e=Ht();return(0,u.useMutation)({mutationFn:async t=>{let n=await Gh(e,t);return Th(n.url),n}})}var qh=B.SECOND*30;function Jh(e){let t=!e.enabled||e.hasData&&!e.isPlaceholderData;return{isSettled:t,isFailed:!t&&e.isError}}async function Yh(e){if(e instanceof h.HTTPError&&e.response.status===400)return{status:`declined`,reason:await He(e)};throw await Ge(e)}function Xh(e,t,n){if(!n||!e||t===void 0)return{value:``,amountOut:``,isDeclined:!1,declineReason:``};if(e.status===`declined`)return{value:``,amountOut:``,isDeclined:!0,declineReason:e.reason};let r=(0,d.fromBaseUnit)(e.quote.min_received,{decimals:t}),i=(0,d.fromBaseUnit)(e.quote.amount_out,{decimals:t});return{value:r&&(0,f.default)(r).gt(0)?(0,d.formatNumber)(r,{dp:6}):``,amountOut:i&&(0,f.default)(i).gt(0)?i:``,isDeclined:!1,declineReason:``}}function Zh(e,t){return{value:t.isFailed?``:e.value,amountOut:t.isFailed?``:e.amountOut,isDeclined:t.isSettled&&e.isDeclined,declineReason:t.isSettled?e.declineReason:``,...t}}function Qh(e,t,n){let{depositApiUrl:r}=z(),i=Ht(),a=Ih(t,n)?.route,o=a?pn(a,t,n):void 0,s=a&&e&&e>0?(0,f.default)((0,d.toBaseUnit)(String(e),{decimals:a.src_decimals})||0).integerValue(f.default.ROUND_DOWN).toString():``,c=!!r&&!!a&&!!o&&!!s&&(0,f.default)(s).gt(0),{data:l,isPlaceholderData:p,isError:m}=(0,u.useQuery)({queryKey:Vt.minReceived(a?.src_chain_id??``,a?.src_denom??``,t,n,s).queryKey,queryFn:async()=>{try{return{status:`quoted`,quote:await i.get(`v1/quote`,{searchParams:{src_chain_id:a?.src_chain_id??``,src_denom:a?.src_denom??``,dst_chain_id:t,dst_denom:n,amount_in:s}}).json()}}catch(e){return await Yh(e)}},enabled:c,staleTime:qh,refetchInterval:qh,placeholderData:u.keepPreviousData}),h=Jh({enabled:c,hasData:!!l,isPlaceholderData:p,isError:m});return Zh(Xh(l,o?.decimals,s),h)}var $h={flag:`_flag_pzx4s_1`},eg=({fiatId:e,size:t=20})=>(0,y.jsx)(K,{src:Ph(e)?.icon??``,alt:``,width:t,height:t,className:$h.flag,classNames:{placeholder:$h.flag}}),tg={icon:`_icon_14b3n_1`,mono:`_mono_14b3n_11`},ng=({iconUrl:e,size:t=28})=>{let n=Math.round(t*.625);return(0,y.jsx)(`span`,{className:tg.icon,style:{width:t,height:t},"aria-hidden":`true`,children:e?(0,y.jsx)(K,{src:e,alt:``,width:n,height:n}):(0,y.jsx)(L.IconPay,{size:n})})},rg={logo:`_logo_6ip0y_1`},ig=({ramp:e,size:t=24})=>{let n=Nh(e);return(0,y.jsx)(K,{className:rg.logo,classNames:{placeholder:rg.logo},src:n?.icon,width:t,height:t,"aria-hidden":`true`})},ag=2;function og({sourceCryptoId:e,sourceRoute:t,fiatAmount:n,limitError:r,quotes:i,providerId:a,quotedFiatAmount:o,fiat:s}){if(!t)return{sourceCryptoId:e,status:`unsupported`};if(!(Number(n)>0))return{sourceCryptoId:e,status:`idle`};if(r)return{sourceCryptoId:e,status:`limit-error`,message:r};if(n!==o)return{sourceCryptoId:e,status:`loading`};if(i.isError&&!i.data)return{sourceCryptoId:e,status:`error`,message:i.errorMessage};if(!i.data)return{sourceCryptoId:e,status:`loading`};let c=hh(i.data),l=gh(c,a);if(!l)return{sourceCryptoId:e,status:`no-offers`,reason:Ch(i.data)};let u=fh(l.payout,t.route),f=un(t.route.min_deposit_amount,t.route.src_decimals,t.crypto.code),p=_h(l.quote);return{sourceCryptoId:e,status:`quoted`,ranked:c,selected:l,belowRouteMinimum:u,routeMinimumLabel:f,quotedFiatAmount:o,feeLabel:`${(0,d.formatNumber)(String(p),{dp:ag})} ${s}`}}function sg(e,t,n,r){let i=Number(e),a=Number(t);return!Number.isFinite(i)||i<=0||!Number.isFinite(a)||a<=0?``:`1 ${n} ≈ ${(0,d.formatNumber)((0,f.default)(e).div(t).toString(),{dp:ag})} ${r}`}function cg({enabled:e=!0}={}){let{control:t}=Lm(),[n,r,i,a,o,s]=(0,I.useWatch)({control:t,name:[`fiatId`,`fiatAmount`,`receiveDenom`,`receiveChainId`,`paymentMethodId`,`providerId`]}),c=Ih(a,i),l=c?.crypto??null,u=Ph(n),d=Vh(n,l?.id??``),f=uh(d.data??[],o),p=d.data?.find(e=>e.paymentTypeId===o)?.name,m=dh(r,f,u?.symbol??``,p),[h]=(0,le.useDebounceValue)(r,300),g=dh(h,f,u?.symbol??``,p),_=Wh({fiat:n,crypto:l?.id??``,amount:g?``:h,paymentMethod:o,enabled:e}),v=Fh(n);return og({sourceCryptoId:l?.id??``,sourceRoute:c,fiatAmount:r,limitError:m,quotes:{isError:_.isError,data:_.data,errorMessage:_.error?.message??``},providerId:s,quotedFiatAmount:h,fiat:v})}var X={form:`_form_78jgk_1`,card:`_card_78jgk_8`,field:`_field_78jgk_14`,fieldLabel:`_fieldLabel_78jgk_20`,fieldLabelChain:`_fieldLabelChain_78jgk_31`,fieldMain:`_fieldMain_78jgk_39`,pill:`_pill_78jgk_45`,pillChevron:`_pillChevron_78jgk_67`,amount:`_amount_78jgk_75`,amountReadOnly:`_amountReadOnly_78jgk_76`,placeholder:`_placeholder_78jgk_104`,divider:`_divider_78jgk_112`,coin:`_coin_78jgk_119`,chainLogo:`_chainLogo_78jgk_127`,sectionLabel:`_sectionLabel_78jgk_135`,methodField:`_methodField_78jgk_142 _field_a687c_4`,methodLeft:`_methodLeft_78jgk_154`,providerPill:`_providerPill_78jgk_161`};function lg(e){switch(e.status){case`unsupported`:return`Not available for this asset`;case`idle`:return`Enter amount`;case`limit-error`:return`Amount out of range`;case`loading`:return`Getting quote…`;case`error`:return`Quote unavailable`;case`no-offers`:return`No quote available`;case`quoted`:return e.belowRouteMinimum?`Amount too low`:void 0}return e}function ug(e){switch(e.status){case`limit-error`:case`error`:return e.message;case`no-offers`:return e.reason;case`quoted`:return e.belowRouteMinimum?`This purchase is below the ${e.routeMinimumLabel} bridge minimum. Increase your amount.`:``;default:return``}}var dg=()=>{let{control:e,watch:t,setValue:n,handleSubmit:r}=Lm(),{onramp:i}=Yt(),a=Rm(),o=cg(),s=kh(),c=t(`fiatId`),l=t(`receiveSymbol`),u=t(`receiveDenom`),f=t(`receiveChainId`),p=t(`paymentMethodId`),m=jn({denom:u,chainId:f,symbol:l}),h=Vh(c,o.sourceCryptoId),_=h.data?.find(e=>e.paymentTypeId===p);(0,g.useEffect)(()=>{let e=h.data;e?.length&&(e.some(e=>e.paymentTypeId===p)||n(`paymentMethodId`,e[0].paymentTypeId))},[h.data,p,n]);let{fiat:v}=Dh(),b=jh();(0,g.useEffect)(()=>{let e=localStorage.getItem(H.ONRAMP_FIAT_ID),t=nh(v,{presetCurrency:i?.currency&&c!==e?i.currency:null,persistedId:e,recommendedCode:b,defaultId:`usd`});c!==t.id&&n(`fiatId`,t.id)},[v,b,c,i?.currency,n]);let x=o.status===`quoted`?o:null,S=x?.selected??null,C=Qh(S?.payout,f,u),w=En(Ih(f,u)?.route,f,u),T=Fh(c),E=x&&C.isSettled?sg(x.quotedFiatAmount,C.amountOut,l,T):``,D=lg(o)??(C.isDeclined||C.isFailed?`Quote unavailable`:void 0)??(C.isSettled?void 0:`Getting quote…`),O=ug(o)||(C.isDeclined?C.declineReason||`The bridge can't quote this purchase. It may be below the route minimum. Try increasing your amount.`:``)||(C.isFailed?`Couldn't reach the bridge for a quote. It retries automatically. Check your connection if this persists.`:``),k=r(()=>{D||a(`onramp-processing`)});return(0,y.jsx)(Wm,{title:`Buy ${l}`,onBack:()=>a(`select-method`),children:(0,y.jsxs)(`form`,{className:X.form,onSubmit:k,"aria-label":`Buy crypto form`,children:[(0,y.jsxs)(`div`,{className:X.card,children:[(0,y.jsxs)(`div`,{className:X.field,children:[(0,y.jsx)(`p`,{className:X.fieldLabel,children:`Pay`}),(0,y.jsxs)(`div`,{className:X.fieldMain,children:[(0,y.jsxs)(`button`,{type:`button`,className:X.pill,onClick:()=>a(`onramp-select-fiat`),children:[(0,y.jsx)(eg,{fiatId:c,size:24}),T,(0,y.jsx)(L.IconChevronDown,{size:16,className:X.pillChevron,"aria-hidden":`true`})]}),(0,y.jsx)(Pu,{name:`fiatAmount`,control:e,dp:2,className:X.amount,"aria-label":`Amount to pay`})]})]}),(0,y.jsx)(`div`,{className:X.divider}),(0,y.jsxs)(`div`,{className:X.field,children:[(0,y.jsxs)(`p`,{className:X.fieldLabel,children:[`Receive`,(0,y.jsxs)(`span`,{className:X.fieldLabelChain,children:[`on`,(0,y.jsx)(K,{src:m.chainLogoUrl,width:18,height:18,className:X.chainLogo,classNames:{placeholder:X.chainLogo}}),m.chainName]})]}),(0,y.jsxs)(`div`,{className:X.fieldMain,children:[(0,y.jsxs)(`button`,{type:`button`,className:X.pill,onClick:()=>a(`onramp-select-receive`),children:[(0,y.jsx)(K,{src:m.logoUrl,width:24,height:24,className:X.coin,classNames:{placeholder:X.coin}}),m.symbol,(0,y.jsx)(L.IconChevronDown,{size:16,className:X.pillChevron,"aria-hidden":`true`})]}),(0,y.jsx)(`p`,{className:(0,F.default)(X.amountReadOnly,{[X.placeholder]:!C.amountOut}),children:C.amountOut?(0,d.formatNumber)(C.amountOut,{dp:6}):`0`})]})]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:X.sectionLabel,children:`Payment method`}),(0,y.jsxs)(`button`,{type:`button`,className:X.methodField,onClick:()=>a(`onramp-select-payment`),children:[(0,y.jsxs)(`span`,{className:X.methodLeft,children:[(0,y.jsx)(ng,{iconUrl:_?.icon,size:32}),_?.name??`Select payment method`]}),(0,y.jsx)(L.IconChevronDown,{size:16,className:X.pillChevron,"aria-hidden":`true`})]})]}),(0,y.jsxs)(cm,{title:`Transaction details`,defaultOpen:!0,children:[(0,y.jsx)(um,{label:`Provider`,children:(0,y.jsxs)(`button`,{type:`button`,className:X.providerPill,onClick:()=>a(`onramp-select-provider`),disabled:!S,children:[S?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ig,{ramp:S.ramp,size:16}),mh(s,S.ramp)]}):`—`,(0,y.jsx)(L.IconChevronDown,{size:12,className:X.pillChevron,"aria-hidden":`true`})]})}),(0,y.jsx)(um,{label:`Estimated price`,children:E||`—`}),(0,y.jsx)(um,{label:`Estimated time`,children:(0,y.jsx)(qm,{estimate:w})}),(0,y.jsx)(um,{label:`Total fees`,children:x?.feeLabel??`—`}),(0,y.jsxs)(um,{label:`Minimum received`,emphasized:!0,children:[(0,y.jsx)(K,{src:m.logoUrl,width:14,height:14,className:X.coin,classNames:{placeholder:X.coin}}),C.value?`${C.value} ${l}`:`—`]})]}),(0,y.jsx)(mc,{extra:O&&(0,y.jsx)(el,{level:`error`,children:O}),children:(0,y.jsx)(G.White,{type:`submit`,fullWidth:!0,disabled:!!D,children:D??`Buy ${l}`})})]})})},fg={status:`_status_15jzq_1`,contrast:`_contrast_15jzq_14`},pg=({error:e,...t})=>(0,y.jsx)(Ia,{...t,error:e,className:(0,F.default)(fg.status,{[fg.contrast]:!e})}),mg={flow:`_flow_11kau_1`,step:`_step_11kau_12`,stepLabel:`_stepLabel_11kau_19`,chip:`_chip_11kau_25`,arrow:`_arrow_11kau_39`,coin:`_coin_11kau_46`},hg=({steps:e})=>(0,y.jsx)(`div`,{className:mg.flow,children:e.map((e,t)=>(0,y.jsxs)(g.Fragment,{children:[t>0&&(0,y.jsx)(L.IconChevronRight,{size:16,className:mg.arrow,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:mg.step,children:[(0,y.jsx)(`span`,{className:mg.stepLabel,children:e.label}),(0,y.jsxs)(`span`,{className:mg.chip,children:[e.icon??(0,y.jsx)(od,{assetLogoUrl:e.logoUrl,chainLogoUrl:e.chainLogoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:mg.coin}),e.text]})]})]},e.label))}),gg={body:`_body_1foy4_1`,logo:`_logo_1foy4_11`,heading:`_heading_1foy4_15`,duration:`_duration_1foy4_20`,durationValue:`_durationValue_1foy4_26`,note:`_note_1foy4_31`,addressSection:`_addressSection_1foy4_40`,addressHeader:`_addressHeader_1foy4_53`,addressChain:`_addressChain_1foy4_63`,addressChainLogo:`_addressChainLogo_1foy4_69`,addressField:`_addressField_1foy4_75`,addressValue:`_addressValue_1foy4_100`,addressCaption:`_addressCaption_1foy4_107`,addressOwner:`_addressOwner_1foy4_114`,redirectFallback:`_redirectFallback_1foy4_122`,continueLink:`_continueLink_1foy4_128`};function _g(e){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),t.remove()}function vg(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var yg=5e3,bg=()=>{let{watch:e}=Lm(),t=zm(),[n,r]=(0,g.useState)(null),i=cg({enabled:!n}),a=kh(),o=U(),s=e(`fiatId`),c=e(`fiatAmount`),l=e(`paymentMethodId`),u=e(`receiveSymbol`),f=e(`receiveDenom`),p=e(`receiveChainId`),m=jn({denom:f,chainId:p,symbol:u}),h=Ih(p,f),_=h?.crypto??null,v=Pm(),b=h?v.symbol(h.route.src_chain_id,h.route.src_denom):``,x=h?v.logoUrl(h.route.src_chain_id,h.route.src_denom):``,S=iu(),C=h?S.find(e=>e.chain_id===h.route.src_chain_id):void 0,w=C?.logo_uri??``,T=h?C?.pretty_name??ln(h.route.src_chain_id):``,E=i.status===`quoted`?i.selected.ramp:``,D=i.status===`quoted`&&i.belowRouteMinimum,O=i.status===`quoted`?i.selected.payout:void 0,k=Qh(n?void 0:O,p,f),A=_?.id??``,j=_?.network??``,M=En(h?.route,p,f),{query:ee,data:te,freshCursor:N}=gm({walletAddress:o,chainId:p,assetDenom:f}),{isError:ne,refetch:re}=ee,ie=te?.deposit_address??``,ae=km({depositAddress:ie,after:N}),oe=ae.data?.[0]?.id??``;(0,g.useEffect)(()=>{oe&&t(oe)},[oe,t]);let se=ae.isError,{mutateAsync:ce}=Kh(),[P]=(0,g.useState)(vg),[le,ue]=(0,g.useState)(null),F=n?.ramp??E,I=F?mh(a,F):`your provider`,de=!!o&&!!E&&!!A&&!!j&&Number(c)>0,fe=de&&!!ie&&!!N&&k.isSettled,pe=(0,g.useRef)(!1);(0,g.useEffect)(()=>{pe.current||!fe||(pe.current=!0,(async()=>{try{if(D)throw Error(`The amount is now below the route minimum. Please go back and adjust it.`);if(k.isDeclined)throw Error(k.declineReason||`The bridge can't quote this purchase. It may be below the route minimum. Please go back and adjust your amount.`);let e=await ce({walletAddress:o,chainId:p,assetDenom:f,onramp:E,fiat:s,crypto:A,network:j,amount:Number(c),paymentMethod:l,uuid:P});_g(e.url),r({url:e.url,ramp:E})}catch(e){ue(e instanceof Error?e:Error(String(e)))}})())},[fe,D,k.isDeclined,k.declineReason,ce,o,p,f,E,s,A,j,c,l,P]),(0,g.useEffect)(()=>{if(de&&k.isSettled)return;let e=setTimeout(()=>{pe.current||ue(Error(`Couldn't start the checkout. Please go back and try again.`))},yg);return()=>clearTimeout(e)},[de,k.isSettled]);let me=Fh(s);if(le)throw le;return(0,y.jsx)(Wm,{title:`Processing…`,children:(0,y.jsxs)(`div`,{className:gg.body,children:[F?(0,y.jsx)(ig,{ramp:F,size:48}):null,(0,y.jsxs)(`p`,{className:gg.heading,children:[`Please proceed with `,I]}),n&&(0,y.jsxs)(`p`,{className:gg.redirectFallback,children:[`If you weren't redirected automatically,`,` `,(0,y.jsxs)(`a`,{className:gg.continueLink,href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:[`continue with `,I]})]}),(0,y.jsxs)(`p`,{className:gg.duration,children:[`Estimated duration`,` `,(0,y.jsx)(`span`,{className:gg.durationValue,children:(0,y.jsx)(qm,{estimate:M})})]}),(0,y.jsx)(`p`,{className:gg.note,children:`Your transaction will continue even if you close this.`}),ne&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(pg,{error:!0,children:`Checkout hasn't started because we couldn't prepare your deposit address.`}),(0,y.jsx)(G.White,{onClick:()=>void re(),children:`Retry`})]}),se&&!ne&&(0,y.jsx)(pg,{error:!0,children:`Deposit detection is temporarily unavailable. Your purchase is unaffected; it will appear once the connection recovers.`}),(0,y.jsx)(hg,{steps:[{label:`Pay`,icon:(0,y.jsx)(eg,{fiatId:s,size:20}),text:me},{label:`Buy`,logoUrl:x,chainLogoUrl:w,text:b},{label:`Receive`,logoUrl:m.logoUrl,chainLogoUrl:m.chainLogoUrl,text:u}]}),ie&&(0,y.jsxs)(`div`,{className:gg.addressSection,children:[(0,y.jsxs)(`div`,{className:gg.addressHeader,children:[(0,y.jsx)(`span`,{children:`Deposit address`}),T&&(0,y.jsxs)(`span`,{className:gg.addressChain,children:[(0,y.jsx)(K,{src:w,width:16,height:16,className:gg.addressChainLogo,classNames:{placeholder:gg.addressChainLogo}}),T]})]}),(0,y.jsx)(Lc,{value:ie,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{type:`button`,className:gg.addressField,onClick:e,"aria-label":t?`Copied`:`Copy deposit address`,children:[(0,y.jsx)(`span`,{className:gg.addressValue,children:ie}),t?(0,y.jsx)(L.IconCheck,{size:12,"aria-hidden":`true`}):(0,y.jsx)(L.IconCopy,{size:12,"aria-hidden":`true`})]})}),F&&b&&(0,y.jsxs)(`p`,{className:gg.addressCaption,children:[I,` sends `,b,` here, then to`,` `,(0,y.jsxs)(`span`,{className:gg.addressOwner,children:[`your wallet (`,(0,d.truncate)(o),`)`]}),`. This should match the address on `,I,`'s page.`]})]})]})})},xg=({error:e,resetErrorBoundary:t})=>{let n=Rm(),r=(0,u.useQueryClient)();return(0,y.jsxs)(Wm,{title:`Processing…`,onBack:()=>n(`onramp`),children:[(0,y.jsx)(pg,{error:!0,children:e.message}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{onClick:()=>{r.resetQueries({queryKey:Vt.assets.queryKey}),r.resetQueries({queryKey:Vt.onramperSupported.queryKey}),r.resetQueries({queryKey:Vt.onramperOnramps.queryKey}),t()},children:`Retry`})})]})},Sg=()=>(0,y.jsx)(W,{errorBoundaryProps:{onError:e=>console.error(e),fallbackRender:({error:e,resetErrorBoundary:t})=>(0,y.jsx)(xg,{error:e,resetErrorBoundary:t})},children:(0,y.jsx)(bg,{})}),Cg={list:`_list_16zre_3`},wg=()=>{let{setValue:e}=Lm(),t=Rm(),{fiat:n}=Dh();return(0,y.jsx)(Wm,{title:`Select fiat currency`,onBack:()=>t(`onramp`),children:(0,y.jsx)(Wm.List,{scroll:!1,children:(0,y.jsx)(gd,{assets:n.map(e=>({denom:e.id,symbol:e.code,name:e.name,decimals:0,logoUrl:e.icon})),searchKeys:[`symbol`,`name`],placeholder:`Search by currency`,emptyMessage:`No currencies`,listClassName:Cg.list,onSelect:n=>{e(`fiatId`,n),localStorage.setItem(H.ONRAMP_FIAT_ID,n),t(`onramp`)}})})})},Tg={name:`_name_1hgng_1`,check:`_check_1hgng_9`},Eg=()=>{let{watch:e,setValue:t}=Lm(),n=Rm(),r=e(`fiatId`),i=e(`paymentMethodId`),a=e(`receiveDenom`),o=Lh(e(`receiveChainId`),a),{data:s,isPending:c,isError:l,error:u}=Vh(r,o?.id??``),d=Hh(r,o?.id??``);return(0,y.jsx)(Wm,{title:`Select payment method`,onBack:()=>n(`onramp`),children:(0,y.jsx)(Wm.List,{children:o?l?(0,y.jsx)(pg,{error:!0,children:u.message}):c?(0,y.jsx)(pg,{children:`Loading…`}):s.length===0?(0,y.jsx)(pg,{children:d?`The only payment method for this pair is Apple Pay, which this browser can't complete. Try Safari or an iOS browser.`:`No payment methods`}):s.map(e=>(0,y.jsxs)(Wm.Row,{onClick:()=>{t(`paymentMethodId`,e.paymentTypeId),localStorage.setItem(H.ONRAMP_PAYMENT_TYPE_ID,e.paymentTypeId),n(`onramp`)},children:[(0,y.jsx)(ng,{iconUrl:e.icon,size:28}),(0,y.jsx)(`span`,{className:Tg.name,children:e.name}),i===e.paymentTypeId&&(0,y.jsx)(L.IconCheck,{size:16,className:Tg.check,"aria-hidden":`true`})]},e.paymentTypeId)):(0,y.jsx)(pg,{children:`Not available for this asset`})})})},Dg={header:`_header_vqn01_2`,left:`_left_vqn01_16`,name:`_name_vqn01_26`,badge:`_badge_vqn01_31`,"badge-success":`_badge-success_vqn01_41`,right:`_right_vqn01_46`,amount:`_amount_vqn01_53`,diff:`_diff_vqn01_59`},Og=()=>{let{watch:e,setValue:t}=Lm(),n=Rm(),r=e(`receiveChainId`),i=e(`receiveDenom`),a=e(`providerId`),o=cg(),s=kh(),c=Ih(r,i),l=Pm(),u=c?l.symbol(c.route.src_chain_id,c.route.src_denom):``;return(0,y.jsxs)(Wm,{title:`Select provider`,onBack:()=>n(`onramp`),children:[(0,y.jsxs)(`div`,{className:Dg.header,children:[(0,y.jsx)(`span`,{children:`Provider`}),(0,y.jsx)(`span`,{children:`You receive`})]}),(0,y.jsx)(Wm.List,{children:o.status===`loading`?(0,y.jsx)(pg,{children:`Loading…`}):o.status===`error`?(0,y.jsx)(pg,{error:!0,children:o.message}):o.status===`no-offers`?(0,y.jsx)(pg,{children:o.reason}):o.status===`quoted`?o.ranked.map(e=>(0,y.jsxs)(Wm.Row,{isActive:a===e.ramp,onClick:()=>{t(`providerId`,e.ramp),n(`onramp`)},children:[(0,y.jsxs)(`span`,{className:Dg.left,children:[(0,y.jsx)(ig,{ramp:e.ramp,size:28}),(0,y.jsx)(`span`,{className:Dg.name,children:mh(s,e.ramp)}),e.isBest&&(0,y.jsx)(`span`,{className:(0,F.default)(Dg.badge,Dg[`badge-success`]),children:`Best price`})]}),(0,y.jsxs)(`span`,{className:Dg.right,children:[(0,y.jsxs)(`span`,{className:Dg.amount,children:[(0,d.formatNumber)(String(e.payout),{dp:6}),` `,u]}),e.diffLabel&&(0,y.jsx)(`span`,{className:Dg.diff,children:e.diffLabel})]})]},e.ramp)):(0,y.jsx)(pg,{children:`No quotes available`})})]})},kg={asset:`_asset_1n04e_1`,placeholder:`_placeholder_1n04e_17`,activeAsset:`_activeAsset_1n04e_30`,iconContainer:`_iconContainer_1n04e_34`,assetIcon:`_assetIcon_1n04e_44`,chainIcon:`_chainIcon_1n04e_54`,assetPlaceholder:`_assetPlaceholder_1n04e_68`,pulse:`_pulse_1n04e_1`,assetName:`_assetName_1n04e_89`,assetChain:`_assetChain_1n04e_104`,balance:`_balance_1n04e_112`,value:`_value_1n04e_121`},Ag=()=>(0,y.jsxs)(`div`,{className:(0,F.default)(kg.asset,kg.placeholder),children:[(0,y.jsxs)(`div`,{className:kg.iconContainer,children:[(0,y.jsx)(`div`,{className:kg.assetIcon}),(0,y.jsx)(`div`,{className:kg.chainIcon})]}),(0,y.jsx)(`div`,{className:kg.assetPlaceholder})]}),jg=({assetLogoUrl:e,assetSymbol:t,chainLogoUrl:n,chainName:r,chainPrettyName:i,balanceLabel:a,valueLabel:o,isActive:s,onClick:c})=>(0,y.jsxs)(`button`,{type:`button`,className:(0,F.default)(kg.asset,s&&kg.activeAsset),onClick:c,children:[(0,y.jsxs)(`div`,{className:kg.iconContainer,children:[(0,y.jsx)(K,{src:e,alt:t,className:kg.assetIcon,classNames:{placeholder:kg.assetIcon}}),(0,y.jsx)(K,{src:n,alt:r,className:kg.chainIcon,classNames:{placeholder:kg.chainIcon}})]}),(0,y.jsxs)(`p`,{className:kg.assetName,children:[t,` `,s&&(0,y.jsx)(`span`,{children:(0,y.jsx)(L.IconCheck,{size:16})})]}),(0,y.jsxs)(`p`,{className:kg.assetChain,children:[`on `,i]}),a!==void 0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:kg.balance,children:a}),(0,y.jsx)(`p`,{className:kg.value,children:o})]})]});jg.Skeleton=Ag;var Mg=()=>{let{watch:e,setValue:t}=Lm(),n=Rm(),{chainAssets:r}=Dn(),{localOptions:i=[]}=Yt(),a=r.filter(e=>i.some(t=>t.chainId===e.chainId&&on(t.denom)===on(e.denom))),{assetGroups:o,unlistedAssets:s}=Aa(),c=[...o.flatMap(e=>e.assets),...s],l=(e,t)=>c.find(n=>n.chain.chainId===e&&on(n.denom)===on(t)),u=(0,p.sortWith)([(0,p.descend)(e=>l(e.chainId,e.denom)?.value??0)],a),f=e(`receiveDenom`),m=e(`receiveChainId`);return(0,y.jsx)(Wm,{title:`Select receive assets`,onBack:()=>n(`onramp`),children:(0,y.jsx)(Wm.List,{children:u.map(e=>{let r=l(e.chainId,e.denom);return(0,y.jsx)(jg,{assetLogoUrl:e.logoUrl,assetSymbol:e.symbol,chainLogoUrl:e.chainLogoUrl,chainName:e.chainName,chainPrettyName:e.chainName,isActive:on(f)===on(e.denom)&&m===e.chainId,onClick:()=>{t(`receiveSymbol`,e.symbol),t(`receiveDenom`,e.denom),t(`receiveChainId`,e.chainId),n(`onramp`)},balanceLabel:r?(0,d.formatAmount)(r.amount,{decimals:r.decimals}):void 0,valueLabel:r?bl(r.value,r.price):void 0},`${e.chainId}-${e.denom}`)})})})},Ng={container:`_container_3iif4_1`,page:`_page_3iif4_7`},Pg=({page:e,renderPage:t})=>{let n=(0,pe.useTransition)(e,{keys:e,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:`absolute`,inset:0},config:{tension:500,friction:30,clamp:!0,duration:150},immediate:(0,le.useMediaQuery)(`(prefers-reduced-motion: reduce)`)});return(0,y.jsx)(`div`,{className:Ng.container,children:n((e,n)=>(0,y.jsx)(pe.animated.div,{style:e,className:Ng.page,children:t(n)}))})},Fg={surface:`_surface_1vgoa_1`},Ig=({children:e})=>(0,y.jsx)(`div`,{className:Fg.surface,children:e});function Lg({chainIds:e,chains:t}){return Object.fromEntries(e.map(e=>[e,t?.[e]?.denoms??{}]))}function Rg(e,t){if(!e)return;if(e[t])return e[t];let n=on(t),r=Object.keys(e).find(e=>on(e)===n);return r?e[r]:void 0}function zg(){let e=an(),{data:t,error:n}=(0,u.useQuery)({queryKey:rn.chains.queryKey,queryFn:()=>e.get(`v2/info/chains`).json(),select:({chains:e})=>e.filter(({chain_type:e,bech32_prefix:t})=>e===`evm`||e===`cosmos`&&t===`init`),staleTime:B.MINUTE});return{chains:t??[],error:n}}function Bg(){let e=an(),t=ja(),n=U(),{chains:r,error:i}=zg(),a=(0,g.useMemo)(()=>r.map(({chain_id:e})=>e),[r]),{data:o,error:s,isLoading:c}=(0,u.useQuery)({queryKey:rn.allBalances(a,[t,n]).queryKey,queryFn:()=>{let i=Object.fromEntries(r.map(e=>[e.chain_id,{address:e.chain_type===`evm`?t:n,denoms:[]}]));return e.post(`v2/info/balances`,{json:{chains:i}}).json()},select:({chains:e})=>Lg({chainIds:a,chains:e}),enabled:!!n&&a.length>0,staleTime:B.SECOND});return{data:o,error:s,isLoading:c,chainsError:i}}var Vg={deposit:{mode:`deposit`,label:`Deposit`,local:{denomKey:`dstDenom`,chainIdKey:`dstChainId`},external:{denomKey:`srcDenom`,chainIdKey:`srcChainId`}},withdraw:{mode:`withdraw`,label:`Withdraw`,local:{denomKey:`srcDenom`,chainIdKey:`srcChainId`},external:{denomKey:`dstDenom`,chainIdKey:`dstChainId`}}};function Hg(e){return Vg[e]}var Ug=(0,g.createContext)(null);function Wg(){let e=(0,g.useContext)(Ug);if(!e)throw Error(`useTransferFlow must be used within TransferFlow`);return e}function Gg(){let{mode:e}=Wg();return Hg(e)}function Kg(){return(0,I.useFormContext)()}function qg({mode:e,initialAsset:t,localOptions:n}){let{local:r}=Hg(e),i={page:`select-local`,quantity:``,srcDenom:``,srcChainId:``,dstDenom:``,dstChainId:``},a=t??(n.length===1?n[0]:void 0);return a&&(i[r.denomKey]=a.denom,i[r.chainIdKey]=a.chainId,i.page=e===`deposit`?`select-external`:`fields`),i}var Jg=`data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23242629'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%23585F67'/%3e%3cpath%20d='M47.7916%2037.0445C47.7916%2035.2783%2049.2313%2033.8464%2051.0071%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.0071C49.2313%2082.8837%2047.7916%2081.4519%2047.7916%2079.6854V37.0445Z'%20fill='%23585F67'/%3e%3cpath%20d='M91.7372%2056.2323C91.7372%2052.6999%2094.6166%2049.8362%2098.1681%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1681C94.6166%2066.8927%2091.7372%2064.0289%2091.7372%2060.4965V56.2323Z'%20fill='%23242629'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.24%2061.5626C97.4642%2061.5626%2096.0245%2060.1308%2096.0245%2058.3646C96.0245%2056.5984%2097.4642%2055.1665%2099.24%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%23585F67'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%232F3337'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23757C82'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23757C82'/%3e%3c/svg%3e`,Yg=`data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e`;function Xg(e){return e.length===0?``:e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(`, `)}, or ${e[e.length-1]}`}function Zg(e,t,n){let r=[...new Set(e)],i=[],a=[...n,t];for(let e of a)r.includes(e)&&!i.includes(e)&&i.push(e);let o=r.filter(e=>!i.includes(e)).sort((e,t)=>e.localeCompare(t));return[...i,...o]}function Qg(e,t,n){if(!e.length)return``;let r=Zg(e,t,n);return r.length===1&&r[0]===t?`from any app`:`using ${Xg(r)} from any app`}function $g({localSymbol:e,externalSourceSymbols:t,externalChainNames:n,appchainSourceSymbols:r}){let i=`No ${e} available to deposit.`,a=n.length>0,o=Xg(n),s=[...new Set(t)],c=Xg(s),l=Qg(r,e,s),u=!!l,d=s.length!==1||s[0]!==e;return a&&u?{title:i,description:`You can deposit ${e} ${d?`using ${c} from ${o}`:`from ${o}`}, or ${l}.`}:a?d?{title:i,description:`You can deposit ${e} using ${c} from ${o}.`}:{title:i,description:`You can deposit ${e} from ${o}.`}:u?{title:i,description:`You can deposit ${e} ${l}.`}:{title:i,description:`No deposit sources are currently available.`}}var e_=`1`,t_=`0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`,n_=`0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a`,r_={[xt]:{externalSourceSymbols:[`USDC`,`AUSD`],extraExternalOptions:[{chainId:e_,denom:t_},{chainId:e_,denom:n_}],extraInitiaSourceSymbols:[`USDC`],externalChainListSource:`extra-options`}};function i_(e,t,n){return e.chainId===t&&on(e.denom)===on(n)}function a_(e){return r_[e]}function o_(e){return e.pretty_name||e.chain_name}function s_(e){return e.chain_type!==`cosmos`||e.bech32_prefix===`init`}var c_={data:[],isLoading:!1,balancesError:null,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:``};function l_(){let{local:e}=Gg(),t=hu(),{watch:n}=Kg(),r=n(),i=r[e.chainIdKey],a=r[e.denomKey];return t.find(({denom:e,chain_id:t})=>on(a)===on(e)&&t===i)||null}function u_(){let{external:e}=Gg(),t=hu(),{watch:n}=Kg(),r=n(),i=r[e.chainIdKey],a=r[e.denomKey];return t.find(({denom:e,chain_id:t})=>on(a)===on(e)&&t===i)||null}function d_(){let{mode:e}=Wg(),t=hu(),n=iu(),r=au(),i=eu(),{data:a,error:o,chainsError:s,isLoading:c}=Bg(),{remoteOptions:l=[]}=Yt(),u=l_(),d=o??s??null;if(!u)return{...c_,isLoading:c,balancesError:d};let f=a_(u.symbol),p=f?.externalSourceSymbols??[u.symbol],m=l.length>0,h=f?.extraExternalOptions??[],g=f?.extraInitiaSourceSymbols??[],_=f?.externalChainListSource??`supported-assets`,v=new Map(n.map(e=>[e.chain_id,e])),y=t.filter(({symbol:e,denom:t,chain_id:n})=>{if(m)return l.some(e=>i_(e,n,t));let r=h.some(e=>i_(e,n,t)),a=v.get(n),o=!!a&&i(a.chain_id)&&g.includes(e),s=r||o;return e===u.symbol||s}).map(e=>{if(e.hidden||e.chain_id===u.chain_id)return null;let t=r(e.chain_id);return!t||!s_(t)?null:{asset:e,chain:t,balance:a?.[t.chain_id]?.[e.denom]}}).filter(e=>e!==null),b=y.filter(({balance:t})=>e!==`deposit`||!!t&&Number(t.amount)>0),x=new Map;if(_===`extra-options`)for(let{chainId:e}of h){let t=v.get(e);t&&s_(t)&&(i(t.chain_id)||x.set(t.chain_id,t))}else for(let{chain:e}of b)i(e.chain_id)||x.set(e.chain_id,e);return{data:b,isLoading:c,balancesError:d,supportedExternalChains:Array.from(x.values()).sort((e,t)=>o_(e).localeCompare(o_(t))),appchainSourceSymbols:[...new Set(y.filter(({chain:e})=>tu(e,i)).map(({asset:e})=>e.symbol))],externalSourceSymbols:p,localSymbol:u.symbol}}var f_={container:`_container_15pv2_1`,"empty-icon":`_empty-icon_15pv2_5`,empty:`_empty_15pv2_5`,"empty-description":`_empty-description_15pv2_20`,list:`_list_15pv2_32`},p_=()=>{let{mode:e,onExit:t}=Wg(),{external:n}=Gg(),{data:r,isLoading:i,balancesError:a,supportedExternalChains:o,appchainSourceSymbols:s,externalSourceSymbols:c,localSymbol:l}=d_(),{setValue:u,watch:f}=Kg(),p=l_(),{data:m}=sn(),{theme:h}=z(),_=f(),v=_[n.denomKey],b=_[n.chainIdKey],x=!i&&r.length===1?`${r[0].chain.chain_id}:${r[0].asset.denom}`:``;function S(t,r){u(n.denomKey,t),u(n.chainIdKey,r),e===`deposit`&&u(`quantity`,``),u(`page`,`fields`)}let C=(0,g.useEffectEvent)(()=>{if(!x)return;let[{asset:e,chain:t}]=r;if(v===e.denom&&b===t.chain_id){u(`page`,`fields`);return}S(e.denom,t.chain_id)});(0,g.useEffect)(()=>{C()},[x]);let w=!!(v&&b),T=w||!!t||m.length>1||e!==`deposit`;function E(){e===`withdraw`||w?u(`page`,`fields`):t?t():u(`page`,`select-local`)}let D=T?E:void 0;if(!p)return(0,y.jsx)(`div`,{className:f_.container,children:(0,y.jsx)(Wm,{title:`No available assets`,onBack:D,children:(0,y.jsx)(pg,{children:`No assets found`})})});if(e===`deposit`&&a&&!r.length)return(0,y.jsx)(`div`,{className:f_.container,children:(0,y.jsx)(Wm,{title:`Deposit ${p.symbol} via wallet`,onBack:D,children:(0,y.jsx)(pg,{error:!0,children:`Failed to load balances`})})});if(!i&&!r.length){let t=$g({localSymbol:l,externalSourceSymbols:c,externalChainNames:o.map(e=>e.pretty_name||e.chain_name).filter(e=>!!e),appchainSourceSymbols:s}),n=e===`withdraw`?`No supported destinations to withdraw ${p.symbol}.`:t.title;return(0,y.jsx)(`div`,{className:f_.container,children:(0,y.jsxs)(Wm,{title:`No available assets`,onBack:D,children:[(0,y.jsx)(`img`,{src:h===`dark`?Jg:Yg,alt:`No assets`,className:f_[`empty-icon`]}),(0,y.jsx)(`p`,{className:f_.empty,children:n}),e===`deposit`&&(0,y.jsx)(`p`,{className:f_[`empty-description`],children:t.description})]})})}return(0,y.jsx)(`div`,{className:f_.container,children:(0,y.jsx)(Wm,{title:e===`withdraw`?`Select destination`:`Deposit ${p.symbol} via wallet`,onBack:D,children:(0,y.jsxs)(Wm.List,{className:f_.list,maxHeight:`min(70vh, 90vh - 81px)`,children:[i&&Array.from({length:5}).map((e,t)=>(0,y.jsx)(jg.Skeleton,{},t)),!i&&r.sort(({balance:e},{balance:t})=>Number(t?.value_usd??0)-Number(e?.value_usd??0)).map(({asset:e,chain:t,balance:n})=>{let r=v===e.denom&&b===t.chain_id;return(0,y.jsx)(jg,{assetLogoUrl:e.logo_uri,assetSymbol:e.symbol,chainLogoUrl:t.logo_uri||``,chainName:t.chain_name,chainPrettyName:t.pretty_name,isActive:r,onClick:()=>S(e.denom,t.chain_id),balanceLabel:n?(0,d.formatAmount)(n.amount,{decimals:n.decimals||6}):void 0,valueLabel:n?bl(n.value_usd,n.price):void 0},`${e.chain_id}-${e.denom}`)})]})})})},m_={list:`_list_vbla8_3`,asset:`_asset_vbla8_9`,imgPlaceholder:`_imgPlaceholder_vbla8_34`},h_=({assets:e,onSelect:t,isBusy:n})=>(0,y.jsx)(`div`,{className:m_.list,"aria-busy":n,children:e.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:m_.asset,onClick:()=>t(e),disabled:n,children:[e.logoUrl?(0,y.jsx)(`img`,{src:e.logoUrl,alt:e.symbol}):(0,y.jsx)(`div`,{className:m_.imgPlaceholder,"aria-hidden":`true`}),e.symbol]},`${e.denom}-${e.chainId}`))}),g_=()=>{let{mode:e}=Wg(),{local:t,external:n}=Gg(),{setValue:r}=Kg(),{data:i}=sn(),[a,o]=(0,g.useTransition)(),s=(i,a)=>{r(t.denomKey,i),r(t.chainIdKey,a),r(`quantity`,``),r(n.denomKey,``),r(n.chainIdKey,``),o(()=>{r(`page`,e===`withdraw`?`fields`:`select-external`)})};return i.length?(0,y.jsx)(Wm,{title:e===`withdraw`?`Select an asset to withdraw`:`Select an asset to receive`,children:(0,y.jsx)(h_,{assets:i.map(({denom:e,chain_id:t,symbol:n,logo_uri:r})=>({denom:e,chainId:t,symbol:n,logoUrl:r})),onSelect:({denom:e,chainId:t})=>s(e,t),isBusy:a})}):(0,y.jsx)(`div`,{children:`No assets found`})},__={links:`_links_xmk1x_1`,link:`_link_xmk1x_1`,divider:`_divider_xmk1x_25`},v_=({explorerUrl:e,onHistoryClick:t})=>!e&&!t?null:(0,y.jsxs)(`div`,{className:__.links,children:[e&&(0,y.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:`View transaction`}),e&&t&&(0,y.jsx)(`span`,{className:__.divider,"aria-hidden":`true`,children:`|`}),t&&(0,y.jsx)(`button`,{type:`button`,className:__.link,onClick:t,children:`Go to history`})]}),y_=`data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M29%202.71875C43.5%202.71875%2055.2812%2014.5%2055.2812%2029C55.2812%2043.5%2043.5%2055.2812%2029%2055.2812C14.5%2055.2812%202.71875%2043.5%202.71875%2029C2.71875%2014.5%2014.5%202.71875%2029%202.71875ZM29%206.34375C16.4937%206.34375%206.34375%2016.4937%206.34375%2029C6.34375%2041.5062%2016.4937%2051.6562%2029%2051.6562C41.5062%2051.6562%2051.6562%2041.5062%2051.6562%2029C51.6562%2016.4937%2041.5062%206.34375%2029%206.34375Z'%20fill='%23F85454'/%3e%3cpath%20d='M36.1616%2018.7623C37.0109%2017.9129%2038.3885%2017.9129%2039.2378%2018.7623C40.087%2019.6117%2040.0871%2020.9893%2039.2378%2021.8386L32.0763%2029.0001L39.2378%2036.1616L39.3865%2036.3279C40.083%2037.1822%2040.034%2038.4417%2039.2378%2039.2378C38.4417%2040.034%2037.1822%2040.083%2036.3279%2039.3865L36.1616%2039.2378L29.0001%2032.0763L21.8386%2039.2378C20.9893%2040.0871%2019.6117%2040.087%2018.7623%2039.2378C17.9129%2038.3885%2017.9129%2037.0109%2018.7623%2036.1616L25.9238%2029.0001L18.7623%2021.8386C17.9129%2020.9892%2017.9129%2019.6116%2018.7623%2018.7623C19.6116%2017.9129%2020.9892%2017.9129%2021.8386%2018.7623L29.0001%2025.9238L36.1616%2018.7623Z'%20fill='%23F85454'/%3e%3c/svg%3e`,b_=`data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M36%209.71875C50.5%209.71875%2062.2812%2021.5%2062.2812%2036C62.2812%2050.5%2050.5%2062.2812%2036%2062.2812C21.5%2062.2812%209.71875%2050.5%209.71875%2036C9.71875%2021.5%2021.5%209.71875%2036%209.71875ZM36%2013.3438C23.4937%2013.3438%2013.3438%2023.4937%2013.3438%2036C13.3438%2048.5062%2023.4937%2058.6562%2036%2058.6562C48.5062%2058.6562%2058.6562%2048.5062%2058.6562%2036C58.6562%2023.4937%2048.5062%2013.3438%2036%2013.3438Z'%20fill='%23D1242F'/%3e%3cpath%20d='M43.1616%2025.7623C44.0109%2024.9129%2045.3885%2024.9129%2046.2378%2025.7623C47.087%2026.6117%2047.0871%2027.9893%2046.2378%2028.8386L39.0763%2036.0001L46.2378%2043.1616L46.3865%2043.3279C47.083%2044.1822%2047.034%2045.4417%2046.2378%2046.2378C45.4417%2047.034%2044.1822%2047.083%2043.3279%2046.3865L43.1616%2046.2378L36.0001%2039.0763L28.8386%2046.2378C27.9893%2047.0871%2026.6117%2047.087%2025.7623%2046.2378C24.9129%2045.3885%2024.9129%2044.0109%2025.7623%2043.1616L32.9238%2036.0001L25.7623%2028.8386C24.9129%2027.9892%2024.9129%2026.6116%2025.7623%2025.7623C26.6116%2024.9129%2027.9892%2024.9129%2028.8386%2025.7623L36.0001%2032.9238L43.1616%2025.7623Z'%20fill='%23D1242F'/%3e%3c/svg%3e`,x_={container:`_container_1md33_1`,subtitle:`_subtitle_1md33_8`,errorIcon:`_errorIcon_1md33_24`,error:`_error_1md33_24`};function S_(e){if(!e)return`pending`;let t=e.state;return t===`STATE_COMPLETED_SUCCESS`?`success`:t===`STATE_ABANDONED`||t===`STATE_COMPLETED_ERROR`||t===`STATE_PENDING_ERROR`?`failed`:`pending`}function C_(){let{mode:e}=Wg(),{closeModal:t}=kr(),{theme:n}=z(),{watch:r}=Kg(),{result:i}=r(),{openDrawer:a}=Or();if(!i)throw Error(`Transfer is completed but result is missing`);let o=!i.success,s=o?``:i.txhash,c=o?``:i.chainId,l=o?0:i.timestamp??0,{route:u,values:d}=i,{srcDenom:f,srcChainId:p,quantity:m}=d,h=Pm().symbol(p,f),g=e===`deposit`?`Deposit`:`Withdraw`,{data:_}=xf({chainId:c,txHash:s,tracked:!1,timestamp:l,route:u,values:d}),{data:v}=Sf({chainId:c,txHash:s,tracked:!!_,timestamp:l,route:u,values:d}),b=S_(v),x=n===`dark`?y_:b_,S=`https://assets.initia.xyz/videos/Loading${n===`dark`?`Dark`:`Light`}.mp4`,C=`https://assets.initia.xyz/videos/Completed${n===`dark`?`Dark`:`Light`}.mp4`;if(o)return(0,y.jsx)(Wm,{title:`${g} failed`,children:(0,y.jsxs)(`div`,{className:x_.container,children:[(0,y.jsx)(`img`,{src:x,alt:`Failed`,className:x_.errorIcon}),(0,y.jsx)(`p`,{className:x_.error,children:i.error}),(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`})]})});let w=Gu(u.estimated_route_duration_seconds),T=new URLSearchParams({tx_hash:s,chain_id:c}),E=new URL(`?${T.toString()}`,`https://explorer.skip.build`),D=()=>(0,y.jsx)(v_,{explorerUrl:E.toString(),onHistoryClick:()=>{t(),a(`/bridge/history`)}});return(0,y.jsx)(Wm,{title:(()=>{switch(b){case`pending`:return`${e===`deposit`?`Depositing`:`Withdrawing`} ${m} ${h}`;case`success`:return`${g} complete`;case`failed`:return`${g} failed`}})(),children:(0,y.jsxs)(`div`,{className:x_.container,children:[b===`pending`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`video`,{src:S,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:`72px`,height:`72px`,marginBottom:`12px`}}),(0,y.jsxs)(`p`,{className:x_.subtitle,children:[`Estimated time: `,(0,y.jsx)(`span`,{children:w})]}),D(),(0,y.jsx)(`p`,{className:x_.subtitle,children:`Your transaction will continue even if you close this`})]}),b===`success`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`video`,{src:C,autoPlay:!0,muted:!0,playsInline:!0,style:{width:`72px`,height:`72px`},onTimeUpdate:e=>{let t=e.currentTarget;t.duration-t.currentTime<.1&&t.pause()}}),D(),(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`})]}),b===`failed`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`img`,{src:x,alt:`Failed`,className:x_.errorIcon}),(0,y.jsx)(`p`,{className:x_.error,children:`Your transaction could not be completed`}),(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`})]})]})})}var w_=(0,m.createQueryKeys)(`interwovenkit:tx-gas-estimate`,{estimate:e=>[e]}),T_=({tx:e,children:t})=>{let{values:n}=ff(),{srcChainId:r}=n,i=U(),a=Gr(),o=Kr(),s=ai(),{data:c,isLoading:l,isFetching:d}=(0,u.useQuery)({queryKey:w_.estimate({tx:e,address:i,chainId:r}).queryKey,queryFn:async()=>{if(!(`cosmos_tx`in e)||!e.cosmos_tx.msgs)return null;try{let t=cf(e.cosmos_tx.msgs,{converters:a,fromAmino:o.fromAmino.bind(o)});return{estimatedGas:await(await s(r)).simulate(i,t,``),messages:t}}catch{return null}},enabled:`cosmos_tx`in e&&!!i&&!!r});return`cosmos_tx`in e&&!c&&l?(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{loading:`Estimating gas...`,disabled:!0,fullWidth:!0})}):(0,y.jsx)(y.Fragment,{children:t(c?.estimatedGas??null,{isEstimatingGas:`cosmos_tx`in e&&(l||d)})})};function E_({hasBalancesSnapshot:e,hasBalanceQueryError:t,isBalancesLoading:n}){if(!e){if(n)return`loading`;if(t)return`error`}}function D_({hasBalancesSnapshot:e,balance:t}){if(e)return t??`0`}function O_(e){if(!e)return null;let t=(0,f.default)(e);return!t.isFinite()||t.lt(0)?null:t}function k_({balance:e,requiredAmount:t}){if(t===`0`)return!0;let n=O_(e??`0`),r=O_(t);return!n||!r?!1:n.gte(r)}function A_({sourceDenom:e,feeDetailsByDenom:t}){let n=t.get(e);if(!(!n||n.isSufficient)){for(let[n,r]of t)if(n!==e&&r.isSufficient)return;if((0,f.default)(n.balance||0).gte(n.fee||0))return`Make sure to leave enough for transaction fee`}}function j_({feeDenom:e,sourceDenom:t,feeWarning:n,hasSourceBalance:r,isFeeBalanceSufficient:i}){if(!r)return{error:`Insufficient balance`};let a=e===t?n:void 0;return a?{warning:a}:i?{}:{error:`Insufficient balance`}}var M_={container:`_container_1qkz8_1`,token:`_token_1qkz8_11`},N_=({renderFee:e})=>{let{route:t}=Yt(),{values:n}=ff(),{dstDenom:r,dstChainId:i}=n,a=hu().find(({denom:e,chain_id:t})=>on(e)===on(r)&&t===i),o=U(),s=zc(),c=t&&t.estimated_route_duration_seconds>60;if(!t||!a)return null;let l=Ku(t.amount_out,n.slippagePercent);return(0,y.jsxs)(`div`,{className:M_.container,children:[(0,y.jsxs)(cm,{title:`Transaction details`,children:[t.does_swap&&(0,y.jsxs)(um,{label:`Slippage`,children:[n.slippagePercent,`%`]}),!!t.estimated_fees?.length&&(0,y.jsx)(um,{label:`Bridge fee`,children:qu(t.estimated_fees)}),e&&(0,y.jsx)(um,{label:`Tx fee`,children:e()}),o&&(0,y.jsxs)(um,{label:`Receiving address`,children:[(0,y.jsx)(`img`,{src:s,alt:`Wallet`,height:12,width:12}),` `,(0,d.truncate)(o)]}),t.does_swap&&(0,y.jsxs)(um,{label:`Minimum received`,children:[(0,y.jsx)(`img`,{src:a.logo_uri,alt:a.symbol,className:M_.token}),` `,(0,d.formatAmount)(l,{decimals:a.decimals}),` `,a.symbol]})]}),(0,y.jsx)(um,{label:`Estimated time`,valueStyle:c?{color:`var(--warning)`}:void 0,children:Gu(t.estimated_route_duration_seconds)}),(0,y.jsxs)(um,{label:`Estimated received`,emphasized:!0,children:[(0,y.jsx)(`img`,{src:a.logo_uri,alt:a.symbol,className:M_.token}),` `,(0,d.formatAmount)(t.amount_out,{decimals:a.decimals}),` `,a.symbol]})]})},P_={trigger:`_trigger_1c7d7_1`,item:`_item_1c7d7_5`,itemText:`_itemText_1c7d7_13`};function F_(e){return!e.isFetchingMessages&&!e.messageRefreshError}function I_(e,t,n){return F_(n)?(0,y.jsx)(np,{tx:e,children:t}):t}function L_({feeDetailsByDenom:e,feeOptions:t,lastUsedFeeDenom:n,preferredFeeDenom:r}){if(r&&e.get(r)?.isSufficient)return r;if(n&&e.get(n)?.isSufficient)return n;for(let n of t){let[{denom:t}]=n.amount;if(e.get(t)?.isSufficient)return t}return t[0]?.amount[0].denom}var R_=({tx:e,gas:t,confirmMessage:n,onCompleted:r,messageRefreshError:i,isRouteTransitioning:a,isFetchingMessages:o,isEstimatingGas:s})=>{let{values:c}=ff(),{srcChainId:l,srcDenom:u,quantity:p}=c,m=hu().find(({denom:e,chain_id:t})=>e===u&&t===l),h=tt(l),_=Rt(h),v=Wi(h),b=Gi(h),x=pt(h),S=t==null?[]:v.map(({amount:e,denom:n})=>(0,M.calculateFee)(Math.ceil(t*Ne),M.GasPrice.fromString(e+n))),C=new Map(S.map(e=>{let[{denom:t}]=e.amount;return[t,e]})),w=new Map(_.map(({denom:e,amount:t})=>[e,t])),T=m?(tn(p)??(0,f.default)(0)).times((0,f.default)(10).pow(m.decimals)).toFixed(0):`0`,E=new Map(S.map(e=>{let[{amount:t,denom:n}]=e.amount,r=w.get(n)||`0`,i=m&&u===n?T:`0`,a=(0,f.default)(t||0).plus(i),{symbol:o,decimals:s}=x(n);return[n,{symbol:o,decimals:s,spend:(0,f.default)(i).gt(0)?i:null,fee:t,total:a.toFixed(),balance:r,isSufficient:(0,f.default)(r).gte(a)}]})),[D,O]=(0,g.useState)(null),k={isRouteTransitioning:a,isFetchingMessages:o,isEstimatingGas:s,messageRefreshError:i},A=L_({feeDetailsByDenom:E,feeOptions:S,lastUsedFeeDenom:b,preferredFeeDenom:D}),j=A?C.get(A):void 0,ee=A?E.get(A):null,te=j_({feeDenom:A,sourceDenom:u,feeWarning:A_({sourceDenom:u,feeDetailsByDenom:E}),hasSourceBalance:k_({balance:w.get(u)||`0`,requiredAmount:T}),isFeeBalanceSufficient:ee?.isSufficient??!0}),N=(0,y.jsx)(Uf,{tx:e,fee:j,onCompleted:r,confirmMessage:n,error:te.error,warning:te.warning,...k});return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(N_,{renderFee:S.length>0?()=>{if(S.length===0)return null;if(S.length===1)return(0,y.jsx)(`span`,{className:`monospace`,children:ol(S[0],x)});if(!j||!A)return null;let e=S.map(e=>{let[{denom:t}]=e.amount,{symbol:n}=x(t);return{value:t,label:ol(e,x),triggerLabel:n}}),[{amount:t,denom:n}]=j.amount,{decimals:r}=x(n);return(0,y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,y.jsx)(`span`,{className:`monospace`,children:(0,d.formatAmount)(t,{decimals:r,dp:al(t,r)})}),(0,y.jsx)(il,{options:e,value:A,onChange:O,classNames:P_})]})}:void 0}),I_(e,N,k)]})},z_=({tx:e,gas:t,messageRefreshError:n,isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:a})=>{let{mode:o}=Wg(),{setValue:s}=Kg(),c={isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:a,messageRefreshError:n},l=e=>{s(`page`,`completed`),s(`result`,e)},u=o===`withdraw`?`Withdraw`:`Deposit`,d=(0,y.jsx)(Uf,{tx:e,fee:void 0,onCompleted:l,confirmMessage:u,...c});return`cosmos_tx`in e?(0,y.jsx)(R_,{tx:e,gas:t,onCompleted:l,confirmMessage:u,...c}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(N_,{}),I_(e,d,c)]})};function B_(e,t){return e?(0,d.InitiaAddress)(e).hex:t}function V_({currentState:e,route:t,quoteVerifiedAt:n,hexAddress:r,values:i}){return{...e,route:t,quoteVerifiedAt:n,values:{sender:r,recipient:B_(e.recipientAddress,r),slippagePercent:`0.1`,...i}}}function H_(e){return{recipient:e.values?.recipient,sender:e.values?.sender}}function U_({currentState:e,nextState:t}){if(e.route!==t.route||e.quoteVerifiedAt!==t.quoteVerifiedAt)return!0;let n=H_(e),r=H_(t);return n.sender!==r.sender||n.recipient!==r.recipient}function W_({mode:e,hasSingleExternalAssetOption:t,canExit:n}){if(e===`deposit`&&t&&n)return{type:`exit`};let r=e===`withdraw`||t;return{type:`page`,page:r?`select-local`:`select-external`,clearLocal:r}}var G_={container:`_container_1wc2a_1`,title:`_title_1wc2a_6`,divider:`_divider_1wc2a_14`,label:`_label_1wc2a_18`,asset:`_asset_1wc2a_25`,assetIcon:`_assetIcon_1wc2a_43`,chainIcon:`_chainIcon_1wc2a_55`,assetName:`_assetName_1wc2a_68`,chevron:`_chevron_1wc2a_80`,input:`_input_1wc2a_84`,balanceContainer:`_balanceContainer_1wc2a_96`,value:`_value_1wc2a_104`,maxButton:`_maxButton_1wc2a_114`};function K_({disabledMessage:e,routeForState:t,routeError:n,isNoRouteError:r,isServerError:i}){return e?`disabled`:t?`ready`:n?r?`no-route`:i?`server-error`:`refresh-failed`:`loading`}function q_({hasRouteState:e,routeStatus:t}){return e&&(t===`ready`||t===`loading`)}function J_({routeStatus:e,disabledMessage:t,isRouteSynced:n}){if(e===`disabled`)return t;if(e===`loading`||e===`ready`&&!n)return`Fetching route...`;if(e===`no-route`)return`No route found`;if(e===`server-error`)return`Server error`;if(e===`refresh-failed`)return`Failed to refresh route`}var Y_=typeof window>`u`?g.useEffect:g.useLayoutEffect,X_=()=>{let{mode:e,onExit:t}=Wg(),n=Gg(),r=Zt(),i=Yt(),{data:a}=sn(),o=au(),{data:s,error:c,chainsError:l,isLoading:u}=Bg(),p=ja(),{watch:m,setValue:_,getValues:v}=Kg(),b=m(),{srcChainId:x,srcDenom:S,quantity:C=``}=b,{recipientAddress:w,route:T}=i,E=b[n.external.denomKey],D=b[n.external.chainIdKey],O=l_(),k=u_(),{data:A,isLoading:j}=d_(),M=!j&&A.length===1,ee=e===`withdraw`&&!j&&A.length>0&&new Set(A.map(({chain:e})=>e.chain_id)).size===1,te=(0,g.useMemo)(()=>j||!A.length?null:M?A[0]:ee?A.reduce((e,t)=>{let n=Number(e.balance?.value_usd??0);return Number(t.balance?.value_usd??0)>n?t:e},A[0]):null,[A,M,ee,j]),N=te?`${te.chain.chain_id}:${te.asset.denom}`:``,ne=D?o(D):null,re=Rg(s?.[x],S),ie=re?.amount,ae=re?.price,oe=(0,f.default)(ae||0).times(tn(C)??0),[se]=(0,le.useDebounceValue)(C,300),ce=e===`withdraw`?O:k,P=E_({hasBalancesSnapshot:s!==void 0,hasBalanceQueryError:!!(c||l),isBalancesLoading:u}),ue=D_({hasBalancesSnapshot:s!==void 0,balance:ie}),F=(0,g.useMemo)(()=>{if(e===`deposit`&&!k)return`Select asset`;let t=tn(C);if(!t||t.lte(0))return`Enter amount`;if(e===`withdraw`&&!k)return`Select destination`;if(P===`loading`)return`Loading balances...`;if(P===`error`)return`Failed to load balances`;if(ue!==void 0){let e=(0,d.fromBaseUnit)(ue,{decimals:ce?.decimals||6});if(t.gt(e||0))return`Insufficient balance`}},[ce,ue,P,k,e,C]),{data:I,error:de,dataUpdatedAt:fe}=Yu(se,{disabled:(0,g.useMemo)(()=>{if(e===`deposit`&&!k)return!0;let t=tn(C);if(!t||t.lte(0)||e===`withdraw`&&!k||P===`error`)return!0;if(ue!==void 0){let e=(0,d.fromBaseUnit)(ue,{decimals:ce?.decimals||6});if(t.gt(e||0))return!0}return!1},[ce,ue,P,k,e,C])}),pe=de instanceof h.HTTPError&&de.response.status===400,me=!F&&!pe?I:void 0,he=me&&fe>0?fe:void 0,R=K_({disabledMessage:F,routeForState:me,routeError:de,isNoRouteError:pe,isServerError:de instanceof h.HTTPError&&de.response.status===500}),ge=R===`ready`&&i.route===me,_e=R===`loading`||R===`ready`&&!ge,ve=q_({hasRouteState:!!i.route,routeStatus:R}),ye=J_({routeStatus:R,disabledMessage:F,isRouteSynced:ge});Y_(()=>{let e=V_({currentState:i,route:me,quoteVerifiedAt:he,hexAddress:p,values:v()});U_({currentState:i,nextState:e})&&r(0,e)},[T,v,p,r,he,w,me]);let be=(0,g.useEffectEvent)(()=>{if(!te||E&&D)return;let{asset:t,chain:r}=te;_(n.external.denomKey,t.denom),_(n.external.chainIdKey,r.chain_id),e===`deposit`&&_(`quantity`,``)});if((0,g.useEffect)(()=>{be()},[N]),!O||e===`deposit`&&!k)return null;let xe=ce?.decimals||6,Se=e===`withdraw`?`Select chain`:`Select asset`,Ce=()=>{let r=W_({mode:e,hasSingleExternalAssetOption:M,canExit:!!t});if(r.type===`exit`){t?.();return}_(`quantity`,``),_(n.external.denomKey,``),_(n.external.chainIdKey,``),r.clearLocal&&(_(n.local.denomKey,``),_(n.local.chainIdKey,``)),_(`page`,r.page)},we=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:G_.label,children:e===`withdraw`?`Destination`:`From`}),(0,y.jsxs)(`button`,{className:G_.asset,disabled:M,onClick:()=>_(`page`,`select-external`),children:[(0,y.jsx)(`div`,{className:G_.assetIcon,children:k?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`img`,{src:k.logo_uri,alt:k.symbol}),(0,y.jsx)(`img`,{src:ne?.logo_uri||``,alt:ne?.pretty_name,className:G_.chainIcon})]}):e===`withdraw`&&(0,y.jsx)(`div`,{className:G_.chainIcon})}),(0,y.jsx)(`p`,{className:G_.assetName,children:k?(0,y.jsxs)(y.Fragment,{children:[k.symbol,(0,y.jsx)(`br`,{}),(0,y.jsxs)(`span`,{children:[`on `,ne?.pretty_name]})]}):Se}),!M&&(0,y.jsx)(L.IconChevronDown,{className:G_.chevron,size:16})]})]}),Te=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:G_.label,children:`Amount`}),(0,y.jsx)(Lu,{balance:ue,decimals:xe,className:G_.input}),ue!==void 0&&(0,y.jsxs)(`div`,{className:G_.balanceContainer,children:[(0,y.jsx)(`p`,{className:G_.value,children:C?bl(oe.toString(),ae):`$-`}),(0,y.jsxs)(`button`,{className:G_.maxButton,onClick:()=>{let e=(0,d.fromBaseUnit)(ue,{decimals:xe});tn(C)?.eq(e||0)||_(`quantity`,e)},children:[(0,y.jsx)(L.IconWallet,{size:16}),` `,(0,d.formatAmount)(ue,{decimals:xe}),` `,(0,y.jsx)(`span`,{children:`MAX`})]})]})]});return(0,y.jsxs)(`section`,{className:G_.container,"aria-label":`Transfer form`,children:[(t!==void 0||a.length>1)&&(0,y.jsx)(Hm,{onClick:Ce}),(0,y.jsx)(`h3`,{className:G_.title,children:e===`deposit`?`Deposit ${O.symbol} via wallet`:`${n.label} ${O.symbol}`}),e===`withdraw`?(0,y.jsxs)(y.Fragment,{children:[Te,(0,y.jsx)(`div`,{className:G_.divider}),we]}):(0,y.jsxs)(y.Fragment,{children:[we,(0,y.jsx)(`div`,{className:G_.divider}),Te]}),(l||c)&&(0,y.jsx)(pg,{error:!0,children:`Failed to load balances`}),ve?(0,y.jsx)(Qf,{children:e=>(0,y.jsx)(dp,{children:t=>(0,y.jsx)(up,{addressList:e,signedOpHook:t,children:(e,{isFetchingMessages:t,messageRefreshError:n})=>(0,y.jsx)(T_,{tx:e,children:(r,{isEstimatingGas:i})=>(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{loading:`Estimating gas...`,disabled:!0,fullWidth:!0})}),children:(0,y.jsx)(z_,{tx:e,gas:r,isRouteTransitioning:_e,isFetchingMessages:t,isEstimatingGas:i,messageRefreshError:n})})})})})}):(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{type:`submit`,loading:_e&&`Fetching route...`,disabled:!0,fullWidth:!0,children:ye})})]})},Z_=({mode:e,initialAsset:t,onExit:n})=>{let{localOptions:r=[]}=Yt(),i=(0,I.useForm)({mode:`onChange`,defaultValues:qg({mode:e,initialAsset:t,localOptions:r})});Bg();let a=(0,g.useMemo)(()=>({mode:e,onExit:n}),[e,n]),o=(0,y.jsx)(Q_,{});return(0,y.jsx)(Ug.Provider,{value:a,children:(0,y.jsx)(I.FormProvider,{...i,children:n?o:(0,y.jsx)(Yc,{children:o})})})},Q_=()=>{let{watch:e}=Kg(),t=e(`page`),n=e=>{switch(e){case`select-local`:return(0,y.jsx)(g_,{});case`select-external`:return(0,y.jsx)(p_,{});case`fields`:return(0,y.jsx)(X_,{});case`completed`:return(0,y.jsx)(C_,{})}};return(0,y.jsx)(Pg,{page:t,renderPage:e=>(0,y.jsx)(Ig,{children:n(e)})})};function $_(e,t={},n){let r={page:`select-asset`,receiveSymbol:``,receiveDenom:``,receiveChainId:``,method:`address`,trackedDepositId:``,fiatId:n?.currency||t.fiatId||`usd`,fiatAmount:n?.amount??``,paymentMethodId:t.paymentMethodId||`creditcard`,providerId:``};if(e.length===1){let[{denom:t,chainId:n}]=e;r.receiveDenom=t,r.receiveChainId=n,r.page=`select-method`}return r}function ev(e){let{amountOut:t,sentAmount:n,dstDecimals:r,srcDecimals:i,receiveSymbol:a,sentSymbol:o}=e,s=t&&r!==void 0?(0,d.fromBaseUnit)(t,{decimals:r}):``;if(s&&(0,f.default)(s).gt(0))return`${(0,d.formatNumber)(s,{dp:6})} ${a}`;let c=n&&i!==void 0?(0,d.fromBaseUnit)(n,{decimals:i}):``;return c&&(0,f.default)(c).gt(0)?`${(0,d.formatNumber)(c,{dp:6})} ${o}`:`Your ${a}`}var tv={body:`_body_nhvhe_1`,heading:`_heading_nhvhe_11`,delayHeading:`_delayHeading_nhvhe_16`,successIcon:`_successIcon_nhvhe_23`,failIcon:`_failIcon_nhvhe_27`,confirming:`_confirming_nhvhe_31`,chainLogo:`_chainLogo_nhvhe_37`},nv=60*1e3,rv=()=>{let e=Rm(),{closeModal:t}=kr(),{openDrawer:n}=Or(),{watch:r}=Lm(),i=U(),a=r(`receiveSymbol`),o=r(`receiveDenom`),s=r(`receiveChainId`),c=r(`method`),l=r(`trackedDepositId`),u=jn({denom:o,chainId:s,symbol:a}),{data:d,isError:f,error:p}=mm({walletAddress:i,chainId:s,assetDenom:o}),{deposit:m,isError:h,error:_}=Mm({depositAddress:d?.deposit_address??``,depositId:l}),v=_ instanceof Dm||f&&!m,b=ym(m),x=_m(b),[S,C]=(0,g.useState)(null),w=m?.status,T=!!w&&S===w;(0,g.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>C(w),nv);return()=>clearTimeout(e)},[w]);let E=Pm(),D=iu(),O=m?E.symbol(m.src_chain_id,m.src_denom):``,k=m?E.logoUrl(m.src_chain_id,m.src_denom):``,A=m?D.find(e=>e.chain_id===m.src_chain_id):void 0,j=m?A?.pretty_name??ln(m.src_chain_id):``,M=m?.bot_tx_explorer_url?(0,fe.default)(jc(m.bot_tx_explorer_url)):``,ee=On(m?.src_chain_id??``,m?.src_denom??``),te=m?.required_min_amount&&ee?un(m.required_min_amount,ee.src_decimals,O):``,N=m&&ee?pn(ee,m.dst_chain_id,m.dst_denom):void 0,ne=ev({amountOut:m?.amount_out,sentAmount:m?.amount,dstDecimals:N?.decimals,srcDecimals:ee?.src_decimals,receiveSymbol:a,sentSymbol:O}),re=()=>{if(v)return`Deposit status`;switch(b){case`waiting`:return`Confirming your deposit…`;case`processing`:return`Transferring…`;case`completed`:return c===`onramp`?`Transaction complete`:`Transfer complete`;case`failed`:case`below_minimum`:return`Deposit status`}},ie=m&&(0,y.jsx)(hg,{steps:[{label:`You sent`,logoUrl:k,chainLogoUrl:A?.logo_uri??``,text:O},{label:`You receive`,logoUrl:u.logoUrl,chainLogoUrl:u.chainLogoUrl,text:a}]}),ae=()=>T?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:tv.delayHeading,children:`This is taking a little longer`}),(0,y.jsxs)(pg,{children:[`We hit a temporary delay and are retrying.`,(0,y.jsx)(`br`,{}),`Your funds are safe at your deposit address.`]})]}):m?b===`waiting`?(0,y.jsx)(pg,{children:(0,y.jsxs)(`span`,{className:tv.confirming,children:[`Your deposit is confirming on`,(0,y.jsx)(K,{src:A?.logo_uri??``,width:16,height:16,className:tv.chainLogo,classNames:{placeholder:tv.chainLogo}}),j]})}):(0,y.jsx)(pg,{children:`We're moving your funds to the destination chain now.`}):null;return(0,y.jsxs)(Wm,{title:re(),children:[(0,y.jsxs)(`div`,{className:tv.body,children:[(()=>{if(v)return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(L.IconCloseCircleFilled,{size:48,className:tv.failIcon,"aria-hidden":`true`}),(0,y.jsx)(`p`,{className:tv.heading,children:`Couldn't track your deposit`}),(0,y.jsx)(pg,{error:!0,children:(p??_)?.message??`Something went wrong while tracking your deposit.`})]});switch(b){case`completed`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(L.IconCheckCircleFilled,{size:48,className:tv.successIcon,"aria-hidden":`true`}),(0,y.jsxs)(pg,{children:[ne,` was delivered to your wallet on `,u.chainName,`. It may take a moment to appear in your activity.`]}),(0,y.jsx)(v_,{explorerUrl:M,onHistoryClick:()=>n(`/activity`)})]});case`failed`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(L.IconCloseCircleFilled,{size:48,className:tv.failIcon,"aria-hidden":`true`}),(0,y.jsx)(`p`,{className:tv.heading,children:`Deposit failed`}),(0,y.jsx)(pg,{error:!0,children:`This deposit could not be completed. Your funds remain at the deposit address with no automatic refund.`}),(0,y.jsx)(v_,{explorerUrl:M})]});case`below_minimum`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(L.IconCloseCircleFilled,{size:48,className:tv.failIcon,"aria-hidden":`true`}),(0,y.jsx)(`p`,{className:tv.heading,children:`Amount below minimum`}),(0,y.jsxs)(pg,{error:!0,children:[te?`Deposits below ${te} can't be processed. `:``,`Your funds remain at the deposit address with no automatic refund.`]})]});case`waiting`:case`processing`:return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(uc,{size:40,color:`var(--success)`}),ae(),ie]})}})(),h&&!v&&!x&&(0,y.jsx)(pg,{error:!0,children:`Connection lost. Retrying…`})]}),v||b===`failed`||b===`below_minimum`?(0,y.jsx)(mc,{children:(0,y.jsx)(G.Outline,{fullWidth:!0,onClick:t,children:`Close`})}):b===`completed`?(0,y.jsx)(mc,{children:c===`onramp`?(0,y.jsx)(G.White,{fullWidth:!0,onClick:t,children:`Close`}):(0,y.jsx)(G.Outline,{fullWidth:!0,onClick:()=>e(`address`),children:`Make another transfer`})}):null]})},iv=()=>{let{setValue:e}=Lm(),t=Rm(),{data:n,isLoading:r,error:i}=sn(),[a,o]=(0,g.useTransition)();if(!n.length)throw Error(`openDeposit requires at least one denom`);let s=n.filter(({symbol:e})=>!e);if(s.length){if(i)throw i;if(r)return(0,y.jsx)(pg,{children:`Loading...`});throw Error(`Asset metadata not found for ${s.map(({denom:e})=>e).join(`, `)}`)}return(0,y.jsx)(Wm,{title:`Select an asset to receive`,children:(0,y.jsx)(h_,{assets:n.map(({denom:e,chain_id:t,symbol:n,logo_uri:r})=>({denom:e,chainId:t,symbol:n,logoUrl:r})),onSelect:({denom:n,chainId:r,symbol:i})=>{e(`receiveSymbol`,i),e(`receiveDenom`,n),e(`receiveChainId`,r),o(()=>{t(`select-method`)})},isBusy:a})})},av=`Card or bank transfer`,ov=()=>{let{watch:e}=Lm(),t=e(`fiatId`),n=e(`receiveDenom`),r=e(`receiveChainId`),i=Ph(t),a=sh(Vh(t,Lh(r,n)?.id??``).data??[]);return a===void 0||!i?av:lh(a,i.symbol)},sv={list:`_list_1j214_1`,section:`_section_1j214_7`,method:`_method_1j214_19`,icon:`_icon_1j214_43`,details:`_details_1j214_51`,title:`_title_1j214_59`,subtext:`_subtext_1j214_64`},cv=({sections:e,onSelect:t})=>(0,y.jsx)(`div`,{className:sv.list,children:e.map(e=>(0,y.jsxs)(g.Fragment,{children:[(0,y.jsx)(`p`,{className:sv.section,children:e.label}),e.methods.map(({id:e,title:n,subtext:r,Icon:i,iconUrl:a,disabled:o})=>(0,y.jsxs)(`button`,{type:`button`,className:sv.method,onClick:()=>t(e),disabled:o,children:[(0,y.jsx)(`span`,{className:sv.icon,children:a?(0,y.jsx)(K,{src:a,width:24,height:24,placeholder:(0,y.jsx)(i,{size:24})}):(0,y.jsx)(i,{size:24})}),(0,y.jsxs)(`span`,{className:sv.details,children:[(0,y.jsx)(`span`,{className:sv.title,children:n}),(0,y.jsx)(`span`,{className:sv.subtext,children:r})]})]},e))]},e.label))}),lv=({availability:e,onrampUnavailableReason:t})=>{let n=Wt(),r=Rm(),i=Bm(),a=ja(),o=zc();Mh();let{remoteOptions:s=[],recipientAddress:c}=Yt(),l=c||s.length>0?`Unavailable for this deposit request`:void 0,u=`Your connected wallet · ${(0,d.truncate)(a,[4,4])}`,f=e.status!==`available`||!!l,p=l??(e.status===`unavailable`?e.reason:void 0);return(0,y.jsx)(cv,{sections:[{label:`Crypto`,methods:[{id:`wallet`,title:`Deposit via wallet`,subtext:u,Icon:L.IconWallet,iconUrl:o},{id:`address`,title:`Deposit via address`,subtext:p??`From any wallet or exchange · No limit`,Icon:L.IconQrCode,disabled:f}]},{label:`Cash`,methods:[{id:`onramp`,title:`Buy with cash/card`,subtext:p??t?p??t:n?e.status===`loading`?av:(0,y.jsx)(W,{errorBoundaryProps:{fallbackRender:()=>av},suspenseFallback:av,children:(0,y.jsx)(ov,{})}):`Unavailable on this app`,Icon:L.IconBuy,disabled:f||!n||!!t}]}],onSelect:e=>{switch(e){case`wallet`:r(`wallet`);break;case`address`:case`onramp`:i(e);break}}})},uv=()=>{let{watch:e}=Lm(),t=e(`receiveDenom`),n=An(e(`receiveChainId`),t),r=Oh(),i=r&&!n.some(e=>th(r,e.src_chain_id,e.src_denom))?`Not available for this asset`:void 0;return(0,y.jsx)(lv,{availability:n.length>0?{status:`available`}:{status:`unavailable`,reason:`Not supported for this asset`},onrampUnavailableReason:i})},dv=()=>{let{depositApiUrl:e}=z(),{watch:t}=Lm(),{localOptions:n=[]}=Yt(),r=Rm(),i=(0,u.useQueryClient)(),a=t(`receiveSymbol`);return(0,y.jsx)(Wm,{title:a?`Deposit ${a}`:`Deposit`,onBack:n.length===1?void 0:()=>r(`select-asset`),children:e?(0,y.jsx)(W,{errorBoundaryProps:{onError:e=>console.error(e),fallbackRender:({resetErrorBoundary:e})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(lv,{availability:{status:`unavailable`,reason:`Unavailable right now`}}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{onClick:()=>{i.resetQueries({queryKey:Vt.assets.queryKey}),e()},children:`Retry`})})]})},suspenseFallback:(0,y.jsx)(lv,{availability:{status:`loading`}}),children:(0,y.jsx)(uv,{})}):(0,y.jsx)(lv,{availability:{status:`unavailable`,reason:`Unavailable on this network`}})})},fv=()=>{let{localOptions:e=[],onramp:t}=Yt();return(0,y.jsxs)(I.FormProvider,{...(0,I.useForm)({mode:`onChange`,defaultValues:$_(e,{paymentMethodId:localStorage.getItem(H.ONRAMP_PAYMENT_TYPE_ID),fiatId:localStorage.getItem(H.ONRAMP_FIAT_ID)},t)}),children:[(0,y.jsx)(pv,{}),(0,y.jsx)(mv,{})]})},pv=()=>{let{watch:e,setValue:t}=Lm(),n=e(`receiveSymbol`),r=e(`receiveDenom`),i=e(`receiveChainId`),{data:a,isLoading:o,error:s}=sn(),c=a.find(({denom:e,chain_id:t})=>e===r&&t===i)?.symbol;if((0,g.useEffect)(()=>{n||!c||t(`receiveSymbol`,c)},[n,c,t]),r&&!n&&!c&&!o)throw s??Error(`Asset metadata not found for ${r} on ${i}`);return null},mv=()=>{let{watch:e}=Lm(),t=e(`page`),n=e=>{switch(e){case`select-asset`:return(0,y.jsx)(iv,{});case`select-method`:return(0,y.jsx)(dv,{});case`wallet`:return(0,y.jsx)(hv,{});case`address`:return(0,y.jsx)(Zm,{});case`track`:return(0,y.jsx)(rv,{});case`onramp`:return(0,y.jsx)(dg,{});case`onramp-select-fiat`:return(0,y.jsx)(wg,{});case`onramp-select-receive`:return(0,y.jsx)(Mg,{});case`onramp-select-payment`:return(0,y.jsx)(Eg,{});case`onramp-select-provider`:return(0,y.jsx)(Og,{});case`onramp-processing`:return(0,y.jsx)(Sg,{})}};return(0,y.jsx)(Yc,{children:(0,y.jsx)(Pg,{page:t,renderPage:e=>e===`wallet`?n(e):(0,y.jsx)(Ig,{children:n(e)})})})},hv=()=>{let{watch:e}=Lm(),t=Rm();return(0,y.jsx)(Z_,{mode:`deposit`,initialAsset:{denom:e(`receiveDenom`),chainId:e(`receiveChainId`)},onExit:()=>t(`select-method`)})},gv=()=>(0,y.jsx)(Z_,{mode:`withdraw`}),_v={root:`_root_1lo0i_1`,address:`_address_1lo0i_9`,copy:`_copy_1lo0i_19`,labelWrapper:`_labelWrapper_1lo0i_33`,labelCopy:`_labelCopy_1lo0i_43`,labelCopied:`_labelCopied_1lo0i_47`,copied:`_copied_1lo0i_55`,derived:`_derived_1lo0i_65`,derivedLabel:`_derivedLabel_1lo0i_79`,derivedAddress:`_derivedAddress_1lo0i_83`,hexAddress:`_hexAddress_1lo0i_89`,derivedCopy:`_derivedCopy_1lo0i_94`},vv=()=>{let e=(0,g.useRef)(null),t=(0,g.useRef)(null),{initiaAddress:n,hexAddress:r}=Pa(),i=Dc(`--gray-0`);return(0,g.useEffect)(()=>{e.current&&(t.current?t.current.update({data:n}):(t.current=new Te.default({type:`canvas`,width:400,height:400,margin:0,data:n,image:`https://registry.initia.xyz/images/INIT.png`,qrOptions:{mode:`Byte`,errorCorrectionLevel:`H`},imageOptions:{crossOrigin:`anonymous`,margin:12},dotsOptions:{type:`dots`,color:i},cornersSquareOptions:{type:`extra-rounded`,color:i},cornersDotOptions:{type:`dot`,color:i},backgroundOptions:{color:`transparent`}}),t.current.append(e.current)))},[n,i]),(0,y.jsx)($l,{title:`Receive`,children:(0,y.jsxs)(`div`,{className:_v.root,children:[(0,y.jsx)(`div`,{ref:e,style:{width:200,height:200}}),(0,y.jsx)(`span`,{className:_v.address,children:n}),(0,y.jsx)(Lc,{value:n,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{className:(0,F.default)(_v.copy,{[_v.copied]:t}),onClick:e,"aria-label":t?`Copied`:`Copy address`,children:[(0,y.jsx)(L.IconCopy,{size:12,"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:_v.labelWrapper,children:[(0,y.jsx)(`span`,{className:_v.labelCopy,children:`Copy address`}),(0,y.jsx)(`span`,{className:_v.labelCopied,children:`Copied!`})]})]})}),(0,y.jsx)(Lc,{value:r,children:({copy:e,copied:t})=>(0,y.jsxs)(`button`,{className:(0,F.default)(_v.derived,{[_v.copied]:t}),onClick:e,"aria-label":t?`Copied`:`Copy derived address`,children:[(0,y.jsx)(`span`,{className:_v.derivedLabel,children:`Derived from`}),(0,y.jsxs)(`span`,{className:_v.derivedAddress,children:[(0,y.jsx)(`span`,{className:_v.hexAddress,children:(0,d.truncate)(r)}),(0,y.jsx)(L.IconCopy,{size:12,className:_v.derivedCopy,"aria-hidden":`true`}),t&&(0,y.jsx)(`span`,{className:_v.copiedText,children:`Copied!`})]})]})})]})})};function yv(e,t){return t==null?e:e.filter(e=>e.grantee===t)}function bv(){let e=U();return(0,u.useQueries)({queries:Ze().map(t=>({queryKey:pi.grants(t.chainId,e).queryKey,queryFn:async()=>{let n=yv(li(await vt(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:t.restUrl},`grants`)),e?hr(e,t.chainId):null);return{chainId:t.chainId,grants:n}},enabled:!!e,staleTime:B.SECOND,retry:!1}))})}var xv={countdown:`_countdown_vfms8_1`},Sv=({expiration:e})=>{let t=()=>{let t=(0,oe.differenceInSeconds)(e,new Date),n=Math.floor(t/(1440*60)),r=Math.floor(t%(1440*60)/3600),i=Math.floor(t%3600/60),a=t%60,o=[];return n>0&&o.push(`${n}d`),(r>0||n>0)&&o.push(`${r}h`),(i>0||r>0||n>0)&&o.push(`${i}m`),o.push(`${a}s`),o.join(` `)},[n,r]=(0,g.useState)(t());return(0,le.useInterval)(()=>{r(t())},1e3),(0,oe.isPast)(e)?`Expired`:(0,y.jsxs)(y.Fragment,{children:[`Expires in `,(0,y.jsx)(`span`,{className:xv.countdown,children:n})]})},Cv={container:`_container_1l528_1`,info:`_info_1l528_11`,header:`_header_1l528_17`,chainName:`_chainName_1l528_23`,expiration:`_expiration_1l528_29`,revokeButton:`_revokeButton_1l528_35`},wv=({chainId:e,grantee:t,expiration:n})=>{let r=tt(e),{mutate:i,isPending:a}=ga({grantee:t,internal:!0});return(0,y.jsxs)(`div`,{className:Cv.container,children:[(0,y.jsxs)(`div`,{className:Cv.info,children:[(0,y.jsxs)(`div`,{className:Cv.header,children:[(0,y.jsx)(K,{src:r.logoUrl,width:16,height:16,logo:!0}),(0,y.jsx)(`div`,{className:Cv.chainName,children:r.name})]}),(0,y.jsx)(`div`,{className:Cv.expiration,children:n?(0,y.jsx)(Sv,{expiration:n}):`Until revoked`})]}),(0,y.jsx)(`button`,{className:Cv.revokeButton,onClick:()=>i(e),disabled:a,"aria-busy":a,children:a?`Revoking...`:`Revoke`})]})},Tv=({chainId:e,grants:t})=>{let n=new Map;for(let e of t){let t=n.get(e.grantee),r=e.expiration?new Date(e.expiration):void 0;if(!t){n.set(e.grantee,{grantee:e.grantee,expiration:r});continue}t.expiration=Di([t.expiration,r])}return[...n.values()].map(t=>(0,g.createElement)(wv,{...t,chainId:e,key:t.grantee}))},Ev={content:`_content_q36qs_1`},Dv=()=>{let e=bv();return(0,y.jsx)($l,{title:`Manage auto-signing`,backButton:`/settings`,children:(()=>{let t=e.filter(e=>e.data&&e.data.grants.length>0).map(e=>e.data);return t.length===0?(0,y.jsx)(Ia,{children:`No permissions found`}):(0,y.jsx)(`div`,{className:Ev.content,children:t.map(({chainId:e,grants:t})=>(0,y.jsx)(Tv,{chainId:e,grants:t},e))})})()})},Ov={version:`_version_1sf5y_1`},kv=()=>(0,y.jsxs)(`aside`,{className:Ov.version,children:[`v`,`2.12.1`]}),Av={link:`_link_se23z_1`,title:`_title_se23z_17`,subtitle:`_subtitle_se23z_23`,icon:`_icon_se23z_30`},jv=({title:e,subtitle:t,rightSection:n,onClick:r})=>(0,y.jsxs)(`button`,{className:Av.link,onClick:r,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:Av.title,children:e}),t&&(0,y.jsx)(`p`,{className:Av.subtitle,children:t})]}),(0,y.jsx)(`div`,{className:Av.icon,children:n??(0,y.jsx)(L.IconChevronRight,{size:16,"aria-hidden":`true`})})]}),Mv=`https://export.initia.xyz/`,Nv=()=>(0,y.jsx)(jv,{title:`Export private key`,rightSection:(0,y.jsx)(L.IconExternalLink,{size:16}),onClick:()=>window.open(Mv,`_blank`,`width=600,height=768,scrollbars=yes,resizable=yes,noopener,noreferrer`)}),Pv={container:`_container_1vxr7_1`,separator:`_separator_1vxr7_7`},Fv=()=>{let e=Zt(),{connector:t}=(0,l.useAccount)();return(0,y.jsx)($l,{title:`Settings`,backButton:`/`,children:(0,y.jsxs)(`div`,{className:Pv.container,children:[(0,y.jsx)(jv,{title:`Manage auto-signing`,subtitle:`Manage chain auto-signing permissions by apps`,onClick:()=>e(`/settings/autosign`)}),t?.id===`cmbq1ozyc006al70lx4uciz0q`&&(0,y.jsx)(Nv,{}),(0,y.jsx)(Ee.Separator,{className:Pv.separator}),(0,y.jsx)(kv,{})]})})},Iv={trigger:`_trigger_1yjkd_1`,icon:`_icon_1yjkd_23`,full:`_full_1yjkd_27`,triggerContent:`_triggerContent_1yjkd_32`,triggerText:`_triggerText_1yjkd_40`,popoverBackdrop:`_popoverBackdrop_1yjkd_51`,popoverPositioner:`_popoverPositioner_1yjkd_70`,popoverPopup:`_popoverPopup_1yjkd_74`,search:`_search_1yjkd_99`,viewport:`_viewport_1yjkd_105`,item:`_item_1yjkd_111`,highlighted:`_highlighted_1yjkd_127`,active:`_active_1yjkd_131`,itemContent:`_itemContent_1yjkd_136`,extra:`_extra_1yjkd_142`,connectedTag:`_connectedTag_1yjkd_149`},Lv=({value:e,onChange:t,chainIds:n,renderExtra:r,fullWidth:i})=>{let{defaultChainId:a}=z(),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(0),[f,p]=(0,g.useState)(),m=(0,g.useRef)([]),h=(0,g.useRef)(null),_=Ze(),v=n.map(e=>_.find(t=>t.chainId===e)).filter(Boolean),b=e=>(0,y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 14 14`,children:[(0,y.jsx)(`path`,{fill:`var(--dimmed)`,d:`M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z`}),(0,y.jsx)(`path`,{fill:`var(--dimmed)`,d:`M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z`})]}),x=(0,g.useMemo)(()=>({chainId:``,name:`All`,logoUrl:b}),[]),S=(0,g.useMemo)(()=>{let e=[x,...v];if(!o)return e;let t=o.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.chainId.toLowerCase().includes(t))},[v,o,x]),C=v.find(t=>t.chainId===e)||x,w=parseInt(Dc(`--drawer-offset`)),T=()=>{if(s(``),d(-1),h.current){let e=h.current.getBoundingClientRect().bottom+6;p(window.innerHeight-e-2*w)}l(!0)};(0,g.useEffect)(()=>{u>=0&&u<m.current.length&&m.current[u]?.scrollIntoView({block:`nearest`,behavior:`auto`})},[u]);let E=(0,g.useCallback)(e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),d(e=>(e+1)%S.length);break;case`ArrowUp`:e.preventDefault(),d(e=>(e-1+S.length)%S.length);break;case`Enter`:e.preventDefault(),S[u]&&(t(S[u].chainId),l(!1));break;case`Escape`:e.preventDefault(),l(!1);break}},[S,u,t,l]),D=e=>{t(e),l(!1)};return(0,y.jsxs)(Oe.Popover.Root,{open:c,onOpenChange:T,modal:`trap-focus`,children:[(0,y.jsx)(Oe.Popover.Trigger,{render:(0,y.jsxs)(`button`,{className:(0,F.default)(Iv.trigger,{[Iv.full]:i}),"aria-expanded":c,role:`listbox`,ref:h,children:[(0,y.jsxs)(`div`,{className:Iv.triggerContent,children:[typeof C.logoUrl==`string`?(0,y.jsx)(K,{src:C.logoUrl,width:14,height:14,logo:!0}):C.logoUrl(14),(0,y.jsx)(`span`,{className:Iv.triggerText,children:C.name})]}),(0,y.jsx)(L.IconChevronDown,{size:16,className:Iv.icon})]})}),(0,y.jsxs)(Oe.Popover.Portal,{container:Ec(),children:[(0,y.jsx)(Oe.Popover.Backdrop,{className:Iv.popoverBackdrop,onClick:()=>l(!1)}),(0,y.jsx)(Oe.Popover.Positioner,{className:Iv.popoverPositioner,align:`end`,side:`bottom`,sideOffset:6,collisionAvoidance:{side:`none`},children:(0,y.jsxs)(Oe.Popover.Popup,{className:(0,F.default)(Iv.popoverPopup,{[Iv.full]:i}),style:{maxHeight:f},children:[(0,y.jsx)(dd,{value:o,onChange:e=>{s(e.target.value),d(0)},onClear:()=>s(``),onKeyDown:E,placeholder:`Search apps`,rootClassName:Iv.search,ref:Mu()}),(0,y.jsx)(`div`,{className:Iv.viewport,role:`listbox`,children:S.length===0?(0,y.jsx)(Ia,{children:`No apps found`}):S.map(({chainId:t,name:n,logoUrl:i},o)=>(0,y.jsxs)(`div`,{className:(0,F.default)(Iv.item,{[Iv.highlighted]:o===u,[Iv.active]:e===t}),onClick:()=>D(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),D(t))},onMouseEnter:()=>d(o),role:`option`,"aria-selected":e===t,tabIndex:-1,ref:e=>{e&&(m.current[o]=e)},children:[(0,y.jsxs)(`div`,{className:Iv.itemContent,children:[typeof i==`string`?(0,y.jsx)(K,{src:i,width:16,height:16,logo:!0}):i(16),(0,y.jsx)(`span`,{className:Iv.name,children:n}),t===a&&(0,y.jsx)(`span`,{className:Iv.connectedTag,children:`Connected`})]}),r&&(0,y.jsx)(`span`,{className:Iv.extra,children:r(t)})]},t))})]})})]})]})},Rv={container:`_container_1nap1_1`,controls:`_controls_1nap1_7`,search:`_search_1nap1_13`},zv={Root:({children:e})=>(0,y.jsx)(`div`,{className:Rv.container,children:e}),Controls:({children:e})=>(0,y.jsx)(`div`,{className:Rv.controls,children:e}),SearchInput:e=>(0,y.jsx)(dd,{...e,rootClassName:Rv.search})},Bv=(0,b.atom)(``),Vv=(0,b.atom)(``),Hv=(0,b.atom)(``),Uv=(0,b.atom)(``),Wv=(0,b.atom)(``),Gv={change:`_change_1nm9m_1`,positive:`_positive_1nm9m_8`,negative:`_negative_1nm9m_12`},Kv=({amount:e,asset:t})=>{let{denom:n,symbol:r,decimals:i}=t,a=e||`0`,o=(0,f.default)(a).isPositive(),s=(0,f.default)(a).abs().toString();return(0,y.jsxs)(`div`,{className:(0,F.default)(Gv.change,o?Gv.positive:Gv.negative),children:[o?`+`:`-`,(0,d.formatAmount)(s,{decimals:i}),` `,r||n]})},qv=({changes:e,chain:t})=>{let n=pt(t);return e.map(({amount:e,denom:t},r)=>(0,y.jsx)(Kv,{amount:e,asset:n(t)},r))},Jv=({changes:e,chain:t})=>{let n=pt(t);return e.map(({amount:e,metadata:r},i)=>(0,y.jsx)(Cl,{metadata:r,chain:t,children:t=>(0,y.jsx)(Kv,{amount:e,asset:n(t)})},i))},Yv=({events:e,chain:t})=>{let{initiaAddress:n,hexAddress:r}=Pa();return t.metadata?.is_l1||t.metadata?.minitia?.type===`minimove`?(0,y.jsx)(Jv,{changes:Sl(e,r),chain:t}):(0,y.jsx)(qv,{changes:xl(e,n),chain:t})},Xv={message:`_message_1qc8m_1`,more:`_more_1qc8m_9`},Zv=({messages:e})=>(0,y.jsxs)(y.Fragment,{children:[e.slice(0,3).map((e,t)=>(0,y.jsx)(`p`,{className:Xv.message,children:(0,me.sentenceCase)(e[`@type`].split(`Msg`)[1])},t)),e.length>3&&(0,y.jsx)(`footer`,{className:Xv.more,children:`+${e.length-3} more`})]}),Qv={link:`_link_1vbb0_1`,inner:`_inner_1vbb0_16`,header:`_header_1vbb0_21`,time:`_time_1vbb0_30`,error:`_error_1vbb0_36`,timestamp:`_timestamp_1vbb0_40`,chainInfo:`_chainInfo_1vbb0_45`,content:`_content_1vbb0_53`,messages:`_messages_1vbb0_61`,changes:`_changes_1vbb0_67`},$v=({txItem:e,chain:t})=>(0,y.jsx)(Nc,{txHash:e.txhash,chainId:t.chainId,className:Qv.link,children:(0,y.jsxs)(`div`,{className:Qv.inner,children:[(0,y.jsxs)(`div`,{className:Qv.header,children:[(0,y.jsxs)(`div`,{className:Qv.time,children:[e.code!==0&&(0,y.jsx)(L.IconWarningFilled,{size:14,className:Qv.error}),(0,y.jsx)(`span`,{className:Qv.timestamp,children:(0,oe.format)(new Date(e.timestamp),`h:mm a`)})]}),(0,y.jsxs)(`div`,{className:Qv.chainInfo,children:[(0,y.jsx)(K,{src:t.logoUrl,width:12,height:12,logo:!0}),(0,y.jsx)(`span`,{children:t.name})]})]}),(0,y.jsxs)(`div`,{className:Qv.content,children:[(0,y.jsx)(`div`,{className:Qv.messages,children:(0,y.jsx)(Zv,{messages:e.tx.body.messages})}),(0,y.jsx)(`div`,{className:Qv.changes,children:(0,y.jsx)(W,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:(0,y.jsx)(Yv,{...e,chain:t})})})]})]})}),ey={list:`_list_1mv55_1`,dateGroup:`_dateGroup_1mv55_7`,dateHeader:`_dateHeader_1mv55_12`,more:`_more_1mv55_18`},ty=({list:e,chainId:t})=>{let n=U(),r=(0,g.useMemo)(()=>Vd(e,e=>{if(e.timestamp)return new Date(e.timestamp)}),[e]);return e.length===0?(0,y.jsx)(Ia,{children:`No activity found`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:ey.list,children:Object.entries(r).map(([e,t])=>(0,y.jsxs)(`div`,{className:ey.dateGroup,children:[(0,y.jsx)(`div`,{className:ey.dateHeader,children:e}),t.map(e=>(0,y.jsx)(W,{errorBoundaryProps:{fallback:null},children:(0,y.jsx)($v,{txItem:e,chain:e.chain})},e.txhash))]},e))}),(0,y.jsx)(Nc,{chainId:t,accountAddress:n,pathSuffix:`/txs`,className:ey.more,showIcon:!0,children:`View more on Initia Scan`})]})},ny=()=>{let{activities:e,isLoading:t}=Vi(),[n,r]=(0,b.useAtom)(Wv),i=V(),a=(0,g.useMemo)(()=>Array.from(new Set(e.map(e=>e.chain.chainId))),[e]),o=(0,g.useMemo)(()=>n?e.filter(e=>e.chain.chainId===n):e,[e,n]);return t&&e.length===0?(0,y.jsx)(Ia,{children:`Loading activities...`}):!e.length&&!t?(0,y.jsx)(Ia,{children:`No activity yet. Recent transactions may take a moment to appear.`}):(0,y.jsxs)(zv.Root,{children:[(0,y.jsx)(zv.Controls,{children:(0,y.jsx)(Lv,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),(0,y.jsx)(ty,{list:o,chainId:n||i.chainId})]})},ry={thumbnail:`_thumbnail_1xyqw_1`,placeholder:`_placeholder_1xyqw_18`,clickable:`_clickable_1xyqw_24`},iy=({nftInfo:e,size:t,onClick:n})=>{let{collection_addr:r,object_addr:i,nft:a,chain:o}=e,{glyphUrl:s}=z(),c=new URL(`/v1/${o.chainId}/${r}/${i||a.token_id}`,s).toString();return n?(0,y.jsx)(`button`,{className:(0,F.default)(ry.thumbnail,ry.clickable),onClick:n,style:{width:t,height:t},children:(0,y.jsx)(K,{src:c,classNames:{placeholder:ry.placeholder}})}):(0,y.jsx)(`div`,{className:ry.thumbnail,style:{width:t,height:t},children:(0,y.jsx)(K,{src:c,classNames:{placeholder:ry.placeholder}})})},ay={collectionName:`_collectionName_qs5tw_1`,nftName:`_nftName_qs5tw_6`,chainInfo:`_chainInfo_qs5tw_10`},oy=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:n,chainIconSize:r=12,classNames:i})=>{let{collection_name:a,name:o,chain:s}=e;return(0,y.jsxs)(`div`,{className:i?.root,children:[(0,y.jsx)(iy,{nftInfo:e,onClick:t,size:n}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:(0,F.default)(ay.collectionName,i?.collectionName),children:a}),(0,y.jsx)(`div`,{className:(0,F.default)(ay.nftName,i?.nftName),children:o}),(0,y.jsxs)(`div`,{className:(0,F.default)(ay.chainInfo,i?.chainInfo),children:[(0,y.jsx)(K,{src:s.logoUrl,width:r,height:r,logo:!0}),(0,y.jsx)(`span`,{children:s.name})]})]})]})},sy=(0,m.createQueryKeys)(`interwovenkit:nft`,{nfts:(e,t)=>[e,t],metadata:e=>[e]});function cy(e,t){let{nft:n}=e,r=t.name??n.token_id;return{...e,...n,...t,name:r}}function ly(e,t){return e.flatMap((e,n)=>(t[n]??[]).map(t=>({...t,chain:e})))}var uy=()=>{let e=U(),t=Ze(),n=(0,u.useQueries)({queries:t.map(t=>({queryKey:sy.nfts(t.indexerUrl,e).queryKey,queryFn:()=>vt(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:t.indexerUrl},`tokens`),staleTime:B.SECOND}))}),r=ly(t,n.map((0,p.prop)(`data`))),i=r.reduce((e,{chain:t})=>({...e,[t.chainId]:(e[t.chainId]||0)+1}),{});return{nftInfos:r,chainCounts:i,totalCount:Object.values(i).reduce((e,t)=>e+t,0),isLoading:n.some(e=>e.isLoading)}};function dy(e){let t=fy(e);return(0,u.useQuery)({queryKey:sy.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};let e=await h.default.get(t).json();return{...e,image:fy(e.image)}}catch{return{}}},staleTime:B.INFINITY})}function fy(e){return e?.replace(`ipfs://`,`https://ipfs.io/ipfs/`)}var py=({nftInfo:e,children:t})=>{let{data:n={}}=dy(e.nft.uri);return t(cy(e,n))},my={grid:`_grid_1wwdn_1`,root:`_root_1wwdn_7`,collectionName:`_collectionName_1wwdn_15`,nftName:`_nftName_1wwdn_23`,chainInfo:`_chainInfo_1wwdn_32`},hy=()=>{let[e,t]=(0,b.useAtom)(Hv),[n,r]=(0,b.useAtom)(Uv),{nftInfos:i,chainCounts:a,totalCount:o,isLoading:s}=uy(),c=Zt(),l=(0,g.useMemo)(()=>i.filter(({collection_addr:t,collection_name:r,nft:i,object_addr:a,chain:o})=>{if(n&&o.chainId!==n)return!1;if(e){let n=e.trim().toLowerCase();return t.toLowerCase().includes(n)||r.toLowerCase().includes(n)||i.token_id.toLowerCase().includes(n)||a.toLowerCase().includes(n)}return!0}),[i,n,e]),u=(0,g.useMemo)(()=>Array.from(new Set(i.map(({chain:e})=>e.chainId))),[i]);return s&&i.length===0?(0,y.jsx)(Ia,{children:`Loading NFTs...`}):!i.length&&!e&&!s?(0,y.jsx)(Ia,{children:`No NFTs`}):(0,y.jsxs)(zv.Root,{children:[(0,y.jsxs)(zv.Controls,{children:[(0,y.jsx)(zv.SearchInput,{value:e,onChange:e=>t(e.target.value),onClear:()=>t(``),placeholder:`Search NFTs`}),(0,y.jsx)(Lv,{value:n,onChange:r,chainIds:u,renderExtra:e=>e?a[e]||0:o})]}),l.length===0?(0,y.jsx)(Ia,{children:`No NFTs found`}):(0,y.jsx)(`div`,{className:my.grid,children:l.map(e=>{let{collection_addr:t,nft:n}=e;return(0,y.jsx)(py,{nftInfo:e,children:e=>(0,y.jsx)(oy,{normalizedNft:e,onThumbnailClick:()=>c(`/nft`,e),classNames:my})},t+n.token_id)})})]})},gy=(0,g.createContext)(null);function _y(){return(0,g.useContext)(gy)}var vy={popup:`_popup_nbecp_1`,item:`_item_nbecp_19`},yy=({asset:e,children:t})=>{let{denom:n,decimals:r,symbol:i,logoUrl:a,unlisted:o,address:s,chain:c}=e,{chainId:d}=c,[f,p]=(0,g.useState)(!1),m=Zt(),h=_y(),{showNotification:_}=Fc(),{defaultChainId:v}=z(),{evm_chain_id:b}=rt(),x=(0,l.useChainId)(),{switchChainAsync:S}=(0,l.useSwitchChain)(),{watchAssetAsync:C}=(0,l.useWatchAsset)(),w=()=>{p(!1),m(`/send`,{denom:n,chain:c})},T=()=>{p(!1),m(`/bridge`,{srcChainId:d,srcDenom:n,quantity:``})},E=(0,u.useMutation)({mutationFn:async()=>{if(!s)throw Error(`Address is required`);let e=a;return await S({chainId:Number(b)}),C({type:`ERC20`,options:{address:s,symbol:i,decimals:r,image:e}})},onSuccess:()=>{_({type:`success`,title:`Asset added`,description:`Asset added to wallet`})},onError:e=>{_({type:`error`,title:`Asset addition failed`,description:e.message})}});return(0,y.jsxs)(Ee.Menu.Root,{open:f,onOpenChange:p,modal:!1,children:[(0,y.jsx)(Ee.Menu.Trigger,{render:t}),(0,y.jsx)(Ee.Menu.Portal,{container:h,children:(0,y.jsx)(Ee.Menu.Positioner,{side:`bottom`,sideOffset:-6,align:`end`,children:(0,y.jsxs)(Ee.Menu.Popup,{className:vy.popup,children:[(0,y.jsxs)(Ee.Menu.Item,{className:vy.item,onClick:w,children:[(0,y.jsx)(L.IconArrowRight,{size:16}),(0,y.jsx)(`span`,{children:`Send`})]}),(0,y.jsxs)(Ee.Menu.Item,{className:vy.item,onClick:T,disabled:o,children:[(0,y.jsx)(L.IconSwap,{size:16}),(0,y.jsx)(`span`,{children:`Bridge/Swap`})]}),d===v&&b===x&&!!s&&(0,y.jsxs)(Ee.Menu.Item,{className:vy.item,onClick:()=>E.mutate(),disabled:E.isPending||E.data,children:[E.data?(0,y.jsx)(L.IconCheck,{size:16}):(0,y.jsx)(L.IconPlus,{size:16}),(0,y.jsx)(`span`,{children:`Add to Wallet`})]})]})})})]})},by={item:`_item_38qhm_1`,info:`_info_38qhm_23`,images:`_images_38qhm_29`,name:`_name_38qhm_33`,value:`_value_38qhm_39`,amount:`_amount_38qhm_47`,usd:`_usd_38qhm_53`},xy=({asset:e})=>{let{amount:t,value:n,logoUrl:r,chain:i}=e,a=(0,d.formatAmount)(t,{decimals:e.decimals});return(0,y.jsx)(yy,{asset:e,children:(0,y.jsxs)(`button`,{className:by.item,children:[(0,y.jsxs)(`div`,{className:by.info,children:[(0,y.jsx)(od,{assetLogoUrl:r,chainLogoUrl:i.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:by.images}),(0,y.jsx)(`span`,{className:by.name,children:i.name})]}),(0,y.jsxs)(`div`,{className:by.value,children:[(0,y.jsx)(`span`,{className:by.amount,children:a}),Number(n)>0&&(0,y.jsx)(`span`,{className:by.usd,children:q(n)})]})]})})},Sy={container:`_container_ytg3p_1`,assetItem:`_assetItem_ytg3p_6`,expandIcon:`_expandIcon_ytg3p_22`,assetInfo:`_assetInfo_ytg3p_27`,logo:`_logo_ytg3p_33`,details:`_details_ytg3p_37`,symbol:`_symbol_ytg3p_42`,chainName:`_chainName_ytg3p_53`,chainInfos:`_chainInfos_ytg3p_59`,chainLogos:`_chainLogos_ytg3p_65`,chainLogo:`_chainLogo_ytg3p_65`,moreChains:`_moreChains_ytg3p_76`,expanded:`_expanded_ytg3p_93`,valueColumn:`_valueColumn_ytg3p_98`,amount:`_amount_ytg3p_108`,value:`_value_ytg3p_98`,collapsibleContent:`_collapsibleContent_ytg3p_121`,slideDown:`_slideDown_ytg3p_1`,slideUp:`_slideUp_ytg3p_1`,chainsList:`_chainsList_ytg3p_151`},Cy=(0,b.atom)([]),wy=({assetGroup:e})=>{let{symbol:t,logoUrl:n,assets:r}=e,i=r.length===1,[a,o]=(0,b.useAtom)(Cy),s=(0,g.useMemo)(()=>Sa(e),[e]),c=(0,g.useMemo)(()=>xa(e),[e]),l=a.includes(t),u=()=>{o(e=>l?e.filter(e=>e!==t):[...new Set([...e,t])])},f=()=>(0,y.jsxs)(`button`,{className:Sy.assetItem,children:[(0,y.jsxs)(`div`,{className:Sy.assetInfo,children:[n&&(0,y.jsx)(K,{src:n,width:32,height:32,className:Sy.logo,logo:!0}),(0,y.jsxs)(`div`,{className:Sy.details,children:[(0,y.jsx)(`div`,{className:Sy.symbol,children:t}),i?(0,y.jsx)(`div`,{className:Sy.chainName,children:r[0].chain.name}):(0,y.jsxs)(`div`,{className:Sy.chainInfos,children:[(0,y.jsx)(`div`,{className:Sy.chainLogos,children:r.slice(0,5).map(({chain:e})=>(0,y.jsx)(K,{src:e.logoUrl,width:16,height:16,className:Sy.chainLogo,logo:!0},e.chainId))}),r.length>5&&(0,y.jsxs)(`span`,{className:Sy.moreChains,children:[`+`,r.length-5]}),(0,y.jsx)(L.IconChevronDown,{size:16,className:(0,F.default)(Sy.expandIcon,{[Sy.expanded]:l})})]})]})]}),(0,y.jsxs)(`div`,{className:Sy.valueColumn,children:[(0,y.jsx)(`div`,{className:Sy.amount,children:(0,d.formatNumber)(s,{dp:r[0].unlisted?0:6})}),c>0&&(0,y.jsx)(`div`,{className:Sy.value,children:q(c)})]})]});if(i){let[e]=r;return(0,y.jsx)(`div`,{className:Sy.container,children:(0,y.jsx)(yy,{asset:e,children:f()})})}return(0,y.jsx)(`div`,{className:Sy.container,children:(0,y.jsxs)(P.Collapsible.Root,{open:l,onOpenChange:u,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:f()}),(0,y.jsx)(P.Collapsible.Content,{className:Sy.collapsibleContent,children:(0,y.jsx)(`div`,{className:Sy.chainsList,children:r.map(e=>(0,y.jsx)(xy,{asset:e},e.chain.chainId))})})]})})},Ty={collapsible:`_collapsible_1g7rh_1`,trigger:`_trigger_1g7rh_5`,divider:`_divider_1g7rh_20`,label:`_label_1g7rh_28`,chevron:`_chevron_1g7rh_33`,content:`_content_1g7rh_41`,list:`_list_1g7rh_45`},Ey=({unlistedAssets:e})=>{let[t,n]=(0,g.useState)(!1),r=_y(),i=(0,g.useRef)(null),[a,o]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(i.current){let e=i.current.scrollHeight;o(e)}},[e]);let s=(0,g.useRef)(null),c=e=>{n(e),e&&s.current&&r?.current&&window.setTimeout(()=>{if(!s.current||!i.current||!r?.current)return;let e=r.current,t=e.getBoundingClientRect(),n=s.current.getBoundingClientRect(),a=i.current.scrollHeight;if(n.bottom+a>t.bottom){let r=n.top-t.top+e.scrollTop-16;e.scrollTo({top:r,behavior:`smooth`})}},50)},l=(0,pe.useSpring)({height:t?a:0,opacity:+!!t,config:{tension:500,friction:30,clamp:!0}}),u=(0,g.useMemo)(()=>e.map(e=>({...e,assets:[e],totalValue:e.value??0,totalAmount:Number(e.quantity)})),[e]);return e.length===0?null:(0,y.jsxs)(P.Collapsible.Root,{open:t,onOpenChange:c,className:Ty.collapsible,children:[(0,y.jsxs)(P.Collapsible.Trigger,{ref:s,className:Ty.trigger,children:[(0,y.jsx)(`div`,{className:Ty.divider}),(0,y.jsxs)(`span`,{className:Ty.label,children:[`Unlisted assets (`,e.length,`)`]}),(0,y.jsx)(L.IconChevronDown,{className:Ty.chevron,size:12,"data-state":t?`open`:`closed`}),(0,y.jsx)(`div`,{className:Ty.divider})]}),(0,y.jsx)(P.Collapsible.Content,{forceMount:!0,asChild:!0,children:(0,y.jsx)(pe.animated.div,{className:Ty.content,style:l,children:(0,y.jsx)(`div`,{className:Ty.list,ref:i,children:u.map(e=>(0,y.jsx)(wy,{assetGroup:e},e.assets[0].denom))})})})]})},Dy={container:`_container_15xfg_1`,header:`_header_15xfg_7`,title:`_title_15xfg_13`,totalValue:`_totalValue_15xfg_19`,list:`_list_15xfg_26`},Oy=()=>{let[e,t]=(0,b.useAtom)(Bv),[n,r]=(0,b.useAtom)(Vv),{assetGroups:i,unlistedAssets:a,chainsByValue:o,totalValue:s,isLoading:c}=Aa(),l=o.map(({chainId:e})=>e),u=(0,g.useMemo)(()=>{let t=e?i.filter(t=>{let{symbol:n,assets:r}=t;return n.toLowerCase().includes(e.toLowerCase())||r.some(({denom:t,address:n})=>t.toLowerCase().includes(e.toLowerCase())||n?.toLowerCase().includes(e.toLowerCase()))}):i;return n?t.map(e=>({...e,assets:e.assets.filter(({chain:e})=>e.chainId===n)})).filter(e=>e.assets.length>0):t},[i,e,n]),d=(0,g.useMemo)(()=>{let t=e?a.filter(({denom:t,address:n})=>t.toLowerCase().includes(e.toLowerCase())||n?.toLowerCase().includes(e.toLowerCase())):a;return n?t.filter(({chain:e})=>e.chainId===n):t},[a,e,n]);return c&&i.length===0?(0,y.jsx)(Ia,{children:`Loading assets...`}):!u.length&&!d.length&&!e&&!n&&!c?(0,y.jsx)(Ia,{children:`No assets`}):(0,y.jsxs)(zv.Root,{children:[(0,y.jsxs)(zv.Controls,{children:[(0,y.jsx)(zv.SearchInput,{value:e,onChange:e=>t(e.target.value),onClear:()=>t(``),placeholder:`Search assets`}),(0,y.jsx)(Lv,{value:n,onChange:r,chainIds:l,renderExtra:e=>{if(!e)return q(s);let t=o.find(t=>t.chainId===e);return t?q(t.value):null}})]}),(0,y.jsx)(`div`,{children:u.length===0&&d.length===0?(0,y.jsx)(Ia,{children:`No assets found`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:Dy.list,children:u.map(e=>(0,y.jsx)(wy,{assetGroup:e},e.symbol))}),(0,y.jsx)(Ey,{unlistedAssets:d})]})})]})},ky={container:`_container_11k2x_1`},Ay=({height:e,length:t=1,width:n=`100%`})=>{let r=Array.from({length:t},(e,t)=>t);return t===1?(0,y.jsx)(Cd,{height:e,width:n}):(0,y.jsx)(`div`,{className:ky.container,"aria-hidden":`true`,children:r.map(t=>(0,y.jsx)(Cd,{height:e,width:n},t))})},jy=(0,g.memo)(({searchQuery:e,selectedChain:t,denomLogos:n,symbolLogos:r,chainInfoMap:i,chainPrices:a})=>{let{balances:o,isLoading:s}=nc(),c=V(),{listedGroups:l,unlistedAssets:u}=(0,g.useMemo)(()=>Ws(o,i,a,c.chainId),[o,i,a,c.chainId]),d=(0,g.useMemo)(()=>Bs(l,n,r),[l,n,r]),{filteredAssets:f,totalAssetsValue:p,filteredUnlistedAssets:m}=(0,g.useMemo)(()=>Us(d,u,e,t),[d,u,e,t]);return(0,y.jsxs)(`div`,{className:Dy.container,children:[(0,y.jsxs)(`div`,{className:Dy.header,children:[(0,y.jsx)(`span`,{className:Dy.title,children:`Assets`}),f.length>0&&(0,y.jsx)(`span`,{className:Dy.totalValue,children:q(p)})]}),f.length>0?(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:Dy.list,children:f.map(e=>(0,y.jsx)(wy,{assetGroup:e},e.symbol))}),(0,y.jsx)(Ey,{unlistedAssets:m})]}):d.length===0&&s?(0,y.jsx)(Ay,{height:56,length:3}):(0,y.jsx)(Ia,{children:`No liquid assets`})]})}),Z={container:`_container_vjtpl_1`,section:`_section_vjtpl_7`,sectionHeader:`_sectionHeader_vjtpl_19`,sectionTitle:`_sectionTitle_vjtpl_25`,sectionLabel:`_sectionLabel_vjtpl_31`,externalLink:`_externalLink_vjtpl_37`,sectionTitleLink:`_sectionTitleLink_vjtpl_49`,sectionValue:`_sectionValue_vjtpl_63`,tokenList:`_tokenList_vjtpl_70`,stakingTokenList:`_stakingTokenList_vjtpl_76`,tokenRow:`_tokenRow_vjtpl_86`,tokenMain:`_tokenMain_vjtpl_92`,tokenTrigger:`_tokenTrigger_vjtpl_98`,tokenChevron:`_tokenChevron_vjtpl_114`,expanded:`_expanded_vjtpl_125`,triggerValue:`_triggerValue_vjtpl_129`,tokenInfo:`_tokenInfo_vjtpl_136`,tokenInfoLabel:`_tokenInfoLabel_vjtpl_142`,tokenLogo:`_tokenLogo_vjtpl_148`,tokenSymbol:`_tokenSymbol_vjtpl_152`,tokenValues:`_tokenValues_vjtpl_158`,tokenAmount:`_tokenAmount_vjtpl_164`,tokenValue:`_tokenValue_vjtpl_158`,typeBreakdown:`_typeBreakdown_vjtpl_178`,typeRow:`_typeRow_vjtpl_186`,typeLabel:`_typeLabel_vjtpl_194`,typeValues:`_typeValues_vjtpl_200`,typeAmount:`_typeAmount_vjtpl_206`,typeValue:`_typeValue_vjtpl_200`,perpRow:`_perpRow_vjtpl_220`,perpLeft:`_perpLeft_vjtpl_227`,perpLogo:`_perpLogo_vjtpl_235`,perpInfo:`_perpInfo_vjtpl_241`,perpPair:`_perpPair_vjtpl_249`,perpDirectionLong:`_perpDirectionLong_vjtpl_255`,perpDirectionShort:`_perpDirectionShort_vjtpl_261`,perpRight:`_perpRight_vjtpl_267`,perpValue:`_perpValue_vjtpl_275`,perpPnl:`_perpPnl_vjtpl_283`,perpPnlPositive:`_perpPnlPositive_vjtpl_290`,perpPnlNegative:`_perpPnlNegative_vjtpl_294`,perpPnlNeutral:`_perpPnlNeutral_vjtpl_298`,collapsibleContent:`_collapsibleContent_vjtpl_302`,slideDown:`_slideDown_vjtpl_1`,slideUp:`_slideUp_vjtpl_1`};function My(e){return[...e].sort((e,t)=>Es(t.position)-Es(e.position)).map(e=>e.id)}var Ny=({protocols:e,denomLogoMap:t,chainName:n,isInitia:r,getClaimableInitByType:i,initPrice:a})=>{let o=e[0]?.manageUrl,s=(0,g.useMemo)(()=>ks(e.flatMap(e=>e.positions)),[e]);return s.size===0?null:(0,y.jsx)(`div`,{className:Z.container,children:Array.from(s.entries()).map(([e,s])=>(0,y.jsx)(Py,{sectionKey:e,sectionGroup:s,denomLogoMap:t,chainName:n,isInitia:r,manageUrl:o,getClaimableInitByType:i,initPrice:a},e))})},Py=({sectionKey:e,sectionGroup:t,denomLogoMap:n,chainName:r,isInitia:i,manageUrl:a,getClaimableInitByType:o,initPrice:s})=>{let{positions:c,totalValue:l}=t,u=Os(e,{isInitia:i,chainName:r}),d=e===`staking`,f=r?.toLowerCase()===Ct,p=d&&!f,m=e===`perp`,h=(0,g.useMemo)(()=>m?[]:Is(c),[c,m]),_=(0,g.useMemo)(()=>{if(!m)return[];let e=new Map;return c.filter(e=>e.type===`perp-position`).map(t=>{let n=`${t.pair}-${t.direction}`,r=e.get(n)??0;return e.set(n,r+1),{id:`${n}-${r}`,position:t}})},[c,m]),v=_.map(e=>e.id).sort().join(`|`),[b,x]=(0,g.useState)(()=>({signature:v,ids:My(_)}));b.signature!==v&&x({signature:v,ids:My(_)});let S=(0,g.useMemo)(()=>{let e=new Map(_.map(e=>[e.id,e.position]));return b.ids.map(t=>({id:t,position:e.get(t)})).filter(e=>e.position!=null)},[_,b.ids]);return(0,y.jsxs)(`section`,{className:Z.section,"aria-label":u,children:[(0,y.jsxs)(`div`,{className:Z.sectionHeader,children:[p&&a?(0,y.jsxs)(`a`,{href:jc(a),target:`_blank`,rel:`noopener noreferrer`,className:Z.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Z.sectionLabel,children:u}),(0,y.jsx)(L.IconExternalLink,{size:14,"aria-hidden":`true`})]}):(0,y.jsx)(`div`,{className:Z.sectionTitle,children:(0,y.jsx)(`span`,{className:Z.sectionLabel,children:u})}),(0,y.jsx)(`span`,{className:Z.sectionValue,children:q(l)})]}),m?(0,y.jsx)(`div`,{className:Z.tokenList,children:S.map(({id:e,position:t})=>(0,y.jsx)(Iy,{position:t},e))}):(0,y.jsx)(`div`,{className:(0,F.default)(Z.tokenList,{[Z.stakingTokenList]:p}),children:h.map(e=>(0,y.jsx)(Ly,{group:e,showTypeBreakdown:p,denomLogoMap:n,getClaimableInitByType:o,initPrice:s},e.denom))})]})};function Fy(e){return e==null||!Number.isFinite(e)||e===0?Z.perpPnlNeutral:e>0?Z.perpPnlPositive:Z.perpPnlNegative}var Iy=({position:e})=>{let t=e.direction===`long`,n=bs(e),r=xs(e),i=Es(e),a=Ss(e),o=ws(n,r),s=o?`${Cs(n)} ${o}`:Cs(n),c=t?`Long`:`Short`,l=Ts(e.leverage),u=l?`${l}X ${c}`:c,d=a?`—`:q(i);return(0,y.jsxs)(`div`,{className:Z.perpRow,children:[(0,y.jsxs)(`div`,{className:Z.perpLeft,children:[e.imageUrl&&(0,y.jsx)(K,{src:e.imageUrl,width:20,height:20,className:Z.perpLogo}),(0,y.jsxs)(`div`,{className:Z.perpInfo,children:[(0,y.jsx)(`span`,{className:Z.perpPair,children:e.pair}),(0,y.jsx)(`span`,{className:t?Z.perpDirectionLong:Z.perpDirectionShort,children:u})]})]}),(0,y.jsxs)(`div`,{className:Z.perpRight,children:[(0,y.jsx)(`span`,{className:Z.perpValue,children:d}),(0,y.jsx)(`span`,{className:(0,F.default)(Z.perpPnl,Fy(n)),children:s})]})]})},Ly=({group:e,showTypeBreakdown:t,denomLogoMap:n,getClaimableInitByType:r,initPrice:i})=>{let{denom:a,symbol:o,totalAmount:s,totalValue:c,positions:l}=e,u=n.get(a),[f,p]=(0,g.useState)(!1),m=(0,g.useMemo)(()=>{if(!t)return null;let e=Ps(l);return e.size>0?e:null},[l,t]);return m?(0,y.jsxs)(P.Collapsible.Root,{open:f,onOpenChange:p,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:Z.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:Z.tokenInfo,children:[(0,y.jsx)(L.IconChevronDown,{size:14,className:(0,F.default)(Z.tokenChevron,{[Z.expanded]:f}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Z.tokenInfoLabel,children:[u?.assetLogo&&(0,y.jsx)(K,{src:u.assetLogo,width:20,height:20,className:Z.tokenLogo}),(0,y.jsx)(`span`,{className:Z.tokenSymbol,children:o})]})]}),(0,y.jsx)(`span`,{className:Z.triggerValue,children:q(c)})]})}),(0,y.jsx)(P.Collapsible.Content,{className:Z.collapsibleContent,children:(0,y.jsx)(Ry,{typeGroups:m,symbol:o,denom:a,getClaimableInitByType:r,initPrice:i})})]}):(0,y.jsx)(`div`,{className:Z.tokenRow,children:(0,y.jsxs)(`div`,{className:Z.tokenMain,children:[(0,y.jsxs)(`div`,{className:Z.tokenInfo,children:[u?.assetLogo&&(0,y.jsx)(K,{src:u.assetLogo,width:20,height:20,className:Z.tokenLogo}),(0,y.jsx)(`span`,{className:Z.tokenSymbol,children:o})]}),(0,y.jsxs)(`div`,{className:Z.tokenValues,children:[(0,y.jsx)(`span`,{className:Z.tokenAmount,children:(0,d.formatNumber)(s,{dp:6})}),(0,y.jsx)(`span`,{className:Z.tokenValue,children:q(c)})]})]})})},Ry=({typeGroups:e,symbol:t,denom:n,getClaimableInitByType:r,initPrice:i})=>{let a=(0,g.useMemo)(()=>Array.from(e.entries()).map(([e,t])=>({type:e,typeAmount:t.reduce((e,t)=>t.type===`fungible-position`||t.type===`perp-position`||t.balance.type===`unknown`?e:e+t.balance.formattedAmount,0),typeValue:t.reduce((e,t)=>e+Es(t),0)})),[e]),o=(0,g.useMemo)(()=>{if(!r)return 0;let e=0;for(let{type:t}of a){let i=r(n,t);e+=Number(i)}return e},[n,r,a]),s=o>0;return(0,y.jsxs)(`div`,{className:Z.typeBreakdown,children:[a.map(({type:e,typeAmount:n,typeValue:r})=>(0,y.jsxs)(`div`,{className:Z.typeRow,children:[(0,y.jsx)(`span`,{className:Z.typeLabel,children:Ns(e)}),(0,y.jsxs)(`div`,{className:Z.typeValues,children:[(0,y.jsxs)(`span`,{className:Z.typeAmount,children:[(0,d.formatNumber)(n,{dp:6}),` `,t]}),(0,y.jsx)(`span`,{className:Z.typeValue,children:q(r)})]})]},e)),s&&(0,y.jsxs)(`div`,{className:Z.typeRow,children:[(0,y.jsx)(`span`,{className:Z.typeLabel,children:`Claimable rewards`}),(0,y.jsxs)(`div`,{className:Z.typeValues,children:[(0,y.jsxs)(`span`,{className:Z.typeAmount,children:[(0,d.formatNumber)(o,{dp:6}),` `,`INIT`]}),(0,y.jsx)(`span`,{className:Z.typeValue,children:q(o*(i??0))})]})]})]})},zy={container:`_container_jelqd_1`,trigger:`_trigger_jelqd_6`,expandIcon:`_expandIcon_jelqd_22`,chainInfo:`_chainInfo_jelqd_27`,logo:`_logo_jelqd_33`,chainNameContainer:`_chainNameContainer_jelqd_37`,chainName:`_chainName_jelqd_37`,externalLink:`_externalLink_jelqd_49`,externalIcon:`_externalIcon_jelqd_53`,chainNameLink:`_chainNameLink_jelqd_58`,valueColumn:`_valueColumn_jelqd_75`,value:`_value_jelqd_75`,expanded:`_expanded_jelqd_92`,collapsibleContent:`_collapsibleContent_jelqd_97`,slideDown:`_slideDown_jelqd_1`,slideUp:`_slideUp_jelqd_1`,content:`_content_jelqd_109`},By=(0,b.atom)([]),Vy=({chainGroup:e})=>{let{chainId:t,chainName:n,chainLogo:r,protocols:i}=e,a=Ze(),o=ft(),{denomLogos:s,symbolLogos:c}=(0,g.useMemo)(()=>ys(o,a),[o,a]);return(0,y.jsx)(Ny,{protocols:i,denomLogoMap:(0,g.useMemo)(()=>{let e=new Map;for(let n of i)for(let i of n.positions){if(i.type===`fungible-position`||i.type===`perp-position`||i.balance.type===`unknown`)continue;let{denom:n,symbol:a}=i.balance,o=a.toUpperCase(),l=`${t}:${n}`,u=s.get(l)??c.get(o);u&&e.set(n,{assetLogo:u,chainLogo:r??``})}return e},[i,s,c,t,r]),chainName:n})},Hy=({chainGroup:e})=>{let{chainName:t,prettyName:n,chainLogo:r,protocols:i}=e,a=i[0]?.manageUrl,[o,s]=(0,b.useAtom)(By),c=(0,g.useMemo)(()=>i.reduce((e,t)=>e+t.positions.reduce((e,t)=>e+Es(t),0),0),[i]),l=[`civitia`,`yominet`],u=o.includes(t),d=t?.toLowerCase(),f=l.includes(d);return(0,y.jsx)(`div`,{className:zy.container,children:(0,y.jsxs)(P.Collapsible.Root,{open:u,onOpenChange:()=>{s(e=>u?e.filter(e=>e!==t):[...new Set([...e,t])])},children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:zy.trigger,children:[(0,y.jsxs)(`div`,{className:zy.chainInfo,children:[r&&(0,y.jsx)(K,{src:r,width:32,height:32,className:zy.logo,logo:!0}),a?(0,y.jsxs)(`a`,{href:jc(a),target:`_blank`,rel:`noopener noreferrer`,className:zy.chainNameLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:zy.chainName,children:n}),(0,y.jsx)(L.IconExternalLink,{size:14,className:zy.externalIcon})]}):(0,y.jsx)(`div`,{className:zy.chainNameContainer,children:(0,y.jsx)(`span`,{className:zy.chainName,children:n})})]}),(0,y.jsxs)(`div`,{className:zy.valueColumn,children:[!f&&(0,y.jsx)(`span`,{className:zy.value,children:q(c)}),(0,y.jsx)(L.IconChevronDown,{size:16,className:(0,F.default)(zy.expandIcon,{[zy.expanded]:u})})]})]})}),(0,y.jsx)(P.Collapsible.Content,{className:zy.collapsibleContent,children:(0,y.jsx)(`div`,{className:zy.content,children:(0,y.jsx)(Vy,{chainGroup:e})})})]})})},Q={container:`_container_176wa_1`,section:`_section_176wa_6`,sectionHeader:`_sectionHeader_176wa_14`,sectionTitle:`_sectionTitle_176wa_20`,sectionLabel:`_sectionLabel_176wa_26`,externalLink:`_externalLink_176wa_32`,sectionTitleLink:`_sectionTitleLink_176wa_44`,sectionValue:`_sectionValue_176wa_58`,tokenList:`_tokenList_176wa_65`,tokenTrigger:`_tokenTrigger_176wa_77`,tokenChevron:`_tokenChevron_176wa_93`,expanded:`_expanded_176wa_104`,tokenInfo:`_tokenInfo_176wa_108`,tokenInfoLabel:`_tokenInfoLabel_176wa_114`,tokenLogo:`_tokenLogo_176wa_120`,pairedLogos:`_pairedLogos_176wa_124`,coinLogo:`_coinLogo_176wa_129`,tokenSymbol:`_tokenSymbol_176wa_147`,triggerValue:`_triggerValue_176wa_153`,clammBreakdownContent:`_clammBreakdownContent_176wa_160`,clammPositionRow:`_clammPositionRow_176wa_168`,statusDot:`_statusDot_176wa_177`,inRange:`_inRange_176wa_184`,outRange:`_outRange_176wa_188`,unknown:`_unknown_176wa_192`,clammStatusValue:`_clammStatusValue_176wa_196`,breakdownContent:`_breakdownContent_176wa_206`,breakdownRow:`_breakdownRow_176wa_214`,breakdownLabel:`_breakdownLabel_176wa_222`,breakdownValues:`_breakdownValues_176wa_228`,breakdownAmount:`_breakdownAmount_176wa_234`,breakdownValue:`_breakdownValue_176wa_228`,empty:`_empty_176wa_248`,collapsibleContent:`_collapsibleContent_176wa_255`,slideDown:`_slideDown_176wa_1`,slideUp:`_slideUp_176wa_1`},Uy=({data:e,denomLogoMap:t})=>{let{totalValue:n,rows:r}=e;return r.length===0?null:(0,y.jsx)(`div`,{className:Q.container,children:(0,y.jsxs)(`section`,{className:Q.section,"aria-label":`Liquidity positions`,children:[(0,y.jsxs)(`div`,{className:Q.sectionHeader,children:[(0,y.jsxs)(`a`,{href:Tt,target:`_blank`,rel:`noopener noreferrer`,className:Q.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:Q.sectionLabel,children:`Liquidity`}),(0,y.jsx)(L.IconExternalLink,{size:14,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:Q.sectionValue,children:q(n)})]}),(0,y.jsx)(`div`,{className:Q.tokenList,children:r.map(e=>(0,y.jsx)(Qy,{row:e,denomLogoMap:t},e.denom))})]})})},Wy={deposit:`Deposit`,staking:`Staking`,lockStaking:`Lock staking`,unstaking:`Unstaking`};function Gy(e){return e===void 0?Q.unknown:e?Q.inRange:Q.outRange}function Ky(e){return e===void 0?`Status unavailable`:e?`In range`:`Out of range`}function qy(e,t){return e===void 0?`-`:`${(0,d.formatNumber)(e,{dp:6})} ${t}`}function Jy({isOpen:e,symbol:t,coinLogos:n,singleLogoUrl:r,rightContent:i}){let a=n&&n.length>0&&n.some(e=>e);return(0,y.jsxs)(`button`,{className:Q.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:Q.tokenInfo,children:[(0,y.jsx)(L.IconChevronDown,{size:14,className:(0,F.default)(Q.tokenChevron,{[Q.expanded]:e}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:Q.tokenInfoLabel,children:[a?(0,y.jsx)(`div`,{className:Q.pairedLogos,children:n.map((e,t)=>(0,y.jsx)(K,{src:e,width:20,height:20,className:Q.coinLogo,logo:!0},t))}):r&&(0,y.jsx)(K,{src:r,width:20,height:20,className:Q.tokenLogo}),(0,y.jsx)(`span`,{className:Q.tokenSymbol,children:t})]})]}),i]})}var Yy=({position:e})=>{let t=Gy(e.inRange),n=Ky(e.inRange);return(0,y.jsxs)(`div`,{className:Q.clammPositionRow,children:[(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Position ID`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:e.positionId})})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Deposit`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(e.value)})})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Status`}),(0,y.jsxs)(`div`,{className:Q.clammStatusValue,children:[(0,y.jsx)(`span`,{className:(0,F.default)(Q.statusDot,t)}),(0,y.jsx)(`span`,{children:n})]})]}),e.isFullRange?(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Range Bounds`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:`Full range`})})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Min`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:qy(e.minPrice,e.pricePairLabel)})})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Max`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownAmount,children:qy(e.maxPrice,e.pricePairLabel)})})]})]}),(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Claimable rewards`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(e.rewardValue)})})]})]})},Xy=({row:e,denomLogoMap:t})=>{let[n,r]=(0,g.useState)(!1),{denom:i,symbol:a,totalValue:o,coinLogos:s,logoUrl:c,clamm:l}=e,u=t.get(i);if(!l)return null;let d=c||u?.assetLogo;return(0,y.jsxs)(P.Collapsible.Root,{open:n,onOpenChange:r,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:Jy({isOpen:n,symbol:a,coinLogos:s,singleLogoUrl:d,rightContent:(0,y.jsx)(`span`,{className:Q.triggerValue,children:q(o)})})}),(0,y.jsx)(P.Collapsible.Content,{className:Q.collapsibleContent,children:(0,y.jsxs)(`div`,{className:Q.clammBreakdownContent,children:[(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Claimable rewards`}),(0,y.jsx)(`div`,{className:Q.breakdownValues,children:(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(l.totalRewardValue)})})]}),l.positions.map(e=>(0,y.jsx)(Yy,{position:e},e.tokenAddress))]})})]})},Zy=({row:e,denomLogoMap:t})=>{let{denom:n,symbol:r,totalValue:i,breakdown:a,logoUrl:o,coinLogos:s,claimableInit:c}=e,[l,u]=(0,g.useState)(!1),f=t.get(n),p=o||f?.assetLogo,m=e.totalAmount>0?e.totalValue/e.totalAmount:0,h=(0,g.useMemo)(()=>Object.entries(a).filter(([,e])=>e>0),[a]),_=c&&Number(c.total)>0;return(0,y.jsxs)(P.Collapsible.Root,{open:l,onOpenChange:u,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:Jy({isOpen:l,symbol:r,coinLogos:s,singleLogoUrl:p,rightContent:(0,y.jsx)(`span`,{className:Q.triggerValue,children:q(i)})})}),(0,y.jsx)(P.Collapsible.Content,{className:Q.collapsibleContent,children:(0,y.jsxs)(`div`,{className:Q.breakdownContent,children:[h.map(([e,t])=>{let n=t*m;return(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:Wy[e]}),(0,y.jsxs)(`div`,{className:Q.breakdownValues,children:[(0,y.jsxs)(`span`,{className:Q.breakdownAmount,children:[(0,d.formatNumber)(t,{dp:6}),` LP`]}),(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(n)})]})]},e)}),_&&(0,y.jsxs)(`div`,{className:Q.breakdownRow,children:[(0,y.jsx)(`span`,{className:Q.breakdownLabel,children:`Claimable rewards`}),(0,y.jsxs)(`div`,{className:Q.breakdownValues,children:[(0,y.jsxs)(`span`,{className:Q.breakdownAmount,children:[(0,d.formatNumber)(Number(c.total),{dp:6}),` `,`INIT`]}),(0,y.jsx)(`span`,{className:Q.breakdownValue,children:q(c.totalValue)})]})]})]})})]})},Qy=({row:e,denomLogoMap:t})=>e.clamm?(0,y.jsx)(Xy,{row:e,denomLogoMap:t}):(0,y.jsx)(Zy,{row:e,denomLogoMap:t}),$={container:`_container_1nf0m_1`,section:`_section_1nf0m_6`,sectionHeader:`_sectionHeader_1nf0m_14`,sectionLabel:`_sectionLabel_1nf0m_20`,sectionTitleLink:`_sectionTitleLink_1nf0m_26`,sectionValue:`_sectionValue_1nf0m_40`,tokenList:`_tokenList_1nf0m_47`,tokenTrigger:`_tokenTrigger_1nf0m_59`,tokenChevron:`_tokenChevron_1nf0m_75`,expanded:`_expanded_1nf0m_86`,tokenInfo:`_tokenInfo_1nf0m_90`,tokenInfoLabel:`_tokenInfoLabel_1nf0m_96`,pairedLogos:`_pairedLogos_1nf0m_102`,coinLogo:`_coinLogo_1nf0m_107`,tokenSymbol:`_tokenSymbol_1nf0m_125`,triggerValue:`_triggerValue_1nf0m_131`,statusDot:`_statusDot_1nf0m_138`,active:`_active_1nf0m_145`,inactive:`_inactive_1nf0m_149`,statusValue:`_statusValue_1nf0m_153`,breakdownContent:`_breakdownContent_1nf0m_163`,breakdownRow:`_breakdownRow_1nf0m_171`,breakdownLabel:`_breakdownLabel_1nf0m_179`,breakdownValues:`_breakdownValues_1nf0m_185`,breakdownValue:`_breakdownValue_1nf0m_185`,curatorLink:`_curatorLink_1nf0m_198`,collapsibleContent:`_collapsibleContent_1nf0m_209`,slideDown:`_slideDown_1nf0m_1`,slideUp:`_slideUp_1nf0m_1`},$y=({data:e,chainId:t})=>{let{totalValue:n,rows:r}=e;return r.length===0?null:(0,y.jsx)(`div`,{className:$.container,children:(0,y.jsxs)(`section`,{className:$.section,"aria-label":`Vault positions`,children:[(0,y.jsxs)(`div`,{className:$.sectionHeader,children:[(0,y.jsxs)(`a`,{href:Tt,target:`_blank`,rel:`noopener noreferrer`,className:$.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:$.sectionLabel,children:`Vault`}),(0,y.jsx)(L.IconExternalLink,{size:14,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:$.sectionValue,children:q(n)})]}),(0,y.jsx)(`div`,{className:$.tokenList,children:r.map(e=>(0,y.jsx)(eb,{row:e,chainId:t},e.vaultAddress))})]})})},eb=({row:e,chainId:t})=>{let[n,r]=(0,g.useState)(!1),{symbol:i,coinLogos:a,value:o,claimableValue:s,isActive:c,curatorAddress:l}=e,u=a.some(e=>e);return(0,y.jsxs)(P.Collapsible.Root,{open:n,onOpenChange:r,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:$.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:$.tokenInfo,children:[(0,y.jsx)(L.IconChevronDown,{size:14,className:(0,F.default)($.tokenChevron,{[$.expanded]:n}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:$.tokenInfoLabel,children:[u&&(0,y.jsx)(`div`,{className:$.pairedLogos,children:a.map((e,t)=>(0,y.jsx)(K,{src:e,width:20,height:20,className:$.coinLogo,logo:!0},t))}),(0,y.jsx)(`span`,{className:$.tokenSymbol,children:i})]})]}),(0,y.jsx)(`span`,{className:$.triggerValue,children:q(o+s)})]})}),(0,y.jsx)(P.Collapsible.Content,{className:$.collapsibleContent,children:(0,y.jsxs)(`div`,{className:$.breakdownContent,children:[(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Deposit`}),(0,y.jsx)(`div`,{className:$.breakdownValues,children:(0,y.jsx)(`span`,{className:$.breakdownValue,children:q(o)})})]}),(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Status`}),(0,y.jsxs)(`div`,{className:$.statusValue,children:[(0,y.jsx)(`span`,{className:(0,F.default)($.statusDot,c?$.active:$.inactive)}),(0,y.jsx)(`span`,{children:c?`Active`:`Inactive`})]})]}),l&&(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Curator`}),(0,y.jsx)(Nc,{chainId:t,accountAddress:l,className:$.curatorLink,showIcon:!0})]}),(0,y.jsxs)(`div`,{className:$.breakdownRow,children:[(0,y.jsx)(`span`,{className:$.breakdownLabel,children:`Claimable rewards`}),(0,y.jsx)(`div`,{className:$.breakdownValues,children:(0,y.jsx)(`span`,{className:$.breakdownValue,children:q(s)})})]})]})})]})},tb={container:`_container_1fdqm_1`,section:`_section_1fdqm_6`,sectionHeader:`_sectionHeader_1fdqm_14`,sectionTitle:`_sectionTitle_1fdqm_20`,sectionLabel:`_sectionLabel_1fdqm_26`,externalLink:`_externalLink_1fdqm_32`,sectionTitleLink:`_sectionTitleLink_1fdqm_44`,sectionValue:`_sectionValue_1fdqm_58`,tokenList:`_tokenList_1fdqm_65`,tokenTrigger:`_tokenTrigger_1fdqm_77`,tokenChevron:`_tokenChevron_1fdqm_93`,expanded:`_expanded_1fdqm_104`,tokenInfo:`_tokenInfo_1fdqm_108`,tokenInfoLabel:`_tokenInfoLabel_1fdqm_114`,tokenLogo:`_tokenLogo_1fdqm_120`,tokenName:`_tokenName_1fdqm_124`,triggerValue:`_triggerValue_1fdqm_130`,breakdownContent:`_breakdownContent_1fdqm_137`,breakdownRow:`_breakdownRow_1fdqm_145`,breakdownLabel:`_breakdownLabel_1fdqm_153`,breakdownValues:`_breakdownValues_1fdqm_159`,breakdownAmount:`_breakdownAmount_1fdqm_165`,breakdownValue:`_breakdownValue_1fdqm_159`,collapsibleContent:`_collapsibleContent_1fdqm_179`,slideDown:`_slideDown_1fdqm_1`,slideUp:`_slideUp_1fdqm_1`},nb=({data:e})=>{let{totalValue:t,rows:n}=e;return n.length===0?null:(0,y.jsx)(`div`,{className:tb.container,children:(0,y.jsxs)(`section`,{className:tb.section,"aria-label":`VIP rewards`,children:[(0,y.jsxs)(`div`,{className:tb.sectionHeader,children:[(0,y.jsxs)(`a`,{href:Et,target:`_blank`,rel:`noopener noreferrer`,className:tb.sectionTitleLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:tb.sectionLabel,children:`VIP`}),(0,y.jsx)(L.IconExternalLink,{size:14,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:tb.sectionValue,children:q(t)})]}),(0,y.jsx)(`div`,{className:tb.tokenList,children:n.map(e=>(0,y.jsx)(rb,{row:e},`${e.bridgeId}-${e.version}`))})]})})},rb=({row:e})=>{let{name:t,logoUrl:n,lockedReward:r,lockedRewardValue:i,claimableReward:a,claimableRewardValue:o}=e,[s,c]=(0,g.useState)(!1),l=i+o;return(0,y.jsxs)(P.Collapsible.Root,{open:s,onOpenChange:c,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:tb.tokenTrigger,children:[(0,y.jsxs)(`div`,{className:tb.tokenInfo,children:[(0,y.jsx)(L.IconChevronDown,{size:14,className:(0,F.default)(tb.tokenChevron,{[tb.expanded]:s}),"aria-hidden":`true`}),(0,y.jsxs)(`div`,{className:tb.tokenInfoLabel,children:[(0,y.jsx)(K,{src:n,width:20,height:20,className:tb.tokenLogo,logo:!0}),(0,y.jsx)(`span`,{className:tb.tokenName,children:t})]})]}),(0,y.jsx)(`span`,{className:tb.triggerValue,children:q(l)})]})}),(0,y.jsx)(P.Collapsible.Content,{className:tb.collapsibleContent,children:(0,y.jsxs)(`div`,{className:tb.breakdownContent,children:[r>0&&(0,y.jsxs)(`div`,{className:tb.breakdownRow,children:[(0,y.jsx)(`span`,{className:tb.breakdownLabel,children:`Locked`}),(0,y.jsxs)(`div`,{className:tb.breakdownValues,children:[(0,y.jsxs)(`span`,{className:tb.breakdownAmount,children:[(0,d.formatNumber)(r,{dp:2}),` INIT`]}),(0,y.jsx)(`span`,{className:tb.breakdownValue,children:q(i)})]})]}),a>0&&(0,y.jsxs)(`div`,{className:tb.breakdownRow,children:[(0,y.jsx)(`span`,{className:tb.breakdownLabel,children:`Claimable rewards`}),(0,y.jsxs)(`div`,{className:tb.breakdownValues,children:[(0,y.jsxs)(`span`,{className:tb.breakdownAmount,children:[(0,d.formatNumber)(a,{dp:2}),` INIT`]}),(0,y.jsx)(`span`,{className:tb.breakdownValue,children:q(o)})]})]})]})})]})},ib={container:`_container_jelqd_1`,trigger:`_trigger_jelqd_6`,expandIcon:`_expandIcon_jelqd_22`,chainInfo:`_chainInfo_jelqd_27`,logo:`_logo_jelqd_33`,chainNameContainer:`_chainNameContainer_jelqd_37`,chainName:`_chainName_jelqd_37`,externalLink:`_externalLink_jelqd_49`,externalIcon:`_externalIcon_jelqd_53`,chainNameLink:`_chainNameLink_jelqd_58`,valueColumn:`_valueColumn_jelqd_75`,value:`_value_jelqd_75`,expanded:`_expanded_jelqd_92`,collapsibleContent:`_collapsibleContent_jelqd_97`,slideDown:`_slideDown_jelqd_1`,slideUp:`_slideUp_jelqd_1`,content:`_content_jelqd_109`},ab=(0,b.atom)(!1),ob=()=>{let{totalValue:e}=Ho(),{totalValue:t}=ts(),{totalValue:n}=hs(),{totalValue:r}=us(),i=e+t+n+r;return(0,y.jsx)(`span`,{className:ib.value,children:q(i)})},sb=({chainId:e,chainLogo:t,denomLogos:n,symbolLogos:r,initPrice:i})=>{let{positions:a}=Ho(),{data:o}=Bo(),{data:s}=Vo(),c=(0,g.useMemo)(()=>{let i=new Map;for(let o of a){if(o.type===`fungible-position`||o.type===`perp-position`||o.balance.type===`unknown`)continue;let{denom:a,symbol:s}=o.balance,c=s.toUpperCase(),l=`${e}:${a}`,u=n.get(l)??r.get(c);u&&i.set(a,{assetLogo:u,chainLogo:t})}return i},[a,n,r,e,t]),l=(0,g.useMemo)(()=>(e,t)=>{let n=(0,d.denomToMetadata)(e);if(t===`staking`){let e=o?.get(n);return e?(0,d.fromBaseUnit)(e.amount,{decimals:6}):`0`}if(t===`lockstaking`){let e=s?.get(n);return e?(0,d.fromBaseUnit)(e.amount,{decimals:6}):`0`}return`0`},[o,s]),u=(0,g.useMemo)(()=>a.length===0?[]:[{protocol:`Initia`,manageUrl:Tt,positions:a}],[a]);return u.length===0?null:(0,y.jsx)(Ny,{protocols:u,denomLogoMap:c,isInitia:!0,getClaimableInitByType:l,initPrice:i})},cb=({chainId:e,chainLogo:t,denomLogos:n,symbolLogos:r})=>{let i=ts(),a=(0,g.useMemo)(()=>{let a=new Map;for(let o of i.rows){let{denom:i,symbol:s}=o,c=s.toUpperCase(),l=`${e}:${i}`,u=n.get(l)??r.get(c);u&&a.set(i,{assetLogo:u,chainLogo:t})}return a},[i.rows,n,r,e,t]);return i.rows.length===0?null:(0,y.jsx)(Uy,{data:i,denomLogoMap:a})},lb=()=>{let e=hs();return e.rows.length===0?null:(0,y.jsx)(nb,{data:e})},ub=({chainId:e})=>{let t=us();return t.rows.length===0?null:(0,y.jsx)($y,{data:t,chainId:e})},db=({chainGroup:e})=>{let{chainId:t,prettyName:n,chainLogo:r}=e,[i,a]=(0,b.useAtom)(ab),o=Ze(),s=ft(),{denomLogos:c,symbolLogos:l}=(0,g.useMemo)(()=>ys(s,o),[s,o]),{data:u}=at(V()),d=(0,g.useMemo)(()=>u?.find(e=>e.id===`uinit`)?.price??0,[u]);return(0,y.jsx)(`div`,{className:ib.container,children:(0,y.jsxs)(P.Collapsible.Root,{open:i,onOpenChange:a,children:[(0,y.jsx)(P.Collapsible.Trigger,{asChild:!0,children:(0,y.jsxs)(`button`,{className:ib.trigger,children:[(0,y.jsxs)(`div`,{className:ib.chainInfo,children:[r&&(0,y.jsx)(K,{src:r,width:32,height:32,className:ib.logo,logo:!0}),(0,y.jsxs)(`a`,{href:Tt,target:`_blank`,rel:`noopener noreferrer`,className:ib.chainNameLink,onClick:e=>e.stopPropagation(),children:[(0,y.jsx)(`span`,{className:ib.chainName,children:n}),(0,y.jsx)(L.IconExternalLink,{size:14,className:ib.externalIcon})]})]}),(0,y.jsxs)(`div`,{className:ib.valueColumn,children:[(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:16,width:60,length:1}),children:(0,y.jsx)(ob,{})}),(0,y.jsx)(L.IconChevronDown,{size:16,className:(0,F.default)(ib.expandIcon,{[ib.expanded]:i})})]})]})}),(0,y.jsx)(P.Collapsible.Content,{className:ib.collapsibleContent,children:(0,y.jsxs)(`div`,{className:ib.content,children:[(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:36,length:2}),children:(0,y.jsx)(sb,{chainId:t,chainLogo:r,denomLogos:c,symbolLogos:l,initPrice:d})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:36,length:1}),children:(0,y.jsx)(ub,{chainId:t})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:36,length:2}),children:(0,y.jsx)(cb,{chainId:t,chainLogo:r,denomLogos:c,symbolLogos:l})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:36,length:1}),children:(0,y.jsx)(lb,{})})]})})]})})},fb={totalValue:`_totalValue_1v2ca_1`},pb=({filteredChainGroups:e})=>{let{totalValue:t}=Ho(),{totalValue:n}=ts(),{totalValue:r}=hs(),{totalValue:i}=us(),a=t+n+r+i,o=(0,g.useMemo)(()=>{let t=e.some(e=>e.isInitia);return e.reduce((e,t)=>t.isInitia?e:e+t.totalValue,0)+(t?a:0)},[e,a]);return(0,y.jsx)(`span`,{className:fb.totalValue,children:q(o)})},mb={container:`_container_1eubu_1`,header:`_header_1eubu_7`,title:`_title_1eubu_13`,list:`_list_1eubu_19`,skeletonWrapper:`_skeletonWrapper_1eubu_24`},hb=(0,g.memo)(({searchQuery:e,selectedChain:t,chainInfoMap:n})=>{let{positions:r,isLoading:i}=nc(),a=V(),o=(0,g.useMemo)(()=>{let i=[];for(let o of r){if(!Array.isArray(o.positions))continue;let r=n.get(o.chainName.toLowerCase()),s=o.chainName.toLowerCase(),c=(r?.prettyName??o.chainName).toLowerCase();if(t&&r?.chainId!==t||!o.positions.some(e=>e.positions.some(e=>e.type!==`fungible-position`)))continue;if(e){let t=e.toLowerCase();if(!s.includes(t)&&!c.includes(t))continue}let l=o.positions.filter(t=>e&&!t.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(t.positions)&&t.positions.length>0),u=a.chainId===r?.chainId,d=l.reduce((e,t)=>e+t.positions.reduce((e,t)=>e+Es(t),0),0);i.push({chainId:r?.chainId??``,chainName:o.chainName,prettyName:r?.prettyName??o.chainName,chainLogo:r?.logoUrl??``,protocols:l,isInitia:u,totalValue:d})}let o=[`civitia`,`yominet`];return(0,p.sortWith)([(0,p.descend)(e=>e.isInitia??!1),(0,p.ascend)(e=>o.includes(e.chainName.toLowerCase())),(0,p.descend)(e=>e.totalValue??0),(0,p.ascend)(e=>e.prettyName.toLowerCase())],i)},[r,n,e,t,a.chainId]),s=o.length>0;return(0,y.jsxs)(`div`,{className:mb.container,children:[(0,y.jsxs)(`div`,{className:mb.header,children:[(0,y.jsx)(`span`,{className:mb.title,children:`Positions`}),s&&(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:16,width:60,length:1}),children:(0,y.jsx)(pb,{filteredChainGroups:o})})]}),s?(0,y.jsx)(`div`,{className:mb.list,children:o.map(e=>e.isInitia?(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(`div`,{className:mb.skeletonWrapper,children:(0,y.jsx)(Ay,{height:56,length:1})}),children:(0,y.jsx)(db,{chainGroup:e})},e.chainName):(0,y.jsx)(Hy,{chainGroup:e},e.chainName))}):r.length===0&&i?(0,y.jsx)(Ay,{height:56,length:3}):(0,y.jsx)(Ia,{children:`No positions`})]})}),gb={content:`_content_1w1ad_1`},_b=({selectedChain:e,setSelectedChain:t})=>{let{defaultChainId:n}=z(),r=V(),i=ic(),{totalValue:a}=hs(),{totalValue:o}=us(),{chainIds:s,chainIdToValueMap:c,totalBalance:l}=(0,g.useMemo)(()=>{let e=new Map,t=0;for(let n of i)e.set(n.chainId,n.totalBalance),t+=n.totalBalance;let s=a+o;return s>0&&(e.set(r.chainId,(e.get(r.chainId)??0)+s),t+=s),{chainIds:(0,p.sortWith)([(0,p.descend)(e=>e===n),(0,p.descend)(e=>e===r.chainId),(0,p.descend)(t=>e.get(t)??0)],i.map(e=>e.chainId)),chainIdToValueMap:e,totalBalance:t}},[i,n,r,a,o]);return(0,y.jsx)(Lv,{value:e,onChange:t,chainIds:s,renderExtra:e=>q(e?c.get(e)??0:l)})},vb=()=>{let[e,t]=(0,b.useAtom)(Bv),[n,r]=(0,b.useAtom)(Vv),i=Ze(),a=ft(),{denomLogos:o,symbolLogos:s}=(0,g.useMemo)(()=>ys(a,i),[a,i]),c=ot(),l=(0,g.useMemo)(()=>Ls(i,c),[i,c]),u=rc();return(0,y.jsxs)(zv.Root,{children:[(0,y.jsxs)(zv.Controls,{children:[(0,y.jsx)(zv.SearchInput,{value:e,onChange:e=>t(e.target.value),onClear:()=>t(``),placeholder:`Search portfolio`}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Cd,{height:44,width:132}),children:(0,y.jsx)(_b,{selectedChain:n,setSelectedChain:r})})]}),(0,y.jsxs)(`section`,{className:gb.content,"aria-label":`Assets and positions`,children:[(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:48,length:5}),children:(0,y.jsx)(jy,{searchQuery:e,selectedChain:n,denomLogos:o,symbolLogos:s,chainInfoMap:u,chainPrices:l})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(Ay,{height:56,length:3}),children:(0,y.jsx)(hb,{searchQuery:e,selectedChain:n,chainInfoMap:u})})]})]})},yb={totalValue:`_totalValue_5pf7e_1`,totalLabel:`_totalLabel_5pf7e_7`,totalAmount:`_totalAmount_5pf7e_13`,loading:`_loading_5pf7e_18`,skeletonWrapper:`_skeletonWrapper_5pf7e_23`,nav:`_nav_5pf7e_28`,item:`_item_5pf7e_34`,tabs:`_tabs_5pf7e_59`,tab:`_tab_5pf7e_59`},bb=()=>{let{totalValue:e,isLoading:t}=Aa();return(0,y.jsx)(`div`,{className:(0,F.default)(yb.totalAmount,{[yb.loading]:t}),children:q(e)})},xb=()=>{let e=ac(),t=oc(),n=e+gs()+t;return(0,y.jsx)(`div`,{className:yb.totalAmount,children:q(n)})},Sb=()=>{Du();let e=$s();(0,g.useEffect)(()=>{e()},[e]);let t=Gs(),n=Zt(),r=Jt(),i=(0,g.useRef)(null);return(0,y.jsx)(gy.Provider,{value:i,children:(0,y.jsxs)(gc,{ref:i,children:[(0,y.jsxs)(`div`,{className:yb.totalValue,children:[(0,y.jsx)(`div`,{className:yb.totalLabel,children:`Total value`}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(`div`,{className:yb.skeletonWrapper,children:(0,y.jsx)(Cd,{height:48,width:120})}),children:t?(0,y.jsx)(bb,{}):(0,y.jsx)(xb,{})})]}),(0,y.jsxs)(`nav`,{className:yb.nav,"aria-label":`Quick actions`,children:[(0,y.jsxs)($t,{to:`/send`,className:yb.item,children:[(0,y.jsx)(L.IconSend,{size:20}),(0,y.jsx)(`span`,{children:`Send`})]}),(0,y.jsxs)($t,{to:`/bridge`,className:yb.item,children:[(0,y.jsx)(L.IconBridge,{size:20}),(0,y.jsx)(`span`,{children:`Bridge/Swap`})]}),(0,y.jsxs)($t,{to:`/receive`,className:yb.item,children:[(0,y.jsx)(L.IconQrCode,{size:20}),(0,y.jsx)(`span`,{children:`Receive`})]})]}),(0,y.jsxs)(De.Tabs.Root,{value:r,onValueChange:n,children:[(0,y.jsxs)(De.Tabs.List,{className:yb.tabs,children:[(0,y.jsx)(De.Tabs.Tab,{className:yb.tab,value:`/`,children:t?`Assets`:`Portfolio`}),(0,y.jsx)(De.Tabs.Tab,{className:yb.tab,value:`/nfts`,children:`NFTs`}),(0,y.jsx)(De.Tabs.Tab,{className:yb.tab,value:`/activity`,children:`Activity`})]}),(0,y.jsx)(De.Tabs.Panel,{value:`/`,children:t?(0,y.jsx)(Oy,{}):(0,y.jsx)(vb,{})}),(0,y.jsx)(De.Tabs.Panel,{value:`/nfts`,children:(0,y.jsx)(hy,{})}),(0,y.jsx)(De.Tabs.Panel,{value:`/activity`,children:(0,y.jsx)(ny,{})})]})]})})},Cb={root:`_root_th990_1`,collectionName:`_collectionName_th990_9`,nftName:`_nftName_th990_13`,chainInfo:`_chainInfo_th990_17`,attributes:`_attributes_th990_21`,title:`_title_th990_24`,count:`_count_th990_29`,item:`_item_th990_33`,type:`_type_th990_39`,value:`_value_th990_45`},wb=()=>{let e=Zt(),t=Yt(),{attributes:n}=t;return(0,y.jsxs)($l,{title:`NFT details`,children:[(0,y.jsx)(oy,{normalizedNft:t,chainIconSize:14,classNames:Cb}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{onClick:()=>e(`/nft/send`,t),sm:!0,children:`Send`})}),n&&(0,y.jsxs)(`div`,{className:Cb.attributes,children:[(0,y.jsxs)(`header`,{className:Cb.title,children:[`Traits `,(0,y.jsxs)(`span`,{className:Cb.count,children:[`(`,n.length,`)`]})]}),(0,y.jsx)(`div`,{children:n.map(({trait_type:e,value:t})=>(0,y.jsxs)(`div`,{className:Cb.item,children:[(0,y.jsx)(`div`,{className:Cb.type,children:e}),(0,y.jsx)(`div`,{className:Cb.value,children:t})]},e))})]})]})};function Tb({balances:e,gasPrices:t,gas:n}){return t.map(({denom:t,amount:r})=>({amount:(0,f.default)(r||0).times(n).toFixed(0,f.default.ROUND_CEIL),denom:t,balance:e.find(e=>e.denom===t)?.amount||`0`})).filter(({amount:e,balance:t})=>(0,f.default)(t).gte(e))}function Eb({denom:e,balances:t,gasPrices:n,lastFeeDenom:r,gas:i}){let a=t.find(t=>t.denom===e)?.amount||`0`,o=Tb({balances:t,gasPrices:n,gas:i}),s=o.find(e=>e.denom===r);if(o.length===0)return a;if(e===r&&s){let e=(0,f.default)(a).minus(s.amount);return f.default.max(e,0).toString()}let c=o.find(t=>t.denom!==e)||o[0];if(!s&&e===c.denom){let e=(0,f.default)(a).minus(c.amount);return f.default.max(e,0).toString()}return(0,f.default)(a).toString()}var Db=({chain:e,onSelect:t})=>(0,y.jsx)(gd,{assets:Bt(e),onSelect:t}),Ob=({afterSelect:e})=>{let{watch:t,setValue:n}=(0,I.useFormContext)(),{chainId:r,denom:i}=t(),{chainId:a}=t(),[o,s]=(0,g.useState)(a),c=tt(o),l=Ze();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(vd.Stack,{children:(0,y.jsx)(vd,{chains:l,value:o,onSelect:s})}),(0,y.jsx)(W,{suspenseFallback:(0,y.jsx)(gd.Placeholder,{}),children:(0,y.jsx)(Db,{chain:c,onSelect:t=>{if(r===o&&i===t){e();return}n(`chainId`,o),n(`denom`,t),n(`quantity`,``,{shouldTouch:!1,shouldDirty:!1}),e()}})},o)]})},kb={fields:`_fields_brpej_1`,divider:`_divider_brpej_11`},Ab=(0,m.createQueryKeys)(`interwovenkit:send`,{gas:e=>[e]}),jb=()=>{let{address:e,initiaAddress:t,estimateGas:n,requestTxSync:r}=Pa(),{register:i,watch:a,setValue:o,handleSubmit:s,formState:c}=(0,I.useFormContext)(),{errors:l}=c,{chainId:p,denom:m,recipient:h,quantity:_,memo:v}=a(),b=tt(p),x=Rt(b),S=Wi(b),C=Gi(b),w=mt(m,b),{data:T}=at(b),{decimals:E}=w,D=x.find(e=>e.denom===m)?.amount||`0`,O=T?.find(({id:e})=>e===m)?.price,{data:k=0,isLoading:A}=(0,u.useQuery)({queryKey:Ab.gas({chainId:p,denom:m,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>n({messages:[{typeUrl:`/cosmos.bank.v1beta1.MsgSend`,value:ke.MsgSend.fromPartial({fromAddress:t,toAddress:(0,d.InitiaAddress)(h).bech32,amount:[{denom:m,amount:`1`}]})}],chainId:p}),enabled:d.InitiaAddress.validate(h),staleTime:B.INFINITY}),j=Eb({denom:m,balances:x,gasPrices:S,lastFeeDenom:C,gas:Math.ceil(k*Ne)}),M=(0,f.default)(D).isZero(),ee=S.some(({denom:e})=>e===m)&&A,te=M||ee,N=tn(_),ne=N?bl(N.times(O??0),O):`$0`,{mutate:re,isPending:ie}=(0,u.useMutation)({mutationFn:({chainId:e,denom:n,quantity:i,recipient:a,memo:o})=>{let s=(0,d.toBaseUnit)(i,{decimals:E});return r({messages:[{typeUrl:`/cosmos.bank.v1beta1.MsgSend`,value:ke.MsgSend.fromPartial({fromAddress:t,toAddress:(0,d.InitiaAddress)(a).bech32,amount:[{denom:n,amount:s}]})}],memo:o,chainId:e,gas:k,gasAdjustment:Ne,gasPrices:S,spendCoins:[{denom:n,amount:s}],internal:`/`})}}),ae=(0,g.useMemo)(()=>{if(!_)return`Enter amount`;if(l.quantity)return l.quantity.message;if(!h)return`Enter recipient address`;if(l.recipient)return l.recipient.message;if(l.memo)return l.memo.message},[_,h,l.quantity,l.recipient,l.memo]);return(0,y.jsx)($l,{title:`Send`,children:(0,y.jsxs)(`form`,{onSubmit:s(e=>re(e)),"aria-label":`Send token form`,children:[(0,y.jsxs)(`div`,{className:kb.fields,children:[(0,y.jsx)(ju,{selectButton:(0,y.jsx)(Ru,{title:`Select chain and asset`,content:e=>(0,y.jsx)(Ob,{afterSelect:e}),children:(0,y.jsx)(cd,{asset:w,chain:b})}),quantityInput:(0,y.jsx)(Lu,{balance:D,decimals:E}),balanceButton:(0,y.jsx)(ku,{onClick:()=>o(`quantity`,(0,d.fromBaseUnit)(j,{decimals:E}),{shouldValidate:!0}),disabled:te,children:(0,d.formatAmount)(D??`0`,{decimals:E})}),value:ne}),(0,y.jsx)(`div`,{className:kb.divider}),(0,y.jsx)($u,{myAddress:e}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{htmlFor:`memo`,children:`Memo (optional)`}),(0,y.jsx)(`input`,{...i(`memo`,{validate:e=>!e||new Blob([e]).size<=256||`Memo is too long`}),id:`memo`,autoComplete:`off`})]}),(0,y.jsx)(el.Stack,{children:!v&&(0,y.jsx)(el,{level:`warning`,children:`Check if the above transaction requires a memo`})})]}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{type:`submit`,loading:(A?`Estimating gas...`:!1)||ie,disabled:!!ae,children:ae??`Confirm`})})]})})},Mb=()=>{let e=Yt(),t=rt(),n=dt(t),{chain:r=t}=e,i=(0,p.head)(n);if(!e.denom&&!i)throw Error(`Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.`);let a=e.denom??i?.denom;return(0,y.jsx)(I.FormProvider,{...(0,I.useForm)({mode:`onChange`,defaultValues:{chainId:r.chainId,denom:a,quantity:``,recipient:``,memo:``}}),children:(0,y.jsx)(jb,{})})};async function Nb(e,t){let n=e.replace(`ibc/`,``),{class_trace:r}=await h.default.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${n}`).json();return r}async function Pb(e,t){let n=new w.Interface([{inputs:[],name:`name`,outputs:[{internalType:`string`,name:``,type:`string`}],stateMutability:`view`,type:`function`}]),{response:r}=await h.default.create({prefixUrl:t}).post(`minievm/evm/v1/call`,{json:{sender:(0,d.InitiaAddress)(`0x1`).bech32,contract_addr:(0,d.InitiaAddress)(e).hex,input:n.encodeFunctionData(`name`)}}).json();return n.decodeFunctionResult(`name`,r)[0]}async function Fb(e,t,n){if(t.startsWith(`evm/`))return e;let{token_infos:r}=await h.default.create({prefixUrl:n}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(`,`)}}).json();return r.map(({token_origin_id:e})=>e)}async function Ib({collection_addr:e},{restUrl:t}){let n=await Pb(e,t);if(!n.startsWith(`ibc/`))return{class_id:`evm/${(0,d.InitiaAddress)(e).rawHex}`,class_trace:void 0};let r=await Nb(n,t);return r?{class_id:n,class_trace:r}:{class_id:`evm/${(0,d.InitiaAddress)(e).rawHex}`,class_trace:void 0}}async function Lb(e,t){let{data:n}=await h.default.create({prefixUrl:t}).post(`initia/move/v1/view/json`,{json:{address:`0x1`,module_name:`collection`,function_name:`name`,type_args:[`0x1::collection::Collection`],args:[JSON.stringify(e)]}}).json();return JSON.parse(n)}async function Rb({object_addr:e,collection_addr:t},{restUrl:n}){let r=await Lb(t,n);return r.startsWith(`ibc/`)?d.InitiaAddress.equals((0,d.createObjectAddress)(`0x1`,r),t)?{class_id:r,class_trace:await Nb(r,n)}:{class_id:`move/${e.replace(`0x`,``).padStart(64,`0`)}`,class_trace:await Nb(r,n)}:{class_id:`move/${t.replace(`0x`,``).padStart(64,`0`)}`,class_trace:void 0}}async function zb(e,t){let n=(0,_.toBase64)((0,we.utf8ToBytes)(JSON.stringify({contract_info:{}}))),{data:r}=await h.default.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return r.name}async function Bb(e,t){let{collection:n}=await h.default.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return n.collection.creator}async function Vb(e,t){let n=(0,_.toBase64)((0,we.toBytes)(JSON.stringify({outgoing_proxy:{}}))),{data:r}=await h.default.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return r}function Hb(e){let t=e.match(/^(.*channel-\d+)\/(.*)$/);if(!t)throw Error("Pattern `channel-{number}/` not found.");let[,n,r]=t;return[n,r]}async function Ub({collection_addr:e},t,n){let r=(0,d.InitiaAddress)(e).bech32,i=await zb(r,t.restUrl),a=t.metadata?.ibc_channels?.find(({chain_id:e,version:t})=>e===n.chain_id&&t.includes(`ics721-1`));if(!a)throw Error(`Channel not found`);let o=a.port_id,s=o.split(`.`)[1],c=(0,_.toBase64)((0,we.toBytes)(JSON.stringify({class_id:{contract:r}}))),{data:l}=await h.default.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${s}/smart/${c}`).json(),u=l??r,f=await Vb(s,t.restUrl),p=await Bb(r,t.indexerUrl);if(u===r)return{class_id:u,class_trace:void 0,outgoing_proxy:f};if(l&&p!==o.replace(`wasm.`,``)){let[e,t]=Hb(l);return{class_id:r,class_trace:{path:e,base_class_id:t},outgoing_proxy:f}}let[m,g]=Hb(i);return{class_id:r,class_trace:{path:m,base_class_id:g},outgoing_proxy:f}}var Wb={minimove:Rb,minievm:Ib,miniwasm:Ub};async function Gb({nft:e,srcChain:t,intermediaryChain:n}){let r=t.metadata?.is_l1?`minimove`:t.metadata?.minitia?.type;if(!(r===`minimove`||r===`minievm`||r===`miniwasm`))throw Error(`Unsupported minitia type: ${r}`);let i=await Wb[r](e,t,n);return Object.assign(i,r===`minievm`&&{token_ids:await Fb([e.token_id],i.class_id,t.restUrl)})}var Kb={root:`_root_1tyvn_1`,collectionName:`_collectionName_1tyvn_10`,nftName:`_nftName_1tyvn_15`,chainInfo:`_chainInfo_1tyvn_19`,fields:`_fields_1tyvn_24`,chain:`_chain_1tyvn_19`},qb=(0,m.createQueryKeys)(`interwovenkit:send-nft`,{simulation:e=>[e]}),Jb=()=>{let e=Ze(),t=Yt(),{chain:n,collection_addr:r}=t,{routerApiUrl:i}=z(),a=Kr(),o=V(),{address:s,initiaAddress:c,requestTxSync:l}=Pa(),{watch:f,setValue:p,handleSubmit:m,formState:_}=(0,I.useFormContext)(),{errors:v}=_,{recipient:b,dstChainId:x}=f(),S=tt(x),{data:C,isLoading:w,error:T}=(0,u.useQuery)({queryKey:qb.simulation({collection_addr:r,nft:t,sender:c,recipient:b,srcChain:n,dstChain:S,layer1:o,routerApiUrl:i}).queryKey,queryFn:async()=>{let e=Object.assign({from_address:c,from_chain_id:n.chainId,to_address:(0,d.InitiaAddress)(b).bech32,to_chain_id:S.chainId,collection_address:r,token_ids:[t.token_id],object_addresses:[t.object_addr]},n.chainId!==S.chainId&&await Gb({nft:t,srcChain:n,intermediaryChain:o})),{msgs:s}=await h.default.create({prefixUrl:i}).post(`nft`,{json:e}).json();return s.map(e=>a.fromAmino(e))},enabled:d.InitiaAddress.validate(b)}),E=(0,u.useQueryClient)(),{mutate:D,isPending:O}=(0,u.useMutation)({mutationFn:async()=>{if(!C)throw Error(`Route not found`);await l({messages:C,chainId:n.chainId,internal:`/nfts`})},onSuccess:()=>{E.invalidateQueries({queryKey:sy.nfts._def})}}),k=(0,g.useMemo)(()=>{if(!b)return`Enter recipient address`;if(v.recipient)return v.recipient.message;if(T)return`Route not found`},[b,v.recipient,T]);return(0,y.jsxs)(`form`,{onSubmit:m(()=>D()),children:[(0,y.jsx)(oy,{normalizedNft:t,thumbnailSize:80,classNames:Kb}),(0,y.jsxs)(`div`,{className:Kb.fields,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`label`,children:`Destination app`}),(0,y.jsxs)(Ru,{title:`Destination app`,content:t=>(0,y.jsx)(td,{onSelect:({chainId:e})=>{p(`dstChainId`,e),t()},list:e,getImage:e=>e.logoUrl,getName:e=>e.name,getKey:e=>e.chainId}),className:(0,F.default)(`input`,Kb.chain),children:[(0,y.jsx)(K,{src:S.logoUrl,width:20,height:20,logo:!0}),(0,y.jsx)(`span`,{children:S.name})]})]}),(0,y.jsx)($u,{myAddress:s,ref:Mu()})]}),(0,y.jsx)(mc,{children:(0,y.jsx)(G.White,{loading:(w?`Finding route...`:!1)||O,disabled:!!k,children:k??`Confirm`})})]})},Yb=()=>{let{chain:e}=Yt();return(0,y.jsx)($l,{title:`Send NFT`,children:(0,y.jsx)(I.FormProvider,{...(0,I.useForm)({mode:`onChange`,defaultValues:{dstChainId:e.chainId,recipient:``}}),children:(0,y.jsx)(Jb,{})})})},Xb=()=>{let e=Zt(),t=Jt(),n=Ma(),{closeDrawer:r}=Or(),{closeModal:i}=ki();(0,g.useEffect)(()=>{i(),t.startsWith(`/bridge/`)&&t!==`/bridge/history`&&e(`/bridge`),(t===`/collection`||t.startsWith(`/nft`))&&e(`/nfts`)},[n]);let a=Fn();if((0,g.useEffect)(()=>{a(`Page View`)},[t,a]),t===`/connect`)return n?null:(0,y.jsx)(om,{onSuccess:r});if(t===`/blank`)return null;if(!n)return(0,y.jsx)(om,{});switch(t){case`/`:case`/nfts`:case`/activity`:return(0,y.jsx)(Sb,{});case`/send`:return(0,y.jsx)(Mb,{},n);case`/receive`:return(0,y.jsx)(vv,{});case`/nft`:return(0,y.jsx)(wb,{});case`/nft/send`:return(0,y.jsx)(Yb,{},n);case`/bridge`:return(0,y.jsx)(Id,{},n);case`/bridge/preview`:return(0,y.jsx)(pp,{});case`/bridge/history`:return(0,y.jsx)(jf,{});case`/op/withdrawals`:return(0,y.jsx)(Bp,{});case`/tx`:return(0,y.jsx)(Nl,{});case`/autosign/enable`:return(0,y.jsx)(Yl,{});case`/settings`:return(0,y.jsx)(Fv,{});case`/settings/autosign`:return(0,y.jsx)(Dv,{});case`/deposit`:return(0,y.jsx)(fv,{});case`/withdraw`:return(0,y.jsx)(gv,{})}},Zb=`https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap`,Qb=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.googleapis.com`}),(0,y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.gstatic.com`,crossOrigin:``}),(0,y.jsx)(`link`,{rel:`stylesheet`,href:Zb}),(0,y.jsx)(`link`,{rel:`stylesheet`,href:`https://assets.initia.xyz/fonts/PilatWide.css`})]}),$b=()=>(sc(),xr(),Ei(),Ze(),ec(),gs(),ft(),null),ex=({children:e,...t})=>((0,g.useEffect)(()=>{_s()},[]),(0,le.useIsClient)()?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Qb,{}),(0,y.jsx)(Ve.Provider,{value:{...Fe,...t},children:(0,y.jsx)(en,{children:(0,y.jsx)(zl,{children:(0,y.jsx)(P.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:(0,y.jsx)(Rl,{children:(0,y.jsxs)(Pl,{children:[e,(0,y.jsx)(cc,{}),(0,y.jsx)(W,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:(0,y.jsx)($b,{})}),(0,y.jsx)(Gc,{children:(0,y.jsx)(Xb,{})}),(0,y.jsx)(Uc,{children:(0,y.jsx)(Xb,{})})]})})})})})})]}):null),tx=({bridge:e})=>(0,y.jsx)(en,{initialEntry:{path:e?`/bridge`:`/`,state:e},children:(0,y.jsx)(`div`,{className:`body`,children:(0,y.jsx)(Kc.Provider,{value:!!e,children:(0,y.jsx)(W,{children:(0,y.jsx)(Xb,{})})})})}),nx={1:`https://ethereum-rpc.publicnode.com`,42161:`https://arbitrum-one-rpc.publicnode.com`,8453:`https://base-rpc.publicnode.com`};function rx(e){if(e.privateKey&&e.addressIndex!==void 0)throw Error(`addressIndex requires mnemonic`);let t=e.addressIndex===void 0?`testWallet`:`testWallet-${e.addressIndex}`,n=e.addressIndex===void 0?`Test Wallet`:`Test Wallet ${e.addressIndex}`,{id:r=t,name:i=n,rpcUrls:a,debug:o=!1,sendTransactionOverrides:s,simulatePopup:c=!1}=e;async function l(e){if(!c)return e();typeof c==`object`&&await new Promise(e=>setTimeout(e,c.delayMs));let t=window.open(void 0,void 0,`popup=1,width=400,height=680`);if(!t)throw Error(`Failed to initialize request`);try{return await e()}finally{t.close()}}if(`mnemonic`in e&&e.mnemonic===``)throw Error(`mnemonic must not be empty`);if(!(`mnemonic`in e&&e.mnemonic)&&!(`privateKey`in e&&e.privateKey))throw Error(`Either mnemonic or privateKey is required`);let u;try{u=e.mnemonic?(0,Ae.mnemonicToAccount)(e.mnemonic,{addressIndex:e.addressIndex}):(0,Ae.privateKeyToAccount)(e.privateKey)}catch(t){throw Error(`[${r}] Failed to create account from ${e.mnemonic?`mnemonic`:`privateKey`}`,{cause:t})}let d=1,f={};function p(e,...t){f[e]?.forEach(e=>{e(...t)})}let m={...nx,...a},h={1:je.mainnet};function g(e){if(m[e])return m[e];let t=h[e];if(t)return t.rpcUrls.default.http[0];throw Error(`[${r}] No RPC configured for chain ${e}`)}async function _(e,t){let n=g(d),i=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:e,params:t??[]})});if(!i.ok)throw Error(`[${r}] RPC "${e}" failed: HTTP ${i.status} ${i.statusText} (${n})`);let a;try{a=await i.json()}catch(t){throw Error(`[${r}] RPC "${e}" returned non-JSON response (${n})`,{cause:t})}if(a.error)throw new A.EIP1193ProviderRpcError(a.error.code,a.error.message);return a.result}let v={request:async({method:e,params:t})=>{switch(o&&console.log(`[${r}] ${e}`,t),e){case`eth_requestAccounts`:case`eth_accounts`:return[u.address];case`eth_chainId`:return`0x${d.toString(16)}`;case`wallet_switchEthereumChain`:{let[{chainId:e}]=t,n=Number(e);if(!h[n]&&!m[n])throw new A.EIP1193ProviderRpcError(4902,`Unrecognized chain ID`);return!h[n]&&m[n]&&(h[n]={id:n,name:`Chain ${n}`,nativeCurrency:{name:`ETH`,symbol:`ETH`,decimals:18},rpcUrls:{default:{http:[m[n]]}}}),d=n,p(`chainChanged`,e),null}case`wallet_addEthereumChain`:{let[e]=t,n=e.rpcUrls?.[0];if(!n)throw Error(`[${r}] wallet_addEthereumChain requires at least one RPC URL`);let i=Number(e.chainId);return h[i]?o&&console.log(`[${r}] Chain ${i} already registered, skipping`):h[i]={id:i,name:e.chainName??`Chain ${i}`,nativeCurrency:{name:`ETH`,symbol:`ETH`,decimals:18},rpcUrls:{default:{http:[n]}}},null}case`personal_sign`:{let[e]=t;return l(()=>u.signMessage({message:{raw:e}}))}case`eth_signTypedData`:case`eth_signTypedData_v4`:{let[,e]=t;return u.signMessage({message:{raw:e}})}case`wallet_getPermissions`:case`wallet_requestPermissions`:return[{parentCapability:`eth_accounts`}];case`eth_sendTransaction`:{let[e]=t,n=h[d];if(!n)throw Error(`[${r}] No chain registered for chain ${d}. Call wallet_switchEthereumChain first.`);return(0,A.createWalletClient)({account:u,chain:n,transport:(0,A.http)(g(d))}).sendTransaction({to:e.to,value:e.value?BigInt(e.value):void 0,data:e.data,chainId:d,...s})}default:return _(e,t)}},on:(e,t)=>{(f[e]??=new Set).add(t)},removeListener:(e,t)=>{f[e]?.delete(t)},removeAllListeners:()=>{for(let e of Object.keys(f))delete f[e]}};return(0,Me.injected)({target:()=>({id:r,name:i,provider:v})})}var ix={"noble-1":`noble`,celestia:`celestia`,"neutron-1":`neutron`,"osmosis-1":`osmo`};function ax(e){let{mnemonic:t,name:n=`Test Cosmos Wallet`,image:r,chains:i,debug:a=!1}=e;if(!t)throw Error(`mnemonic is required`);let o=new Map;function s(e){return i?.[e]?i[e].prefix:ix[e]?ix[e]:e.replace(/-\d+$/,``)}function c(e){let r=s(e),i=o.get(r);if(i)return i;a&&console.log(`[${n}] Creating wallet for chain ${e} (prefix: ${r})`);let c=E.Secp256k1HdWallet.fromMnemonic(t,{prefix:r});return c.catch(e=>{o.delete(r),console.error(`[${n}] Failed to create wallet for prefix "${r}":`,e)}),o.set(r,c),c}function l(e){return{async getAccounts(){return(await c(e)).getAccounts()},async signAmino(t,n){return(await c(e)).signAmino(t,n)}}}let u={getOfflineSigner(e){return l(e)},getOfflineSignerOnlyAmino(e){return l(e)}};return{name:n,image:r,getProvider:()=>u}}exports.DEFAULT_GAS_ADJUSTMENT=Ne,exports.DEFAULT_GAS_PRICE_MULTIPLIER=Pe,exports.InterwovenKit=tx,exports.InterwovenKitProvider=ex,exports.MAINNET=Fe,exports.MoveError=Ai,exports.PRIVY_APP_ID=Le,exports.TESTNET=Ie,exports.createTestCosmosWallet=ax,exports.createTestWalletConnector=rx,exports.initiaPrivyWallet=Be,exports.initiaPrivyWalletConnector=ze,exports.initiaPrivyWalletOptions=Re,exports.injectStyles=wc,exports.useAddress=Ma,exports.useHexAddress=ja,exports.useInitiaAddress=U,exports.useInterwovenKit=Pa,exports.usePortfolio=Aa,exports.useUsernameQuery=Na;
|