@initia/interwovenkit-react 2.2.3 → 2.2.5
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.js +5174 -4916
- package/dist/styles.css +1 -1
- package/dist/styles.js +1 -1
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wa=require("@privy-io/cross-app-connect/rainbow-kit"),ve=require("wagmi"),T=require("@tanstack/react-query"),j=require("@initia/utils"),B=require("bignumber.js"),A=require("ramda"),ye=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),ie=require("@cosmjs/encoding"),Gi=require("@mysten/bcs"),W=require("jotai"),Ha=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),ao=require("@cosmjs/amino/build/signdoc"),ro=require("@cosmjs/crypto"),ra=require("@cosmjs/math"),ms=require("@cosmjs/proto-signing"),Ke=require("@cosmjs/stargate"),ia=require("@cosmjs/tendermint-rpc"),Yi=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),It=require("cosmjs-types/cosmos/tx/v1beta1/tx"),pt=require("ethers"),sn=require("@initia/amino-converter"),jn=require("@cosmjs/amino"),Zi=require("cosmjs-types/cosmos/auth/v1beta1/auth"),io=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ji=require("cosmjs-types/google/protobuf/any"),Ge=require("date-fns"),bo=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),ca=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),la=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),Qa=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),J=require("radix-ui"),Le=require("usehooks-ts"),Ga=require("react-error-boundary"),L=require("clsx"),_e=require("react-hook-form"),ke=require("@base-ui/react/dialog"),Xi=require("xss"),S=require("@initia/icons-react"),rt=require("@react-spring/web"),hs=require("change-case"),ut=require("@base-ui/react/select"),Ps=require("@base-ui/react/collapsible"),da=require("nanoid"),ec=require("react-dom"),tc=require("jotai/utils"),Ya=require("react-merge-refs"),nc=require("react-number-format"),sc=require("react-intersection-observer"),oc=require("@noble/hashes/sha3"),Dt=require("@noble/hashes/utils"),ac=require("qr-code-styling"),ht=require("@base-ui/react"),wt=require("@base-ui/react/tabs"),Qt=require("@base-ui/react/popover"),ua=require("cosmjs-types/cosmos/bank/v1beta1/tx");function rc(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const wo=rc(Ha),on=1.4,Za=1.05,Ja={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",lockStakeModuleAddress:"0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initia.xyz",vipUrl:"https://vip-api.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark"},ic={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",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initiation-2.initia.xyz",vipUrl:"https://vip-api.testnet.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark",disableAnalytics:!0},vo="cmbq1ozyc006al70lx4uciz0q",bn={id:vo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},cc=Wa.toPrivyWalletConnector(bn),lc=Wa.toPrivyWallet(bn),Xa=_.createContext(null);function Y(){const e=_.useContext(Xa);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function dc(e){if(e instanceof z.HTTPError){const{response:n}=e,s=n.headers.get("content-type")??"";if(A.includes("application/json",s))try{const o=await n.json();if(o.message)return o.message}catch{return e.message}try{return await n.text()}catch{return e.message}}if(e instanceof Error){if(A.path(["code"],e)===4001||A.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const n=A.path(["error","message"],e),s=A.path(["cause","message"],e),o=A.path(["shortMessage"],e);return n||s||o||e.message}return String(e)}async function ft(e){return new Error(await dc(e))}const ps=ye.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Qn(e){const n=A.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function uc(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,l=o||s,c=a?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=r,f=Qn(d),p=Qn(u),g=Qn(m),x=i?.minitia?.type==="minievm"?Qn(h):void 0;return{...e,chainId:n,name:l,logoUrl:c,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:x}}function de(){const{defaultChainId:e,registryUrl:n,customChain:s}=Y(),{data:o}=T.useSuspenseQuery({queryKey:ps.list(n).queryKey,queryFn:()=>z.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(uc).toSorted(A.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return o}function er(){const{registryUrl:e}=Y(),{data:n}=T.useSuspenseQuery({queryKey:ps.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:K.MINUTE});return n}function Ye(){const e=ae(),n=de(),s=er();return o=>{const a=n.find(i=>i.chain_id===o);if(a)return a;const r=s.find(i=>i.chain_id===o);if(!r)throw new Error(`Chain not found: ${o}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:r.pretty_name,logoUrl:r.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function Ze(e){return Ye()(e)}function Vt(){const{defaultChainId:e}=Y();return Ze(e)}function ae(){const n=de().find(s=>s.metadata?.is_l1);if(!n)throw new Error("Layer 1 not found");return n}function tr(){return({chainId:e})=>T.queryOptions({queryKey:ps.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function _t(e){const n=tr();return T.useQuery(n(e))}function Co(){const e=de(),n=tr();return T.useQueries({queries:e.map(s=>n(s))})}const mc=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
2
|
<circle fill="#2F3337" cx="30" cy="30" r="30"/>
|
|
3
3
|
<path fill="#757C82" d="M26.328 34.288v-.48c0-2.048 1.024-2.816 4.128-4.16 3.104-1.28 3.712-1.952 3.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816 0-4.416.736-4.768 3.296h-5.248c.416-5.536 4.416-7.584 9.888-7.584h.352c6.208 0 9.28 2.496 9.28 6.24v.352c0 3.392-1.28 4.96-5.376 6.592-1.504.64-2.048 1.024-2.208 1.824h-5.536ZM26.168 42v-5.152h5.792V42h-5.792Z"/>
|
|
4
|
-
</svg>`,uc=encodeURIComponent(dc),vo=`data:image/svg+xml;utf8,${uc}`,Cn=ye.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,n)=>[e,n],resource:(e,n)=>[e.chainId,n.denom],denom:(e,n)=>[e,n],metadata:(e,n)=>[e,n]});function mc(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,d=o.find(m=>m.denom===a)?.exponent??o.find(m=>m.denom===n)?.exponent??A.head(o)?.exponent??0,u=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:u,name:i,address:c,traces:l}}function sr(){const e=T.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return T.queryOptions({queryKey:Cn.list(s).queryKey,queryFn:async()=>s?V.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(mc);for(const r of a)e.setQueryData(Cn.item(n.chainId,r.denom).queryKey,r);return a},staleTime:z.MINUTE})}}function xt(e){const n=sr(),{data:s}=T.useSuspenseQuery(n(e));return s}function An(){const e=ue(),n=sr();return T.useQueries({queries:e.map(s=>n(s))})}function ct(e){const n=xt(e),s=ie(),o=xt(s),a=ar(e);return r=>{const i=n.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:vo}}}function or(e,n){const s=ct(n),a=T.useQueryClient().getQueryData(Cn.item(n.chainId,e).queryKey);return a||s(e)}function ar(e){const n=ie(),s=xt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)?.traces;if(r){for(const i of r)if(i.counterparty.chain_name===n.chain_name)return i.counterparty.base_denom}}const a=n.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?j.getIbcDenom(a,o):""}}function wo(e){const n=ie(),s=V.create({prefixUrl:n.restUrl}),o=T.useSuspenseQueries({queries:e.map(a=>({queryFn:()=>s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json(),queryKey:Cn.denom(n.restUrl,a).queryKey,select:r=>[a,r.denom],staleTime:z.INFINITY}))});return new Map(o.map(({data:a})=>a))}function hc(e){return e.pagination?.next_key??null}async function rr(e,n,s){const o=V.create(n),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],d=hc(c),u=[...r,...l];return d?a(u,d):u};return a([],null)}const ma="usernames";function pc({restUrl:e,moduleAddress:n}){const{viewFunction:s}=j.createMoveClient(e);async function o(i){if(!j.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:n,moduleName:ma,functionName:"get_name_from_address",typeArgs:[],args:[re.toBase64(j.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const c=await s({moduleAddress:n,moduleName:ma,functionName:"get_address_from_name",typeArgs:[],args:[Hi.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?j.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const ps=ye.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function ir(){const{restUrl:e}=ie(),{usernamesModuleAddress:n}=G();return pc({restUrl:e,moduleAddress:n})}function cr(){const e=X();return n=>T.queryOptions({queryKey:ps.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?rr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:z.SECOND})}function Sn(e){const n=cr(),{data:s}=T.useSuspenseQuery(n(e));return s}function fc(){const e=ue(),n=cr();return T.useQueries({queries:e.map(s=>n(s))})}function gc(e){const n=Sn(e),s=xt(e),o=ct(e),a=ar(e),{data:r}=yt(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>s.some(d=>d.denom===l);return A.sortWith([A.descend(({denom:l})=>a(l)==="uinit"),A.descend(({denom:l})=>i(l)),A.descend(({value:l})=>l),A.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>U(d).comparedTo(l)??0,A.descend(({symbol:l})=>l.toLowerCase())],n.filter(({amount:l})=>!U(l).isZero()).map(({amount:l,denom:d})=>{const u=o(d),m=r?.find(({id:p})=>p===u?.denom)?.price??0,h=U(l).times(m).div(U(10).pow(u.decimals)).toNumber();return{...u,balance:l,price:m,value:h}}))}const lr=g.createContext(null);function fs(){return g.useContext(lr)}function dr(){const{location:e}=fs();return e}function et(){const{path:e}=dr();return e}function Ke(){const{state:e={}}=dr();return e}function ur(){const{history:e}=fs();return e}function je(){const{navigate:e}=fs();return e}function Co(){const{reset:e}=fs();return e}const nn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=je(),c=Co(),l=d=>{d.preventDefault(),a?.(d),s?c(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:l,children:o})},mr=({children:e,initialEntry:n})=>{const[s,o]=g.useState([n??{path:"/"}]),a=s[s.length-1],r=g.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const u=d.length+c;if(u<1)return d;const m=A.take(u,d);return l!==void 0?A.adjust(u-1,h=>({...h,state:l}),m):m})},[]),i=g.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return t.jsx(lr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},_c="c33b940c24c17e95f7d9d525d508ac61";function xc(){const{disableAnalytics:e}=G();g.useEffect(()=>{e||yo.init(_c,{autocapture:!1})},[e])}function yc(){const{connector:e}=we.useAccount(),{defaultChainId:n,disableAnalytics:s}=G();g.useEffect(()=>{const o=new Qa.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),yo.identify(o)},[n,e?.name,s])}function $n(){const e=et();return g.useCallback((s,o)=>{yo.track(s,{path:e,...o})},[e])}const st="interwovenkit",ke="uinit",Qe="INIT",Me=6,jc="uoinit",bc="omniINIT",hr="https://app.initia.xyz",No=`${hr}/liquidity/my`,vc=`${hr}/vip/my`,wc=1e3,pr=60*wc,fr=60*pr,ha=24*fr,oe={PUBLIC_KEY:`${st}:public-key`,BRIDGE_SRC_CHAIN_ID:`${st}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${st}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${st}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${st}:bridge:dst-denom`,BRIDGE_QUANTITY:`${st}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${st}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${st}:bridge:route-type`,BRIDGE_HISTORY:`${st}:bridge:history`,OP_REMINDER:`${st}:op:reminder`},gr=K.atom(!1),_r=K.atom(!1);function lt(){const e=Co(),[n,s]=K.useAtom(gr),o=K.useSetAtom(_r),a=$n();return{isDrawerOpen:n,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function dn(){const e=Co(),[n,s]=K.useAtom(_r),o=K.useSetAtom(gr),a=$n();return{isModalOpen:n,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function ko(){const e=je(),{closeDrawer:n}=lt(),{closeModal:s}=dn(),{disconnect:o}=we.useDisconnect();return()=>{e("/blank"),n(),s(),o(),localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM),localStorage.removeItem(oe.BRIDGE_QUANTITY),localStorage.removeItem(oe.BRIDGE_SLIPPAGE_PERCENT)}}function Cc(){const e=kt(),n=Ot(),{openModal:s}=dn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(u=>({denom:u,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Nc(){const e=kt(),n=Ot(),{openModal:s}=dn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(u=>({denom:u,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Io(){const{privyContext:e}=G(),{address:n}=we.useAccount();return e?n?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>j.InitiaAddress.equals(o,n)):!1:!0}function kc(){const{privyContext:e}=G(),n=Io(),{address:s}=we.useAccount(),{signMessageAsync:o}=we.useSignMessage(),a=ko(),r=!!e?.privy.ready,i=g.useRef(e);g.useEffect(()=>{i.current=e},[e]);const c=async l=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:l});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{a()}};g.useEffect(()=>{n||r&&s&&c(s)},[n,r,s])}function Ic(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=ro.PubKey.decode(e.value);return wn.encodeSecp256k1Pubkey(n)}return ds.decodeOptionalPubkey(e)}function Ac({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Gi.BaseAccount.decode(n),i=Ic(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ve.accountFromAny({typeUrl:e,value:n})}function Sc(e){return e.type==="initia/PubKeyEthSecp256k1"}const $c={...wn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Tc(e){if(Sc(e)){const n=ro.PubKey.fromPartial({key:re.fromBase64(e.value)});return Yi.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(ro.PubKey.encode(n).finish())})}return ds.encodePubkey(e)}function xr(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:$c.ethsecp256k1,value:re.toBase64(e)}}function Ec(e,n){if(n.length!==64)throw new 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:xr(e),signature:re.toBase64(n)}}const Tn=()=>{const e=G();return new ds.Registry([...sn.protoRegistry,...e.protoTypes??[]])},En=()=>{const e=G();return new Ve.AminoTypes({...sn.aminoConverters,...e.aminoConverters})};class yr{constructor(n,s,o){this.address=n,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${oe.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=re.fromHex(s),re.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,re.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,re.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await V.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?re.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=gt.ethers.hashMessage(n),a=gt.ethers.SigningKey.recoverPublicKey(o,s);return ao.Secp256k1.compressPubkey(re.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const o=oo.escapeCharacters(oo.sortedJsonStringify(s)),a=await this.signMessage(o),r=re.fromHex(a.replace("0x","")).subarray(0,-1),c=ao.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Ec(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function gs(){const e=Tn(),n=En(),s=qn(),o=Ao();return async function(a,r,i,c,l,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const m=await o(a),{accountNumber:h,...p}=await m.getSequence(r),f=p.sequence+(d?.incrementSequence??0),[_]=await u.getAccounts(),x=Tc(xr(_.pubkey)),y=Qi.SignMode.SIGN_MODE_EIP_191,b=i.map(N=>n.toAmino(N)),w=oo.makeSignDoc(b,c,a,l,h,f),{signature:v,signed:C}=await u.signAmino(r,w),S={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:C.msgs.map(N=>n.fromAmino(N)),memo:l}},M=e.encode(S),F=ra.Int53.fromString(C.fee.gas).toNumber(),E=ra.Int53.fromString(C.sequence).toNumber(),$=ds.makeAuthInfoBytes([{pubkey:x,sequence:E}],C.fee.amount,F,C.fee.granter,C.fee.payer,y);return Nt.TxRaw.fromPartial({bodyBytes:M,authInfoBytes:$,signatures:[re.fromBase64(v.signature)]})}}function qn(){const e=X(),{signMessageAsync:n}=we.useSignMessage(),s=ie();return g.useMemo(()=>new yr(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Ds=new Map,Ps=new Map;function jr(){const e=Je();return async n=>{if(Ds.has(n))return Ds.get(n);const{rpcUrl:s}=e(n),o=await ia.Comet38Client.create(new ia.HttpClient(s));return Ds.set(n,o),o}}function Ao(){const e=Tn(),n=En(),s=qn(),o=X(),a=jr();return async r=>{const i=`${o}:${r}`;if(Ps.has(i))return Ps.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Ve.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:n,accountParser:Ac,broadcastPollIntervalMs:500});return Ps.set(i,l),l}}function br(){const{connector:e}=we.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new gt.BrowserProvider(await e.getProvider())}}function vr(){const e=X(),n=Je();return{fetchFeegrant:async(a,r)=>{if(!e)return null;const i=n(a),c=V.create({prefixUrl:i.restUrl});try{const{allowance:l}=await c.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return l}catch{return null}},fetchGrants:async(a,r)=>{if(!e)return[];const i=n(a),c=V.create({prefixUrl:i.restUrl}),{grants:l}=await c.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:r}}).json();return l}}}function wr(){const{privyContext:e}=G(),n=Io();if(!(!e||!n))return e.wallets.find(s=>s.connectorType==="embedded")}function _s(){const e=wr();return e?.address?j.InitiaAddress(e.address).bech32:void 0}function Cr(){const e=wr(),n=_s(),s=Tn(),o=Je(),a=gs();return async(r,i,c,l,d)=>{if(!e||!n)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:xo.MsgExec.fromPartial({grantee:n,msgs:c.map(p=>({typeUrl:p.typeUrl,value:s.encode(p)}))})}],m={...l,granter:i},h=new yr(n,e.sign,o(r).restUrl);return await a(r,n,u,m,d,{customSigner:h})}}const Nn=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n)=>[e,n],grants:(e,n)=>[e,n]});function xs(){const e=G(),n=Ot(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(n.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function Nr(){const{data:e}=So(),n=xs();return async(s,o)=>{const a=o.every(i=>{const c=n[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function So(){const e=X(),n=_s(),s=xs(),{fetchFeegrant:o,fetchGrants:a}=vr();return T.useQuery({queryKey:Nn.expirations(e,n).queryKey,queryFn:async()=>{if(!e||!n)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[c,l]of Object.entries(s))try{const d=await a(c,n);if(!l.every(x=>d.some(y=>y.authorization?.msg===x))){r[c]=null;continue}const m=await o(c,n);if(!m){r[c]=null;continue}const h=d.filter(x=>l.includes(x.authorization.msg)).map(x=>x.expiration),p=m.allowance.expiration,f=[...h,p],_=$o(f);r[c]=_?new Date(_):void 0}catch{r[c]=null}const i={};for(const[c,l]of Object.entries(r))switch(l){case null:i[c]=!1;break;case void 0:i[c]=!0;break;default:i[c]=Ze.isFuture(l);break}return{expiredAtByChain:r,isEnabledByChain:i}},staleTime:z.INFINITY,retry:!1})}function qc(){const{data:e,refetch:n}=So();g.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Ze.isFuture(c));if(o.length===0)return;const r=$o(o).getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function $o(e){return e.filter(n=>n!==void 0).toSorted((n,s)=>new Date(n).getTime()-new Date(s).getTime())[0]}const kr=g.createContext(null),ys=()=>g.useContext(kr);class Ir extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,c){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const Lc=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Rs=new Map;function Mc(e){const n=e.match(Lc);if(!n)return null;const[,s,o,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Dc(e,n,s){const o=`${e}:${n}`;if(Rs.has(o))return Rs.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await V.get(r).json();return Rs.set(o,i),i}catch{return null}}function Pc(e,n,s,o,a,r,i){return new Ir(e,n,s,o,a,r,i)}async function Zt(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await _t(e);const o=Mc(e.message);if(!o)return await _t(e);const a=await Dc(n.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return Pc(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Ar="approve",js=K.atom(),Sr=K.atom(null);function $r(){const e=K.useAtomValue(js);if(!e)throw new Error("Tx request not found");return e}function bs(){const e=je(),n=X(),{defaultChainId:s,registryUrl:o}=G(),a=Je(),{openDrawer:r,closeDrawer:i}=lt(),{openModal:c,closeModal:l}=ys(),d=K.useSetAtom(js),u=K.useSetAtom(Sr),m=jr(),h=Ao(),p=qn(),f=Tn(),_=Nr(),x=Cr(),y=gs(),b=async({messages:E,memo:$,chainId:N=s})=>{try{return await(await h(N)).simulate(n,E,$)}catch(R){throw await Zt(R,a(N),o)}},w=async({messages:E,memo:$,chainId:N=s})=>{const R=await m(N),P=Ve.QueryClient.withExtensions(R,Ve.setupTxExtension),q=E.map(ee=>f.encodeAsAny(ee)),[D]=await p.getAccounts(),H=wn.encodeSecp256k1Pubkey(D.pubkey),W=await h(N),{sequence:O}=await W.getSequence(n);return P.tx.simulate(q,$,H,O)},v=async({txRequest:E,broadcaster:$})=>{const R={...{memo:"",chainId:s,gas:E.gas||await b(E),gasAdjustment:on,gasPrices:null,spendCoins:[],internal:!1},...E};return new Promise((P,q)=>{d({txRequest:R,resolve:async H=>{try{const W=await h(R.chainId),O=await $(W,Nt.TxRaw.encode(H).finish());P(O),typeof R.internal=="string"&&e(R.internal)}catch(W){q(await Zt(W,a(R.chainId),o))}finally{D()}},reject:H=>{q(H),D()}}),R.internal?c({path:"/tx"}):r("/tx");const D=()=>{if(!R.internal){e("/blank"),i();return}l()}})},C=async E=>{const $=E.chainId??s;try{const N=await v({txRequest:E,broadcaster:async(R,P)=>await R.broadcastTxSync(P)});return E.internal&&typeof E.internal!="number"&&(u({txHash:N,chainId:$,status:"loading"}),F({txHash:N,chainId:E.chainId}).then(R=>{u({status:R.code===0?"success":"error",chainId:$,txHash:N})}).catch(()=>{u({status:"error",chainId:$,txHash:N})})),N}catch(N){throw E.internal&&typeof E.internal!="number"&&u({status:"error",chainId:$,error:N}),N}},k=(E,$=30*1e3,N=.5*1e3)=>v({txRequest:E,broadcaster:async(R,P)=>{const q=await R.broadcastTx(P,$,N);if(q.code!==0)throw new Error(q.rawLog);return q}}),S=async E=>{const $=E.chainId??s;try{const{messages:N,memo:R="",fee:P}=E,q=await h($),H=await _($,N)?await x($,n,N,P,R):await y($,n,N,P,R);return await q.broadcastTxSync(Nt.TxRaw.encode(H).finish())}catch(N){throw await Zt(N,a($),o)}},M=async(E,$=30*1e3,N=.5*1e3)=>{const R=E.chainId??s;try{const{messages:P,memo:q="",fee:D}=E,H=await h(R),O=await _(R,P)?await x(R,n,P,D,q):await y(R,n,P,D,q),ee=await H.broadcastTx(Nt.TxRaw.encode(O).finish(),$,N);if(ee.code!==0)throw new Error(ee.rawLog);return ee}catch(P){throw await Zt(P,a(R),o)}},F=async({chainId:E=s,...$})=>{try{const N=await h(E);return await Tr({...$,client:N})}catch(N){throw await Zt(N,a(E),o)}};return{estimateGas:b,simulateTx:w,requestTxSync:C,requestTxBlock:k,submitTxSync:S,submitTxBlock:M,waitForTxConfirmation:F}}async function Tr({txHash:e,client:n,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await n.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Ln=K.atom(null);function Er(){const e=X(),n=xs(),{fetchFeegrant:s,fetchGrants:o}=vr();return async a=>{const{chainId:r,grantee:i}=a;if(!e)throw new Error("Granter wallet not initialized");const c=await s(r,i),l=await o(r,i),d=c?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Ga.MsgRevokeAllowance.fromPartial({granter:e,grantee:i})}]:[],u=n[r].filter(m=>l.some(h=>h?.authorization?.msg===m)).map(m=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:xo.MsgRevoke.fromPartial({granter:e,grantee:i,msgTypeUrl:m})}));return[...d,...u]}}function Rc(){const{privyContext:e}=G(),n=X(),s=_s(),o=xs(),{requestTxBlock:a}=bs(),r=T.useQueryClient(),[i,c]=K.useAtom(Ln),{closeDrawer:l}=lt(),d=Er(),u=async()=>{if(s)return s;if(!e)throw new Error("Privy context not available");const m=await e.createWallet({createAdditional:!1});return j.InitiaAddress(m.address).bech32};return T.useMutation({mutationFn:async m=>{if(!i)throw new Error("No pending request");const{chainId:h}=i,p=await u();if(!n||!p)throw new Error("Wallets not initialized");const f=await d({chainId:h,grantee:p}),_=m===0?void 0:Ze.addMilliseconds(new Date,m),x={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Ga.MsgGrantAllowance.fromPartial({granter:n,grantee:p,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:la.BasicAllowance.encode(la.BasicAllowance.fromPartial({expiration:_})).finish()}})},y=o[h].map(w=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:xo.MsgGrant.fromPartial({granter:n,grantee:p,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:ca.GenericAuthorization.encode(ca.GenericAuthorization.fromPartial({msg:w})).finish()},expiration:_}})})),b=[...f,x,...y];await a({messages:b,chainId:h,internal:!0})},onSuccess:async()=>{await r.invalidateQueries({queryKey:Nn.expirations._def}),i?.resolve()},onError:m=>{i?.reject(m)},onSettled:()=>{c(null),l()}})}function qr(e){const n=G(),s=_s(),o=e?.grantee||s,{requestTxBlock:a}=bs(),r=T.useQueryClient(),i=Er();return T.useMutation({mutationFn:async(c=n.defaultChainId)=>{if(!o)throw new Error("Wallets not initialized");const l=await i({chainId:c,grantee:o});await a({messages:l,chainId:c,internal:e?.internal})},onSuccess:async()=>{const c=[Nn.expirations._def,Nn.grants._def];for(const l of c)await r.invalidateQueries({queryKey:l})}})}function Bc(){const{defaultChainId:e}=G(),{openDrawer:n}=lt(),s=K.useSetAtom(Ln),o=qr(),{data:a={expiredAtByChain:{},isEnabledByChain:{}},isLoading:r}=So();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,u)=>{s({chainId:l,resolve:d,reject:u}),n("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function Lr(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function Uc(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),U(0)).toString()}function Fc(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??vo}}function pa(e){return A.pick(["chainId","name","logoUrl"],e)}function Oc(e){return A.sortWith([A.descend(({symbol:n})=>n===Qe),A.descend(Lr),A.descend(({assets:n})=>n.length),A.ascend(({symbol:n})=>n)])(e)}function Vc(e){return A.sortWith([A.descend(({value:n})=>n??0),A.descend(({quantity:n})=>Number(n)),A.ascend(({chain:n})=>n.name)])(e)}function zc(e,n){return A.sortWith([A.descend(({chain:s})=>s.chainId===n),A.ascend(({chain:s})=>s.name),A.ascend(({denom:s})=>s)])(e)}function Kc(e,n){return A.sortWith([A.descend(({chainId:s})=>s===n),A.descend(A.prop("value"))])(e)}function Wc(e,n,s,o,a){const r=e.find(m=>m.metadata?.is_l1)?.chainId,i={};for(const m of e){const h=m.chainId,p=n[h]??[],f=s[h],_=o[h],x=[];for(const{amount:y,denom:b}of p){if(!U(y).gt(0))continue;const w=f?.find(M=>M.denom===b),v=_?.find(M=>M.id===b)?.price,C=w?.decimals??0,k=j.fromBaseUnit(y,{decimals:C}),S=v?U(k).times(v).toNumber():void 0;x.push({...Fc(b,w),amount:y,denom:b,decimals:C,quantity:k,price:v,value:S,address:w?.address,unlisted:!w,chain:pa(m)})}i[h]=x}const c=new Map;for(const[m,h]of Object.entries(i)){if(h.length===0)continue;const p=e.find(_=>_.chainId===m);if(!p)continue;const f=h.reduce((_,{value:x})=>_+(x??0),0);c.set(m,{...pa(p),value:f})}const l=new Map;for(const m of Object.values(i))for(const h of m)if(!h.unlisted){const{symbol:p}=h,f=l.get(p)??[];l.set(p,[...f,h])}const d=[];for(const[m,h]of l){const p=A.head(h);if(!p)continue;const f=Vc(h),_=f.reduce((y,{value:b})=>y+(b??0),0),x=f.reduce((y,{quantity:b})=>y.plus(b),U(0)).toNumber();d.push({symbol:m,logoUrl:p.logoUrl,assets:f,totalValue:_,totalAmount:x})}const u=[];for(const m of Object.values(i))for(const h of m)h.unlisted&&u.push(h);return{chainsByValue:Kc(Array.from(c.values()),a),assetGroups:Oc(d),unlistedAssets:zc(u,r),totalValue:d.reduce((m,h)=>m+h.totalValue,0)}}function To(){const{defaultChainId:e}=G(),n=ue(),s=fc(),o=An(),a=bo(),r=n.map(h=>h.chainId),i=A.zipObj(r,s.map(A.prop("data"))),c=A.zipObj(r,o.map(A.prop("data"))),l=A.zipObj(r,a.map(A.prop("data"))),d=Wc(n,i,c,l,e),u=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function X(){const e=Vt();return e?j.InitiaAddress(e).bech32:""}function Vt(){const{address:e}=we.useAccount(),n=Io();return!e||!n?"":j.InitiaAddress(e).hex}function kt(){const e=Ot(),n=X(),s=Vt();return e.metadata?.minitia?.type==="minievm"?s:n}function Mr(){const e=kt(),n=ir();return T.useQuery({queryKey:ps.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:z.MINUTE})}function De(){const e=kt(),n=X(),s=Vt(),{data:o}=Mr(),a=qn(),r=ko(),i=Bc(),{isDrawerOpen:c,openDrawer:l}=lt(),{isModalOpen:d}=dn(),u=()=>{l("/")},m=()=>{l("/connect")},h=b=>{l("/bridge",b)},p=Cc(),f=Nc(),_=bs();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:m,openWallet:u,openBridge:h,openDeposit:p,openWithdraw:f,disconnect:r,autoSign:i,..._}}const Hc="_status_tn9m1_1",Qc="_error_tn9m1_9",fa={status:Hc,error:Qc},he=({error:e,children:n})=>t.jsx("p",{className:L(fa.status,{[fa.error]:e}),children:n}),de=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(he,{error:!0,children:o.message})},suspenseFallback:n=t.jsx(he,{children:"Loading..."}),children:s})=>t.jsx(Ya.ErrorBoundary,{...e,children:t.jsx(g.Suspense,{fallback:n,children:s})}),Gc="lock_staking";function Dr(e,n){const s=`${n}::lock_staking::StakingAccount`,o=j.createObjectAddress(e,s);return j.InitiaAddress(o).bech32}const Mn=ye.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,n)=>[e,n],undelegations:(e,n,s)=>[e,n,s],lockStaking:(e,n,s)=>[e,n,s],stakingRewards:(e,n)=>[e,n],lockStakingRewards:(e,n,s)=>[e,n,s]});function Eo(){const{restUrl:e}=ie(),n=X();return T.useSuspenseQuery({queryKey:Mn.delegations(e,n||"").queryKey,queryFn:async()=>n?(await V.get(`${e}/initia/mstaking/v1/delegations/${n}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=j.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},d=o.get(c)??[];d.push(l),o.set(c,d)}}return o},staleTime:z.MINUTE})}function qo(){const{restUrl:e}=ie(),{lockStakeModuleAddress:n}=G(),s=X(),o=s?Dr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await V.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await V.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const u=j.denomToMetadata(d.denom),m={denom:d.denom,metadata:u,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(u)??[];h.push(m),r.set(u,h)}}return r},staleTime:z.MINUTE})}function Lo(){const{restUrl:e}=ie(),{lockStakeModuleAddress:n}=G(),s=X();return T.useSuspenseQuery({queryKey:Mn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=j.createMoveClient(e);return await o({moduleAddress:n,moduleName:Gc,functionName:"get_locked_delegations",typeArgs:[],args:[re.toBase64(j.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:z.MINUTE})}function Pr(e){const n=new Map;if(!e.total||!Array.isArray(e.total))return n;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=j.denomToMetadata(s.denom);let a=new U(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=n.get(o);if(r){const i=new U(r.amount);a=a.plus(i)}n.set(o,{denom:s.denom,amount:a.toString()})}return n}function Rr(){const{restUrl:e}=ie(),n=X();return T.useSuspenseQuery({queryKey:Mn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await V.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:z.MINUTE})}function Br(){const{restUrl:e}=ie(),{lockStakeModuleAddress:n}=G(),s=X(),o=s?Dr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await V.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:z.MINUTE})}function Mo(){const e=ie(),n=xt(e),{data:s,isLoading:o}=yt(e),{data:a}=Eo(),{data:r}=qo(),{data:i}=Lo(),c=g.useMemo(()=>{const p=new Set;for(const f of a.keys())p.add(f);for(const f of i.keys())p.add(f);for(const f of r.keys())p.add(f);return Array.from(p)},[a,i,r]),l=wo(c),d=g.useMemo(()=>{const p=new Map;if(s)for(const f of s)p.set(f.id,f.price);return p},[s]),u=g.useMemo(()=>{const p=new Map;for(const f of n)p.set(f.denom,f);return p},[n]),m=g.useMemo(()=>{const p=[],f=_=>{const x=u.get(_);return x?{symbol:x.symbol,decimals:x.decimals}:null};for(const[_,x]of a){const y=l.get(_)??x[0]?.denom;if(!y)continue;const b=f(y);if(!b)continue;const w=d.get(y)??0;for(const v of x){const{symbol:C,decimals:k}=b,S=Number(j.fromBaseUnit(v.amount,{decimals:k})),M={type:"asset",denom:y,symbol:C,amount:v.amount,formattedAmount:S,decimals:k,value:S*w};p.push({type:"staking",validator:v.validator,balance:M})}}for(const[_,x]of i){const y=l.get(_);if(!y)continue;const b=f(y);if(!b)continue;const w=d.get(y)??0;for(const v of x){const{symbol:C,decimals:k}=b,S=Number(j.fromBaseUnit(v.amount,{decimals:k})),M={type:"asset",denom:y,symbol:C,amount:v.amount,formattedAmount:S,decimals:k,value:S*w},F=Number(v.releaseTime);p.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(F)?0:F,balance:M})}}for(const[_,x]of r){const y=l.get(_)??x[0]?.denom;if(!y)continue;const b=f(y);if(!b)continue;const w=d.get(y)??0;for(const v of x){const{symbol:C,decimals:k}=b,S=Number(j.fromBaseUnit(v.amount,{decimals:k})),M={type:"asset",denom:y,symbol:C,amount:v.amount,formattedAmount:S,decimals:k,value:S*w},F=new Date(v.completionTime).getTime(),E=Number.isNaN(F)?0:Math.floor(F/1e3);p.push({type:"unstaking",validator:v.validator,completionTime:E,balance:M})}}return p.filter(_=>_.type!=="fungible-position"&&_.balance.denom===ke)},[a,i,r,l,u,d]),h=g.useMemo(()=>m.reduce((p,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?p:p+(f.balance.value??0),0),[m]);return{positions:m,totalValue:h,isLoading:o}}const Do=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function Yc(e){const n=new Map;for(const s of e){const o=j.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function Zc(e){const{dexUrl:n}=G();return T.useSuspenseQuery({queryKey:Do.checkLpTokens(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await V.post(`${n}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:z.MINUTE})}function Ur(){const e=ie(),n=Sn(e),s=g.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=Zc(s);return g.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return Yc(a)},[n,o])}function Fr(e){const{dexUrl:n}=G();return T.useSuspenseQuery({queryKey:Do.lpPrices(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await V.get(`${n}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:z.MINUTE})}function Jc(e){const{dexUrl:n}=G(),s=ie(),o=xt(s),a=g.useMemo(()=>{const c=new Map;for(const l of o)c.set(l.denom,l);return c},[o]),i=T.useSuspenseQueries({queries:e.map(c=>({queryKey:Do.pool(n,c).queryKey,queryFn:async()=>{try{const l=j.denomToMetadata(c);return(await V.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(l)}`).json()).pool}catch{return null}},staleTime:z.MINUTE}))}).map(c=>c.data);return g.useMemo(()=>{const c=new Map;return e.forEach((l,d)=>{const u=i[d];if(!u){c.set(l,null);return}if(l===jc){c.set(l,{...u,symbol:bc});return}const m=u.coins.map(h=>a.get(h.denom)?.symbol||h.denom).join("-");c.set(l,{...u,symbol:m})}),c},[e,i,a])}function Xc(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const c=i[0]?.denom;c&&c!==ke&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const c=i[0]?.denom;c&&c!==ke&&a.add(r)}return Array.from(a)}function el(e){const n=[];for(const[,s]of e)s&&s!==ke&&n.push(s);return n}function tl(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function nl(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=tl(o,s),i=r.length>0&&r.some(l=>l),c=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:c,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Bs(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r)??i[0]?.denom;if(!c||c===ke)continue;const l=o.get(c);if(l)for(const d of i){const u=String(d.amount),m=l.decimals,h=Number(j.fromBaseUnit(u,{decimals:m})),p=s.get(c)??0,f=h*p;l.breakdown[a]+=h,l.totalAmount+=h,l.totalValue+=f}}}function sl(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r);if(!c||c===ke)continue;const l=o.get(c);if(l)for(const d of i){const u=String(d.amount),m=l.decimals,h=Number(j.fromBaseUnit(u,{decimals:m})),p=s.get(c)??0,f=h*p;l.breakdown[a]+=h,l.totalAmount+=h,l.totalValue+=f}}}function ol(e,n,s,o){for(const[a,r]of e){const i=j.denomToMetadata(a),c=n?.get(i),l=c?j.fromBaseUnit(c.amount,{decimals:Me}):"0",d=s?.get(i),u=d?j.fromBaseUnit(d.amount,{decimals:Me}):"0",m=Number(l)+Number(u);m>0&&(r.claimableInit={staking:l,lockStaking:u,total:String(m),totalValue:m*o})}}function Po(){const e=ie(),n=xt(e),s=Ur(),{data:o}=Eo(),{data:a}=Lo(),{data:r}=qo(),{data:i}=Rr(),{data:c}=Br(),{data:l}=yt(e),d=g.useMemo(()=>{const y=new Map;for(const b of n)y.set(b.denom,b);return y},[n]),u=g.useMemo(()=>Xc(s,o,a,r),[s,o,a,r]),m=wo(u),h=g.useMemo(()=>el(m),[m]),{data:p}=Fr(h),f=Jc(h),{rows:_,totalValue:x}=g.useMemo(()=>{const y=l?.find(C=>C.id===ke)?.price??0,b=new Map;for(const C of h)b.set(C,nl(C,f,d));Bs(s,m,p,b,"deposit"),Bs(o,m,p,b,"staking"),sl(a,m,p,b,"lockStaking"),Bs(r,m,p,b,"unstaking"),ol(b,i,c,y);const w=Array.from(b.values()).filter(C=>C.totalAmount>0).sort((C,k)=>k.totalValue-C.totalValue),v=w.reduce((C,k)=>C+k.totalValue,0);return{rows:w,totalValue:v}},[h,f,d,s,o,a,r,m,p,i,c,l]);return{totalValue:x,rows:_}}const al=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function rl(e){return e.filter(n=>n.data.length>0).map(n=>{const s=n.data[0].bridge_id,o=n.data[0].version,a=n.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:n.total_claimable_reward,claimedReward:a,initialReward:n.total_vesting_reward,lockedReward:n.total_locked_reward,requiredScore:n.required_score,rollup:{bridgeId:s,version:o}}}).filter(n=>n.initialReward>0).toSorted((n,s)=>s.initialReward-n.initialReward)}function Or(){const{vipUrl:e}=G(),n=X();return T.useQuery({queryKey:al.allVestingPositions(e,n).queryKey,queryFn:async()=>(await V.get(`${e}/vesting/positions/${n}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:z.MINUTE,enabled:!!n})}function il(){const e=ue();return g.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Ro(){const{data:e}=Or(),n=ie(),{data:s}=yt(n),o=il(),a=g.useMemo(()=>s?.find(l=>l.id===ke)?.price??0,[s]),r=g.useMemo(()=>e?rl(e).map(l=>{const d=o(l.rollup.bridgeId),u=Number(j.fromBaseUnit(String(l.lockedReward),{decimals:Me})),m=Number(j.fromBaseUnit(String(l.claimableReward),{decimals:Me})),h=U(j.fromBaseUnit(String(l.lockedReward),{decimals:Me})).times(a).toNumber(),p=U(j.fromBaseUnit(String(l.claimableReward),{decimals:Me})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:h,claimableReward:m,claimableRewardValue:p}}):[],[e,a,o]),i=g.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Vr(){const e=Ur(),{data:n}=Eo(),{data:s}=Lo(),{data:o}=qo(),{data:a}=Or(),r=ie(),{data:i}=yt(r),c=g.useMemo(()=>i?.find(_=>_.id===ke)?.price??0,[i]),l=g.useMemo(()=>{const f=new Set;for(const[_]of e)f.add(_);for(const[_]of n)f.add(_);for(const[_]of s)f.add(_);for(const[_]of o)f.add(_);return Array.from(f)},[e,n,s,o]),d=wo(l),u=g.useMemo(()=>Array.from(d.values()).filter(f=>f!==ke),[d]),{data:m}=Fr(u),h=xt(r),p=g.useMemo(()=>{const f=new Map;for(const _ of h)f.set(_.denom,{decimals:_.decimals});return f},[h]);return g.useMemo(()=>{let f=0,_=0;const x=c??0,y=(w,v)=>{const C=d.get(w)??w;if(C===ke)return 0;const k=p.get(C)?.decimals??Me;return Number(j.fromBaseUnit(v,{decimals:k}))*(m.get(C)??0)};for(const[,w]of n)for(const{denom:v,metadata:C,amount:k}of w)v===ke?f+=Number(j.fromBaseUnit(k,{decimals:Me}))*x:_+=y(C,k);for(const[w,v]of s){const k=(d.get(w)??w)===ke;for(const{amount:S}of v)k?f+=Number(j.fromBaseUnit(S,{decimals:Me}))*x:_+=y(w,S)}for(const[,w]of o)for(const{denom:v,metadata:C,amount:k}of w)v===ke?f+=Number(j.fromBaseUnit(k,{decimals:Me}))*x:_+=y(C,k);for(const[w,v]of e)for(const{amount:C}of v)_+=y(w,String(C));let b=0;if(a)for(const w of a){const v=w.total_locked_reward??0,C=w.total_claimable_reward??0;b+=Number(j.fromBaseUnit(String(v+C),{decimals:Me}))*x}return f+_+b},[n,s,o,e,a,c,d,m,p])}function cl(){const 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"],n={"initia-wallet-widget:ethereum-public-keys":{prefix:oe.PUBLIC_KEY,getSuffix:s=>j.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(n)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const d=`${o}:${a(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(s)}catch{}}}const io=ye.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,n)=>[e,n],balances:(e,n,s)=>[e,n,s],initiaPositions:(e,n)=>[e,"initia",n],echelonPositions:(e,n)=>[e,"echelon",n],inertiaPositions:(e,n)=>[e,"inertia",n],ravePositions:(e,n,s)=>[e,"rave",n,s],civitiaPositions:(e,n)=>[e,"civitia",n],yominetPositions:(e,n)=>[e,"yominet",n],chainPositions:(e,n,s)=>[e,n,s]});function Bo(e){const n=new Map,s=new Map;for(const o of e){const a=o.data;if(a){for(const r of a)if(r.logoUrl&&!r.logoUrl.includes("undefined")){n.has(r.denom)||n.set(r.denom,r.logoUrl);const i=r.symbol.toUpperCase();s.has(i)||s.set(i,r.logoUrl)}}}return{denomLogos:n,symbolLogos:s}}function an(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const n=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-n:n}function ll(e){return e.type==="fungible-position"?null:e.type==="staking"||e.type==="unstaking"||e.type==="lockstaking"?"staking":e.type==="lending"?e.direction==="supply"?"lending":"borrowing":null}function dl(e,n=!1){switch(e){case"staking":return n?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function ul(e){const n=new Map;for(const d of e){const u=ll(d);if(!u)continue;const m=n.get(u)??[];m.push(d),n.set(u,m)}const s=new Map,o=new Map;for(const[d,u]of n){const m=u.reduce((p,f)=>p+an(f),0),h=u.reduce((p,f)=>p+Math.abs(an(f)),0);s.set(d,m),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...n.keys()].sort((d,u)=>{const m=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:h-m}),l=new Map;for(const d of c)l.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return l}function ml(e){return e.type==="fungible-position"?e.title:e.balance.denom}function hl(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function pl(e){return e.type==="fungible-position"?null:e.balance}function fl(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";default:return""}}function gl(e){const n=new Map;for(const s of e){const o=n.get(s.type)??[];o.push(s),n.set(s.type,o)}return n}function _l(e,n){return e.symbol===Qe&&n.symbol===Qe?0:e.symbol===Qe?-1:n.symbol===Qe?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function xl(e){const n=new Map;for(const o of e){const a=ml(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=pl(a[0]);let i=0;for(const c of a)c.type!=="fungible-position"&&c.balance.type!=="unknown"&&(i+=c.balance.formattedAmount);return{denom:o,symbol:hl(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+an(l),0),totalAmount:i,balance:r}}).toSorted(_l)}function zr(e,n){const s=new Map;return e.forEach((o,a)=>{const r=n[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function yl(e,n){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=n.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function jl(e,n){return e.symbol===Qe&&n.symbol===Qe?0:e.symbol===Qe?-1:n.symbol===Qe?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function bl(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=n.get(i.denom)??s.get(c)??"";return l!==i.logoUrl?{...i,logoUrl:l}:i});let r="";for(const i of a)if(i.logoUrl){r=i.logoUrl;break}return r||(r=s.get(o.symbol.toUpperCase())??""),r!==o.logoUrl||a!==o.assets?{...o,logoUrl:r,assets:a}:o})}function vl(e,n,s){const o=n?e.filter(i=>{const{symbol:c,assets:l}=i,d=n.toLowerCase();return c.toLowerCase().includes(d)||l.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function wl(e,n,s){const o=n?e.filter(({denom:a,address:r})=>{const i=n.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Cl(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=vl(e,s,o),i=wl(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Nl(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:d,balances:u}=c;if(!Array.isArray(u))continue;const m=n.get(l.toLowerCase()),h=m?.chainId??d??l,p=m?.prettyName??l,f=m?.logoUrl??"",_=s.get(h);for(const x of u){if(x.type==="unknown"){if(!x.amount||x.amount==="0")continue;r.push({symbol:x.denom,logoUrl:"",denom:x.denom,amount:x.amount,decimals:0,quantity:x.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:p,logoUrl:f}});continue}if(x.type==="lp"||(x.value??0)<=0&&(x.formattedAmount??0)<=0)continue;let y=x.value;if((y==null||y<=0)&&_){const v=_.get(x.denom)??0;v>0&&(y=x.formattedAmount*v)}const b={symbol:x.symbol,logoUrl:"",denom:x.denom,amount:x.amount,decimals:x.decimals,quantity:String(x.formattedAmount),value:y,chain:{chainId:h,name:p,logoUrl:f}},w=a.get(x.symbol);w?w.push(b):a.set(x.symbol,[b])}}r.sort((c,l)=>{const d=c.chain.chainId===o,u=l.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const m=c.chain.name.localeCompare(l.chain.name);if(m!==0)return m;try{const h=BigInt(c.amount),p=BigInt(l.amount);if(h>p)return-1;if(h<p)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((m,h)=>(h.value??0)-(m.value??0));let d=0,u=0;for(const m of l)d+=m.value??0,u+=Number(m.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:u})}return i.sort(jl),{listedGroups:i,unlistedAssets:r}}function Uo(){return ie().network_type==="testnet"}function It(){return pe.useFormContext()}function kl(){const e=Ke(),n=Uo(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},r=A.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(oe.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(oe.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(oe.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(oe.BRIDGE_DST_DENOM),quantity:localStorage.getItem(oe.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(oe.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Il={balances:[],positions:[],isLoading:!0,isComplete:!1},Kr=K.atom(0),Al=1e3;let ga=0;function Sl(){const e=K.useSetAtom(Kr);g.useEffect(()=>{const n=Date.now();n-ga>=Al&&(ga=n,e(s=>s+1))},[e])}function $l(){const e=T.useQueryClient(),n=X(),{minityUrl:s}=G(),o=Uo(),a=K.useAtomValue(Kr),r=g.useEffectEvent((l,d)=>{const u=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:u})}),i=g.useEffectEvent((l,d)=>{const u=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:u})}),c=g.useEffectEvent((l,d)=>{const u=io.ssePortfolio(n??"",s).queryKey,m=e.getQueryData(u)??Il,h=l.size>0||d.size>0;e.setQueryData(u,{...m,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:m.isLoading,isComplete:!1})});g.useEffect(()=>{if(!n||o)return;const l=io.ssePortfolio(n,s).queryKey,d=e.getQueryData(l),u=new Map,m=new Map;for(const x of d?.balances??[])u.set(x.chainName,x);for(const x of d?.positions??[])m.set(x.chainName,x);const p=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let f=null,_=!1;return e.setQueryData(l,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),f=new EventSource(p),f.onmessage=x=>{if(!_)try{const y=JSON.parse(x.data);y.type==="balances"?r(y,u):y.type==="positions"&&i(y,m),c(u,m)}catch{}},f.onerror=()=>{f?.close()},()=>{_=!0,f?.close()}},[n,o,a])}const _a={balances:[],positions:[],isLoading:!0,isComplete:!1};function Dn(){const e=X(),{minityUrl:n}=G(),s=io.ssePortfolio(e??"",n).queryKey,{data:o}=T.useQuery({queryKey:s,queryFn:()=>_a,enabled:!!e,staleTime:z.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??_a}function Tl(){const e=ue();return g.useMemo(()=>{const n=new Map;for(const s of e){const o=s.chain_name.toLowerCase();n.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return n},[e])}function El(){const{balances:e,positions:n}=Dn(),s=ue(),o=g.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return g.useMemo(()=>{const r=p=>p.type==="unknown"?0:p.value??0,i=p=>p.positions.reduce((f,_)=>{if(_.type==="fungible-position")return f+(_.value??0);if(_.balance.type==="unknown")return f;const x=_.balance.value??0;return _.type==="lending"&&_.direction==="borrow"?f-x:f+x},0),c=new Map,l=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:p,balances:f}of l){if(!Array.isArray(f))continue;const _=f.reduce((x,y)=>x+r(y),0);c.set(p,(c.get(p)||0)+_)}for(const{chainName:p,positions:f}of d){if(!Array.isArray(f))continue;const _=f.reduce((x,y)=>x+i(y),0);c.set(p,(c.get(p)||0)+_)}const u=Array.from(c.values()).reduce((p,f)=>p+f,0),m=Array.from(c.entries()).filter(([,p])=>p>0).map(([p,f])=>{const _=o.get(p.toLowerCase());return{chainId:_?.chainId||"",chainName:_?.name||p,logoUrl:_?.logoUrl||"",totalBalance:f,percentage:u>0?f/u:0}}).filter(p=>p.chainId!==""),h=p=>p.chainName.toLowerCase()==="initia";return A.sortWith([A.descend(h),A.descend(A.prop("totalBalance"))],m)},[e,n,o])}function ql(){const{balances:e}=Dn(),n=ue(),s=bo(),o=g.useMemo(()=>zr(n,s),[n,s]);return g.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=yl(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const d of l)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function Ll(){const{positions:e}=Dn();return g.useMemo(()=>{const n=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,d)=>l+n(d),0))}return o},[e])}const qe=ye.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,n)=>[e,n],allBalances:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[e,n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function tt(){const{routerApiUrl:e}=G();return g.useMemo(()=>V.create({prefixUrl:e}),[e])}function Wr(){const e=ue();return n=>e.some(s=>s.chain_id===n)}function Pn(){const e=Wr();return n=>e(n.chain_id)?"initia":n.chain_type}function kn(e){return Pn()(e)}function Rn(){const e=tt(),{data:n}=T.useSuspenseQuery({queryKey:qe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>A.sortWith([A.descend(({chain_name:o})=>o==="initia"),A.ascend(({pretty_name:o})=>o)],s),staleTime:z.MINUTE});return n}function dt(){const e=Rn(),n=tr();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=n.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function rt(e){return dt()(e)}function zt(){const e=tt(),n=Rn(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),select:({chain_to_assets_map:a})=>{const r=[];for(const i in a){if(!n.find(l=>l.chain_id===i))continue;const{assets:c}=a[i]??{assets:[]};s.setQueryData(qe.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...c);for(const l of c)s.setQueryData(qe.asset(i,l.denom).queryKey,l)}return r},staleTime:z.MINUTE});return o}function os(e){const n=tt(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(qe.asset(e,i.denom).queryKey,i);return r.toSorted(A.descend(i=>i.symbol==="INIT"))},staleTime:z.MINUTE});return o}function Hr(e){const n=os(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function it(e,n){return Hr(n)(e)}const Ml=()=>(xc(),yc(),null),Dl="_loader_1vxch_1",Pl={loader:Dl},Kt=({size:e=24,color:n="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:Pl.loader,style:o})},Rl="_button_1q027_1",Bl="_outline_1q027_28",Ul="_sm_1q027_46",Fl="_full_1q027_53",Ol="_small_1q027_57",Vl="_unpadded_1q027_88",Pt={button:Rl,outline:Bl,sm:Ul,full:Fl,small:Ol,unpadded:Vl},Qr=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return t.jsx("button",{...c,className:L(Pt.button,{[Pt.sm]:n,[Pt.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(Kt,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Pt.loading,children:o})]}):r})},zl=({className:e,...n})=>t.jsx(Qr,{...n,className:L(Pt.outline,e)}),Kl=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:L(Pt.small,{[Pt.unpadded]:n},e)}),ne={White:Qr,Outline:zl,Small:Kl},Wl="_footer_1vp4h_1",Hl="_actions_1vp4h_10",xa={footer:Wl,actions:Hl},fe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:L(xa.footer,n),children:[e,t.jsx("div",{className:xa.actions,children:s})]}),Ql="_scrollable_13su7_1",Gl={scrollable:Ql},ut=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:L(Gl.scrollable,e),children:n});function vs(){return Ie.useMediaQuery("(max-width: 576px)")}const co="interwoven-kit";function Gr(){const e=document.querySelector(co)||document.body.appendChild(document.createElement(co));return e.shadowRoot||e.attachShadow({mode:"open"})}function Yr(){const{theme:e,container:n}=G();return g.useEffect(()=>{document.querySelector(co)?.setAttribute("data-theme",e)},[e]),n??Gr()}function Yl(e){const n=Gr(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const ws=g.createContext(null);function Ft(){const{container:e}=g.useContext(ws);return e}function Zr(e){const n=Ft();return n?getComputedStyle(n).getPropertyValue(e):""}function Zl(){return Ie.useScrollLock(),null}function Jl(e){return/^[A-F0-9]{64}$/i.test(e)}function Xl(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return Jl(s)?A.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!j.InitiaAddress.validate(o))return;const i=A.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function ed(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const td="_link_j1lkz_1",ya={link:td},Cs=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,u=Xe(e),m=Xl(u,{txHash:n,accountAddress:s,pathSuffix:o}),h=n?j.truncate(n):s?j.truncate(s):"",p=c??h;return m?t.jsxs("a",{...d,href:Zi(ed(m)),className:L(ya.link,i),onClick:l,target:"_blank",children:[p,r&&t.jsx(I.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:L(ya.link,i),children:p})},Jr=g.createContext(null),Fo=()=>g.useContext(Jr),nd=()=>{const[e,n]=K.useAtom(Sr),{showNotification:s,updateNotification:o,hideNotification:a}=Fo();return g.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(Cs,{txHash:c,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,o,a]),null},as=({value:e,children:n})=>{const[s,o]=g.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},sd="_placeholder_10r3x_1",od="_logo_10r3x_5",ja={placeholder:sd,logo:od},J=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=g.useState(void 0),{width:d,height:u}=i,m=s??t.jsx("div",{className:L(ja.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||c===e?m:t.jsx("img",{...i,className:L(i.className,{[ja.logo]:r}),style:{width:d,height:u,...a},src:e,alt:n,loading:"lazy",onError:()=>l(e)})};function Xr(){const{connector:e}=we.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const ad="_header_1q8ju_1",rd="_account_1q8ju_17",id="_name_1q8ju_28",cd="_address_1q8ju_32",ld="_icon_1q8ju_36",dd="_copied_1q8ju_43",ud="_button_1q8ju_58",md="_settings_1q8ju_69",hd="_disconnect_1q8ju_73",pd="_label_1q8ju_83",fd="_expanded_1q8ju_91",Be={header:ad,account:rd,name:id,address:cd,icon:ld,copied:dd,button:ud,settings:md,disconnect:hd,label:pd,expanded:fd},gd=()=>{const e=ko(),{address:n,username:s}=De(),o=Xr(),a=s??n,[r,i]=g.useState(!1),c=g.useRef(null),l=ze.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return g.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),n?t.jsxs("header",{className:Be.header,children:[t.jsx(as,{value:n,children:({copy:h,copied:p})=>t.jsxs("button",{className:L(Be.account,{[Be.copied]:p}),onClick:h,children:[t.jsx(J,{src:o,width:18,height:18}),t.jsx("div",{className:Be.address,children:j.truncate(n)}),t.jsx("div",{className:Be.name,children:j.truncate(a)}),t.jsx(I.IconCopy,{className:Be.icon,size:12}),p?"Copied!":""]})}),t.jsx(nn,{to:"/settings",className:L(Be.button,Be.settings),"aria-label":"Open settings",children:t.jsx(I.IconSettingFilled,{size:16})}),t.jsxs(ze.animated.button,{className:L(Be.button,Be.disconnect,{[Be.expanded]:r}),style:l,onClick:d,onMouseLeave:u,onMouseEnter:m,children:[t.jsx(I.IconSignOut,{size:16}),t.jsx("span",{className:Be.label,children:"Disconnect"})]})]}):null},_d="_overlay_jij9g_1",xd="_content_jij9g_28",yd="_inner_jij9g_60",Us={overlay:_d,content:xd,inner:yd},jd=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=lt(),{setContainer:o}=g.useContext(ws),a=vs(),r=Yr(),i=K.useAtomValue(js),c=K.useAtomValue(Ln),l=T.useIsMutating({mutationKey:[Ar]}),d=()=>{const f=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(f)),c?.reject(new Error("User rejected"))},u=et(),m=je(),h=T.useQueryClient(),p={fallbackRender:({error:f,resetErrorBoundary:_})=>{const x=()=>{u==="/bridge"&&(localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM)),m("/"),h.clear(),_()};return t.jsxs(ut,{children:[t.jsx(he,{error:!0,children:f.message}),t.jsx(fe,{children:t.jsx(ne.White,{onClick:x,children:"Retry"})})]})}};return t.jsx(Ne.Dialog.Root,{open:n,onOpenChange:f=>!f&&d(),modal:!1,children:t.jsxs(Ne.Dialog.Portal,{container:r,children:[a&&t.jsx(Ne.Dialog.Backdrop,{className:Us.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.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"}),t.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"})]})}),t.jsx(Ne.Dialog.Popup,{className:Us.content,children:t.jsxs("div",{className:L(Us.inner,"body"),ref:o,children:[a&&t.jsx(Zl,{}),t.jsx(nd,{}),t.jsx(gd,{}),t.jsx(de,{errorBoundaryProps:p,children:e})]})})]})})},bd="_backdrop_1bqx9_1",vd="_modal_1bqx9_12",wd="_closeButton_1bqx9_44",Fs={backdrop:bd,modal:vd,closeButton:wd},Cd=({children:e})=>{const{isModalOpen:n,closeModal:s}=dn(),{setContainer:o}=g.useContext(ws),a=Yr();return t.jsx(Ne.Dialog.Root,{open:n,onOpenChange:r=>!r&&s(),children:t.jsxs(Ne.Dialog.Portal,{container:a,children:[t.jsx(Ne.Dialog.Backdrop,{className:Fs.backdrop,onClick:s}),t.jsxs(Ne.Dialog.Popup,{className:L(Fs.modal),ref:o,children:[t.jsx("button",{className:Fs.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(I.IconClose,{size:20})}),e]})]})})},ei=g.createContext(!1),Nd="_overlay_1iyfl_1",kd="_fullscreen_1iyfl_15",Id="_content_1iyfl_19",Ad="_header_1iyfl_56",Sd="_title_1iyfl_65",$d="_close_1iyfl_70",$t={overlay:Nd,fullscreen:kd,content:Id,header:Ad,title:Sd,close:$d},ti=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ft(),c=g.useContext(ei);return i?t.jsxs(Ne.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&t.jsx(Ne.Dialog.Trigger,{className:o,children:s}),t.jsxs(Ne.Dialog.Portal,{container:i,children:[t.jsx(Ne.Dialog.Backdrop,{className:L($t.overlay,{[$t.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(Ne.Dialog.Popup,{className:L($t.content,{[$t.fullscreen]:c}),children:[e&&t.jsxs("header",{className:$t.header,children:[t.jsx(Ne.Dialog.Title,{className:$t.title,children:e}),t.jsx(Ne.Dialog.Close,{className:$t.close,children:t.jsx(I.IconClose,{size:20})})]}),n]})]})]}):null},rn=({children:e})=>{const n=g.useRef(null),[s,o]=g.useState(0),[a,r]=g.useState(!1),i=ze.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return g.useEffect(()=>{const c=n.current;if(!c)return;const l=()=>{const{height:u}=c.getBoundingClientRect();o(u),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?t.jsx(ze.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},Td="_help_qcmtq_1",Ed="_icon_qcmtq_10",qd="_info_qcmtq_19",Ld="_warning_qcmtq_23",Md="_error_qcmtq_27",Dd="_success_qcmtq_33",Os={help:Td,icon:Ed,info:qd,warning:Ld,error:Md,success:Dd},Jt=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(Kt,{size:12});case"info":return t.jsx(I.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(I.IconWarningFilled,{size:12});default:return t.jsx(I.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:L(Os.help,e&&Os[e],n),style:{marginTop:s},children:[t.jsx("div",{className:Os.icon,children:a()}),o]})},Pd="_stack_a6m7u_1",Rd="_help_a6m7u_6",Bd="_info_a6m7u_14",Ud="_warning_a6m7u_19",Fd="_error_a6m7u_24",Od="_success_a6m7u_29",lo={stack:Pd,help:Rd,info:Bd,warning:Ud,error:Fd,success:Od},Vd=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(rn,{children:t.jsx("div",{className:lo.stack,children:e})}),xe=({mt:e=0,...n})=>t.jsx(Jt,{...n,className:L(lo.help,lo[n.level]),mt:e});xe.Stack=Vd;const zd="_root_16p5j_1",Kd="_item_16p5j_10",Wd="_chevron_16p5j_14",Hd="_trigger_16p5j_19",Qd="_content_16p5j_39",fn={root:zd,item:Kd,chevron:Wd,trigger:Hd,content:Qd};function Gd(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(Y.Accordion.Root,{className:fn.root,type:"multiple",...i,children:[n.map((c,l)=>t.jsxs(Y.Accordion.Item,{className:fn.item,value:s?.(c)??String(l),children:[t.jsx(Y.Accordion.Header,{children:t.jsxs(Y.Accordion.Trigger,{className:fn.trigger,children:[o(c),t.jsx(I.IconChevronDown,{className:fn.chevron,size:16})]})}),t.jsx(Y.Accordion.Content,{className:fn.content,children:a(c)})]},s?.(c)??l)),r]})}const Yd=10;function ni(){const e=X();return(n,s)=>T.queryOptions({queryKey:ps.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Yd},{txs:a}=await V.create({prefixUrl:n.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:z.SECOND})}function Zd(e,n){const s=ni();return T.useSuspenseQuery(s(e,n))}function Jd(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return A.sortWith([A.descend(o=>new Date(o.timestamp).getTime())])(s)}const Xd=()=>{const e=ue(),n=ni(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(A.prop("data")),a=Jd(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};function Oo(e){const{data:n}=T.useSuspenseQuery({queryKey:hs.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:s}=e,{gas_prices:o}=await V.create({prefixUrl:s}).get("initia/tx/v1/gas_prices").json();return o.toSorted(A.descend(({denom:a})=>a==="uinit")).map(({denom:a,amount:r})=>{const i=a==="uinit"?1:Ja;return{amount:U(r).times(i).toFixed(18),denom:a}})}return e.fees.fee_tokens.map(({denom:s,fixed_min_gas_price:o})=>{if(A.isNil(o))throw new Error(`${s} has no price`);return{amount:String(o),denom:s}})},staleTime:z.SECOND});return n}function Vo(e){const n=X(),{data:s}=Zd(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>j.InitiaAddress.equals(n,gt.computeAddress(`0x${re.toHex(ao.Secp256k1.uncompressPubkey(re.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const eu="_trigger_u613p_1",tu="_icon_u613p_18",nu="_content_u613p_27",su="_item_u613p_36",ou="_itemText_u613p_52",au="_itemIndicator_u613p_57",ru="_active_u613p_60",vt={trigger:eu,icon:tu,content:nu,item:su,itemText:ou,itemIndicator:au,active:ru};function zo({options:e,value:n,onChange:s,classNames:o}){const a=Ft(),r=e.find(c=>c.value===n);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return t.jsxs(ht.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ht.Select.Trigger,{className:L(vt.trigger,o?.trigger),children:[t.jsx(ht.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ht.Select.Icon,{className:vt.icon,children:t.jsx(I.IconChevronDown,{size:12})})]}),t.jsx(ht.Select.Portal,{container:a,children:t.jsx(ht.Select.Positioner,{className:vt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ht.Select.Popup,{className:vt.popup,children:e.map(c=>t.jsxs(ht.Select.Item,{className:L(vt.item,o?.item),value:String(c.value),children:[t.jsx(ht.Select.ItemText,{className:L(vt.itemText,o?.itemText),children:c.label}),t.jsx(I.IconCheck,{size:12,className:L(vt.itemIndicator,{[vt.active]:c.value===n})})]},String(c.value)))})})})]})}const iu="_root_1t37n_1",cu="_trigger_1t37n_7",lu="_item_1t37n_11",du="_itemText_1t37n_17",ba={root:iu,trigger:cu,item:lu,itemText:du},uu=({options:e,value:n,onChange:s})=>{const{txRequest:o}=$r(),a=Xe(o.chainId),r=ct(a),i=(f,_)=>{if(j.formatAmount(f,{decimals:_})==="0.000000")return 8},c=({amount:[{amount:f,denom:_}]})=>{if(U(f).isZero())return"0";const{symbol:x,decimals:y}=r(_),b=i(f,y);return`${j.formatAmount(f,{decimals:y,dp:b})} ${x}`},l=e.map(f=>{const[{denom:_}]=f.amount,{symbol:x}=r(_);return{value:_,label:c(f),triggerLabel:x}});if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(f=>f.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:m}]=d.amount,{decimals:h}=r(m),p=i(u,h);return t.jsxs("div",{className:ba.root,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(u,{decimals:h,dp:p})}),t.jsx(zo,{options:l,value:n,onChange:s,classNames:ba})]})},mu="_root_16nr2_1",hu="_trigger_16nr2_5",pu="_chevron_16nr2_13",fu="_panel_16nr2_27",gu="_details_16nr2_39",_u="_row_16nr2_48",Gt={root:mu,trigger:hu,chevron:pu,panel:fu,details:gu,row:_u},xu=({spend:e,fee:n,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:n},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return t.jsxs(Ms.Collapsible.Root,{className:Gt.root,children:[t.jsxs(Ms.Collapsible.Trigger,{className:Gt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(I.IconChevronDown,{className:Gt.chevron,size:16})]}),t.jsx(Ms.Collapsible.Panel,{className:Gt.panel,children:t.jsx("div",{className:Gt.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:Gt.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[j.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function rs(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?re.toBase64(e):Array.isArray(e)?`[${e.map(rs).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const yu="_container_1xzyq_1",ju="_toggle_1xzyq_5",bu="_list_1xzyq_11",vu="_arg_1xzyq_16",wu="_type_1xzyq_21",gn={container:yu,toggle:ju,list:bu,arg:vu,type:wu},Cu=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),Nu=({type:e,arg:n})=>rs(j.resolveBcsType(e).parse(n)),ku=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Ie.useToggle(!1),{restUrl:r}=Xe(n),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:u}=T.useQuery({queryKey:Cu.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await V.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),f=JSON.parse(h.module.abi).exposed_functions.find(({name:_})=>_===l);if(!f)throw new Error(`Function ${l} not found in module ${c}`);return f.params.filter(_=>!_.startsWith("&"))},staleTime:z.INFINITY});if(!u)return s;const m=(h,p)=>{const f=u[p];return t.jsxs("div",{className:gn.arg,children:[t.jsx("div",{className:gn.type,children:f}),t.jsx(Ya.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(Nu,{type:f,arg:h})})]},p)};return t.jsxs("div",{className:gn.container,children:[t.jsx(ne.Small,{className:gn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:gn.list,children:d.map(m)}):s]})},Iu="_list_oip9m_1",Au="_key_oip9m_9",Su="_value_oip9m_14",Vs={list:Iu,key:Au,value:Su},$u=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:Vs.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:Vs.key,children:a}),t.jsx("div",{className:Vs.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(ku,{msg:o,chainId:n,fallback:rs(r)}):rs(r)})]},a))})},Tu="_item_1n572_1",Eu="_title_1n572_10",qu="_content_1n572_14",zs={item:Tu,title:Eu,content:qu},Ks=({title:e,content:n})=>t.jsxs("div",{className:zs.item,children:[t.jsx("div",{className:zs.title,children:e}),t.jsx("div",{className:zs.content,children:n})]});function Z(e){const n=e?U(e).abs():void 0;if(n&&n.gt(0)&&n.lt(.01))return"< $0.01";const s=e&&U(e).lt(0),o=j.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function si(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d-BigInt(c)}}}if(o.type==="coin_received"){const r=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function oi(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&j.createUserDerivedObjectAddress(n,u)===l){const h=s[u]||BigInt(0);s[u]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&j.createUserDerivedObjectAddress(n,u)===l){const h=s[u]||BigInt(0);s[u]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const ai=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=T.useSuspenseQuery({queryKey:Cn.denom(o,e).queryKey,queryFn:()=>V.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:z.INFINITY});return s(a)},Lu="_root_1p8a4_1",Mu="_title_1p8a4_8",Du="_changes_1p8a4_14",Pu="_change_1p8a4_14",Ru="_amount_1p8a4_35",Bu="_text_1p8a4_42",Uu="_value_1p8a4_49",Rt={root:Lu,title:Mu,changes:Du,change:Pu,amount:Ru,text:Bu,value:Uu},ri=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,c=j.formatAmount(e,{decimals:r}),l=s&&U(j.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Rt.change,children:[t.jsxs("div",{className:Rt.amount,children:[t.jsx(J,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Rt.text,children:[c," ",a||o]})]}),l&&t.jsx("div",{className:Rt.value,children:Z(l)})]})},Fu=({changes:e,chain:n})=>{const s=ct(n),{data:o}=yt(n);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return t.jsx(ri,{amount:a,asset:c,price:l},i)})},Ou=({changes:e,chain:n})=>{const s=ct(n),{data:o}=yt(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(ai,{metadata:r,chain:n,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(ri,{amount:a,asset:s(c),price:l})}},i))};function Vu(e,n){return typeof n=="bigint"?n.toString():n}const zu=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Vu)]}),Ku=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=De(),r=Xe(s),{simulateTx:i}=bs(),{data:c}=T.useSuspenseQuery({queryKey:zu.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:z.SECOND}),l=h=>t.jsxs("div",{className:Rt.root,children:[t.jsx("h2",{className:Rt.title,children:"Estimated changes"}),t.jsx("div",{className:Rt.changes,children:h})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=oi(d,a),[p]=va(h);return p.length===0?null:l(t.jsx(Ou,{changes:p,chain:r}))}const u=si(d,o),[m]=va(u);return m.length===0?null:l(t.jsx(Fu,{changes:m,chain:r}))};function va(e){return A.partition(n=>new U(n.amount).isNegative(),e)}const Wu="_title_1d032_1",Hu="_meta_1d032_7",Qu="_footer_1d032_14",Gu="_rejectButton_1d032_19",Wn={title:Wu,meta:Hu,footer:Qu,rejectButton:Gu},ii=()=>{const{txRequest:e,resolve:n,reject:s}=$r(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=X(),u=gs(),m=Xe(r),h=Sn(m),p=Oo(m),f=Vo(m),_=ct(m),x=Nr(),y=Cr(),b=(e.gasPrices??p).map(({amount:N,denom:R})=>Ve.calculateFee(Math.ceil(i*c),Ve.GasPrice.fromString(N+R))),w=b.map(N=>N.amount[0]),v=N=>{const R=h.find(ee=>ee.denom===N)?.amount??"0",P=w.find(ee=>ee.denom===N)?.amount??"0",q=l.filter(ee=>ee.denom===N).reduce((ee,me)=>U(ee).plus(me.amount),U("0")),D=U(P).plus(q),H=U(R).gte(D),{symbol:W,decimals:O}=_(N);return{symbol:W,decimals:O,spend:q.gt(0)?q.toFixed():null,fee:P,total:D.toFixed(),balance:R,isSufficient:H}},C=()=>{if(f&&v(f).isSufficient)return f;for(const{denom:N}of w)if(v(N).isSufficient)return N;return w[0]?.denom},[k,S]=g.useState(C),{mutate:M,isPending:F}=T.useMutation({mutationKey:[Ar],mutationFn:async()=>{const N=b.find(q=>q.amount[0].denom===k);if(!N)throw new Error("Fee not found");const P=!e.internal&&await x(r,o)?await y(r,d,o,N,a||""):await u(r,d,o,N,a);await n(P)},onError:async N=>{s(N)}}),E=v(k),$=!E.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(ut,{children:[t.jsx("h1",{className:Wn.title,children:"Confirm tx"}),t.jsxs("div",{className:Wn.meta,children:[t.jsx(Ks,{title:"Chain",content:r}),t.jsx(Ks,{title:"Tx fee",content:t.jsx(uu,{options:b,value:k,onChange:S})}),a&&t.jsx(Ks,{title:"Memo",content:a}),$&&t.jsx(xe,{level:"error",children:t.jsx(xu,{...E})})]}),t.jsx(Ku,{messages:o,memo:a,chainId:r}),t.jsx(Gd,{list:o,renderHeader:({typeUrl:N})=>us.sentenceCase(N.split(".").pop().replace(/^Msg/,"")),renderContent:N=>t.jsx($u,{message:N,chainId:r})})]}),t.jsxs(fe,{className:Wn.footer,children:[t.jsx(ne.Outline,{onClick:()=>s(new Error("User rejected")),disabled:F,className:Wn.rejectButton,children:t.jsx(I.IconClose,{size:16})}),t.jsx(ne.White,{onClick:()=>M(),disabled:$,loading:F,children:"Approve"})]})]})},Yu=({children:e})=>{const[{title:n,content:s,path:o},a]=g.useState({}),[r,i]=g.useState(!1),c=K.useAtomValue(js),l=g.useCallback(m=>{a(m),i(!0)},[]),d=g.useCallback(()=>{a({}),i(!1)},[]),u=g.useCallback(m=>{m||(c?.reject(new Error("User rejected")),a({})),i(m)},[c]);return t.jsxs(kr.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(ti,{title:n,open:r,onOpenChange:u,children:t.jsx(de,{children:o==="/tx"?t.jsx(ii,{}):s})})]})},Zu="_container_1w1hx_1",Ju="_toast_1w1hx_11",Xu="_info_1w1hx_24",em="_success_1w1hx_28",tm="_error_1w1hx_32",nm="_icon_1w1hx_37",sm="_content_1w1hx_45",om="_title_1w1hx_48",am="_description_1w1hx_53",rm="_close_1w1hx_75",wt={container:Zu,toast:Ju,info:Xu,success:em,error:tm,icon:nm,content:sm,title:om,description:am,close:rm},im=({notification:e,onClose:n,...s})=>{const o=ze.useTransition(e,{keys:r=>r?.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}}),a=r=>{switch(r){case"loading":return t.jsx(Kt,{size:16});case"info":case"success":return t.jsx(I.IconCheckCircleFilled,{size:16});case"error":return t.jsx(I.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,u=a(c);return t.jsx(ze.animated.div,{style:r,className:wt.container,children:t.jsxs("div",{className:L(wt.toast,c&&wt[c]),...s,children:[u&&t.jsx("div",{className:wt.icon,children:u}),t.jsxs("div",{className:wt.content,children:[t.jsx("p",{className:wt.title,children:l}),d&&t.jsx("div",{className:wt.description,children:d})]}),t.jsx("button",{className:wt.close,onClick:n,children:t.jsx(I.IconClose,{size:14})})]})})})},Ws=5e3,cm=({children:e})=>{const n=Ft(),[s,o]=g.useState(null),a=g.useRef(null),r=g.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=g.useCallback(()=>{i(),o(null)},[]),l=g.useCallback(h=>{i(),o({...h,id:da.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Ws))},[c]),d=g.useCallback(h=>{i(),o(p=>p?{...p,...h}:{...h,id:da.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Ws))},[c]),u=()=>{i(),r.current=!0},m=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Ws))};return g.useEffect(()=>()=>i(),[]),t.jsxs(Jr.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,n&&Ji.createPortal(t.jsx(im,{notification:s,onClose:c,onMouseEnter:u,onMouseLeave:m}),n)]})},lm=({children:e})=>{const[n,s]=g.useState(null);return t.jsx(ws.Provider,{value:{container:n,setContainer:s},children:e})},ci=[{value:10*pr,label:"for 10 minutes"},{value:fr,label:"for 1 hour"},{value:ha,label:"for 1 day"},{value:7*ha,label:"for 7 days"},{value:0,label:"until revoked"}],dm=ci[0].value,um="_container_1422v_1",mm="_title_1422v_7",hm="_description_1422v_14",pm="_sectionTitle_1422v_20",fm="_websiteInfo_1422v_27",gm="_favicon_1422v_37",_m="_websiteTitle_1422v_42",xm="_websiteHost_1422v_48",ym="_warningContent_1422v_54",jm="_ignoreButton_1422v_61",bm="_infoList_1422v_65",vm="_infoItem_1422v_75",wm="_label_1422v_84",Cm="_infoValue_1422v_94",Nm="_durationTrigger_1422v_100",km="_durationItem_1422v_101",Im="_featureList_1422v_105",Am="_featureItem_1422v_113",Sm="_checkIcon_1422v_123",$m="_learnMoreLink_1422v_127",Tm="_feedbackContainer_1422v_140",Em="_footer_1422v_146",ae={container:um,title:mm,description:hm,sectionTitle:pm,websiteInfo:fm,favicon:gm,websiteTitle:_m,websiteHost:xm,warningContent:ym,ignoreButton:jm,infoList:bm,infoItem:vm,label:wm,infoValue:Cm,durationTrigger:Nm,durationItem:km,featureList:Im,featureItem:Am,checkIcon:Sm,learnMoreLink:$m,feedbackContainer:Tm,footer:Em},qm=ye.createQueryKeys("interwovenkit:account",{info:(e,n)=>({queryKey:[e,n],queryFn:async()=>{const s=V.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${n}`;return s.get(o).json()}})}),Lm=()=>{const[e,n]=g.useState(dm),[s,o]=K.useAtom(Ln),[a,r]=g.useState(!1),i=Je(),c=ue(),{address:l,username:d}=De(),{mutate:u,isPending:m}=Rc(),{closeDrawer:h}=lt();if(!s)throw new Error("Pending request not found");const{logoUrl:p,name:f,restUrl:_}=i(s.chainId),{data:x,isLoading:y}=T.useQuery(qm.info(_,l)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.some(S=>{if(!S.website)return!1;const M=wa(new URL(S.website).hostname),F=wa(window.location.hostname);return M===F}),v=()=>{u(e)},C=()=>{s?.reject(new Error("User cancelled")),o(null),h()},k=!w&&!a;return t.jsxs(t.Fragment,{children:[t.jsxs(ut,{className:ae.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:ae.title,children:"Enable auto-signing"}),t.jsx("p",{className:ae.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ae.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:ae.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:ae.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:ae.websiteTitle,children:b.title}),t.jsx("div",{className:ae.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ae.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:ae.infoList,children:[t.jsxs("div",{className:ae.infoItem,children:[t.jsx("div",{className:ae.label,children:"Address"}),t.jsxs("div",{className:ae.infoValue,children:[t.jsx(I.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:j.truncate(d??l)})]})]}),t.jsxs("div",{className:ae.infoItem,children:[t.jsx("div",{className:ae.label,children:"Chain"}),t.jsxs("div",{className:ae.infoValue,children:[t.jsx(J,{src:p,width:14,height:14,logo:!0}),t.jsx("span",{children:f})]})]}),t.jsxs("div",{className:ae.infoItem,children:[t.jsx("div",{className:ae.label,children:"Duration"}),t.jsx(zo,{options:ci,value:e,onChange:n,classNames:{trigger:ae.durationTrigger,item:ae.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ae.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:ae.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map(S=>t.jsxs("li",{className:ae.featureItem,children:[t.jsx(I.IconCheckCircle,{size:12,className:ae.checkIcon}),t.jsx("span",{children:S})]},S))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:ae.learnMoreLink,children:["Learn more ",t.jsx(I.IconExternalLink,{size:12})]})]})]}),t.jsxs(fe,{className:ae.footer,extra:t.jsxs("div",{className:ae.feedbackContainer,children:[!y&&!x&&t.jsx(xe,{level:"error",children:"Insufficient balance for fee"}),!w&&!a&&t.jsx(xe,{level:"warning",children:t.jsxs("div",{className:ae.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:ae.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(ne.Outline,{onClick:C,children:"Cancel"}),t.jsx(ne.White,{onClick:v,disabled:k||!x||y,loading:m,children:"Enable"})]})]})},Mm=()=>K.useAtomValue(Ln)?t.jsx(Lm,{}):null;function wa(e){const n=e.split(".");return n.length<2?e:n.slice(-2).join(".")}const Dm="_container_mqvhs_1",Pm="_badge_mqvhs_5",Ca={container:Dm,badge:Pm},li=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:L(Ca.container,a),children:[o,!s&&t.jsx("div",{className:Ca.badge,style:{right:n,top:n}})]})},Rm="_header_s7mee_1",Bm="_back_s7mee_12",Um="_title_s7mee_24",Hs={header:Rm,back:Bm,title:Um},mt=({title:e,backButton:n,extra:s,children:o})=>{const a=ur();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Hs.header,children:[t.jsx(nn,{to:n??(a.length>1?-1:"/"),className:Hs.back,shouldReset:!!n,children:t.jsx(I.IconBack,{size:16})}),t.jsx("h1",{className:Hs.title,children:e}),s]}),t.jsx(ut,{children:o})]})};function di(){const{initiaAddress:e,hexAddress:n}=De(),s=dt(),o=Pn();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function ui(){const e=dt(),n=Pn();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return j.InitiaAddress.validate(s);case"evm":return gt.isAddress(s);case"cosmos":try{return re.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function Fm(){const e=dt(),n=Pn();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=n(i),l=e(a),d=n(l);if(c==="evm"&&d==="initia")return j.InitiaAddress(s).bech32;if(c==="initia"&&d==="evm")return j.InitiaAddress(s).hex;if(c===d)return s;if(r){if(d==="initia")return j.InitiaAddress(r).bech32;if(d==="evm")return j.InitiaAddress(r).hex}return""}}const Om="_root_ekn9t_1",Vm="_header_ekn9t_6",zm="_title_ekn9t_12",Km="_warning_ekn9t_18",Wm="_content_ekn9t_22",Hm="_footer_ekn9t_26",Qm="_secondary_ekn9t_36",Tt={root:Om,header:Vm,title:zm,warning:Km,content:Wm,footer:Hm,secondary:Qm},mi=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(ut,{className:Tt.root,children:[t.jsxs("header",{className:L(Tt.header,n&&Tt[n]),children:[s,t.jsx("h1",{className:Tt.title,children:o})]}),t.jsx("div",{className:Tt.content,children:a}),t.jsxs("footer",{className:Tt.footer,children:[t.jsx(ne.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Tt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(I.IconChevronRight,{size:14})]})]})]})},Gm="_list_k4n3k_1",Ym="_row_k4n3k_9",Zm="_dt_k4n3k_20",Jm="_asset_k4n3k_26",Hn={list:Gm,row:Ym,dt:Zm,asset:Jm},Xm=({list:e,onNavigate:n,onDismiss:s})=>{const o=ie(),a=Je(),r=ct(o);return t.jsx(mi,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:Hn.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const u=a(c),{decimals:m,symbol:h}=r(d),p=j.formatAmount(l,{decimals:m});return t.jsxs("div",{className:Hn.row,children:[t.jsxs("div",{className:Hn.dt,children:[t.jsx(J,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Hn.asset,children:[p," ",h]})]},i)})})})};function Qs(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const Qn=({chainId:e,txHash:n})=>`${oe.OP_REMINDER}:${e}:${n}`,eh=Xi.atomWithStorage(oe.OP_REMINDER,[]);function un(){const e=X(),[n=[],s]=K.useAtom(eh),o=g.useMemo(()=>n.map(l=>{const d=localStorage.getItem(Qn(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:u}=l;return d!==e?!1:Ze.isPast(u)}),[e,n]),a=g.useCallback((l,d)=>{n.some(u=>Qs(u,l))||(s((u=[])=>[...u,l]),localStorage.setItem(Qn(l),JSON.stringify(d)))},[n,s]),r=g.useCallback(l=>{s((d=[])=>d.filter(u=>!Qs(u,l))),localStorage.removeItem(Qn(l))},[s]),i=g.useCallback(l=>{const d=l.filter(u=>!n.some(m=>Qs(m,u)));d.length!==0&&s((u=[])=>[...u,...d])},[n,s]),c=g.useCallback((l,d)=>{localStorage.setItem(Qn(l),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function hi(){const e=je(),{openModal:n,closeModal:s}=ys(),{reminders:o,setReminder:a}=un();g.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{s();for(const l of r)a(l,{...l,dismissed:!0})};n({content:g.createElement(Xm,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,n,a])}const th="_wrapper_5ssm8_1",nh="_balance_5ssm8_11",sh="_button_5ssm8_15",Gs={wrapper:th,balance:nh,button:sh},pi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:Gs.wrapper,children:[t.jsx(I.IconWallet,{size:16}),t.jsx("span",{className:Gs.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:Gs.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),oh="_fieldset_up6fh_1",ah="_upper_up6fh_9",rh="_select_up6fh_14",ih="_account_up6fh_20",ch="_lower_up6fh_25",lh="_wrapper_up6fh_26",dh="_balance_up6fh_33",uh="_value_up6fh_37",mh="_error_up6fh_50",pt={fieldset:oh,upper:ah,select:rh,account:ih,lower:ch,wrapper:lh,balance:dh,value:uh,error:mh},uo=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:pt.fieldset,children:[t.jsxs("div",{className:pt.upper,children:[t.jsx("div",{className:pt.select,children:n}),t.jsx("div",{className:pt.account,children:s})]}),!c&&t.jsxs("div",{className:pt.lower,children:[o,t.jsxs("div",{className:pt.wrapper,children:[t.jsx("div",{className:pt.balance,children:a}),r&&t.jsx("div",{className:pt.value,children:r})]}),i&&t.jsxs("footer",{className:pt.error,children:[t.jsx(I.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Bn(){const e=g.useRef(null),n=vs();return g.useEffect(()=>{n||e.current?.focus()},[n]),e}const hh="_input_h8073_1",ph={input:hh};function fi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,c=Bn();return t.jsx(pe.Controller,{name:n,control:s,rules:r,render:({field:l})=>t.jsx(ec.NumericFormat,{value:l.value,getInputRef:Za.mergeRefs([l.ref,c]),className:L(ph.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const fh="_input_19r9r_1",gh="_placeholder_19r9r_18",mo={input:fh,placeholder:gh},_h=({children:e})=>t.jsx("p",{className:L(mo.input,{[mo.placeholder]:U(e).isZero()}),children:e}),cn=({balance:e,decimals:n,className:s})=>{const{control:o}=pe.useFormContext(),a={required:"Enter amount",validate:r=>U(r).isZero()?"Enter amount":U(j.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(fi,{name:"quantity",control:o,className:L(mo.input,s),rules:a})};cn.ReadOnly=_h;const ln=({title:e,content:n,children:s,className:o})=>{const[a,r]=g.useState(!1),i=()=>r(!1);return t.jsx(ti,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},xh="_tooltip_19kvs_1",yh="_arrow_19kvs_44",Na={tooltip:xh,arrow:yh},Un=({label:e,children:n,small:s,...o})=>t.jsxs(Y.Tooltip.Root,{...o,children:[t.jsx(Y.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(Y.Tooltip.Portal,{container:Ft(),children:t.jsxs(Y.Tooltip.Content,{className:L(Na.tooltip,{small:s}),collisionBoundary:Ft(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Y.Tooltip.Arrow,{className:Na.arrow})]})})]});function Ko(e,n){const s=tt();return T.useQuery({queryKey:qe.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[n].denoms??{}:{}:{},enabled:!!e,staleTime:z.SECOND})}function jh(e,n,s){const{data:o={}}=Ko(e,n);return A.path([s],o)}const bh=[["d",1440*60],["h",3600],["m",60],["s",1]];function In(e){if(!e)return;const{formattedParts:n}=bh.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function Wo(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${j.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function is(e,n){const{watch:s}=It(),o=s(),a=tt(),r=$n(),i={...o,quantity:e},c=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,l=T.useQueryClient();return T.useQuery({queryKey:qe.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:d,srcDenom:u,quantity:m,dstChainId:h,dstDenom:p}=i,{decimals:f}=l.getQueryData(qe.asset(d,u).queryKey)??{decimals:0},_={amount_in:j.toBaseUnit(m,{decimals:f}),source_asset_chain_id:d,source_asset_denom:u,dest_asset_chain_id:h,dest_asset_denom:p,is_op_withdraw:n?.isOpWithdraw},x=await a.post("v2/fungible/route",{json:_}).json(),y={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return r("Bridge Simulation Success",y),x},enabled:!!Number(i.quantity)&&!n?.disabled&&!c,staleTime:z.MINUTE})}function vh(e){return T.useQuery({queryKey:qe.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof V.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null}})}function wh(){const{watch:e}=It(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=rt(n),i=kn(r),c=it(s,n),l=it(a,o),d=ie(),u=ue();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&u.find(m=>m.chainId===n)?.metadata?.op_denoms?.includes(l.denom)}const Ch="_label_t93ix_1",Nh="_wrapper_t93ix_7",kh="_input_t93ix_10",Ih="_clear_t93ix_18",Gn={label:Ch,wrapper:Nh,input:kh,clear:Ih},Ho=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=j.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=Bn(),{control:l,getValues:d,setValue:u,formState:m}=pe.useFormContext(),h=d("recipient"),[p,f]=g.useState(h),_=ir(),{data:x,isLoading:y,error:b}=T.useQuery({queryKey:ps.address(_.restUrl,p).queryKey,queryFn:()=>_.getAddress(p),staleTime:z.MINUTE,enabled:_.validateUsername(p)}),w=x??(o(p)?p:""),v=n&&j.InitiaAddress.equals(w,n),C=async()=>{try{const M=await navigator.clipboard.readText();f(M.trim())}catch{}};g.useEffect(()=>{e==="onChange"&&(!p&&!m.dirtyFields.recipient||u("recipient",x??p,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,p,e,u,x]);const k=()=>{y||b||(u("recipient",w,{shouldValidate:!0,shouldDirty:!0}),r?.())},S=()=>{if(y)return t.jsx(Jt,{level:"loading",children:"Resolving username..."});if(b)return t.jsx(Jt,{level:"error",children:b.message});if(x)return t.jsx(Jt,{level:"success",className:"monospace",children:x});if(e==="onSubmit"&&p&&!w)return t.jsx(Jt,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:Gn.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(ne.Small,{type:"button",tabIndex:-1,onClick:C,children:"Paste"})]}),t.jsxs("div",{className:Gn.wrapper,children:[t.jsx(pe.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:M=>o(M)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:L(Gn.input,"monospace"),value:p,onChange:M=>f(M.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":p?"true":void 0,ref:e==="onSubmit"?Za.mergeRefs([i,c]):i})}),!!p&&t.jsx("button",{type:"button",className:Gn.clear,onClick:()=>f(""),"aria-label":"Clear recipient",children:t.jsx(I.IconCloseCircleFilled,{size:16})})]}),S(),v&&t.jsx(Jt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(fe,{extra:(!n||!!w&&!v)&&t.jsx(xe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(ne.White,{type:"button",onClick:k,disabled:y||!!b||!w,children:"Apply"})})]})},Ah="_scrollable_vgj3r_1",Sh="_list_vgj3r_5",$h="_item_vgj3r_9",Th="_name_vgj3r_22",Yn={scrollable:Ah,list:Sh,item:$h,name:Th};function gi({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return t.jsx(ut,{className:Yn.scrollable,children:t.jsx("div",{className:Yn.list,children:n.map(l=>t.jsxs("button",{className:Yn.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(J,{src:o(l),width:28,height:28}),t.jsx("span",{className:Yn.name,children:a(l)}),i?.(l)&&t.jsx(Kt,{size:16})]},r(l)))})})}function Ns(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(o=>o.name===s)}}const Eh="_account_h04x1_8",qh="_clear_h04x1_28",Lh="_white_h04x1_39",_n={account:Eh,clear:qh,white:Lh},ka=({type:e})=>{const{watch:n,setValue:s}=It(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),c=n(e==="src"?"sender":"recipient"),l=kn(rt(a)),{list:d,find:u}=Ns(),m=u(r),h=di(),p=ui(),f=h(a),_=j.InitiaAddress.equals(c,f),x=()=>t.jsx(ln,{title:"Connect wallet",content:w=>t.jsx(gi,{onSelect:async v=>{const C=v.getProvider();if(!C)return window.open(v.fallbackUrl,"_blank");const k=C.getOfflineSigner(o),[{address:S}]=await k.getAccounts();s("sender",S),s("cosmosWalletName",v.name),w()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:L(_n.account,{[_n.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[m&&t.jsx(J,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:j.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(I.IconChevronRight,{size:14})]})}),y=w=>t.jsx(ln,{title:"Recipient",content:v=>t.jsx(ut,{children:t.jsx(Ho,{mode:"onSubmit",myAddress:f,chainType:l,validate:C=>p(C,a),onApply:v})}),className:_n.account,children:w}),b=()=>{switch(l){case"initia":case"evm":return _?y(t.jsx(I.IconWallet,{size:14})):t.jsxs("div",{className:_n.account,children:[t.jsx("span",{className:"monospace",children:j.truncate(c)}),t.jsx("button",{type:"button",className:_n.clear,onClick:()=>s("recipient",f,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(I.IconCloseCircleFilled,{size:14})})]});case"cosmos":return y(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:j.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(I.IconEdit,{size:14})]}))}};switch(e){case"src":return x();case"dst":return b()}},Mh="_images_cj4xz_1",Ys={images:Mh},ks=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:L(Ys.images,r),style:{position:"relative"},children:[t.jsx(J,{src:e,width:n,height:n,className:Ys.asset,logo:!0}),t.jsx(J,{src:s,width:o,height:o,className:Ys.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Dh="_root_6187w_1",Ph="_content_6187w_10",Rh="_details_6187w_20",Bh="_symbol_6187w_26",Uh="_chain_6187w_34",Fh="_chevron_6187w_43",Et={root:Dh,content:Ph,details:Rh,symbol:Bh,chain:Uh,chevron:Fh},_i=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:Et.content,children:[t.jsx(ks,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:Et.details,children:[t.jsx("div",{className:Et.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:Et.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:Et.root,children:o}):t.jsxs("div",{className:Et.root,children:[o,t.jsx(I.IconChevronDown,{size:16,className:Et.chevron})]})};function Oh(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return A.any(A.includes(n.toLowerCase()),a)})}const Vh="_root_1sh27_1",zh="_label_1sh27_8",Kh="_input_1sh27_21",Wh="_hasValue_1sh27_31",Hh="_clear_1sh27_35",xn={root:Vh,label:zh,input:Kh,hasValue:Wh,clear:Hh},Is=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:L(xn.root,n,{[xn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:xn.label,children:t.jsx(I.IconSearch,{size:o})}),t.jsx("input",{className:xn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:xn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:t.jsx(I.IconCloseCircleFilled,{size:o})})]})},Qh="_container_5tajg_1",Gh="_search_5tajg_7",Yh="_list_5tajg_11",Zh="_item_5tajg_15",Jh="_logo_5tajg_37",Xh="_info_5tajg_41",ep="_symbol_5tajg_47",tp="_name_5tajg_56",np="_balance_5tajg_62",sp="_value_5tajg_69",Oe={container:Qh,search:Gh,list:Yh,item:Zh,logo:Jh,info:Xh,symbol:ep,name:tp,balance:np,value:sp},Fn=e=>{const{assets:n,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=g.useState(""),i=Oh(["symbol"],a,n);return t.jsxs("div",{className:Oe.container,children:[t.jsx(Is,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:Oe.search,padding:20,ref:Bn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:Oe.list,children:i.map(c=>t.jsx("button",{type:"button",className:Oe.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:p,decimals:f,value:_=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(J,{src:u,width:32,height:32,className:Oe.logo,logo:!0}),t.jsxs("div",{className:Oe.info,children:[t.jsx("div",{className:Oe.symbol,children:m||d}),t.jsx("div",{className:Oe.name,children:h})]}),t.jsxs("div",{className:Oe.balance,children:[p&&t.jsx("div",{children:j.formatAmount(p,{decimals:f})}),_>0&&t.jsx("div",{className:Oe.value,children:Z(_)})]})]})})},c.denom))})]})},op=()=>t.jsxs("div",{className:Oe.container,children:[t.jsx(Is,{rootClassName:Oe.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});Fn.Placeholder=op;const ap="_stack_16oqn_1",rp="_title_16oqn_9",ip="_grid_16oqn_16",cp="_item_16oqn_22",lp="_button_16oqn_26",dp="_active_16oqn_44",Xt={stack:ap,title:rp,grid:ip,item:cp,button:lp,active:dp},Bt=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Xt.title,children:e}),t.jsx("div",{className:Xt.grid,children:n.map(({chainId:r,name:i,logoUrl:c})=>t.jsx(li,{offset:-2,disabled:!a?.(r),className:Xt.item,children:t.jsx(Un,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:L(Xt.button,{[Xt.active]:r===s}),onClick:()=>o(r),children:t.jsx(J,{src:c,width:28,height:28,logo:!0})})})},r))})]}),up=({children:e})=>t.jsx("div",{className:Xt.stack,children:e});Bt.Stack=up;const mp=({address:e,chain:n,onSelect:s})=>{const o=os(n.chain_id),{data:a={}}=Ko(e,n.chain_id);return t.jsx(Fn,{assets:A.sortWith([A.descend(r=>r.symbol==="INIT"),A.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>U(i).comparedTo(r)??0,A.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=j.truncate(i),logo_uri:l}=r,d=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},hp=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=kt(),i=Rn(),{watch:c,setValue:l}=It(),d=c(a),u=c(s),m=c(o),[h,p]=g.useState(u),f=rt(h),_=Fm(),x=Wr(),[y,b]=A.partition(v=>x(v.chain_id),i.filter(v=>!v.hidden)),w=v=>{if(u===h&&m===v){n();return}l(s,h),l(o,v),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Bt.Stack,{children:[t.jsx(Bt,{label:"Interwoven Economy",chains:y.map(({chain_id:v,chain_name:C,pretty_name:k,logo_uri:S})=>({chainId:v,name:k||C,logoUrl:S??""})),value:h,onSelect:p}),t.jsx(Bt,{label:"Chains",chains:b.map(({chain_id:v,chain_name:C,pretty_name:k,logo_uri:S})=>({chainId:v,name:k||C,logoUrl:S??""})),value:h,onSelect:p})]}),t.jsx(de,{suspenseFallback:t.jsx(Fn.Placeholder,{}),children:t.jsx(mp,{address:_({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:f,onSelect:w})},h)]})},Ia=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=It(),r=a(n),i=a(s),c=rt(r),l=it(i,r);return t.jsx(ln,{title:o,content:d=>t.jsx(hp,{type:e,afterSelect:d}),children:t.jsx(_i,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},pp="_skeleton_1l4jn_1",fp={skeleton:pp},Ut=({width:e="100%",height:n})=>t.jsx("div",{className:fp.skeleton,style:{width:e,height:n}}),gp="_stack_oq1ir_1",_p="_button_oq1ir_6",xp="_isLoading_oq1ir_19",yp="_disabled_oq1ir_19",jp="_checked_oq1ir_23",bp="_header_oq1ir_37",vp="_title_oq1ir_43",wp="_duration_oq1ir_52",Cp="_warning_oq1ir_62",Np="_amount_oq1ir_66",kp="_value_oq1ir_67",Fe={stack:gp,button:_p,isLoading:xp,disabled:yp,checked:jp,header:bp,title:vp,duration:wp,warning:Cp,amount:Np,value:kp},Ip=({children:e})=>t.jsx("div",{className:Fe.stack,children:e}),ts=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:c}=It(),{dstChainId:l,dstDenom:d}=c(),u=it(d,l),m=!i&&a.checked,h=!i&&!r;return t.jsxs("button",{type:"button",className:L(Fe.button,{[Fe.isLoading]:i,[Fe.disabled]:h,[Fe.checked]:m}),onClick:()=>{i||h||o(s)},children:[t.jsxs("div",{className:Fe.header,children:[t.jsxs("div",{className:Fe.title,children:[t.jsx("span",{children:e}),m&&t.jsx(I.IconCheck,{size:14})]}),i?t.jsx(Ut,{width:80,height:16}):r?t.jsxs("div",{className:L(Fe.duration,{[Fe.warning]:s==="op"}),children:[t.jsx(I.IconClockFilled,{size:12}),t.jsx("span",{children:In(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:Fe.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Fe.amount,children:i?t.jsx(Ut,{width:260,height:40}):r?j.formatAmount(r.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:Fe.value,children:i?t.jsx(Ut,{width:120,height:16}):r?r.usd_amount_out?Z(r.usd_amount_out):"$-":null})]})]})};ts.Stack=Ip;const Ap="_description_nuyvt_1",Sp="_presets_nuyvt_8",$p="_preset_nuyvt_8",Tp="_active_nuyvt_29",Ep="_custom_nuyvt_40",qp="_wrapper_nuyvt_47",Lp="_percent_nuyvt_58",ot={description:Ap,presets:Sp,preset:$p,active:Tp,custom:Ep,wrapper:qp,percent:Lp},Aa=["0.1","0.5","1.0"],Mp=({afterConfirm:e})=>{const n=It(),s=n.getValues("slippagePercent"),[o,a]=g.useState(null),{control:r,watch:i,getValues:c,setValue:l}=pe.useForm({defaultValues:{value:s}}),d=i("value");g.useEffect(()=>{const _=Aa.findIndex(x=>x===s);a(_>=0?_:null)},[s]);const u=(_,x)=>{l("value",_),a(x)},m=()=>{a(null)},h=g.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),p=h?.type==="error",f=({value:_})=>{n.setValue("slippagePercent",_),e()};return t.jsxs(ut,{children:[t.jsx("p",{className:ot.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."}),t.jsxs("div",{className:ot.presets,children:[Aa.map((_,x)=>t.jsxs("button",{type:"button",className:L(ot.preset,{[ot.active]:o===x}),onClick:()=>u(_,x),children:[_,"%"]},_)),o!==null?t.jsx("button",{type:"button",className:L(ot.preset,ot.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:ot.wrapper,children:[t.jsx(fi,{name:"value",control:r,dp:2,onFocus:m,placeholder:"",className:L(ot.preset,ot.active)}),t.jsx("span",{className:ot.percent,children:"%"})]})]}),h&&t.jsx(xe,{level:h.type,children:h.text}),t.jsx(fe,{children:t.jsx(ne.White,{type:"button",onClick:()=>f(c()),disabled:p,children:"Confirm"})})]})},Dp="_form_1owk5_1",Pp="_arrow_1owk5_5",Rp="_divider_1owk5_14",Bp="_flip_1owk5_23",Up="_meta_1owk5_41",Fp="_row_1owk5_54",Op="_title_1owk5_60",Vp="_description_1owk5_64",zp="_icon_1owk5_71",Kp="_edit_1owk5_76",Wp="_warning_1owk5_99",Le={form:Dp,arrow:Pp,divider:Rp,flip:Bp,meta:Up,row:Fp,title:Op,description:Vp,icon:zp,edit:Kp,warning:Wp},Hp=()=>{const e=je(),n=vs(),[s,o]=Ie.useLocalStorage(oe.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:c}=It(),l=a(),{srcChainId:d,srcDenom:u,dstChainId:m,dstDenom:h,quantity:p,sender:f,slippagePercent:_}=l,x=Je(),y=rt(d),b=kn(y),w=rt(m),v=kn(w),C=it(u,d),k=it(h,m),{data:S}=Ko(f,d),M=jh(f,d,u),F=!M?.amount||U(M.amount).isZero(),[E]=Ie.useDebounceValue(p,300),$=b!=="initia"&&v!=="initia",N=wh(),R=is(E,{disabled:$}),P=is(E,{isOpWithdraw:!0,disabled:!N}),q=N&&s==="op"?P:R,{data:D,isLoading:H,isFetching:W,error:O}=q,{data:ee}=vh(O),me=E&&(H||W),Ae=()=>{r("srcChainId",m),r("srcDenom",h),r("dstChainId",d),r("dstDenom",u),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:We,closeModal:At}=ys(),mn=i(te=>{if(D?.warning){const{type:St="",message:Ls}=D.warning??{};We({content:t.jsx(mi,{type:"warning",icon:t.jsx(I.IconWarningFilled,{size:40}),title:us.sentenceCase(St),primaryButton:{label:"Cancel",onClick:At},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:D,values:te}),At()}},children:t.jsx("p",{className:Le.warning,children:Ls})})});return}e("/bridge/preview",{route:D,values:te})}),hn=g.useMemo(()=>D?.estimated_fees?.filter(({fee_behavior:te})=>te==="FEE_BEHAVIOR_DEDUCTED")??[],[D]),Ht=g.useMemo(()=>D?.estimated_fees?.filter(({fee_behavior:te})=>te==="FEE_BEHAVIOR_ADDITIONAL")??[],[D]),Pe=g.useMemo(()=>{for(const te of Ht){const St=S?.[te.origin_asset.denom]?.amount??"0",Ls=D?.source_asset_denom===te.origin_asset.denom?D.amount_in:"0";if(U(St).lt(U(Ls).plus(te.amount??"0")))return`Insufficient ${te.origin_asset.symbol} for fees`}},[S,D,Ht]),Re=g.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!E)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!D)return"Route not found";if(Pe)return Pe},[E,Pe,c,D,l]),pn=D?j.formatAmount(D.amount_out,{decimals:k.decimals}):"0",Vn=U(p).gt(0)&&U(p).isEqualTo(j.fromBaseUnit(M?.amount,{decimals:M?.decimals??0})),Wi=(()=>{switch(b){case"initia":return x(d).fees.fee_tokens.some(({denom:te})=>te===u);case"cosmos":return y.fee_assets.some(({denom:te})=>te===u);case"evm":return!gt.isAddress(u);default:return!1}})(),qs=g.useCallback((te,St)=>te.length?t.jsxs("div",{className:Le.description,children:[Wo(te),!n&&t.jsx(Un,{label:St,children:t.jsx("span",{className:Le.icon,children:t.jsx(I.IconInfoFilled,{size:12})})})]}):null,[n]),zn=U(p).gt(0)&&N,aa=g.useMemo(()=>D?[{condition:!!D.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[qs(hn,"Fee deducted from the amount you receive"),qs(Ht,"Fee charged in addition to the amount you enter")]})},{condition:!zn&&!!In(D.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Le.description,children:In(D.estimated_route_duration_seconds)})},{condition:D.does_swap,title:"Slippage",content:t.jsxs("span",{className:Le.description,children:[t.jsxs("span",{children:[_,"%"]}),t.jsx(ln,{title:"Slippage tolerance",content:te=>t.jsx(Mp,{afterConfirm:te}),className:Le.edit,children:t.jsx(I.IconSettingFilled,{size:12})})]})}].filter(te=>te.condition):[],[Ht,hn,qs,D,zn,_]);return t.jsxs("form",{className:Le.form,onSubmit:mn,children:[t.jsx(uo,{selectButton:t.jsx(Ia,{type:"src"}),accountButton:b==="cosmos"&&t.jsx(ka,{type:"src"}),quantityInput:t.jsx(cn,{balance:M?.amount,decimals:C?.decimals}),balanceButton:t.jsx(pi,{onClick:()=>r("quantity",j.fromBaseUnit(M?.amount,{decimals:C?.decimals??0}),{shouldValidate:!0}),disabled:F,children:j.formatAmount(M?.amount??"0",{decimals:C.decimals})}),value:D?Z(D.usd_amount_in):"$-"}),t.jsxs("div",{className:Le.arrow,children:[t.jsx("div",{className:Le.divider}),t.jsx("button",{type:"button",className:Le.flip,onClick:()=>Ae(),children:t.jsx(I.IconChevronDown,{size:16})})]}),t.jsx(uo,{selectButton:t.jsx(Ia,{type:"dst"}),accountButton:t.jsx(ka,{type:"dst"}),quantityInput:t.jsx(cn.ReadOnly,{children:pn}),value:D?Z(D.usd_amount_out):"$-",hideNumbers:zn}),t.jsx(rn,{children:zn?t.jsxs(ts.Stack,{children:[t.jsx(ts,{label:"Fast",query:R,value:"default",onSelect:o,checked:s==="default"}),t.jsx(ts,{label:"Lossless",query:P,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(fe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(xe.Stack,{children:[D?.extra_infos?.map(te=>t.jsx(xe,{level:"info",children:te},te)),ee&&t.jsx(xe,{level:"info",children:ee}),Vn&&Wi&&t.jsx(xe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),D?.warning&&t.jsx(xe,{level:"warning",children:D.warning.message}),D?.extra_warnings?.map(te=>t.jsx(xe,{level:"warning",children:te},te))]}),t.jsx(rn,{children:aa.length>0&&t.jsx("div",{className:Le.meta,children:aa.map((te,St)=>t.jsxs("div",{className:Le.row,children:[t.jsx("span",{className:Le.title,children:te.title}),te.content]},St))})})]}),children:t.jsx(ne.White,{loading:me&&"Simulating...",disabled:!!Re,children:Re??"Preview route"})})]})},Qp=()=>{hi();const e=ur(),n=je(),{closeDrawer:s}=lt(),o=kt(),a=kl(),r=pe.useForm({mode:"onChange",defaultValues:a}),{watch:i,setValue:c}=r,{srcChainId:l,dstChainId:d,srcDenom:u,dstDenom:m,quantity:h,slippagePercent:p,recipient:f}=i();i((E,{name:$})=>{($==="srcChainId"||$==="srcDenom")&&c("quantity","",{shouldTouch:!1,shouldDirty:!1})});const _=di(),x=_(l),y=_(d),w=ui()(f,d);g.useEffect(()=>{c("cosmosWalletName",void 0),c("sender",x)},[l,x,c]),g.useEffect(()=>{w||c("recipient",y)},[y,w,c]);const v=os(l),C=os(d),k=g.useMemo(()=>{if(!v.find(E=>E.denom===u))return`${u} is not available for bridge/swap on ${l}`;if(!C.find(E=>E.denom===m))return`${m} is not available for bridge/swap on ${d}`},[C,d,m,v,l,u]);g.useEffect(()=>{k||(localStorage.setItem(oe.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(oe.BRIDGE_SRC_DENOM,u),localStorage.setItem(oe.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(oe.BRIDGE_DST_DENOM,m),localStorage.setItem(oe.BRIDGE_QUANTITY,h),localStorage.setItem(oe.BRIDGE_SLIPPAGE_PERCENT,p))},[l,u,d,m,h,p,k]);const S=e[0].path==="/bridge",M=()=>t.jsxs(t.Fragment,{children:[t.jsx(he,{error:!0,children:k}),t.jsx(fe,{children:S?t.jsx(ne.White,{onClick:s,children:"Close"}):t.jsx(ne.White,{onClick:()=>n(-1),children:"Go back"})})]}),{reminders:F}=un();return t.jsx(mt,{title:"Bridge/Swap",backButton:S?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(ne.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.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"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(li,{offset:0,disabled:F.length===0,children:t.jsx(ne.Small,{onClick:()=>n("/op/withdrawals"),disabled:!o,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:k?M():t.jsx(pe.FormProvider,{...r,children:t.jsx(de,{children:t.jsx(Hp,{})})})})},Gp="_button_1crvp_1",Yp="_checkbox_1crvp_11",Zp="_checked_1crvp_25",Zn={button:Gp,checkbox:Yp,checked:Zp},Jp=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:L(Zn.button,o),onClick:n,children:[t.jsx("div",{className:L(Zn.checkbox,{[Zn.checked]:e}),children:e&&t.jsx(I.IconCheck,{size:12})}),t.jsx("span",{className:Zn.label,children:s})]}),Xp="_button_aoxv2_1",ef={button:Xp},xi=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=tc.useInView();return g.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:ef.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(I.IconChevronDown,{size:12})]})};function yi(e,n){return e.reduce((s,o)=>{const a=n(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const ns=({chainId:e,txHash:n})=>`${oe.BRIDGE_HISTORY}:${e}:${n}`,cs=100,Sa=10;function ji(){const[e,n]=Ie.useLocalStorage(oe.BRIDGE_HISTORY,[]),s=g.useCallback((a,r)=>{localStorage.setItem(ns(a),JSON.stringify(r));for(const i of e.slice(cs-1))localStorage.removeItem(ns(i));n((i=[])=>[a,...i.slice(0,cs-1)])},[e,n]),o=g.useCallback(a=>{const r=localStorage.getItem(ns(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function bi(e){return Ie.useLocalStorage(ns(e),null)}async function tf(e,n){const s=V.create({prefixUrl:n}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function ho(e,n){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(A.path(["error","code"],c)!==4902)throw c;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function jt(){return Ke()}function nf(e,n){const{customFee:s,onCompleted:o}=n??{},a=je(),{showNotification:r,updateNotification:i,hideNotification:c}=Fo(),{addHistoryItem:l}=ji(),d=$n(),{route:u,values:m}=jt(),{srcChainId:h,sender:p,recipient:f,cosmosWalletName:_}=m,x=br(),{requestTxSync:y,submitTxSync:b,waitForTxConfirmation:w}=De(),{find:v}=Ns(),C=Tn(),k=En(),S=rt(h),M=kn(S),F=Hr(h),E=T.useQueryClient(),{registryUrl:$}=G(),N=Je(),{addReminder:R}=un(),P=tt();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const q=e.cosmos_tx.msgs.map(({msg_type_url:Pe,msg:Re})=>{if(!(Pe&&Re))throw new Error("Invalid transaction data");return k.fromAmino({type:sn.aminoConverters[Pe].aminoType,value:JSON.parse(Re)})});if(M==="initia"){const{srcDenom:Pe,quantity:Re}=m,{decimals:pn}=F(Pe),Vn=s?await b({messages:q,chainId:h,fee:s}):await y({messages:q,chainId:h,internal:1,spendCoins:[{denom:Pe,amount:j.toBaseUnit(Re,{decimals:pn})}]}),oa=w({txHash:Vn,chainId:h});return{txHash:Vn,wait:oa}}const D=v(_)?.getProvider();if(!D)throw new Error("Wallet not connected");const H=D.getOfflineSignerOnlyAmino(h),W=await Ve.SigningStargateClient.connectWithSigner(S.rpc,H,{registry:C,aminoTypes:k}),O=await W.getAllBalances(p),ee=S.fee_assets.find(Pe=>O.some(Re=>Re.denom===Pe.denom&&U(Re.amount).gt(0)));if(!ee){const Re=["Insufficient balance for fees.",`Available fee assets: ${S.fee_assets.map(pn=>F(pn.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:me,gas_price:Ae}=ee;if(!Ae)throw new Error(`Gas price not found for ${me}`);const We=await W.simulate(p,q,""),At=Ve.GasPrice.fromString(Ae.average+me),mn=Ve.calculateFee(Math.ceil(We*on),At),hn=await W.signAndBroadcastSync(p,q,mn),Ht=Tr({txHash:hn,client:W});return{txHash:hn,wait:Ht}}if("evm_tx"in e){const{chain_id:q,to:D,value:H,data:W}=e.evm_tx,O=await x(),ee=await O.getSigner();await ho(O,S);const me=await ee.sendTransaction({chainId:q,to:D,value:H,data:`0x${W}`});return{txHash:me.hash,wait:me.wait()}}throw new Error("Unlisted chain type")}catch(q){throw await _t(q)}},onSuccess:async({txHash:q,wait:D})=>{localStorage.removeItem(oe.BRIDGE_QUANTITY),o?o({txhash:q,chainId:h,timestamp:Date.now(),success:!0,route:u,values:m}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await D;const H=Qo(u)==="OP Bridge withdrawal",W=H?{success:!0,error:null}:await cf(P,q,h);if(!o&&!W.success&&W.error){const We=W.error instanceof Error?W.error.message:String(W.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${We}. The transaction may still be processing.`,autoHide:!0})}const O=W.success,me=af({txHash:q,srcChainId:h,route:u,values:m,recipient:f},O);l(me.tx,me.details),o||i(of(c));const Ae=Zs(m,q);if(d("Bridge Transaction Success",Ae),H){const We=rf(me.tx,u,f);R(me.tx,We)}}catch(H){const W=H instanceof Error?H.message:String(H);o?o({success:!1,error:W,route:u,values:m}):i({type:"error",title:"Transaction not confirmed",description:W});const O={...Zs(m,q),error:W};d("Bridge Confirmation Failed",O)}finally{E.invalidateQueries({queryKey:qe.balances(h,p).queryKey})}},onError:async q=>{const D=M==="initia"?await Zt(q,N(h),$):q;o?o({success:!1,error:D.message,route:u,values:m}):r({type:"error",title:"Transaction failed",description:D.message});const H=Zs(m);d("Bridge Transaction Failed",{...H,error:D.message})}})}function sf(){const e=tt(),n=X(),s=gs(),{route:o,values:a}=jt(),r=dt();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:j.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await tf(n,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:m,msg:h})=>sn.aminoTypes.fromAmino({type:sn.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await s(i,n,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=Nt.Tx.fromPartial({body:Nt.TxBody.decode(d.bodyBytes),authInfo:Nt.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:re.toBase64(Nt.Tx.encode(u).finish())}}catch(i){throw await _t(i)}}})}function of(e){return{type:"info",title:"Transaction submitted",description:g.createElement(g.Fragment,null,"Check ",g.createElement(nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Zs(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function af(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=Qo(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:n},isOpWithdraw:c}}function rf(e,n,s){return{...e,recipient:j.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function cf(e,n,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await _t(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function vi(e){const{chainId:n,txHash:s,tracked:o}=e,a=tt();return T.useQuery({queryKey:qe.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(r){throw await _t(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:z.INFINITY,enabled:!o})}function wi(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=tt();return T.useQuery({queryKey:qe.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:z.INFINITY})}var ss=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(ss||{});function Qo(e){const{operations:n,dest_asset_denom:s}=e;return A.has("op_init_transfer",A.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const lf="_success_t4dfk_1",df="_error_t4dfk_5",$a={success:lf,error:df},uf=({tx:e})=>{const[n,s]=bi(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=wi(n),a=n.state??mf(o);switch(g.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:$a.error,children:t.jsx(I.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:$a.success,children:t.jsx(I.IconCheckCircleFilled,{size:14})});default:return t.jsx(Kt,{size:14})}};function mf(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"}}const hf="_link_104m3_1",pf="_header_104m3_23",ff="_title_104m3_31",gf="_date_104m3_37",_f="_explorer_104m3_41",xf="_fees_104m3_57",yf="_label_104m3_65",jf="_content_104m3_69",bf="_route_104m3_75",vf="_row_104m3_80",wf="_asset_104m3_86",Cf="_amount_104m3_94",Nf="_chain_104m3_99",kf="_account_104m3_108",If="_arrow_104m3_115",be={link:hf,header:pf,title:ff,date:gf,explorer:_f,fees:xf,label:yf,content:jf,route:bf,row:vf,asset:wf,amount:Cf,chain:Nf,account:kf,arrow:If},Af=({tx:e})=>{const[n,s]=bi(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=n,{data:d}=vi(n),{address:u="",connector:m}=we.useAccount(),{find:h}=Ns();g.useEffect(()=>{d&&s(q=>{if(!q)throw new Error("Bridge history details not found");return{...q,tracked:!0}})},[s,d]);const{amount_in:p,amount_out:f,source_asset_chain_id:_,source_asset_denom:x,dest_asset_chain_id:y,dest_asset_denom:b,estimated_fees:w=[]}=r,v=rt(_),C=rt(y),k=it(x,_),S=it(b,y),M=(q,D)=>D?t.jsx(J,{src:D,width:12,height:12}):j.InitiaAddress.equals(q,u)?t.jsx(J,{src:m?.icon,width:12,height:12}):t.jsx(I.IconWallet,{size:12}),F=(q,{symbol:D,decimals:H,logo_uri:W},{chain_name:O,pretty_name:ee,...me},Ae,We)=>t.jsxs("div",{className:be.row,children:[t.jsx(ks,{assetLogoUrl:W,chainLogoUrl:me.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:j.formatAmount(q,{decimals:H})}),t.jsx("span",{children:D})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",ee||O]}),t.jsxs("div",{className:be.account,children:[We,t.jsx("span",{className:"monospace",children:j.truncate(Ae)})]})]})]})]}),E=Qo(r),$=g.useMemo(()=>{switch(E){case ss.SKIP:return"Skip Explorer";case ss.OP_WITHDRAW:return"Initia Scan"}},[E]),N=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[l?t.jsx(uf,{tx:e}):t.jsx(Kt,{size:14}),t.jsx("div",{className:be.date,children:Ze.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:$}),t.jsx(I.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[F(p,k,v,i.sender,M(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(I.IconArrowDown,{size:12})}),F(f,S,C,i.recipient,M(i.recipient))]}),w.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:Wo(w)})]})]});if(E===ss.OP_WITHDRAW)return t.jsx(Cs,{chainId:o,txHash:a,className:be.link,children:N});const R=new URLSearchParams({tx_hash:a,chain_id:o}),P=new URL(`?${R.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:P.toString(),className:be.link,target:"_blank",children:N})},Sf="_history_13u9z_1",$f="_header_13u9z_5",Tf="_checkbox_13u9z_9",Ef="_groups_13u9z_13",qf="_dateGroup_13u9z_21",Lf="_dateHeader_13u9z_26",Mf="_list_13u9z_32",qt={history:Sf,header:$f,checkbox:Tf,groups:Ef,dateGroup:qf,dateHeader:Lf,list:Mf},Df=()=>{const{initiaAddress:e,hexAddress:n}=De(),{history:s,getHistoryDetails:o}=ji(),a=s.filter(p=>o(p)),r=a.filter(p=>{const f=o(p);if(!f)return!1;const{values:_}=f,{sender:x,recipient:y}=_;return[x,y].some(b=>[e,n].includes(b))}),[i,c]=g.useState(1),[l,d]=Ie.useToggle(!r.length),u=l?a:r,m=u.slice(0,i*Sa),h=g.useMemo(()=>yi(m,p=>{const f=o(p);if(f)return new Date(f.timestamp)}),[m,o]);return t.jsx(mt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:qt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:qt.header,children:t.jsx(Jp,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:qt.checkbox})}),u.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:qt.groups,children:Object.entries(h).map(([p,f])=>t.jsxs("div",{className:qt.dateGroup,children:[t.jsx("div",{className:qt.dateHeader,children:p}),t.jsx("div",{className:qt.list,children:f.map(_=>t.jsx(de,{children:t.jsx(Af,{tx:_})},_.txHash))})]},p))}),u.length>i*Sa?t.jsx(xi,{onClick:()=>c(p=>p+1)}):s.length>=cs&&t.jsxs(he,{children:["Only the latest ",cs," items are stored. Older entries will be removed automatically."]})]})})},Go=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=nf(e,{customFee:n,onCompleted:s});return t.jsx(fe,{children:t.jsx(ne.White,{onClick:()=>r(),loading:i&&"Signing transaction...",disabled:!!a,children:a||o||"Confirm"})})},Pf="_content_1hzj2_1",Rf="_info_1hzj2_6",Bf="_arrow_1hzj2_11",Uf="_divider_1hzj2_19",Ff="_type_1hzj2_27",Of="_asset_1hzj2_47",Vf="_amount_1hzj2_55",zf="_lower_1hzj2_60",Kf="_chain_1hzj2_66",Wf="_address_1hzj2_72",Ue={content:Pf,info:Rf,arrow:Bf,divider:Uf,type:Ff,asset:Of,amount:Vf,lower:zf,chain:Kf,address:Wf},Ci=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=j.truncate(a),decimals:d=0,logo_uri:u=vo}=e,{chain_name:m,pretty_name:h,...p}=rt(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:Ue.arrow,children:[t.jsx("div",{className:Ue.divider}),s?t.jsx(Un,{label:s,children:t.jsx("button",{className:Ue.type,children:t.jsx(I.IconArrowDown,{size:12})})}):t.jsx("span",{className:Ue.type,children:t.jsx(I.IconArrowDown,{size:12})}),t.jsx("div",{className:Ue.divider})]}),t.jsxs("div",{className:Ue.content,children:[t.jsx(ks,{assetLogoUrl:u,chainLogoUrl:p.logo_uri??void 0}),t.jsxs("div",{className:Ue.info,children:[t.jsxs("div",{className:Ue.asset,children:[t.jsx("span",{className:Ue.amount,children:j.formatAmount(o,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:Ue.lower,children:[t.jsxs("div",{className:Ue.chain,children:["on ",h||m]}),i&&t.jsx(as,{value:i,children:({copy:f,copied:_})=>t.jsxs("button",{className:Ue.address,onClick:f,children:[c,_?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:j.truncate(i)})]})})]})]})]})]})},en=e=>{const n=it(e.denom,e.chainId);return t.jsx(Ci,{...e,...n})};en.Placeholder=Ci;const Hf="_root_1hbar_1",Qf="_flexEnd_1hbar_6",Gf="_toggle_1hbar_11",Yf="_route_1hbar_36",Zf="_content_1hbar_43",yn={root:Hf,flexEnd:Qf,toggle:Gf,route:Yf,content:Zf};function Jf(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":us.capitalCase(A.head(s?.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){const s=e.swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"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){const s=e.evm_swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"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 new Error("Unknown operation type")}const Xf=({addressList:e})=>{const{values:n,route:s}=jt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=A.zipObj(s.required_chain_addresses,e),{find:l}=Ns(),{connector:d,address:u=""}=we.useAccount(),[m,h]=Ie.useToggle(!1),p=i.length>1,f=t.jsx(J,{src:n.cosmosWalletName?l(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),_={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:f},x=C=>j.InitiaAddress.equals(C,u)?f:t.jsx(I.IconWallet,{size:11}),y=C=>{const{label:k,amount_out:S,denom:M,denom_out:F=M,chain_id:E,from_chain_id:$,to_chain_id:N=E??$}=C,R=c[N];return{label:p&&!m?void 0:k,amount:S,denom:F,chainId:N,address:R,walletIcon:x(R)}},b=i.map(Jf).map(y),w=b.slice(0,-1),v=b[b.length-1];return t.jsxs(Y.Collapsible.Root,{className:yn.root,open:m,onOpenChange:h,children:[p&&t.jsx("div",{className:yn.flexEnd,children:t.jsx(Y.Collapsible.Trigger,{className:yn.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(I.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(I.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:yn.route,children:[t.jsx(en,{..._,source:!0}),t.jsx(Y.Collapsible.Content,{className:yn.content,children:w.map((C,k)=>t.jsx(de,{suspenseFallback:t.jsx(en.Placeholder,{...C}),errorBoundaryProps:{fallback:t.jsx(en.Placeholder,{...C})},children:t.jsx(en,{...C})},k))}),t.jsx(en,{...v})]})]})},Ni=({error:e})=>{const n=je();return t.jsx(fe,{extra:t.jsx(xe,{level:"error",children:e.message}),children:t.jsx(ne.White,{onClick:()=>n("/bridge"),children:"Home"})})},Yo=({children:e})=>{const n=jt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:u}=De(),m=qn(),h=dt(),p=Pn(),f=h(r),_=p(f),x=a.slice(0,-1).some(S=>{const M=h(S);return p(M)==="cosmos"})&&_!=="cosmos",[y,b]=g.useState(void 0),[w,v]=g.useState(!1),[C,k]=g.useState(null);if(g.useEffect(()=>{(async()=>{try{if(!x)return;if(!m)throw new Error("Wallet not connected");v(!0),k(null);const[{pubkey:M}]=await m.getAccounts();b(M)}catch(M){k(await _t(M))}finally{v(!1)}})()},[x,m]),C)return t.jsx(Ni,{error:C});if(w)return t.jsx(fe,{children:t.jsx(ne.White,{loading:w&&"Generating intermediary addresses..."})});if(!x||y){const S=a.map((M,F)=>{if(F===a.length-1){const P=h(i);return p(P)==="initia"?j.InitiaAddress(l).bech32:l}const E=h(M),$=p(E),N=h(r),R=p(N);switch($){case"initia":return d;case"evm":return u;case"cosmos":{if(R==="cosmos")return re.toBech32(E.bech32_prefix,re.fromBech32(c).data);if(!y)throw new Error("Pubkey not found");return wn.pubkeyToAddress(wn.encodeSecp256k1Pubkey(y),E.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(S)}return null},Zo=({tx:e,children:n})=>{const s=br(),o=dt(),{data:a,isLoading:r}=T.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:m}=e.evm_tx,h=await s();await ho(h,o(u));const p=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async _=>{const{token_contract:x,spender:y}=_,w=await new gt.ethers.Contract(x,p,h).allowance(m,y);return{approval:_,currentAllowance:BigInt(w.toString())}}))).filter(({approval:_,currentAllowance:x})=>x<BigInt(_.amount)).map(({approval:_})=>_)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=T.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,m=await s(),h=await m.getSigner();await ho(m,o(u));for(const p of a){const{token_contract:f,spender:_,amount:x}=p,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new gt.ethers.Contract(f,y,h).approve(_,x)).wait()}return!0}catch(u){throw await _t(u)}}});return r?t.jsx(fe,{children:t.jsx(ne.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!c?t.jsx(fe,{extra:t.jsx(xe,{level:"error",children:d?.message}),children:t.jsx(ne.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):n},Jo=({addressList:e,signedOpHook:n,children:s})=>{const o=tt(),{route:a,values:r}=jt(),[i,c]=g.useState(void 0),[l,d]=g.useState(!1),[u,m]=g.useState(null);return g.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),m(null);const p={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:r.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:f}=await o.post("v2/fungible/msgs",{json:p}).json();if(!f||f.length===0)throw new Error("No transaction data found");const[_]=f;c(_)}catch(p){m(p)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),u?t.jsx(Ni,{error:u}):l||!i?t.jsx(fe,{children:t.jsx(ne.White,{loading:"Fetching messages..."})}):s(i)},Xo=({children:e})=>{const{route:n}=jt(),s=sf();return n.required_op_hook&&!s.data?t.jsx(fe,{extra:t.jsx(xe,{level:"error",children:s.error?.message}),children:t.jsx(ne.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},eg=()=>t.jsx(mt,{title:"Route preview",children:t.jsx(Yo,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Xf,{addressList:e}),t.jsx(Xo,{children:n=>t.jsx(Jo,{addressList:e,signedOpHook:n,children:s=>t.jsx(Zo,{tx:s,children:t.jsx(Go,{tx:s})})})})]})})}),ki=g.createContext(null);function As(){return g.useContext(ki)}const Wt=ye.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function Ss(){const{restUrl:e}=ie();return g.useMemo(()=>V.create({prefixUrl:e}),[e])}function tg(e){const n=Ss(),{data:s}=T.useSuspenseQuery({queryKey:Wt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:z.INFINITY});return s}const Ta=20;function ng(e){const n=X();return T.useSuspenseInfiniteQuery({queryKey:Wt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Ta,offset:s,order:"desc"},{withdrawals:a}=await V.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=A.last(s)?.sequence;return s.length<Ta||!o||o<=1?null:o-1},initialPageParam:0,staleTime:z.SECOND})}function sg(e){const n=Ss(),{data:s}=T.useSuspenseQuery({queryKey:Wt.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:z.SECOND});return s}function og({bridge_id:e,output_index:n}){const s=Ss(),{data:o}=T.useSuspenseQuery({queryKey:Wt.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:z.SECOND});return o}function ag({bridge_id:e,sequence:n}){const o=ue().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Je()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=T.useSuspenseQuery({queryKey:Wt.outputResponse(i,n).queryKey,queryFn:()=>V.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:z.SECOND});return c}function Ii(e,n){const{bridge_id:s}=e,o=Ss(),{data:a}=T.useSuspenseQuery({queryKey:Wt.withdrawalClaimed(s,n).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:z.SECOND});return a}function jn(e){return nc.sha3_256.create().update(e).digest()}function Js(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function Ai(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=Js(n.toString(),8),c=Js(s.toString(),8),l=Js(o.amount,8),d=Dt.concatBytes(i,c,jn(Dt.utf8ToBytes(a)),jn(Dt.utf8ToBytes(r)),jn(Dt.utf8ToBytes(o.denom)),l);return jn(jn(d))}const rg="_button_17r1o_1",ig="_claimed_17r1o_24",Ea={button:rg,claimed:ig},cg=()=>{const{withdrawalTx:e}=As(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,u=ie(),m=X(),{requestTxSync:h,waitForTxConfirmation:p}=De(),f=ag(e),_=re.toBase64(Ai(e)),x=Ii(e,_),y=T.useQueryClient(),{mutate:b,isPending:w}=T.useMutation({mutationFn:async()=>{if(!f)throw new Error("Output not found");const{last_block_hash:v}=f;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(re.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:re.fromBase64(d),storageRoot:re.fromBase64(i),lastBlockHash:re.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await p({chainId:u.chain_id,txHash:v}),y.invalidateQueries({queryKey:Wt.withdrawalClaimed(n,_).queryKey})}});return x?t.jsxs("div",{className:Ea.claimed,children:[t.jsx(I.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ea.button,onClick:()=>b(),disabled:w,children:"Claim"})},lg=({children:e})=>{const{withdrawalTx:n}=As(),s=tg(n.bridge_id),o=og(n),a=g.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ze.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},Si=1e3,dg=60,ug=60,mg=24,po=Si*dg,fo=po*ug,qa=fo*mg,hg=({date:e})=>{const n=g.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/qa),p=Math.floor(m%qa/fo),f=Math.floor(m%fo/po),_=Math.floor(m%po/Si);return{days:h,hours:p,minutes:f,seconds:_}},[e]),[s,o]=g.useState(n());g.useEffect(()=>{const d=window.setInterval(()=>{o(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return t.jsx(Un,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},pg="_container_1lz3w_1",fg="_title_1lz3w_5",La={container:pg,title:fg},gg=({date:e})=>t.jsxs("div",{className:La.container,children:[t.jsx("div",{className:La.title,children:"Claimable in"}),t.jsx(hg,{date:e})]}),_g="_container_1oldz_1",xg="_icon_1oldz_7",Ma={container:_g,icon:xg},yg="Withdrawal will begin within an hour",Da=()=>{const e=vs();return t.jsxs("div",{className:Ma.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Un,{label:yg,children:t.jsx("span",{className:Ma.icon,children:t.jsx(I.IconInfoFilled,{size:12})})})]})},jg=({children:e})=>{const{withdrawalTx:n}=As(),s=sg(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},bg=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=As(),a=re.toBase64(Ai(o)),r=Ii(o,a),{setReminder:i,removeReminder:c}=un();return g.useEffect(()=>{const l={chainId:s,txHash:o.tx_hash};r?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Ze.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),n},vg=()=>t.jsx(jg,{children:e=>e?t.jsx(Da,{}):t.jsx(lg,{children:n=>n?t.jsx(bg,{date:n,children:Ze.isFuture(n)?t.jsx(gg,{date:n}):t.jsx(cg,{})}):t.jsx(Da,{})})}),wg="_asset_6h8u2_1",Cg="_info_6h8u2_7",Ng="_symbol_6h8u2_11",Xs={asset:wg,info:Cg,symbol:Ng},kg=({amount:e,denom:n})=>{const s=ie(),o=or(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:Xs.asset,children:[t.jsx(J,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:Xs.info,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(e,{decimals:i})}),t.jsx("span",{className:Xs.symbol,children:a})]})]})},Ig="_item_km5w2_1",Ag={item:Ig},Sg=({chain:e})=>{const n=e.metadata?.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=ng(n),i=g.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=un();return g.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:Ag.item,children:[t.jsx(kg,{...d}),t.jsx(de,{suspenseFallback:null,children:t.jsx(ki.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(vg,{})})})]},l.sequence)}),a&&t.jsx(xi,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},$g="_content_dj1qm_1",Tg="_title_dj1qm_5",Pa={content:$g,title:Tg},Eg=()=>{const{chainId:e}=Ke(),n=ue(),s=Ot(),[o,a]=g.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Je(),{reminders:i}=un(),c=o?r(o):void 0;return t.jsxs(mt,{title:"OP Bridge withdrawals",children:[t.jsx(Bt,{chains:n.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:Pa.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Pa.title,children:c.name}),t.jsx(de,{children:t.jsx(Sg,{chain:c})},o)]}):t.jsx(xe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},qg="_page_1g5uz_1",Lg="_title_1g5uz_11",Mg="_scrollable_1g5uz_18",Dg="_list_1g5uz_24",Pg="_item_1g5uz_35",Rg="_name_1g5uz_59",Bg="_dimmed_1g5uz_67",Ug="_recent_1g5uz_71",Fg="_installed_1g5uz_72",He={page:qg,title:Lg,scrollable:Mg,list:Dg,item:Pg,name:Rg,dimmed:Bg,recent:Ug,installed:Fg},Og=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Ra=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=we.useConnect(),o=Ie.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=g.useState(null),{mutate:i,isPending:c}=T.useMutation({mutationFn:async l=>{r(l.id);try{await s({connector:l})}catch(d){throw await _t(d)}},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:He.page,children:[t.jsx("h1",{className:He.title,children:"Connect wallet"}),t.jsx(ut,{className:He.scrollable,children:t.jsxs("div",{className:He.list,children:[n.toSorted(A.descend(l=>l.id===o)).map(l=>{const{name:d,icon:u,id:m}=l;return t.jsxs("button",{className:He.item,onClick:()=>i(l),disabled:c,children:[t.jsx(J,{src:u,width:24,height:24}),t.jsx("span",{className:He.name,children:d}),a===m?t.jsx(Kt,{size:16}):o===m?t.jsx("span",{className:He.recent,children:"Recent"}):l.id===ms.id?null:t.jsx("span",{className:He.installed,children:"Installed"})]},m)}),Og.filter(({name:l})=>!n.some(d=>d.name.includes(l))).map(({name:l,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${l}.webp`;return t.jsxs("a",{href:d,className:He.item,target:"_blank",children:[t.jsx(J,{src:u,width:24,height:24}),t.jsx("span",{className:L(He.name,He.dimmed),children:l}),t.jsx(I.IconExternalLink,{size:10})]},l)})]})})]})},Vg=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),$i=({tx:e,children:n})=>{const{values:s}=jt(),{srcChainId:o}=s,a=X(),r=En(),i=Ao(),{data:c,isLoading:l}=T.useQuery({queryKey:Vg.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const u=e.cosmos_tx.msgs.map(({msg_type_url:p,msg:f})=>{if(!(p&&f))throw new Error("Invalid transaction data");return r.fromAmino({type:sn.aminoConverters[p].aminoType,value:JSON.parse(f)})});return{estimatedGas:await(await i(o)).simulate(a,u,""),messages:u}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(l)return t.jsx(fe,{children:t.jsx(ne.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})};function On(){const e=tt(),n=Vt(),s=X(),o=Rn(),a=Object.fromEntries(o.filter(({chain_type:r,bech32_prefix:i})=>r==="evm"||r==="cosmos"&&i==="init").map(r=>[r.chain_id,{address:r.chain_type==="evm"?n:s,denoms:[]}]));return T.useQuery({queryKey:qe.allBalances(Object.keys(a),[n,s]).queryKey,queryFn:()=>e.post("v2/info/balances",{json:{chains:a}}).json(),select:({chains:r})=>r?Object.fromEntries(Object.entries(r).map(([i,{denoms:c}])=>[i,c||{}])):{},enabled:!!s,staleTime:z.SECOND})}function $s(){const{localOptions:e=[]}=Ke();return zt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function Ts(){const n=et()==="/withdraw",s=zt(),{watch:o}=nt(),{dstChainId:a,dstDenom:r,srcChainId:i,srcDenom:c}=o(),l=n?i:a,d=n?c:r;return s.find(({denom:u,chain_id:m})=>d===u&&m===l)||null}function Ti(){const n=et()==="/withdraw",s=zt(),{watch:o}=nt(),{srcChainId:a,srcDenom:r,dstChainId:i,dstDenom:c}=o(),l=n?i:a,d=n?c:r;return s.find(({denom:u,chain_id:m})=>d===u&&m===l)||null}function zg(){const n=et()==="/withdraw",s=zt(),o=dt(),{data:a,isLoading:r}=On(),{remoteOptions:i=[]}=Ke(),c=Ts();return c?{data:s.filter(({symbol:d,denom:u,chain_id:m})=>i.length?i.some(h=>h.denom===u&&h.chainId===m):d===c.symbol).map(d=>{if(d.hidden||d.chain_id===c.chain_id)return null;const u=o(d.chain_id);if(!u||u.chain_type==="cosmos"&&u.bech32_prefix!=="init")return null;const m=a?.[u.chain_id]?.[d.denom];return!n&&(!m||!Number(m.amount))?null:{asset:d,chain:u,balance:m}}).filter(d=>d!==null),isLoading:r}:{data:[],isLoading:r}}function nt(){return pe.useFormContext()}const Kg="_container_eg177_1",Wg="_back_eg177_6",Hg="_title_eg177_18",Qg="_divider_eg177_26",Gg="_label_eg177_30",Yg="_asset_eg177_37",Zg="_assetIcon_eg177_55",Jg="_chainIcon_eg177_67",Xg="_assetName_eg177_80",e_="_chevron_eg177_92",t_="_input_eg177_96",n_="_balanceContainer_eg177_108",s_="_value_eg177_116",o_="_maxButton_eg177_126",a_="_detail_eg177_142",r_="_detailsContainer_eg177_153",i_="_detailsButton_eg177_163",c_="_detailValue_eg177_180",l_="_detailToken_eg177_190",d_="_minimumReceived_eg177_198",B={container:Kg,back:Wg,title:Hg,divider:Qg,label:Gg,asset:Yg,assetIcon:Zg,chainIcon:Jg,assetName:Xg,chevron:e_,input:t_,balanceContainer:n_,value:s_,maxButton:o_,detail:a_,detailsContainer:r_,detailsButton:i_,detailValue:c_,detailToken:l_,minimumReceived:d_},Ei=({renderFee:e})=>{const{route:n}=Ke(),{values:s}=jt(),{dstDenom:o,dstChainId:a}=s,i=zt().find(({denom:p,chain_id:f})=>p===o&&f===a),c=X(),l=Xr(),[d,u]=Ie.useToggle(!1),m=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const h=n.does_swap?BigInt(n.amount_out||n.estimated_amount_out)*BigInt(1e4-Number(s.slippagePercent)*100)/BigInt(1e4):BigInt(n.amount_out||n.estimated_amount_out);return t.jsx(rn,{children:t.jsxs("div",{className:B.detailsContainer,children:[t.jsxs("button",{className:B.detailsButton,onClick:u,children:["Transaction details"," ",t.jsx(I.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&t.jsxs(t.Fragment,{children:[n.does_swap&&t.jsxs("div",{className:B.detail,children:[t.jsx("p",{className:B.detailLabel,children:"Slippage"}),t.jsxs("p",{className:B.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:B.detail,children:[t.jsx("p",{className:B.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:B.detailValue,children:Wo(n.estimated_fees)})]}),e&&t.jsxs("div",{className:B.detail,children:[t.jsx("p",{className:B.detailLabel,children:"Tx fee"}),t.jsx("div",{className:B.detailValue,children:e()})]}),c&&t.jsxs("div",{className:B.detail,children:[t.jsx("p",{className:B.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:B.detailValue,children:[t.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",j.truncate(c)]})]})]}),t.jsxs("div",{className:B.detail,children:[t.jsx("p",{className:B.detailLabel,children:"Estimated time"}),t.jsx("p",{className:L(B.detailValue),style:m?{color:"var(--warning)"}:void 0,children:In(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:L(B.detail,B.minimumReceived),children:[t.jsx("p",{className:B.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:B.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:B.detailToken})," ",j.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]})})},u_="_trigger_1c7d7_1",m_="_item_1c7d7_5",h_="_itemText_1c7d7_13",p_={trigger:u_,item:m_,itemText:h_},f_=({tx:e,gas:n})=>{const a=et().startsWith("/withdraw")?"Withdraw":"Deposit",{setValue:r}=nt(),i=P=>{r("page","completed"),r("result",P)},{values:c}=jt(),{srcChainId:l,srcDenom:d,quantity:u}=c,h=zt().find(({denom:P,chain_id:q})=>P===d&&q===l),p=Xe(l),f=Sn(p),_=Oo(p),x=Vo(p),y=ct(p),b=n&&"cosmos_tx"in e?_.map(({amount:P,denom:q})=>Ve.calculateFee(Math.ceil(n*on),Ve.GasPrice.fromString(P+q))):null,w=b?.map(P=>P.amount[0])??[],v=P=>{const q=f.find(Ae=>Ae.denom===P)?.amount??"0",D=w.find(Ae=>Ae.denom===P)?.amount??"0",H=h&&d===P?U(u||"0").times(U(10).pow(h.decimals)).toFixed(0):"0",W=U(D).plus(H),O=U(q).gte(W),{symbol:ee,decimals:me}=y(P);return{symbol:ee,decimals:me,spend:U(H).gt(0)?H:null,fee:D,total:W.toFixed(),balance:q,isSufficient:O}},C=()=>{if(!w.length)return null;if(x&&v(x).isSufficient)return x;for(const{denom:P}of w)if(v(P).isSufficient)return P;return w[0]?.denom},[k,S]=g.useState(C),M=b?.find(P=>P.amount[0].denom===k)??void 0,F=k?v(k):null,E=F&&!F.isSufficient?"Insufficient balance":void 0,$=(P,q)=>{if(j.formatAmount(P,{decimals:q})==="0.000000")return 8},N=P=>{const[{amount:q,denom:D}]=P.amount;if(U(q).isZero())return"0";const{symbol:H,decimals:W}=y(D),O=$(q,W);return`${j.formatAmount(q,{decimals:W,dp:O})} ${H}`},R=()=>{if(!b||b.length===0)return null;if(b.length===1)return t.jsx("span",{className:"monospace",children:N(b[0])});if(!M||!k)return null;const P=b.map(O=>{const[{denom:ee}]=O.amount,{symbol:me}=y(ee);return{value:ee,label:N(O),triggerLabel:me}}),[{amount:q,denom:D}]=M.amount,{decimals:H}=y(D),W=$(q,H);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:j.formatAmount(q,{decimals:H,dp:W})}),t.jsx(zo,{options:P,value:k,onChange:S,classNames:p_})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Ei,{renderFee:b&&b.length>0?R:void 0}),t.jsx(Zo,{tx:e,children:t.jsx(Go,{tx:e,fee:M,onCompleted:i,confirmMessage:a,error:E})})]})},qi=({tx:e,gas:n})=>{const s=et(),{setValue:o}=nt(),a=c=>{o("page","completed"),o("result",c)},i=s.startsWith("/withdraw")?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsxs(t.Fragment,{children:[t.jsx(Ei,{}),t.jsx(Zo,{tx:e,children:t.jsx(Go,{tx:e,fee:void 0,onCompleted:a,confirmMessage:i})})]}):t.jsx(f_,{tx:e,gas:n})},g_=()=>{const e=je(),n=Ke(),s=$s(),o=dt(),{data:a}=On(),r=Vt(),{watch:i,setValue:c,getValues:l}=nt(),{srcDenom:d,srcChainId:u,quantity:m}=i(),h=Ts(),p=Ti(),f=u?o(u):null,_=a?.[u]?.[d]?.amount,x=a?.[u]?.[d]?.price||0,y=Number(x)*Number(m||0),[b]=Ie.useDebounceValue(Number(m),300),w=g.useMemo(()=>{if(!p)return"Select asset";if(!Number(m))return"Enter amount";if(Number(m)>Number(j.fromBaseUnit(_,{decimals:p?.decimals||6})))return"Insufficient balance"},[m,_,p]),{data:v,error:C}=is(b.toString(),{disabled:!!w}),k=g.useEffectEvent(()=>{e(0,{...n,route:v,values:{sender:r,recipient:n.recipientAddress?j.InitiaAddress(n.recipientAddress).hex:r,slippagePercent:"1",...l()}})});return g.useEffect(()=>{k()},[v,r]),!h||!p?null:t.jsxs("div",{className:B.container,children:[s.length>1&&t.jsx("button",{className:B.back,onClick:()=>{c("quantity",""),c("srcDenom",""),c("srcChainId",""),c("page","select-external")},children:t.jsx(I.IconBack,{size:20})}),t.jsxs("h3",{className:B.title,children:["Deposit ",h.symbol]}),t.jsx("p",{className:B.label,children:"From"}),t.jsxs("button",{className:B.asset,onClick:()=>{c("page","select-external")},children:[t.jsx("div",{className:B.assetIcon,children:!!p&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:p?.logo_uri,alt:p.symbol}),t.jsx("img",{src:f?.logo_uri||"",alt:f?.pretty_name,className:B.chainIcon})]})}),t.jsx("p",{className:B.assetName,children:p?t.jsxs(t.Fragment,{children:[p.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",f?.pretty_name]})]}):"Select asset"}),t.jsx(I.IconChevronDown,{className:B.chevron,size:16})]}),t.jsx("div",{className:B.divider}),t.jsx("p",{className:B.label,children:"Amount"}),t.jsx(cn,{balance:_,decimals:p?.decimals||6,className:B.input}),_&&t.jsxs("div",{className:B.balanceContainer,children:[t.jsx("p",{className:B.value,children:y?Z(y):"$-"}),t.jsxs("button",{className:B.maxButton,onClick:()=>{const S=j.fromBaseUnit(_,{decimals:p?.decimals||6});Number(m)!==Number(S)&&c("quantity",S)},children:[t.jsx(I.IconWallet,{size:16})," ",j.formatAmount(_,{decimals:p?.decimals||6})," ",t.jsx("span",{children:"MAX"})]})]}),!n.route||w?t.jsx(fe,{children:t.jsx(ne.White,{type:"submit",loading:!C&&!w&&"Fetching route...",disabled:!0,fullWidth:!0,children:C?"No route found":w})}):t.jsx(Yo,{children:S=>t.jsx(Xo,{children:M=>t.jsx(Jo,{addressList:S,signedOpHook:M,children:F=>t.jsx($i,{tx:F,children:E=>t.jsx(qi,{tx:F,gas:E})})})})})]})},__="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",x_="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",y_="_container_uxgnj_1",j_="_title_uxgnj_5",b_="_close_uxgnj_12",v_="_emptyIcon_uxgnj_24",w_="_empty_uxgnj_24",C_="_list_uxgnj_51",N_="_asset_uxgnj_66",k_="_placeholder_uxgnj_82",I_="_activeAsset_uxgnj_95",A_="_iconContainer_uxgnj_99",S_="_assetIcon_uxgnj_109",$_="_chainIcon_uxgnj_119",T_="_assetPlaceholder_uxgnj_133",E_="_assetName_uxgnj_154",q_="_assetChain_uxgnj_169",L_="_balance_uxgnj_177",M_="_value_uxgnj_186",le={container:y_,title:j_,close:b_,emptyIcon:v_,empty:w_,list:C_,asset:N_,placeholder:k_,activeAsset:I_,iconContainer:A_,assetIcon:S_,chainIcon:$_,assetPlaceholder:T_,assetName:E_,assetChain:q_,balance:L_,value:M_},Li=()=>{const e=et(),{data:n,isLoading:s}=zg(),{setValue:o,watch:a}=nt(),r=Ts(),i=$s(),{theme:c}=G(),{srcDenom:l,srcChainId:d,dstDenom:u,dstChainId:m}=a(),h=e==="/withdraw",p=h?"dstDenom":"srcDenom",f=h?"dstChainId":"srcChainId";function _(){const b=(h?u:l)&&(h?m:d);return!b&&i.length<=1&&!h?null:t.jsx("button",{className:le.close,onClick:()=>{h||b?o("page","fields"):o("page","select-local")},children:t.jsx(I.IconBack,{size:20})})}return r?!s&&!n.length?t.jsxs("div",{className:le.container,children:[_(),t.jsx("h4",{className:le.title,children:"No available assets"}),t.jsx("img",{src:c==="dark"?__:x_,alt:"No assets",className:le.emptyIcon}),t.jsxs("p",{className:le.empty,children:["You do not have supported assets to deposit ",r.symbol,"."]})]}):t.jsxs("div",{className:le.container,children:[_(),t.jsxs("h4",{className:le.title,children:[h?"Select destination":`Deposit ${r.symbol}`," "]}),t.jsxs("div",{className:le.list,children:[s&&Array.from({length:5}).map((x,y)=>t.jsxs("div",{className:L(le.asset,le.placeholder),children:[t.jsxs("div",{className:le.iconContainer,children:[t.jsx("div",{className:le.assetIcon}),t.jsx("div",{className:le.chainIcon})]}),t.jsx("div",{className:le.assetPlaceholder})]},y)),!s&&n.sort(({balance:x},{balance:y})=>Number(y?.value_usd??0)-Number(x?.value_usd??0)).map(({asset:x,chain:y,balance:b})=>{const w=h?u:l,v=h?m:d,C=w===x.denom&&v===y.chain_id;return t.jsxs("button",{className:L(le.asset,C&&le.activeAsset),onClick:()=>{o(p,x.denom),o(f,y.chain_id),h||o("quantity",""),o("page","fields")},children:[t.jsxs("div",{className:le.iconContainer,children:[t.jsx("img",{src:x.logo_uri,alt:x.symbol,className:le.assetIcon}),t.jsx("img",{src:y.logo_uri||"",alt:y.chain_name,className:le.chainIcon})]}),t.jsxs("p",{className:le.assetName,children:[x.symbol," ",C&&t.jsx("span",{children:t.jsx(I.IconCheck,{size:16})})]}),t.jsxs("p",{className:le.assetChain,children:["on ",y.pretty_name]}),b&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:le.balance,children:j.formatAmount(b.amount,{decimals:b.decimals||6})}),t.jsx("p",{className:le.value,children:Z(b.value_usd||0)})]})]},`${x.chain_id}-${x.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},D_="_title_9ovji_1",P_="_list_9ovji_7",R_="_asset_9ovji_15",eo={title:D_,list:P_,asset:R_},Mi=()=>{const e=et(),{setValue:n}=nt(),s=$s(),o=e==="/withdraw",a=o?"srcDenom":"dstDenom",r=o?"srcChainId":"dstChainId",i=o?"dstDenom":"srcDenom",c=o?"dstChainId":"srcChainId",l=(u,m)=>{n(a,u),n(r,m),n("quantity",""),n(i,""),n(c,""),n("page",o?"fields":"select-external")},d=g.useEffectEvent(()=>{const{denom:u,chain_id:m}=s[0];l(u,m)});return g.useEffect(()=>{s.length===1&&d()},[s]),s.length===1?t.jsx("div",{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:eo.title,children:o?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:eo.list,children:s.map(({denom:u,chain_id:m,symbol:h,logo_uri:p})=>t.jsxs("button",{className:eo.asset,onClick:()=>l(u,m),children:[t.jsx("img",{src:p,alt:h}),h]},`${u}-${m}`))})]})},B_="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",U_="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",F_="_container_9k4hs_1",O_="_title_9k4hs_8",V_="_subtitle_9k4hs_14",z_="_linkContainer_9k4hs_30",K_="_link_9k4hs_30",W_="_separator_9k4hs_51",H_="_errorIcon_9k4hs_62",Q_="_error_9k4hs_62",ve={container:F_,title:O_,subtitle:V_,linkContainer:z_,link:K_,separator:W_,errorIcon:H_,error:Q_};function G_(e){if(!e)return"pending";const n=e.state;return n==="STATE_COMPLETED_SUCCESS"?"success":n==="STATE_ABANDONED"||n==="STATE_COMPLETED_ERROR"||n==="STATE_PENDING_ERROR"?"failed":"pending"}function ls({type:e}){const{closeModal:n}=dn(),{theme:s}=G(),{watch:o}=nt(),{result:a}=o(),{openDrawer:r}=lt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:m}=a,{srcDenom:h,srcChainId:p,quantity:f}=m,_=it(h,p),x=e==="deposit"?"Deposit":"Withdraw",{data:y}=vi({chainId:l,txHash:c,tracked:!1}),{data:b}=wi({chainId:l,txHash:c,tracked:!!y,timestamp:d,route:u}),w=G_(b),v=s==="dark"?B_:U_,C=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:ve.container,children:[t.jsxs("h3",{className:ve.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:ve.errorIcon}),t.jsx("p",{className:ve.error,children:a?.error}),t.jsx(ne.White,{fullWidth:!0,onClick:n,children:"Close"})]});const S=In(u.estimated_route_duration_seconds),M=new URLSearchParams({tx_hash:c,chain_id:l}),F=new URL(`?${M.toString()}`,"https://explorer.skip.build"),E=()=>t.jsxs("div",{className:ve.linkContainer,children:[t.jsx("a",{href:F.toString(),target:"_blank",rel:"noopener noreferrer",className:ve.link,children:"View transaction"}),t.jsx("div",{className:ve.separator}),t.jsx("button",{className:ve.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:ve.container,children:[w==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",f," ",_.symbol]}),t.jsx("video",{src:C,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:ve.subtitle,children:["Estimated time: ",t.jsx("span",{children:S})]}),E(),t.jsx("p",{className:ve.subtitle,children:"Your transaction will continue even if you close this"})]}),w==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[x," complete"]}),t.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:$=>{const N=$.currentTarget;N.duration-N.currentTime<.1&&N.pause()}}),E(),t.jsx(ne.White,{fullWidth:!0,onClick:n,children:"Close"})]}),w==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:ve.errorIcon}),t.jsx("p",{className:ve.error,children:"Your transaction could not be completed"}),t.jsx(ne.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const Y_="_container_7nl9j_1",Z_="_page_7nl9j_5",Ba={container:Y_,page:Z_},J_=()=>{const e=pe.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:""}});return On(),t.jsx(pe.FormProvider,{...e,children:t.jsx(X_,{})})},X_=()=>{const{watch:e}=nt(),n=e("page"),s=ze.useTransition(n,{keys:n,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),o=a=>{switch(a){case"select-local":return t.jsx(Mi,{});case"select-external":return t.jsx(Li,{});case"fields":return t.jsx(g_,{});case"completed":return t.jsx(ls,{type:"deposit"})}};return t.jsx(rn,{children:t.jsx("div",{className:Ba.container,children:s((a,r)=>t.jsx(ze.animated.div,{style:a,className:Ba.page,children:o(r)}))})})},ex=()=>{const e=je(),n=Ke(),s=$s(),o=dt(),{data:a}=On(),r=Vt(),{watch:i,setValue:c,getValues:l}=nt(),{srcChainId:d,srcDenom:u,dstChainId:m,quantity:h}=i(),p=Ts(),f=Ti(),_=a?.[d]?.[u]?.amount,x=a?.[d]?.[u]?.price||0,y=Number(x)*Number(h||0),[b]=Ie.useDebounceValue(Number(h),300),w=g.useMemo(()=>{if(!Number(h))return"Enter amount";if(Number(h)>Number(j.fromBaseUnit(_,{decimals:p?.decimals||6})))return"Insufficient balance";if(!f)return"Select destination"},[h,_,f,p]),{data:v,error:C}=is(b.toString(),{disabled:!!w}),k=g.useEffectEvent(()=>{e(0,{...n,route:v,values:{sender:r,recipient:n.recipientAddress?j.InitiaAddress(n.recipientAddress).hex:r,slippagePercent:"1",...l()}})});return g.useEffect(()=>{k()},[v,r]),p?t.jsxs("div",{className:B.container,children:[s.length>1&&t.jsx("button",{className:B.back,onClick:()=>{c("dstDenom",""),c("dstChainId",""),c("quantity",""),c("srcDenom",""),c("srcChainId",""),c("page","select-local")},children:t.jsx(I.IconBack,{size:20})}),t.jsxs("h3",{className:B.title,children:["Withdraw ",p.symbol]}),t.jsx("p",{className:B.label,children:"Amount"}),t.jsx(cn,{balance:_,decimals:p?.decimals||6,className:B.input}),_&&t.jsxs("div",{className:B.balanceContainer,children:[t.jsx("p",{className:B.value,children:y?Z(y):"$-"}),t.jsxs("button",{className:B.maxButton,onClick:()=>{const S=j.fromBaseUnit(_,{decimals:p?.decimals||6});Number(h)!==Number(S)&&c("quantity",S)},children:[t.jsx(I.IconWallet,{size:16})," ",j.formatAmount(_,{decimals:p?.decimals||6})," ",t.jsx("span",{children:"MAX"})]})]}),t.jsx("div",{className:B.divider}),t.jsx("p",{className:B.label,children:"Destination"}),t.jsxs("button",{className:B.asset,onClick:()=>{c("page","select-external")},children:[t.jsx("div",{className:B.assetIcon,children:f?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:f?.logo_uri,alt:f.symbol}),t.jsx("img",{src:o(m)?.logo_uri||"",alt:o(m)?.pretty_name,className:B.chainIcon})]}):t.jsx("div",{className:B.chainIcon})}),t.jsx("p",{className:B.assetName,children:f?t.jsxs(t.Fragment,{children:[f.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",o(m)?.pretty_name]})]}):"Select chain"}),t.jsx(I.IconChevronDown,{className:B.chevron,size:16})]}),!n.route||w?t.jsx(fe,{children:t.jsx(ne.White,{type:"submit",loading:!C&&!w&&"Fetching route...",disabled:!0,fullWidth:!0,className:B.submit,children:C?"No route found":w})}):t.jsx(Yo,{children:S=>t.jsx(Xo,{children:M=>t.jsx(Jo,{addressList:S,signedOpHook:M,children:F=>t.jsx($i,{tx:F,children:E=>t.jsx(qi,{tx:F,gas:E})})})})})]}):null},tx="_container_7nl9j_1",nx="_page_7nl9j_5",Ua={container:tx,page:nx},sx=()=>{const e=pe.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:""}});return On(),t.jsx(pe.FormProvider,{...e,children:t.jsx(ox,{})})},ox=()=>{const{watch:e}=nt(),n=e("page"),s=ze.useTransition(n,{keys:n,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),o=a=>{switch(a){case"select-local":return t.jsx(Mi,{});case"select-external":return t.jsx(Li,{});case"fields":return t.jsx(ex,{});case"completed":return t.jsx(ls,{type:"withdraw"})}};return t.jsx(rn,{children:t.jsx("div",{className:Ua.container,children:s((a,r)=>t.jsx(ze.animated.div,{style:a,className:Ua.page,children:o(r)}))})})},ax="_root_1lo0i_1",rx="_address_1lo0i_9",ix="_copy_1lo0i_19",cx="_labelWrapper_1lo0i_33",lx="_labelCopy_1lo0i_43",dx="_labelCopied_1lo0i_47",ux="_copied_1lo0i_55",mx="_derived_1lo0i_65",hx="_derivedLabel_1lo0i_79",px="_derivedAddress_1lo0i_83",fx="_hexAddress_1lo0i_89",gx="_derivedCopy_1lo0i_94",Se={root:ax,address:rx,copy:ix,labelWrapper:cx,labelCopy:lx,labelCopied:dx,copied:ux,derived:mx,derivedLabel:hx,derivedAddress:px,hexAddress:fx,derivedCopy:gx},_x=()=>{const e=g.useRef(null),n=g.useRef(null),{initiaAddress:s,hexAddress:o}=De(),a=Zr("--gray-0");return g.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new sc({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),n.current.append(e.current)))},[s,a]),t.jsx(mt,{title:"Receive",children:t.jsxs("div",{className:Se.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:Se.address,children:s}),t.jsx(as,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(Se.copy,{[Se.copied]:i}),onClick:r,children:[t.jsx(I.IconCopy,{size:12}),t.jsxs("div",{className:Se.labelWrapper,children:[t.jsx("span",{className:Se.labelCopy,children:"Copy address"}),t.jsx("span",{className:Se.labelCopied,children:"Copied!"})]})]})}),t.jsx(as,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(Se.derived,{[Se.copied]:i}),onClick:r,children:[t.jsx("span",{className:Se.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:Se.derivedAddress,children:[t.jsx("span",{className:Se.hexAddress,children:j.truncate(o)}),t.jsx(I.IconCopy,{size:12,className:Se.derivedCopy}),i&&t.jsx("span",{className:Se.copiedText,children:"Copied!"})]})]})})]})})};function xx(){const e=X(),n=ue();return T.useQueries({queries:n.map(s=>({queryKey:Nn.grants(s.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await V.create({prefixUrl:s.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:s.chainId,grants:o}},enabled:!!e,staleTime:z.SECOND,retry:!1}))})}const yx="_countdown_vfms8_1",jx={countdown:yx},bx=({expiration:e})=>{const n=()=>{const a=new Date,r=Ze.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(c>0||i>0)&&u.push(`${c}h`),(l>0||c>0||i>0)&&u.push(`${l}m`),u.push(`${d}s`),u.join(" ")},[s,o]=g.useState(n());return Ie.useInterval(()=>{o(n())},1e3),Ze.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:jx.countdown,children:s})]})},vx="_container_1l528_1",wx="_info_1l528_11",Cx="_header_1l528_17",Nx="_chainName_1l528_23",kx="_expiration_1l528_29",Ix="_revokeButton_1l528_35",Yt={container:vx,info:wx,header:Cx,chainName:Nx,expiration:kx,revokeButton:Ix},Ax=({chainId:e,grantee:n,messageTypes:s,expiration:o})=>{const a=Xe(e),{mutate:r,isPending:i}=qr({grantee:n,internal:!0});return t.jsxs("div",{className:Yt.container,children:[t.jsxs("div",{className:Yt.info,children:[t.jsxs("div",{className:Yt.header,children:[t.jsx(J,{src:a.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:Yt.chainName,children:a.name})]}),t.jsx("div",{className:Yt.expiration,children:o?t.jsx(bx,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:Yt.revokeButton,onClick:()=>r(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},Sx=({chainId:e,grants:n})=>Object.values(n.reduce((o,a)=>{const r=o[a.grantee];return r?{...o,[a.grantee]:{...r,messageTypes:[...r.messageTypes,a.authorization.msg],expiration:$o([r.expiration,a.expiration?new Date(a.expiration):void 0])}}:{...o,[a.grantee]:{grantee:a.grantee,messageTypes:[a.authorization.msg],expiration:a.expiration?new Date(a.expiration):void 0}}},{})).map(o=>g.createElement(Ax,{...o,chainId:e,key:o.grantee})),$x="_content_q36qs_1",Tx={content:$x},Ex=()=>{const e=xx(),n=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?t.jsx(he,{children:"No permissions found"}):t.jsx("div",{className:Tx.content,children:s.map(({chainId:o,grants:a})=>t.jsx(Sx,{chainId:o,grants:a},o))})};return t.jsx(mt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},qx="2.2.3",Lx="_version_1sf5y_1",Mx={version:Lx},Dx=()=>t.jsxs("aside",{className:Mx.version,children:["v",qx]}),Px="_link_se23z_1",Rx="_title_se23z_17",Bx="_subtitle_se23z_23",Ux="_icon_se23z_30",Jn={link:Px,title:Rx,subtitle:Bx,icon:Ux},Di=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:Jn.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:Jn.title,children:e}),n&&t.jsx("p",{className:Jn.subtitle,children:n})]}),t.jsx("div",{className:Jn.icon,children:s??t.jsx(I.IconChevronRight,{size:16})})]}),Fx="https://export.initia.xyz/",Ox=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Di,{title:"Export private key",rightSection:t.jsx(I.IconExternalLink,{size:16}),onClick:()=>window.open(Fx,"_blank",e)})},Vx="_container_1vxr7_1",zx="_separator_1vxr7_7",Fa={container:Vx,separator:zx},Kx=()=>{const e=je(),{connector:n}=we.useAccount();return t.jsx(mt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Fa.container,children:[t.jsx(Di,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===jo&&t.jsx(Ox,{}),t.jsx(ft.Separator,{className:Fa.separator}),t.jsx(Dx,{})]})})},Wx="_trigger_1yjkd_1",Hx="_icon_1yjkd_23",Qx="_full_1yjkd_27",Gx="_triggerContent_1yjkd_32",Yx="_triggerText_1yjkd_40",Zx="_popoverBackdrop_1yjkd_51",Jx="_popoverPositioner_1yjkd_70",Xx="_popoverPopup_1yjkd_74",ey="_search_1yjkd_99",ty="_viewport_1yjkd_105",ny="_item_1yjkd_111",sy="_highlighted_1yjkd_127",oy="_active_1yjkd_131",ay="_itemContent_1yjkd_136",ry="_extra_1yjkd_142",iy="_connectedTag_1yjkd_149",_e={trigger:Wx,icon:Hx,full:Qx,triggerContent:Gx,triggerText:Yx,popoverBackdrop:Zx,popoverPositioner:Jx,popoverPopup:Xx,search:ey,viewport:ty,item:ny,highlighted:sy,active:oy,itemContent:ay,extra:ry,connectedTag:iy},Es=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=G(),[i,c]=g.useState(""),[l,d]=g.useState(!1),[u,m]=g.useState(0),[h,p]=g.useState(),f=g.useRef([]),_=g.useRef(null),x=ue(),y=s.map($=>x.find(N=>N.chainId===$)).filter(Boolean),b=$=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:$,height:$,viewBox:"0 0 14 14",children:[t.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"}),t.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"})]}),w=g.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=g.useMemo(()=>{const $=[w,...y];if(!i)return $;const N=i.toLowerCase();return $.filter(R=>R.name.toLowerCase().includes(N)||R.chainId.toLowerCase().includes(N))},[y,i,w]),C=y.find($=>$.chainId===e)||w,k=parseInt(Zr("--drawer-offset")),S=6,M=()=>{if(c(""),m(-1),_.current){const N=_.current.getBoundingClientRect().bottom+S,R=window.innerHeight-N-2*k;p(R)}d(!0)};g.useEffect(()=>{u>=0&&u<f.current.length&&f.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const F=g.useCallback($=>{switch($.key){case"ArrowDown":$.preventDefault(),m(N=>(N+1)%v.length);break;case"ArrowUp":$.preventDefault(),m(N=>(N-1+v.length)%v.length);break;case"Enter":$.preventDefault(),v[u]&&(n(v[u].chainId),d(!1));break;case"Escape":$.preventDefault(),d(!1);break}},[v,u,n,d]),E=$=>{n($),d(!1)};return t.jsxs(Qt.Popover.Root,{open:l,onOpenChange:M,modal:"trap-focus",children:[t.jsx(Qt.Popover.Trigger,{render:t.jsxs("button",{className:L(_e.trigger,{[_e.full]:a}),"aria-expanded":l,role:"listbox",ref:_,children:[t.jsxs("div",{className:_e.triggerContent,children:[typeof C.logoUrl=="string"?t.jsx(J,{src:C.logoUrl,width:14,height:14,logo:!0}):C.logoUrl(14),t.jsx("span",{className:_e.triggerText,children:C.name})]}),t.jsx(I.IconChevronDown,{size:16,className:_e.icon})]})}),t.jsxs(Qt.Popover.Portal,{container:Ft(),children:[t.jsx(Qt.Popover.Backdrop,{className:_e.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Qt.Popover.Positioner,{className:_e.popoverPositioner,align:"end",side:"bottom",sideOffset:S,collisionAvoidance:{side:"none"},children:t.jsxs(Qt.Popover.Popup,{className:L(_e.popoverPopup,{[_e.full]:a}),style:{maxHeight:h},children:[t.jsx(Is,{value:i,onChange:$=>{c($.target.value),m(0)},onClear:()=>c(""),onKeyDown:F,placeholder:"Search appchains",rootClassName:_e.search,ref:Bn()}),t.jsx("div",{className:_e.viewport,role:"listbox",children:v.length===0?t.jsx(he,{children:"No appchains found"}):v.map(({chainId:$,name:N,logoUrl:R},P)=>t.jsxs("div",{className:L(_e.item,{[_e.highlighted]:P===u,[_e.active]:e===$}),onClick:()=>E($),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),E($))},onMouseEnter:()=>m(P),role:"option","aria-selected":e===$,tabIndex:-1,ref:q=>{q&&(f.current[P]=q)},children:[t.jsxs("div",{className:_e.itemContent,children:[typeof R=="string"?t.jsx(J,{src:R,width:16,height:16,logo:!0}):R(16),t.jsx("span",{className:_e.name,children:N}),$===r&&t.jsx("span",{className:_e.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:_e.extra,children:o($)})]},$))})]})})]})]})},cy="_container_1nap1_1",ly="_controls_1nap1_7",dy="_search_1nap1_13",ea={container:cy,controls:ly,search:dy},uy=({children:e})=>t.jsx("div",{className:ea.container,children:e}),my=({children:e})=>t.jsx("div",{className:ea.controls,children:e}),hy=e=>t.jsx(Is,{...e,rootClassName:ea.search}),Ye={Root:uy,Controls:my,SearchInput:hy},Pi=K.atom(""),Ri=K.atom(""),py=K.atom(""),fy=K.atom(""),gy=K.atom(""),_y="_change_1x9v4_1",xy="_positive_1x9v4_10",yy="_negative_1x9v4_14",to={change:_y,positive:xy,negative:yy},Bi=({amount:e,asset:n})=>{const{denom:s,symbol:o,decimals:a}=n,r=new U(e).isPositive(),i=new U(e).abs().toString();return t.jsxs("div",{className:L(to.change,r?to.positive:to.negative),children:[r?"+":"-",j.formatAmount(i,{decimals:a})," ",o||s]})},jy=({changes:e,chain:n})=>{const s=ct(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Bi,{amount:o,asset:s(a)},r))},by=({changes:e,chain:n})=>{const s=ct(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(ai,{metadata:a,chain:n,children:i=>t.jsx(Bi,{amount:o,asset:s(i)})},r))},vy=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=De();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(by,{changes:oi(e,o),chain:n}):t.jsx(jy,{changes:si(e,s),chain:n})},wy="_message_1g2hc_1",Cy="_more_1g2hc_8",Oa={message:wy,more:Cy},Ny=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Oa.message,children:us.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Oa.more,children:`+${e.length-3} more`})]}),ky="_link_fuhbt_1",Iy="_inner_fuhbt_16",Ay="_header_fuhbt_21",Sy="_time_fuhbt_30",$y="_error_fuhbt_36",Ty="_timestamp_fuhbt_40",Ey="_chainInfo_fuhbt_45",qy="_content_fuhbt_53",Ly="_messages_fuhbt_61",My="_changes_fuhbt_67",at={link:ky,inner:Iy,header:Ay,time:Sy,error:$y,timestamp:Ty,chainInfo:Ey,content:qy,messages:Ly,changes:My},Dy=({txItem:e,chain:n})=>t.jsx(Cs,{txHash:e.txhash,chainId:n.chainId,className:at.link,children:t.jsxs("div",{className:at.inner,children:[t.jsxs("div",{className:at.header,children:[t.jsxs("div",{className:at.time,children:[e.code!==0&&t.jsx(I.IconWarningFilled,{size:14,className:at.error}),t.jsx("span",{className:at.timestamp,children:Ze.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:at.chainInfo,children:[t.jsx(J,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:at.content,children:[t.jsx("div",{className:at.messages,children:t.jsx(Ny,{messages:e.tx.body.messages})}),t.jsx("div",{className:at.changes,children:t.jsx(de,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(vy,{...e,chain:n})})})]})]})}),Py="_list_1mv55_1",Ry="_dateGroup_1mv55_7",By="_dateHeader_1mv55_12",Uy="_more_1mv55_18",Xn={list:Py,dateGroup:Ry,dateHeader:By,more:Uy},Fy=({list:e,chainId:n})=>{const s=X(),o=g.useMemo(()=>yi(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?t.jsx(he,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Xn.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:Xn.dateGroup,children:[t.jsx("div",{className:Xn.dateHeader,children:a}),r.map(i=>t.jsx(de,{errorBoundaryProps:{fallback:null},children:t.jsx(Dy,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(Cs,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:Xn.more,showIcon:!0,children:"View more on Initia Scan"})]})},Oy=()=>{const{activities:e,isLoading:n}=Xd(),[s,o]=K.useAtom(gy),a=ie(),r=g.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=g.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return n&&e.length===0?t.jsx(he,{children:"Loading activities..."}):!e.length&&!n?t.jsx(he,{children:"No activity yet"}):t.jsxs(Ye.Root,{children:[t.jsx(Ye.Controls,{children:t.jsx(Es,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(Fy,{list:i,chainId:s||a.chainId})]})},Vy="_thumbnail_1xyqw_1",zy="_placeholder_1xyqw_18",Ky="_clickable_1xyqw_24",bn={thumbnail:Vy,placeholder:zy,clickable:Ky},Wy=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=G(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?t.jsx("button",{className:L(bn.thumbnail,bn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(J,{src:l,classNames:{placeholder:bn.placeholder}})}):t.jsx("div",{className:bn.thumbnail,style:{width:n,height:n},children:t.jsx(J,{src:l,classNames:{placeholder:bn.placeholder}})})},Hy="_collectionName_qs5tw_1",Qy="_nftName_qs5tw_6",Gy="_chainInfo_qs5tw_10",no={collectionName:Hy,nftName:Qy,chainInfo:Gy},ta=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(Wy,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:L(no.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:L(no.nftName,a?.nftName),children:i}),t.jsxs("div",{className:L(no.chainInfo,a?.chainInfo),children:[t.jsx(J,{src:c.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},na=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function Yy(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function Zy(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const Jy=()=>{const e=X(),n=ue(),s=T.useQueries({queries:n.map(l=>({queryKey:na.nfts(l.indexerUrl,e).queryKey,queryFn:()=>rr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:z.SECOND}))}),o=s.map(A.prop("data")),a=Zy(n,o),r=a.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,d)=>l+d,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function Xy(e){const n=Va(e);return T.useQuery({queryKey:na.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await V.get(n).json();return{...s,image:Va(s.image)}}catch{return{}}},staleTime:z.INFINITY})}function Va(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const e1=({nftInfo:e,children:n})=>{const{data:s={}}=Xy(e.nft.uri),o=Yy(e,s);return n(o)},t1="_grid_1wwdn_1",n1="_root_1wwdn_7",s1="_collectionName_1wwdn_15",o1="_nftName_1wwdn_23",a1="_chainInfo_1wwdn_32",za={grid:t1,root:n1,collectionName:s1,nftName:o1,chainInfo:a1},r1=()=>{const[e,n]=K.useAtom(py),[s,o]=K.useAtom(fy),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=Jy(),l=je(),d=g.useMemo(()=>a.filter(({collection_addr:m,collection_name:h,nft:p,object_addr:f,chain:_})=>{if(s&&_.chainId!==s)return!1;if(e){const x=e.trim().toLowerCase();return m.toLowerCase().includes(x)||h.toLowerCase().includes(x)||p.token_id.toLowerCase().includes(x)||f.toLowerCase().includes(x)}return!0}),[a,s,e]),u=g.useMemo(()=>Array.from(new Set(a.map(({chain:m})=>m.chainId))),[a]);return c&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!c?t.jsx(he,{children:"No NFTs"}):t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:m=>n(m.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(Es,{value:s,onChange:o,chainIds:u,renderExtra:m=>m?r[m]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:za.grid,children:d.map(m=>{const{collection_addr:h,nft:p}=m;return t.jsx(e1,{nftInfo:m,children:f=>t.jsx(ta,{normalizedNft:f,onThumbnailClick:()=>l("/nft",f),classNames:za})},h+p.token_id)})})]})},Ui=g.createContext(null);function Fi(){return g.useContext(Ui)}const i1="_popup_nbecp_1",c1="_item_nbecp_19",es={popup:i1,item:c1},Oi=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[u,m]=g.useState(!1),h=je(),p=Fi(),{showNotification:f}=Fo(),{defaultChainId:_}=G(),{evm_chain_id:x}=Ot(),y=we.useChainId(),{switchChainAsync:b}=we.useSwitchChain(),{watchAssetAsync:w}=we.useWatchAsset(),v=()=>{m(!1),h("/send",{denom:s,chain:l})},C=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=T.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const S=r;return await b({chainId:Number(x)}),w({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:S}})},onSuccess:()=>{f({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:S=>{f({type:"error",title:"Asset addition failed",description:S.message})}});return t.jsxs(ft.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[t.jsx(ft.Menu.Trigger,{render:n}),t.jsx(ft.Menu.Portal,{container:p,children:t.jsx(ft.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(ft.Menu.Popup,{className:es.popup,children:[t.jsxs(ft.Menu.Item,{className:es.item,onClick:v,children:[t.jsx(I.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(ft.Menu.Item,{className:es.item,onClick:C,disabled:i,children:[t.jsx(I.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===_&&x===y&&!!c&&t.jsxs(ft.Menu.Item,{className:es.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?t.jsx(I.IconCheck,{size:16}):t.jsx(I.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},l1="_item_38qhm_1",d1="_info_38qhm_23",u1="_images_38qhm_29",m1="_name_38qhm_33",h1="_value_38qhm_39",p1="_amount_38qhm_47",f1="_usd_38qhm_53",Lt={item:l1,info:d1,images:u1,name:m1,value:h1,amount:p1,usd:f1},g1=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=j.formatAmount(n,{decimals:e.decimals});return t.jsx(Oi,{asset:e,children:t.jsxs("button",{className:Lt.item,children:[t.jsxs("div",{className:Lt.info,children:[t.jsx(ks,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Lt.images}),t.jsx("span",{className:Lt.name,children:a.name})]}),t.jsxs("div",{className:Lt.value,children:[t.jsx("span",{className:Lt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Lt.usd,children:Z(s)})]})]})})},_1="_container_ytg3p_1",x1="_assetItem_ytg3p_6",y1="_expandIcon_ytg3p_22",j1="_assetInfo_ytg3p_27",b1="_logo_ytg3p_33",v1="_details_ytg3p_37",w1="_symbol_ytg3p_42",C1="_chainName_ytg3p_53",N1="_chainInfos_ytg3p_59",k1="_chainLogos_ytg3p_65",I1="_chainLogo_ytg3p_65",A1="_moreChains_ytg3p_76",S1="_expanded_ytg3p_93",$1="_valueColumn_ytg3p_98",T1="_amount_ytg3p_108",E1="_value_ytg3p_98",q1="_collapsibleContent_ytg3p_121",L1="_chainsList_ytg3p_151",ge={container:_1,assetItem:x1,expandIcon:y1,assetInfo:j1,logo:b1,details:v1,symbol:w1,chainName:C1,chainInfos:N1,chainLogos:k1,chainLogo:I1,moreChains:A1,expanded:S1,valueColumn:$1,amount:T1,value:E1,collapsibleContent:q1,chainsList:L1},M1=K.atom([]),sa=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=K.useAtom(M1),c=g.useMemo(()=>Uc(e),[e]),l=g.useMemo(()=>Lr(e),[e]),d=r.includes(n),u=()=>{i(h=>d?h.filter(p=>p!==n):[...new Set([...h,n])])},m=()=>t.jsxs("button",{className:ge.assetItem,children:[t.jsxs("div",{className:ge.assetInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:ge.logo,logo:!0}),t.jsxs("div",{className:ge.details,children:[t.jsx("div",{className:ge.symbol,children:n}),a?t.jsx("div",{className:ge.chainName,children:o[0].chain.name}):t.jsxs("div",{className:ge.chainInfos,children:[t.jsx("div",{className:ge.chainLogos,children:o.slice(0,5).map(({chain:h})=>t.jsx(J,{src:h.logoUrl,width:16,height:16,className:ge.chainLogo,logo:!0},h.chainId))}),o.length>5&&t.jsxs("span",{className:ge.moreChains,children:["+",o.length-5]}),t.jsx(I.IconChevronDown,{size:16,className:L(ge.expandIcon,{[ge.expanded]:d})})]})]})]}),t.jsxs("div",{className:ge.valueColumn,children:[t.jsx("div",{className:ge.amount,children:j.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:ge.value,children:Z(l)})]})]});if(a){const[h]=o;return t.jsx("div",{className:ge.container,children:t.jsx(Oi,{asset:h,children:m()})})}return t.jsx("div",{className:ge.container,children:t.jsxs(Y.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:m()}),t.jsx(Y.Collapsible.Content,{className:ge.collapsibleContent,children:t.jsx("div",{className:ge.chainsList,children:o.map(h=>t.jsx(g1,{asset:h},h.chain.chainId))})})]})})},D1="_collapsible_1g7rh_1",P1="_trigger_1g7rh_5",R1="_divider_1g7rh_20",B1="_label_1g7rh_28",U1="_chevron_1g7rh_33",F1="_content_1g7rh_41",O1="_list_1g7rh_45",Ct={collapsible:D1,trigger:P1,divider:R1,label:B1,chevron:U1,content:F1,list:O1},Vi=({unlistedAssets:e})=>{const[n,s]=g.useState(!1),o=Fi(),a=g.useRef(null),[r,i]=g.useState(0);g.useEffect(()=>{if(a.current){const m=a.current.scrollHeight;i(m)}},[e]);const c=g.useRef(null),l=m=>{s(m),m&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,p=h.getBoundingClientRect(),f=c.current.getBoundingClientRect(),_=a.current.scrollHeight;if(f.bottom+_>p.bottom){const y=f.top-p.top+h.scrollTop-16;h.scrollTo({top:y,behavior:"smooth"})}},50)},d=ze.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),u=g.useMemo(()=>e.map(m=>({...m,assets:[m],totalValue:m.value??0,totalAmount:Number(m.quantity)})),[e]);return e.length===0?null:t.jsxs(Y.Collapsible.Root,{open:n,onOpenChange:l,className:Ct.collapsible,children:[t.jsxs(Y.Collapsible.Trigger,{ref:c,className:Ct.trigger,children:[t.jsx("div",{className:Ct.divider}),t.jsxs("span",{className:Ct.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(I.IconChevronDown,{className:Ct.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:Ct.divider})]}),t.jsx(Y.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(ze.animated.div,{className:Ct.content,style:d,children:t.jsx("div",{className:Ct.list,ref:a,children:u.map(m=>t.jsx(sa,{assetGroup:m},m.assets[0].denom))})})})]})},V1="_container_15xfg_1",z1="_header_15xfg_7",K1="_title_15xfg_13",W1="_totalValue_15xfg_19",H1="_list_15xfg_26",tn={container:V1,header:z1,title:K1,totalValue:W1,list:H1},Q1=()=>{const[e,n]=K.useAtom(Pi),[s,o]=K.useAtom(Ri),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=To(),d=i.map(({chainId:h})=>h),u=g.useMemo(()=>{const h=e?a.filter(f=>{const{symbol:_,assets:x}=f;return _.toLowerCase().includes(e.toLowerCase())||x.some(({denom:y,address:b})=>y.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(f=>({...f,assets:f.assets.filter(({chain:_})=>_.chainId===s)})).filter(f=>f.assets.length>0):h},[a,e,s]),m=g.useMemo(()=>{const h=e?r.filter(({denom:f,address:_})=>f.toLowerCase().includes(e.toLowerCase())||_?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:f})=>f.chainId===s):h},[r,e,s]);return l&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!s&&!l?t.jsx(he,{children:"No assets"}):t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(Es,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return Z(c);const p=i.find(f=>f.chainId===h);return p?Z(p.value):null}})]}),t.jsx("div",{children:u.length===0&&m.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tn.list,children:u.map(h=>t.jsx(sa,{assetGroup:h},h.symbol))}),t.jsx(Vi,{unlistedAssets:m})]})})]})},G1="_container_11k2x_1",Y1={container:G1},Ge=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Ut,{height:e,width:s}):t.jsx("div",{className:Y1.container,children:o.map(a=>t.jsx(Ut,{height:e,width:s},a))})},Z1=g.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=Dn(),l=ie(),{listedGroups:d,unlistedAssets:u}=g.useMemo(()=>Nl(i,a,r,l.chainId),[i,a,r,l.chainId]),m=g.useMemo(()=>bl(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:p,filteredUnlistedAssets:f}=g.useMemo(()=>Cl(m,u,e,n),[m,u,e,n]);return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.header,children:[t.jsx("span",{className:tn.title,children:"Assets"}),h.length>0&&t.jsx("span",{className:tn.totalValue,children:Z(p)})]}),h.length>0?t.jsxs("div",{children:[t.jsx("div",{className:tn.list,children:h.map(_=>t.jsx(sa,{assetGroup:_},_.symbol))}),t.jsx(Vi,{unlistedAssets:f})]}):m.length===0&&c?t.jsx(Ge,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),J1=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function zi(){const{civitiaUrl:e}=G(),n=X();return T.useQuery({enabled:!!n,queryKey:J1.player(e,n??"").queryKey,queryFn:async()=>{if(!n)throw new Error("address is not available");return V.get(`${e}/players/${n}`).json()},staleTime:z.MINUTE,throwOnError:!1})}const X1="_section_xdyfz_2",e0="_row_xdyfz_15",t0="_rowLeft_xdyfz_23",n0="_rowIcon_xdyfz_29",s0="_goldIcon_xdyfz_38",o0="_silverIcon_xdyfz_46",a0="_rowTitle_xdyfz_54",r0="_rowValue_xdyfz_60",i0="_rowSubtitle_xdyfz_67",Ce={section:X1,row:e0,rowLeft:t0,rowIcon:n0,goldIcon:s0,silverIcon:o0,rowTitle:a0,rowValue:r0,rowSubtitle:i0},c0=()=>{const{data:e,isLoading:n}=zi();if(n)return t.jsx(Ge,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ce.section,children:[t.jsxs("div",{className:Ce.row,children:[t.jsxs("div",{className:Ce.rowLeft,children:[t.jsx("div",{className:L(Ce.rowIcon,Ce.goldIcon)}),t.jsx("span",{className:Ce.rowTitle,children:"Gold"})]}),t.jsx("span",{className:L(Ce.rowValue,s===0&&Ce.rowSubtitle),children:s===0?"—":j.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ce.row,children:[t.jsxs("div",{className:Ce.rowLeft,children:[t.jsx("div",{className:L(Ce.rowIcon,Ce.silverIcon)}),t.jsx("span",{className:Ce.rowTitle,children:"Silver"})]}),t.jsx("span",{className:L(Ce.rowValue,o===0&&Ce.rowSubtitle),children:o===0?"—":j.formatNumber(o,{dp:6})})]})]})},l0="_container_1n61l_1",d0="_section_1n61l_7",u0="_sectionHeader_1n61l_19",m0="_sectionTitle_1n61l_25",h0="_sectionLabel_1n61l_31",p0="_externalLink_1n61l_37",f0="_sectionValue_1n61l_49",g0="_tokenList_1n61l_56",_0="_stakingTokenList_1n61l_62",x0="_tokenRow_1n61l_72",y0="_tokenMain_1n61l_78",j0="_tokenTrigger_1n61l_84",b0="_tokenChevron_1n61l_100",v0="_expanded_1n61l_111",w0="_triggerValue_1n61l_115",C0="_tokenInfo_1n61l_122",N0="_tokenInfoLabel_1n61l_128",k0="_tokenLogo_1n61l_134",I0="_tokenSymbol_1n61l_138",A0="_tokenValues_1n61l_144",S0="_tokenAmount_1n61l_150",$0="_tokenValue_1n61l_144",T0="_typeBreakdown_1n61l_164",E0="_typeRow_1n61l_172",q0="_typeLabel_1n61l_180",L0="_typeValues_1n61l_186",M0="_typeAmount_1n61l_192",D0="_typeValue_1n61l_186",P0="_collapsibleContent_1n61l_206",Q={container:l0,section:d0,sectionHeader:u0,sectionTitle:m0,sectionLabel:h0,externalLink:p0,sectionValue:f0,tokenList:g0,stakingTokenList:_0,tokenRow:x0,tokenMain:y0,tokenTrigger:j0,tokenChevron:b0,expanded:v0,triggerValue:w0,tokenInfo:C0,tokenInfoLabel:N0,tokenLogo:k0,tokenSymbol:I0,tokenValues:A0,tokenAmount:S0,tokenValue:$0,typeBreakdown:T0,typeRow:E0,typeLabel:q0,typeValues:L0,typeAmount:M0,typeValue:D0,collapsibleContent:P0},Ki=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=g.useMemo(()=>{const c=e.flatMap(l=>l.positions);return ul(c)},[e]);return i.size===0?null:t.jsx("div",{className:Q.container,children:Array.from(i.entries()).map(([c,l])=>t.jsx(R0,{sectionKey:c,sectionGroup:l,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},R0=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=n,d=dl(e,o),u=g.useMemo(()=>xl(c),[c]),m=e==="staking";return t.jsxs("div",{className:Q.section,children:[t.jsxs("div",{className:Q.sectionHeader,children:[t.jsxs("div",{className:Q.sectionTitle,children:[t.jsx("span",{className:Q.sectionLabel,children:d}),m&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Q.externalLink,onClick:h=>h.stopPropagation(),children:t.jsx(I.IconExternalLink,{size:12})})]}),t.jsx("span",{className:Q.sectionValue,children:Z(l)})]}),t.jsx("div",{className:L(Q.tokenList,{[Q.stakingTokenList]:m}),children:u.map(h=>t.jsx(B0,{group:h,showTypeBreakdown:m,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},B0=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,u=s.get(r),[m,h]=g.useState(!1),p=g.useMemo(()=>{if(!n)return null;const f=gl(d);return f.size>0?f:null},[d,n]);return p?t.jsxs(Y.Collapsible.Root,{open:m,onOpenChange:h,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Q.tokenTrigger,children:[t.jsxs("div",{className:Q.tokenInfo,children:[t.jsx(I.IconChevronDown,{size:14,className:L(Q.tokenChevron,{[Q.expanded]:m})}),t.jsxs("div",{className:Q.tokenInfoLabel,children:[u?.assetLogo&&t.jsx(J,{src:u.assetLogo,width:20,height:20,className:Q.tokenLogo}),t.jsx("span",{className:Q.tokenSymbol,children:i})]})]}),t.jsx("span",{className:Q.triggerValue,children:Z(l)})]})}),t.jsx(Y.Collapsible.Content,{className:Q.collapsibleContent,children:t.jsx(U0,{typeGroups:p,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:Q.tokenRow,children:t.jsxs("div",{className:Q.tokenMain,children:[t.jsxs("div",{className:Q.tokenInfo,children:[u?.assetLogo&&t.jsx(J,{src:u.assetLogo,width:20,height:20,className:Q.tokenLogo}),t.jsx("span",{className:Q.tokenSymbol,children:i})]}),t.jsxs("div",{className:Q.tokenValues,children:[t.jsx("span",{className:Q.tokenAmount,children:j.formatNumber(c,{dp:6})}),t.jsx("span",{className:Q.tokenValue,children:Z(l)})]})]})})},U0=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=g.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const u=d.reduce((h,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?h:h+p.balance.formattedAmount,0),m=d.reduce((h,p)=>h+an(p),0);return{type:l,typeAmount:u,typeValue:m}}),[e]),i=g.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const u=o(s,d);l+=Number(u)}return l},[s,o,r]),c=i>0;return t.jsxs("div",{className:Q.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:u})=>t.jsxs("div",{className:Q.typeRow,children:[t.jsx("span",{className:Q.typeLabel,children:fl(l)}),t.jsxs("div",{className:Q.typeValues,children:[t.jsxs("span",{className:Q.typeAmount,children:[j.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:Q.typeValue,children:Z(u)})]})]},l)),c&&t.jsxs("div",{className:Q.typeRow,children:[t.jsx("span",{className:Q.typeLabel,children:"Claimable"}),t.jsxs("div",{className:Q.typeValues,children:[t.jsxs("span",{className:Q.typeAmount,children:[j.formatNumber(i,{dp:6})," ",Qe]}),t.jsx("span",{className:Q.typeValue,children:Z(i*(a??0))})]})]})]})},F0="_container_ymkoc_1",O0="_trigger_ymkoc_6",V0="_expandIcon_ymkoc_22",z0="_chainInfo_ymkoc_27",K0="_logo_ymkoc_33",W0="_chainNameContainer_ymkoc_37",H0="_chainName_ymkoc_37",Q0="_externalLink_ymkoc_49",G0="_externalIcon_ymkoc_53",Y0="_valueColumn_ymkoc_63",Z0="_value_ymkoc_63",J0="_expanded_ymkoc_80",X0="_collapsibleContent_ymkoc_85",e2="_content_ymkoc_97",$e={container:F0,trigger:O0,expandIcon:V0,chainInfo:z0,logo:K0,chainNameContainer:W0,chainName:H0,externalLink:Q0,externalIcon:G0,valueColumn:Y0,value:Z0,expanded:J0,collapsibleContent:X0,content:e2},t2=K.atom([]),n2=({chainGroup:e})=>{const{chainLogo:n,protocols:s}=e,o=An(),{denomLogos:a,symbolLogos:r}=g.useMemo(()=>Bo(o),[o]),i=g.useMemo(()=>{const c=new Map;for(const l of s)for(const d of l.positions){if(d.type==="fungible-position"||d.balance.type==="unknown")continue;const{denom:u,symbol:m}=d.balance,h=m.toUpperCase(),p=a.get(u)??r.get(h);p&&c.set(u,{assetLogo:p,chainLogo:n??""})}return c},[s,a,r,n]);return t.jsx(Ki,{protocols:s,denomLogoMap:i})},s2=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=K.useAtom(t2),c=g.useMemo(()=>o.reduce((f,_)=>f+_.positions.reduce((x,y)=>x+an(y),0),0),[o]),l=["civitia","yominet"],d=r.includes(n),u=n?.toLowerCase(),m=u==="civitia",h=l.includes(u),p=()=>{i(f=>d?f.filter(_=>_!==n):[...new Set([...f,n])])};return t.jsx("div",{className:$e.container,children:t.jsxs(Y.Collapsible.Root,{open:d,onOpenChange:p,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:$e.trigger,children:[t.jsxs("div",{className:$e.chainInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:$e.logo,logo:!0}),t.jsxs("div",{className:$e.chainNameContainer,children:[t.jsx("span",{className:$e.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:$e.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(I.IconExternalLink,{size:12,className:$e.externalIcon})})]})]}),t.jsxs("div",{className:$e.valueColumn,children:[!h&&t.jsx("span",{className:$e.value,children:Z(c)}),t.jsx(I.IconChevronDown,{size:16,className:L($e.expandIcon,{[$e.expanded]:d})})]})]})}),t.jsx(Y.Collapsible.Content,{className:$e.collapsibleContent,children:t.jsxs("div",{className:$e.content,children:[t.jsx(n2,{chainGroup:e}),m&&t.jsx(c0,{})]})})]})})},o2="_container_1gqx9_1",a2="_section_1gqx9_6",r2="_sectionHeader_1gqx9_14",i2="_sectionTitle_1gqx9_20",c2="_sectionLabel_1gqx9_26",l2="_externalLink_1gqx9_32",d2="_sectionValue_1gqx9_44",u2="_tokenList_1gqx9_51",m2="_tokenTrigger_1gqx9_63",h2="_tokenChevron_1gqx9_79",p2="_expanded_1gqx9_90",f2="_tokenInfo_1gqx9_94",g2="_tokenInfoLabel_1gqx9_100",_2="_tokenLogo_1gqx9_106",x2="_pairedLogos_1gqx9_110",y2="_coinLogo_1gqx9_115",j2="_tokenSymbol_1gqx9_133",b2="_triggerValue_1gqx9_139",v2="_breakdownContent_1gqx9_146",w2="_breakdownRow_1gqx9_154",C2="_breakdownLabel_1gqx9_162",N2="_breakdownValues_1gqx9_168",k2="_breakdownAmount_1gqx9_174",I2="_breakdownValue_1gqx9_168",A2="_collapsibleContent_1gqx9_195",se={container:o2,section:a2,sectionHeader:r2,sectionTitle:i2,sectionLabel:c2,externalLink:l2,sectionValue:d2,tokenList:u2,tokenTrigger:m2,tokenChevron:h2,expanded:p2,tokenInfo:f2,tokenInfoLabel:g2,tokenLogo:_2,pairedLogos:x2,coinLogo:y2,tokenSymbol:j2,triggerValue:b2,breakdownContent:v2,breakdownRow:w2,breakdownLabel:C2,breakdownValues:N2,breakdownAmount:k2,breakdownValue:I2,collapsibleContent:A2},S2=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:se.container,children:t.jsxs("div",{className:se.section,children:[t.jsxs("div",{className:se.sectionHeader,children:[t.jsxs("div",{className:se.sectionTitle,children:[t.jsx("span",{className:se.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:No,target:"_blank",rel:"noopener noreferrer",className:se.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(I.IconExternalLink,{size:12})})]}),t.jsx("span",{className:se.sectionValue,children:Z(s)})]}),t.jsx("div",{className:se.tokenList,children:o.map(a=>t.jsx(T2,{row:a,denomLogoMap:n},a.denom))})]})})},$2={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},T2=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,u]=g.useState(!1),m=n.get(s),h=i||m?.assetLogo,p=e.totalAmount>0?e.totalValue/e.totalAmount:0,f=g.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),_=c&&c.length>0&&c.some(y=>y),x=l&&Number(l.total)>0;return t.jsxs(Y.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:se.tokenTrigger,children:[t.jsxs("div",{className:se.tokenInfo,children:[t.jsx(I.IconChevronDown,{size:14,className:L(se.tokenChevron,{[se.expanded]:d})}),t.jsxs("div",{className:se.tokenInfoLabel,children:[_?t.jsx("div",{className:se.pairedLogos,children:c.map((y,b)=>t.jsx(J,{src:y,width:20,height:20,className:se.coinLogo,logo:!0},b))}):h&&t.jsx(J,{src:h,width:20,height:20,className:se.tokenLogo}),t.jsx("span",{className:se.tokenSymbol,children:o})]})]}),t.jsx("span",{className:se.triggerValue,children:Z(a)})]})}),t.jsx(Y.Collapsible.Content,{className:se.collapsibleContent,children:t.jsxs("div",{className:se.breakdownContent,children:[f.map(([y,b])=>{const w=b*p;return t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:$2[y]}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(b,{dp:6})," LP"]}),t.jsx("span",{className:se.breakdownValue,children:Z(w)})]})]},y)}),x&&t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(Number(l.total),{dp:6})," ",Qe]}),t.jsx("span",{className:se.breakdownValue,children:Z(l.totalValue)})]})]})]})})]})},E2="_container_1nijk_1",q2="_section_1nijk_6",L2="_sectionHeader_1nijk_14",M2="_sectionTitle_1nijk_20",D2="_sectionLabel_1nijk_26",P2="_externalLink_1nijk_32",R2="_sectionValue_1nijk_44",B2="_tokenList_1nijk_51",U2="_tokenTrigger_1nijk_63",F2="_tokenChevron_1nijk_79",O2="_expanded_1nijk_90",V2="_tokenInfo_1nijk_94",z2="_tokenInfoLabel_1nijk_100",K2="_tokenLogo_1nijk_106",W2="_tokenName_1nijk_110",H2="_triggerValue_1nijk_116",Q2="_breakdownContent_1nijk_123",G2="_breakdownRow_1nijk_131",Y2="_breakdownLabel_1nijk_139",Z2="_breakdownValues_1nijk_145",J2="_breakdownAmount_1nijk_151",X2="_breakdownValue_1nijk_145",ej="_collapsibleContent_1nijk_165",ce={container:E2,section:q2,sectionHeader:L2,sectionTitle:M2,sectionLabel:D2,externalLink:P2,sectionValue:R2,tokenList:B2,tokenTrigger:U2,tokenChevron:F2,expanded:O2,tokenInfo:V2,tokenInfoLabel:z2,tokenLogo:K2,tokenName:W2,triggerValue:H2,breakdownContent:Q2,breakdownRow:G2,breakdownLabel:Y2,breakdownValues:Z2,breakdownAmount:J2,breakdownValue:X2,collapsibleContent:ej},tj=({data:e})=>{const{totalValue:n,rows:s}=e;return s.length===0?null:t.jsx("div",{className:ce.container,children:t.jsxs("div",{className:ce.section,children:[t.jsxs("div",{className:ce.sectionHeader,children:[t.jsxs("div",{className:ce.sectionTitle,children:[t.jsx("span",{className:ce.sectionLabel,children:"VIP"}),t.jsx("a",{href:vc,target:"_blank",rel:"noopener noreferrer",className:ce.externalLink,onClick:o=>o.stopPropagation(),children:t.jsx(I.IconExternalLink,{size:12})})]}),t.jsx("span",{className:ce.sectionValue,children:Z(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(nj,{row:o},`${o.bridgeId}-${o.version}`))})]})})},nj=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=g.useState(!1),d=a+i;return t.jsxs(Y.Collapsible.Root,{open:c,onOpenChange:l,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:ce.tokenTrigger,children:[t.jsxs("div",{className:ce.tokenInfo,children:[t.jsx(I.IconChevronDown,{size:14,className:L(ce.tokenChevron,{[ce.expanded]:c})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(J,{src:s,width:20,height:20,className:ce.tokenLogo,logo:!0}),t.jsx("span",{className:ce.tokenName,children:n})]})]}),t.jsx("span",{className:ce.triggerValue,children:Z(d)})]})}),t.jsx(Y.Collapsible.Content,{className:ce.collapsibleContent,children:t.jsxs("div",{className:ce.breakdownContent,children:[o>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Locked"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[j.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:Z(a)})]})]}),r>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[j.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:Z(i)})]})]})]})})]})},sj="_container_ymkoc_1",oj="_trigger_ymkoc_6",aj="_expandIcon_ymkoc_22",rj="_chainInfo_ymkoc_27",ij="_logo_ymkoc_33",cj="_chainNameContainer_ymkoc_37",lj="_chainName_ymkoc_37",dj="_externalLink_ymkoc_49",uj="_externalIcon_ymkoc_53",mj="_valueColumn_ymkoc_63",hj="_value_ymkoc_63",pj="_expanded_ymkoc_80",fj="_collapsibleContent_ymkoc_85",gj="_content_ymkoc_97",Te={container:sj,trigger:oj,expandIcon:aj,chainInfo:rj,logo:ij,chainNameContainer:cj,chainName:lj,externalLink:dj,externalIcon:uj,valueColumn:mj,value:hj,expanded:pj,collapsibleContent:fj,content:gj},_j=K.atom(!1),xj=()=>{const{totalValue:e}=Mo(),{totalValue:n}=Po(),{totalValue:s}=Ro(),o=e+n+s;return t.jsx("span",{className:Te.value,children:Z(o)})},yj=({chainLogo:e,denomLogos:n,symbolLogos:s,initPrice:o})=>{const{positions:a}=Mo(),{data:r}=Rr(),{data:i}=Br(),c=g.useMemo(()=>{const u=new Map;for(const m of a){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:h,symbol:p}=m.balance,f=p.toUpperCase(),_=n.get(h)??s.get(f);_&&u.set(h,{assetLogo:_,chainLogo:e})}return u},[a,n,s,e]),l=g.useMemo(()=>(u,m)=>{const h=j.denomToMetadata(u);if(m==="staking"){const p=r?.get(h);return p?j.fromBaseUnit(p.amount,{decimals:Me}):"0"}if(m==="lockstaking"){const p=i?.get(h);return p?j.fromBaseUnit(p.amount,{decimals:Me}):"0"}return"0"},[r,i]),d=g.useMemo(()=>a.length===0?[]:[{protocol:"Initia",manageUrl:No,positions:a}],[a]);return d.length===0?null:t.jsx(Ki,{protocols:d,denomLogoMap:c,isInitia:!0,getClaimableInitByType:l,initPrice:o})},jj=({chainLogo:e,denomLogos:n,symbolLogos:s})=>{const o=Po(),a=g.useMemo(()=>{const r=new Map;for(const i of o.rows){const{denom:c,symbol:l}=i,d=l.toUpperCase(),u=n.get(c)??s.get(d);u&&r.set(c,{assetLogo:u,chainLogo:e})}return r},[o.rows,n,s,e]);return o.rows.length===0?null:t.jsx(S2,{data:o,denomLogoMap:a})},bj=()=>{const e=Ro();return e.rows.length===0?null:t.jsx(tj,{data:e})},vj=({chainGroup:e})=>{const{chainName:n,chainLogo:s}=e,[o,a]=K.useAtom(_j),r=An(),{denomLogos:i,symbolLogos:c}=g.useMemo(()=>Bo(r),[r]),l=ie(),{data:d}=yt(l),u=g.useMemo(()=>d?.find(h=>h.id===ke)?.price??0,[d]);return t.jsx("div",{className:Te.container,children:t.jsxs(Y.Collapsible.Root,{open:o,onOpenChange:a,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:n}),t.jsx("a",{href:No,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:m=>m.stopPropagation(),children:t.jsx(I.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:16,width:60,length:1}),children:t.jsx(xj,{})}),t.jsx(I.IconChevronDown,{size:16,className:L(Te.expandIcon,{[Te.expanded]:o})})]})]})}),t.jsx(Y.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:36,length:2}),children:t.jsx(yj,{chainLogo:s,denomLogos:i,symbolLogos:c,initPrice:u})}),t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:36,length:2}),children:t.jsx(jj,{chainLogo:s,denomLogos:i,symbolLogos:c})}),t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:36,length:1}),children:t.jsx(bj,{})})]})})]})})},wj="_totalValue_1v2ca_1",Cj={totalValue:wj},Nj=({filteredChainGroups:e})=>{const{totalValue:n}=Mo(),{totalValue:s}=Po(),{totalValue:o}=Ro(),a=n+s+o,r=g.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,d)=>d.isInitia?l:l+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:Cj.totalValue,children:Z(r)})},kj="_container_1eubu_1",Ij="_header_1eubu_7",Aj="_title_1eubu_13",Sj="_list_1eubu_19",$j="_skeletonWrapper_1eubu_24",vn={container:kj,header:Ij,title:Aj,list:Sj,skeletonWrapper:$j},Tj=g.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Dn(),r=ie(),{data:i,isLoading:c}=zi(),l=g.useMemo(()=>{const u=[];for(const h of o){if(!Array.isArray(h.positions))continue;const p=s.get(h.chainName.toLowerCase()),f=h.chainName.toLowerCase(),_=f==="civitia";if(n&&p?.chainId!==n)continue;const x=h.positions.some(C=>C.positions.some(k=>k.type!=="fungible-position")),y=_&&!c&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!x&&!y||e&&!f.includes(e.toLowerCase()))continue;const b=h.positions.filter(C=>e&&!C.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(C.positions)&&C.positions.length>0),w=r.chainId===p?.chainId,v=b.reduce((C,k)=>C+k.positions.reduce((S,M)=>S+an(M),0),0);u.push({chainName:p?.prettyName??h.chainName,chainLogo:p?.logoUrl??"",protocols:b,isInitia:w,totalValue:v})}const m=["civitia","yominet"];return A.sortWith([A.descend(h=>h.isInitia??!1),A.ascend(h=>m.includes(h.chainName.toLowerCase())),A.descend(h=>h.totalValue??0),A.ascend(h=>h.chainName.toLowerCase())],u)},[o,s,e,n,r.chainId,i,c]),d=l.length>0;return t.jsxs("div",{className:vn.container,children:[t.jsxs("div",{className:vn.header,children:[t.jsx("span",{className:vn.title,children:"Positions"}),d&&t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:16,width:60,length:1}),children:t.jsx(Nj,{filteredChainGroups:l})})]}),d?t.jsx("div",{className:vn.list,children:l.map(u=>u.isInitia?t.jsx(de,{suspenseFallback:t.jsx("div",{className:vn.skeletonWrapper,children:t.jsx(Ge,{height:56,length:1})}),children:t.jsx(vj,{chainGroup:u})},u.chainName):t.jsx(s2,{chainGroup:u},u.chainName))}):o.length===0&&a?t.jsx(Ge,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),Ej="_content_1w1ad_1",qj={content:Ej},Lj=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=G(),o=ie(),a=El(),{chainIds:r,chainIdToValueMap:i,totalBalance:c}=g.useMemo(()=>{const l=new Map;let d=0;for(const m of a)l.set(m.chainId,m.totalBalance),d+=m.totalBalance;return{chainIds:A.sortWith([A.descend(m=>m===s),A.descend(m=>m===o.chainId),A.descend(m=>l.get(m)??0)],a.map(m=>m.chainId)),chainIdToValueMap:l,totalBalance:d}},[a,s,o]);return t.jsx(Es,{value:e,onChange:n,chainIds:r,renderExtra:l=>Z(l?i.get(l)??0:c)})},Mj=()=>{const[e,n]=K.useAtom(Pi),[s,o]=K.useAtom(Ri),a=ue(),r=An(),{denomLogos:i,symbolLogos:c}=g.useMemo(()=>Bo(r),[r]),l=bo(),d=g.useMemo(()=>zr(a,l),[a,l]),u=Tl();return t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:m=>n(m.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(de,{suspenseFallback:t.jsx(Ut,{height:44,width:132}),children:t.jsx(Lj,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:qj.content,children:[t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:48,length:5}),children:t.jsx(Z1,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:u,chainPrices:d})}),t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:56,length:3}),children:t.jsx(Tj,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},Dj="_totalValue_5pf7e_1",Pj="_totalLabel_5pf7e_7",Rj="_totalAmount_5pf7e_13",Bj="_loading_5pf7e_18",Uj="_skeletonWrapper_5pf7e_23",Fj="_nav_5pf7e_28",Oj="_item_5pf7e_34",Vj="_tabs_5pf7e_59",zj="_tab_5pf7e_59",Ee={totalValue:Dj,totalLabel:Pj,totalAmount:Rj,loading:Bj,skeletonWrapper:Uj,nav:Fj,item:Oj,tabs:Vj,tab:zj},Kj=()=>{const{totalValue:e,isLoading:n}=To();return t.jsx("div",{className:L(Ee.totalAmount,{[Ee.loading]:n}),children:Z(e)})},Wj=()=>{const e=ql(),n=Ll(),s=Vr(),o=e+s+n;return t.jsx("div",{className:Ee.totalAmount,children:Z(o)})},Hj=()=>{hi(),Sl();const e=Uo(),n=je(),s=et(),o=g.useRef(null);return t.jsx(Ui.Provider,{value:o,children:t.jsxs(ut,{ref:o,children:[t.jsxs("div",{className:Ee.totalValue,children:[t.jsx("div",{className:Ee.totalLabel,children:"Total value"}),t.jsx(de,{suspenseFallback:t.jsx("div",{className:Ee.skeletonWrapper,children:t.jsx(Ut,{height:48,width:120})}),children:e?t.jsx(Kj,{}):t.jsx(Wj,{})})]}),t.jsxs("div",{className:Ee.nav,children:[t.jsxs(nn,{to:"/send",className:Ee.item,children:[t.jsx(I.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(nn,{to:"/bridge",className:Ee.item,children:[t.jsx(I.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(nn,{to:"/receive",className:Ee.item,children:[t.jsx(I.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(bt.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(bt.Tabs.List,{className:Ee.tabs,children:[t.jsx(bt.Tabs.Tab,{className:Ee.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(bt.Tabs.Tab,{className:Ee.tab,value:"/nfts",children:"NFTs"}),t.jsx(bt.Tabs.Tab,{className:Ee.tab,value:"/activity",children:"Activity"})]}),t.jsx(bt.Tabs.Panel,{value:"/",children:e?t.jsx(Q1,{}):t.jsx(Mj,{})}),t.jsx(bt.Tabs.Panel,{value:"/nfts",children:t.jsx(r1,{})}),t.jsx(bt.Tabs.Panel,{value:"/activity",children:t.jsx(Oy,{})})]})]})})},Qj="_root_th990_1",Gj="_collectionName_th990_9",Yj="_nftName_th990_13",Zj="_chainInfo_th990_17",Jj="_attributes_th990_21",Xj="_title_th990_24",eb="_count_th990_29",tb="_item_th990_33",nb="_type_th990_39",sb="_value_th990_45",Mt={root:Qj,collectionName:Gj,nftName:Yj,chainInfo:Zj,attributes:Jj,title:Xj,count:eb,item:tb,type:nb,value:sb},ob=()=>{const e=je(),n=Ke(),{attributes:s}=n;return t.jsxs(mt,{title:"NFT details",children:[t.jsx(ta,{normalizedNft:n,chainIconSize:14,classNames:Mt}),t.jsx(fe,{children:t.jsx(ne.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Mt.attributes,children:[t.jsxs("header",{className:Mt.title,children:["Traits ",t.jsxs("span",{className:Mt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Mt.item,children:[t.jsx("div",{className:Mt.type,children:o}),t.jsx("div",{className:Mt.value,children:a})]},o))})]})]})};function ab({balances:e,gasPrices:n,gas:s}){return n.map(({denom:o,amount:a})=>{const r=U(a).times(s).toFixed(0,U.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>U(a).gte(o))}function rb({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=ab({balances:n,gasPrices:s,gas:a}),c=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&c){const d=U(r).minus(c.amount);return U.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=U(r).minus(l.amount);return U.max(d,0).toString()}return U(r).toString()}const ib=({chain:e,onSelect:n})=>{const s=gc(e);return t.jsx(Fn,{assets:s,onSelect:n})},cb=({afterSelect:e})=>{const{watch:n,setValue:s}=pe.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,c]=g.useState(r),l=Xe(i),d=ue(),u=m=>{if(o===i&&a===m){e();return}s("chainId",i),s("denom",m),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Bt.Stack,{children:t.jsx(Bt,{chains:d,value:i,onSelect:c})}),t.jsx(de,{suspenseFallback:t.jsx(Fn.Placeholder,{}),children:t.jsx(ib,{chain:l,onSelect:u})},i)]})},lb="_fields_brpej_1",db="_divider_brpej_11",Ka={fields:lb,divider:db},ub=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),mb=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=De(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=pe.useFormContext(),{errors:d}=l,{chainId:u,denom:m,recipient:h,quantity:p,memo:f}=r(),_=Xe(u),x=Sn(_),y=Oo(_),b=Vo(_),w=or(m,_),{data:v}=yt(_),{decimals:C}=w,k=x.find(O=>O.denom===m)?.amount??"0",S=v?.find(({id:O})=>O===m)?.price,{data:M=0,isLoading:F}=T.useQuery({queryKey:ub.gas({chainId:u,denom:m,recipient:h,initiaAddress:n}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return s({messages:O,chainId:u})},enabled:j.InitiaAddress.validate(h),staleTime:z.INFINITY}),E=Math.ceil(M*on),$=rb({denom:m,balances:x,gasPrices:y,lastFeeDenom:b,gas:E}),N=U(k).isZero(),P=y.some(({denom:O})=>O===m)&&F,q=N||P,{mutate:D,isPending:H}=T.useMutation({mutationFn:({chainId:O,denom:ee,quantity:me,recipient:Ae,memo:We})=>{const At=j.toBaseUnit(me,{decimals:C}),mn=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(Ae).bech32,amount:[{denom:ee,amount:At}]})}];return o({messages:mn,memo:We,chainId:O,gas:M,gasAdjustment:on,gasPrices:y,spendCoins:[{denom:ee,amount:At}],internal:"/"})}}),W=g.useMemo(()=>{if(!p)return"Enter amount";if(d.quantity)return d.quantity.message;if(!h)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[p,h,d.quantity,d.recipient,d.memo]);return t.jsx(mt,{title:"Send",children:t.jsxs("form",{onSubmit:c(O=>D(O)),children:[t.jsxs("div",{className:Ka.fields,children:[t.jsx(uo,{selectButton:t.jsx(ln,{title:"Select chain and asset",content:O=>t.jsx(cb,{afterSelect:O}),children:t.jsx(_i,{asset:w,chain:_})}),quantityInput:t.jsx(cn,{balance:k,decimals:C}),balanceButton:t.jsx(pi,{onClick:()=>i("quantity",j.fromBaseUnit($,{decimals:C}),{shouldValidate:!0}),disabled:q,children:j.formatAmount(k??"0",{decimals:C})}),value:p?S?Z(U(p).times(S)):"$-":"$0"}),t.jsx("div",{className:Ka.divider}),t.jsx(Ho,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(xe.Stack,{children:!f&&t.jsx(xe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(fe,{children:t.jsx(ne.White,{type:"submit",loading:(F?"Estimating gas...":!1)||H,disabled:!!W,children:W??"Confirm"})})]})})},hb=()=>{const e=Ke(),n=Ot(),s=xt(n),{chain:o=n}=e,a=A.head(s);if(!e.denom&&!a)throw new 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.");const r=e.denom??a?.denom,i=pe.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(pe.FormProvider,{...i,children:t.jsx(mb,{})})};async function go(e,n){const s=e.replace("ibc/",""),{class_trace:o}=await V.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function pb(e,n){const s=new gt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await V.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:j.InitiaAddress("0x1").bech32,contract_addr:j.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function fb(e,n,s){if(n.startsWith("evm/"))return e;const{token_infos:o}=await V.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function gb({collection_addr:e},{restUrl:n}){const s=await pb(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await go(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function _b(e,n){const{data:s}=await V.create({prefixUrl:n}).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(s)}async function xb({object_addr:e,collection_addr:n},{restUrl:s}){const o=await _b(n,s);return o.startsWith("ibc/")?j.InitiaAddress.equals(j.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await go(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await go(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function yb(e,n){const s=re.toBase64(Dt.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await V.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function jb(e,n){const{collection:s}=await V.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function bb(e,n){const s=re.toBase64(Dt.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await V.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function Wa(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function vb({collection_addr:e},n,s){const o=j.InitiaAddress(e).bech32,a=await yb(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:_,version:x})=>_===s.chain_id&&x.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=re.toBase64(Dt.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await V.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),u=d??o,m=await bb(c,n.restUrl),h=await jb(o,n.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:m};if(d&&h!==i.replace("wasm.","")){const[_,x]=Wa(d);return{class_id:o,class_trace:{path:_,base_class_id:x},outgoing_proxy:m}}const[p,f]=Wa(a);return{class_id:o,class_trace:{path:p,base_class_id:f},outgoing_proxy:m}}const wb={minimove:xb,minievm:gb,miniwasm:vb};async function Cb({nft:e,srcChain:n,intermediaryChain:s}){const o=n.metadata?.is_l1?"minimove":n.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await wb[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await fb([e.token_id],a.class_id,n.restUrl)})}const Nb="_root_1tyvn_1",kb="_collectionName_1tyvn_10",Ib="_nftName_1tyvn_15",Ab="_chainInfo_1tyvn_19",Sb="_fields_1tyvn_24",$b="_chain_1tyvn_19",so={root:Nb,collectionName:kb,nftName:Ib,chainInfo:Ab,fields:Sb,chain:$b},Tb=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),Eb=()=>{const e=ue(),n=Ke(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=G(),r=En(),i=ie(),{address:c,initiaAddress:l,requestTxSync:d}=De(),{watch:u,setValue:m,handleSubmit:h,formState:p}=pe.useFormContext(),{errors:f}=p,_=u(),{recipient:x,dstChainId:y}=_,b=Xe(y),w=T.useQuery({queryKey:Tb.simulation({collection_addr:o,nft:n,sender:l,recipient:x,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const $=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:j.InitiaAddress(x).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==b.chainId&&await Cb({nft:n,srcChain:s,intermediaryChain:i})),{msgs:N}=await V.create({prefixUrl:a}).post("nft",{json:$}).json();return N.map(R=>r.fromAmino(R))},enabled:j.InitiaAddress.validate(x)}),{data:v,isLoading:C,error:k}=w,S=T.useQueryClient(),{mutate:M,isPending:F}=T.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await d({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{S.invalidateQueries({queryKey:na.nfts._def})}}),E=g.useMemo(()=>{if(!x)return"Enter recipient address";if(f.recipient)return f.recipient.message;if(k)return"Route not found"},[x,f.recipient,k]);return t.jsxs("form",{onSubmit:h(()=>M()),children:[t.jsx(ta,{normalizedNft:n,thumbnailSize:80,classNames:so}),t.jsxs("div",{className:so.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(ln,{title:"Destination appchain",content:$=>t.jsx(gi,{onSelect:({chainId:N})=>{m("dstChainId",N),$()},list:e,getImage:N=>N.logoUrl,getName:N=>N.name,getKey:N=>N.chainId}),className:L("input",so.chain),children:[t.jsx(J,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]}),t.jsx(Ho,{myAddress:c,ref:Bn()})]}),t.jsx(fe,{children:t.jsx(ne.White,{loading:(C?"Finding route...":!1)||F,disabled:!!E,children:E??"Confirm"})})]})},qb=()=>{const{chain:e}=Ke(),n=pe.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(mt,{title:"Send NFT",children:t.jsx(pe.FormProvider,{...n,children:t.jsx(Eb,{})})})},_o=()=>{const e=je(),n=et(),s=kt(),{closeDrawer:o}=lt(),{closeModal:a}=ys();g.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=$n();if(g.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ra,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ra,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(Hj,{});case"/send":return t.jsx(hb,{},s);case"/receive":return t.jsx(_x,{});case"/nft":return t.jsx(ob,{});case"/nft/send":return t.jsx(qb,{},s);case"/bridge":return t.jsx(Qp,{},s);case"/bridge/preview":return t.jsx(eg,{});case"/bridge/history":return t.jsx(Df,{});case"/op/withdrawals":return t.jsx(Eg,{});case"/tx":return t.jsx(ii,{});case"/autosign/enable":return t.jsx(Mm,{});case"/settings":return t.jsx(Kx,{});case"/settings/autosign":return t.jsx(Ex,{});case"/deposit":return t.jsx(J_,{});case"/deposit/completed":return t.jsx(ls,{type:"deposit"});case"/withdraw":return t.jsx(sx,{});case"/withdraw/completed":return t.jsx(ls,{type:"withdraw"})}},Lb="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",Mb=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:Lb}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Db=()=>(kc(),qc(),ue(),$l(),Vr(),An(),Rn(),zt(),null),Pb=({children:e,...n})=>(g.useEffect(()=>{cl()},[]),Ie.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(Mb,{}),t.jsx(er.Provider,{value:{...Xa,...n},children:t.jsx(mr,{children:t.jsx(lm,{children:t.jsx(Y.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(cm,{children:t.jsxs(Yu,{children:[e,t.jsx(Ml,{}),t.jsx(de,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Db,{})}),t.jsx(Cd,{children:t.jsx(_o,{})}),t.jsx(jd,{children:t.jsx(_o,{})})]})})})})})})]}):null),Rb=({bridge:e})=>t.jsx(mr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(ei.Provider,{value:!!e,children:t.jsx(de,{children:t.jsx(_o,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Ja;exports.InterwovenKit=Rb;exports.InterwovenKitProvider=Pb;exports.MAINNET=Xa;exports.MoveError=Ir;exports.PRIVY_APP_ID=jo;exports.TESTNET=ac;exports.initiaPrivyWallet=ic;exports.initiaPrivyWalletConnector=rc;exports.initiaPrivyWalletOptions=ms;exports.injectStyles=Yl;exports.useAddress=kt;exports.useHexAddress=Vt;exports.useInitiaAddress=X;exports.useInterwovenKit=De;exports.usePortfolio=To;exports.useUsernameQuery=Mr;
|
|
4
|
+
</svg>`,hc=encodeURIComponent(mc),No=`data:image/svg+xml;utf8,${hc}`,wn=ye.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,n)=>[e,n],resource:(e,n)=>[e.chainId,n.denom],denom:(e,n)=>[e,n],metadata:(e,n)=>[e,n]});function pc(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:l,traces:c}=e,d=o.find(h=>h.denom===a)?.exponent??o.find(h=>h.denom===n)?.exponent??A.head(o)?.exponent??0,u=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function nr(){const e=T.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return T.queryOptions({queryKey:wn.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(pc);for(const r of a)e.setQueryData(wn.item(n.chainId,r.denom).queryKey,r);return a},staleTime:K.MINUTE})}}function gt(e){const n=nr(),{data:s}=T.useSuspenseQuery(n(e));return s}function Sn(){const e=de(),n=nr();return T.useQueries({queries:e.map(s=>n(s))})}function lt(e){const n=gt(e),s=ae(),o=gt(s),a=or(e);return r=>{const i=n.find(c=>c.denom===r);if(i)return i;const l=o.find(c=>c.denom===a(r));return l?{...l,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:No}}}function sr(e,n){const s=lt(n),a=T.useQueryClient().getQueryData(wn.item(n.chainId,e).queryKey);return a||s(e)}function or(e){const n=ae(),s=gt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(l=>l.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===n.chain_name)return i.counterparty.base_denom}}const a=n.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?j.getIbcDenom(a,o):""}}function Io(e){const n=ae(),s=z.create({prefixUrl:n.restUrl}),o=T.useSuspenseQueries({queries:e.map(a=>({queryFn:()=>s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json(),queryKey:wn.denom(n.restUrl,a).queryKey,select:r=>[a,r.denom],staleTime:K.INFINITY}))});return new Map(o.map(({data:a})=>a))}function fc(e){return e.pagination?.next_key??null}async function ar(e,n,s){const o=z.create(n),a=async(r,i)=>{const l=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[s]??[],d=fc(l),u=[...r,...c];return d?a(u,d):u};return a([],null)}const ma="usernames";function gc({restUrl:e,moduleAddress:n}){const{viewFunction:s}=j.createMoveClient(e);async function o(i){if(!j.InitiaAddress.validate(i))return null;const l=await s({moduleAddress:n,moduleName:ma,functionName:"get_name_from_address",typeArgs:[],args:[ie.toBase64(j.InitiaAddress(i,32).bytes)]});return l?l+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const l=await s({moduleAddress:n,moduleName:ma,functionName:"get_address_from_name",typeArgs:[],args:[Gi.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?j.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const fs=ye.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function rr(){const{restUrl:e}=ae(),{usernamesModuleAddress:n}=Y();return gc({restUrl:e,moduleAddress:n})}function ir(){const e=te();return n=>T.queryOptions({queryKey:fs.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?ar(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:K.SECOND})}function An(e){const n=ir(),{data:s}=T.useSuspenseQuery(n(e));return s}function _c(){const e=de(),n=ir();return T.useQueries({queries:e.map(s=>n(s))})}function xc(e){const n=An(e),s=gt(e),o=lt(e),a=or(e),{data:r}=_t(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>s.some(d=>d.denom===c);return A.sortWith([A.descend(({denom:c})=>a(c)==="uinit"),A.descend(({denom:c})=>i(c)),A.descend(({value:c})=>c),A.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>B(d).comparedTo(c)??0,A.descend(({symbol:c})=>c.toLowerCase())],n.filter(({amount:c})=>!B(c).isZero()).map(({amount:c,denom:d})=>{const u=o(d),h=r?.find(({id:f})=>f===u?.denom)?.price??0,m=B(c).times(h).div(B(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const cr=_.createContext(null);function gs(){return _.useContext(cr)}function lr(){const{location:e}=gs();return e}function _s(){const{path:e}=lr();return e}function Je(){const{state:e={}}=lr();return e}function dr(){const{history:e}=gs();return e}function Ce(){const{navigate:e}=gs();return e}function ko(){const{reset:e}=gs();return e}const nn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ce(),l=ko(),c=d=>{d.preventDefault(),a?.(d),s?l(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:c,children:o})},ur=({children:e,initialEntry:n})=>{const[s,o]=_.useState([n??{path:"/"}]),a=s[s.length-1],r=_.useCallback((l,c)=>{o(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=A.take(u,d);return c!==void 0?A.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=_.useCallback((l,c)=>{o([{path:l,state:c}])},[]);return t.jsx(cr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},yc="c33b940c24c17e95f7d9d525d508ac61";function jc(){const{disableAnalytics:e}=Y();_.useEffect(()=>{e||wo.init(yc,{autocapture:!1})},[e])}function bc(){const{connector:e}=ve.useAccount(),{defaultChainId:n,disableAnalytics:s}=Y();_.useEffect(()=>{const o=new Ha.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),wo.identify(o)},[n,e?.name,s])}function Tn(){const e=_s();return _.useCallback((s,o)=>{wo.track(s,{path:e,...o})},[e])}const st="interwovenkit",Se="uinit",We="INIT",Pe=6,wc="uoinit",vc="omniINIT",mr="https://app.initia.xyz",So=`${mr}/liquidity/my`,Cc=`${mr}/vip/my`,Nc=1e3,hr=60*Nc,pr=60*hr,ha=24*pr,oe={PUBLIC_KEY:`${st}:public-key`,BRIDGE_SRC_CHAIN_ID:`${st}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${st}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${st}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${st}:bridge:dst-denom`,BRIDGE_QUANTITY:`${st}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${st}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${st}:bridge:route-type`,BRIDGE_HISTORY:`${st}:bridge:history`,OP_REMINDER:`${st}:op:reminder`},fr=W.atom(!1),gr=W.atom(!1);function xt(){const e=ko(),[n,s]=W.useAtom(fr),o=W.useSetAtom(gr),a=Tn();return{isDrawerOpen:n,openDrawer:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function cn(){const e=ko(),[n,s]=W.useAtom(gr),o=W.useSetAtom(fr),a=Tn();return{isModalOpen:n,openModal:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ao(){const e=Ce(),{closeDrawer:n}=xt(),{closeModal:s}=cn(),{disconnect:o}=ve.useDisconnect();return()=>{e("/blank"),n(),s(),o(),localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM),localStorage.removeItem(oe.BRIDGE_QUANTITY),localStorage.removeItem(oe.BRIDGE_SLIPPAGE_PERCENT)}}function Ic(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function kc(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function To(){const{privyContext:e}=Y(),{address:n}=ve.useAccount();return e?n?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>j.InitiaAddress.equals(o,n)):!1:!0}function Sc(){const{privyContext:e}=Y(),n=To(),{address:s}=ve.useAccount(),{signMessageAsync:o}=ve.useSignMessage(),a=Ao(),r=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const l=async c=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:c});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{a()}};_.useEffect(()=>{n||r&&s&&l(s)},[n,r,s])}function Ac(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=io.PubKey.decode(e.value);return jn.encodeSecp256k1Pubkey(n)}return ms.decodeOptionalPubkey(e)}function Tc({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Zi.BaseAccount.decode(n),i=Ac(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ke.accountFromAny({typeUrl:e,value:n})}function $c(e){return e.type==="initia/PubKeyEthSecp256k1"}const Ec={...jn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function qc(e){if($c(e)){const n=io.PubKey.fromPartial({key:ie.fromBase64(e.value)});return Ji.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(io.PubKey.encode(n).finish())})}return ms.encodePubkey(e)}function _r(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:Ec.ethsecp256k1,value:ie.toBase64(e)}}function Lc(e,n){if(n.length!==64)throw new 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:_r(e),signature:ie.toBase64(n)}}const $n=()=>{const e=Y();return new ms.Registry([...sn.protoRegistry,...e.protoTypes??[]])},En=()=>{const e=Y();return new Ke.AminoTypes({...sn.aminoConverters,...e.aminoConverters})};class xr{constructor(n,s,o){this.address=n,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${oe.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=ie.fromHex(s),ie.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,ie.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,ie.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?ie.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=pt.ethers.hashMessage(n),a=pt.ethers.SigningKey.recoverPublicKey(o,s);return ro.Secp256k1.compressPubkey(ie.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const o=ao.escapeCharacters(ao.sortedJsonStringify(s)),a=await this.signMessage(o),r=ie.fromHex(a.replace("0x","")).subarray(0,-1),l=ro.Secp256k1Signature.fromFixedLength(r).toFixedLength(),c=Lc(await this.getCachedPublicKey(),l);return{signed:s,signature:c}}}function xs(){const e=$n(),n=En(),s=qn(),o=$o();return async function(a,r,i,l,c,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const h=await o(a),{accountNumber:m,...f}=await h.getSequence(r),p=f.sequence+(d?.incrementSequence??0),[g]=await u.getAccounts(),x=qc(_r(g.pubkey)),y=Yi.SignMode.SIGN_MODE_EIP_191,b=i.map(w=>n.toAmino(w)),C=ao.makeSignDoc(b,l,a,c,m,p),{signature:v,signed:N}=await u.signAmino(r,C),$={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:N.msgs.map(w=>n.fromAmino(w)),memo:c}},q=e.encode($),V=ra.Int53.fromString(N.fee.gas).toNumber(),M=ra.Int53.fromString(N.sequence).toNumber(),I=ms.makeAuthInfoBytes([{pubkey:x,sequence:M}],N.fee.amount,V,N.fee.granter,N.fee.payer,y);return It.TxRaw.fromPartial({bodyBytes:q,authInfoBytes:I,signatures:[ie.fromBase64(v.signature)]})}}function qn(){const e=te(),{signMessageAsync:n}=ve.useSignMessage(),s=ae();return _.useMemo(()=>new xr(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Ds=new Map,Bs=new Map;function yr(){const e=Ye();return async n=>{if(Ds.has(n))return Ds.get(n);const{rpcUrl:s}=e(n),o=await ia.Comet38Client.create(new ia.HttpClient(s));return Ds.set(n,o),o}}function $o(){const e=$n(),n=En(),s=qn(),o=te(),a=yr();return async r=>{const i=`${o}:${r}`;if(Bs.has(i))return Bs.get(i);if(!s)throw new Error("Signer not initialized");const l=await a(r),c=await Ke.SigningStargateClient.createWithSigner(l,s,{registry:e,aminoTypes:n,accountParser:Tc,broadcastPollIntervalMs:500});return Bs.set(i,c),c}}function jr(){const{connector:e}=ve.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new pt.BrowserProvider(await e.getProvider())}}function br(){const e=te(),n=Ye();return{fetchFeegrant:async(a,r)=>{if(!e)return null;const i=n(a),l=z.create({prefixUrl:i.restUrl});try{const{allowance:c}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return c}catch{return null}},fetchGrants:async(a,r)=>{if(!e)return[];const i=n(a),l=z.create({prefixUrl:i.restUrl}),{grants:c}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:r}}).json();return c}}}function wr(){const{privyContext:e}=Y(),n=To();if(!(!e||!n))return e.wallets.find(s=>s.connectorType==="embedded")}function ys(){const e=wr();return e?.address?j.InitiaAddress(e.address).bech32:void 0}function vr(){const e=wr(),n=ys(),s=$n(),o=Ye(),a=xs();return async(r,i,l,c,d)=>{if(!e||!n)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:bo.MsgExec.fromPartial({grantee:n,msgs:l.map(f=>({typeUrl:f.typeUrl,value:s.encode(f)}))})}],h={...c,granter:i},m=new xr(n,e.sign,o(r).restUrl);return await a(r,n,u,h,d,{customSigner:m})}}const vn=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n)=>[e,n],grants:(e,n)=>[e,n]});function js(){const e=Y(),n=Vt(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(n.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function Cr(){const{data:e}=Eo(),n=js();return async(s,o)=>{const a=o.every(i=>{const l=n[s];return l?l.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Eo(){const e=te(),n=ys(),s=js(),{fetchFeegrant:o,fetchGrants:a}=br();return T.useQuery({queryKey:vn.expirations(e,n).queryKey,queryFn:async()=>{if(!e||!n)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[l,c]of Object.entries(s))try{const d=await a(l,n);if(!c.every(x=>d.some(y=>y.authorization?.msg===x))){r[l]=null;continue}const h=await o(l,n);if(!h){r[l]=null;continue}const m=d.filter(x=>c.includes(x.authorization.msg)).map(x=>x.expiration),f=h.allowance.expiration,p=[...m,f],g=qo(p);r[l]=g?new Date(g):void 0}catch{r[l]=null}const i={};for(const[l,c]of Object.entries(r))switch(c){case null:i[l]=!1;break;case void 0:i[l]=!0;break;default:i[l]=Ge.isFuture(c);break}return{expiredAtByChain:r,isEnabledByChain:i}},staleTime:K.INFINITY,retry:!1})}function Mc(){const{data:e,refetch:n}=Eo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(l=>l instanceof Date&&Ge.isFuture(l));if(o.length===0)return;const r=qo(o).getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function qo(e){return e.filter(n=>n!==void 0).toSorted((n,s)=>new Date(n).getTime()-new Date(s).getTime())[0]}const Nr=_.createContext(null),bs=()=>_.useContext(Nr);class Ir extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,l){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=l}}const Pc=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Rs=new Map;function Dc(e){const n=e.match(Pc);if(!n)return null;const[,s,o,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Bc(e,n,s){const o=`${e}:${n}`;if(Rs.has(o))return Rs.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return Rs.set(o,i),i}catch{return null}}function Rc(e,n,s,o,a,r,i){return new Ir(e,n,s,o,a,r,i)}async function Zt(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await ft(e);const o=Dc(e.message);if(!o)return await ft(e);const a=await Bc(n.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,l=a?.[o.moduleName]?.[o.errorCode],c=l||i,d=!!l;return Rc(c,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const kr="approve",ws=W.atom(),Sr=W.atom(null);function Ar(){const e=W.useAtomValue(ws);if(!e)throw new Error("Tx request not found");return e}function vs(){const e=Ce(),n=te(),{defaultChainId:s,registryUrl:o}=Y(),a=Ye(),{openDrawer:r,closeDrawer:i}=xt(),{openModal:l,closeModal:c}=bs(),d=W.useSetAtom(ws),u=W.useSetAtom(Sr),h=yr(),m=$o(),f=qn(),p=$n(),g=Cr(),x=vr(),y=xs(),b=async({messages:M,memo:I,chainId:w=s})=>{try{return await(await m(w)).simulate(n,M,I)}catch(E){throw await Zt(E,a(w),o)}},C=async({messages:M,memo:I,chainId:w=s})=>{const E=await h(w),U=Ke.QueryClient.withExtensions(E,Ke.setupTxExtension),F=M.map(P=>p.encodeAsAny(P)),[O]=await f.getAccounts(),Z=jn.encodeSecp256k1Pubkey(O.pubkey),H=await m(w),{sequence:R}=await H.getSequence(n);return U.tx.simulate(F,I,Z,R)},v=async({txRequest:M,broadcaster:I})=>{const E={...{memo:"",chainId:s,gas:M.gas||await b(M),gasAdjustment:on,gasPrices:null,spendCoins:[],internal:!1},...M};return new Promise((U,F)=>{d({txRequest:E,resolve:async Z=>{try{const H=await m(E.chainId),R=await I(H,It.TxRaw.encode(Z).finish());U(R),typeof E.internal=="string"&&e(E.internal)}catch(H){F(await Zt(H,a(E.chainId),o))}finally{O()}},reject:Z=>{F(Z),O()}}),E.internal?l({path:"/tx"}):r("/tx");const O=()=>{if(!E.internal){e("/blank"),i();return}c()}})},N=async M=>{const I=M.chainId??s;try{const w=await v({txRequest:M,broadcaster:async(E,U)=>await E.broadcastTxSync(U)});return M.internal&&typeof M.internal!="number"&&(u({txHash:w,chainId:I,status:"loading"}),V({txHash:w,chainId:M.chainId}).then(E=>{u({status:E.code===0?"success":"error",chainId:I,txHash:w})}).catch(()=>{u({status:"error",chainId:I,txHash:w})})),w}catch(w){throw M.internal&&typeof M.internal!="number"&&u({status:"error",chainId:I,error:w}),w}},k=(M,I=30*1e3,w=.5*1e3)=>v({txRequest:M,broadcaster:async(E,U)=>{const F=await E.broadcastTx(U,I,w);if(F.code!==0)throw new Error(F.rawLog);return F}}),$=async M=>{const I=M.chainId??s;try{const{messages:w,memo:E="",fee:U}=M,F=await m(I),Z=await g(I,w)?await x(I,n,w,U,E):await y(I,n,w,U,E);return await F.broadcastTxSync(It.TxRaw.encode(Z).finish())}catch(w){throw await Zt(w,a(I),o)}},q=async(M,I=30*1e3,w=.5*1e3)=>{const E=M.chainId??s;try{const{messages:U,memo:F="",fee:O}=M,Z=await m(E),R=await g(E,U)?await x(E,n,U,O,F):await y(E,n,U,O,F),P=await Z.broadcastTx(It.TxRaw.encode(R).finish(),I,w);if(P.code!==0)throw new Error(P.rawLog);return P}catch(U){throw await Zt(U,a(E),o)}},V=async({chainId:M=s,...I})=>{try{const w=await m(M);return await Tr({...I,client:w})}catch(w){throw await Zt(w,a(M),o)}};return{estimateGas:b,simulateTx:C,requestTxSync:N,requestTxBlock:k,submitTxSync:$,submitTxBlock:q,waitForTxConfirmation:V}}async function Tr({txHash:e,client:n,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await n.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Ln=W.atom(null);function $r(){const e=te(),n=js(),{fetchFeegrant:s,fetchGrants:o}=br();return async a=>{const{chainId:r,grantee:i}=a;if(!e)throw new Error("Granter wallet not initialized");const l=await s(r,i),c=await o(r,i),d=l?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Qa.MsgRevokeAllowance.fromPartial({granter:e,grantee:i})}]:[],u=n[r].filter(h=>c.some(m=>m?.authorization?.msg===h)).map(h=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:bo.MsgRevoke.fromPartial({granter:e,grantee:i,msgTypeUrl:h})}));return[...d,...u]}}function Fc(){const{privyContext:e}=Y(),n=te(),s=ys(),o=js(),{requestTxBlock:a}=vs(),r=T.useQueryClient(),[i,l]=W.useAtom(Ln),{closeDrawer:c}=xt(),d=$r(),u=async()=>{if(s)return s;if(!e)throw new Error("Privy context not available");const h=await e.createWallet({createAdditional:!1});return j.InitiaAddress(h.address).bech32};return T.useMutation({mutationFn:async h=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,f=await u();if(!n||!f)throw new Error("Wallets not initialized");const p=await d({chainId:m,grantee:f}),g=h===0?void 0:Ge.addMilliseconds(new Date,h),x={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Qa.MsgGrantAllowance.fromPartial({granter:n,grantee:f,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:la.BasicAllowance.encode(la.BasicAllowance.fromPartial({expiration:g})).finish()}})},y=o[m].map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:bo.MsgGrant.fromPartial({granter:n,grantee:f,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:ca.GenericAuthorization.encode(ca.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:g}})})),b=[...p,x,...y];await a({messages:b,chainId:m,internal:!0})},onSuccess:async()=>{await r.invalidateQueries({queryKey:vn.expirations._def}),i?.resolve()},onError:h=>{i?.reject(h)},onSettled:()=>{l(null),c()}})}function Er(e){const n=Y(),s=ys(),o=e?.grantee||s,{requestTxBlock:a}=vs(),r=T.useQueryClient(),i=$r();return T.useMutation({mutationFn:async(l=n.defaultChainId)=>{if(!o)throw new Error("Wallets not initialized");const c=await i({chainId:l,grantee:o});await a({messages:c,chainId:l,internal:e?.internal})},onSuccess:async()=>{const l=[vn.expirations._def,vn.grants._def];for(const c of l)await r.invalidateQueries({queryKey:c})}})}function Uc(){const{defaultChainId:e}=Y(),{openDrawer:n}=xt(),s=W.useSetAtom(Ln),o=Er(),{data:a={expiredAtByChain:{},isEnabledByChain:{}},isLoading:r}=Eo();return{...a,isLoading:r,enable:async(c=e)=>new Promise((d,u)=>{s({chainId:c,resolve:d,reject:u}),n("/autosign/enable")}),disable:async(c=e)=>{await o.mutateAsync(c)}}}function qr(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function Oc(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),B(0)).toString()}function Vc(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??No}}function pa(e){return A.pick(["chainId","name","logoUrl"],e)}function Kc(e){return A.sortWith([A.descend(({symbol:n})=>n===We),A.descend(qr),A.descend(({assets:n})=>n.length),A.ascend(({symbol:n})=>n)])(e)}function zc(e){return A.sortWith([A.descend(({value:n})=>n??0),A.descend(({quantity:n})=>Number(n)),A.ascend(({chain:n})=>n.name)])(e)}function Wc(e,n){return A.sortWith([A.descend(({chain:s})=>s.chainId===n),A.ascend(({chain:s})=>s.name),A.ascend(({denom:s})=>s)])(e)}function Hc(e,n){return A.sortWith([A.descend(({chainId:s})=>s===n),A.descend(A.prop("value"))])(e)}function Qc(e,n,s,o,a){const r=e.find(h=>h.metadata?.is_l1)?.chainId,i={};for(const h of e){const m=h.chainId,f=n[m]??[],p=s[m],g=o[m],x=[];for(const{amount:y,denom:b}of f){if(!B(y).gt(0))continue;const C=p?.find(q=>q.denom===b),v=g?.find(q=>q.id===b)?.price,N=C?.decimals??0,k=j.fromBaseUnit(y,{decimals:N}),$=v?B(k).times(v).toNumber():void 0;x.push({...Vc(b,C),amount:y,denom:b,decimals:N,quantity:k,price:v,value:$,address:C?.address,unlisted:!C,chain:pa(h)})}i[m]=x}const l=new Map;for(const[h,m]of Object.entries(i)){if(m.length===0)continue;const f=e.find(g=>g.chainId===h);if(!f)continue;const p=m.reduce((g,{value:x})=>g+(x??0),0);l.set(h,{...pa(f),value:p})}const c=new Map;for(const h of Object.values(i))for(const m of h)if(!m.unlisted){const{symbol:f}=m,p=c.get(f)??[];c.set(f,[...p,m])}const d=[];for(const[h,m]of c){const f=A.head(m);if(!f)continue;const p=zc(m),g=p.reduce((y,{value:b})=>y+(b??0),0),x=p.reduce((y,{quantity:b})=>y.plus(b),B(0)).toNumber();d.push({symbol:h,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:x})}const u=[];for(const h of Object.values(i))for(const m of h)m.unlisted&&u.push(m);return{chainsByValue:Hc(Array.from(l.values()),a),assetGroups:Kc(d),unlistedAssets:Wc(u,r),totalValue:d.reduce((h,m)=>h+m.totalValue,0)}}function Lo(){const{defaultChainId:e}=Y(),n=de(),s=_c(),o=Sn(),a=Co(),r=n.map(m=>m.chainId),i=A.zipObj(r,s.map(A.prop("data"))),l=A.zipObj(r,o.map(A.prop("data"))),c=A.zipObj(r,a.map(A.prop("data"))),d=Qc(n,i,l,c,e),u=[s,o,a].flat().some(({isLoading:m})=>m);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:m})=>m()),o.forEach(({refetch:m})=>m()),a.forEach(({refetch:m})=>m())}}}function te(){const e=ln();return e?j.InitiaAddress(e).bech32:""}function ln(){const{address:e}=ve.useAccount(),n=To();return!e||!n?"":j.InitiaAddress(e).hex}function kt(){const e=Vt(),n=te(),s=ln();return e.metadata?.minitia?.type==="minievm"?s:n}function Lr(){const e=kt(),n=rr();return T.useQuery({queryKey:fs.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function De(){const e=kt(),n=te(),s=ln(),{data:o}=Lr(),a=qn(),r=Ao(),i=Uc(),{isDrawerOpen:l,openDrawer:c}=xt(),{isModalOpen:d}=cn(),u=()=>{c("/")},h=()=>{c("/connect")},m=b=>{c("/bridge",b)},f=Ic(),p=kc(),g=vs();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:l||d,openConnect:h,openWallet:u,openBridge:m,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const Gc="_status_tn9m1_1",Yc="_error_tn9m1_9",fa={status:Gc,error:Yc},he=({error:e,children:n})=>t.jsx("p",{className:L(fa.status,{[fa.error]:e}),children:n}),me=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(he,{error:!0,children:o.message})},suspenseFallback:n=t.jsx(he,{children:"Loading..."}),children:s})=>t.jsx(Ga.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:n,children:s})}),Zc="lock_staking";function Mr(e,n){const s=`${n}::lock_staking::StakingAccount`,o=j.createObjectAddress(e,s);return j.InitiaAddress(o).bech32}const Mn=ye.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,n)=>[e,n],undelegations:(e,n,s)=>[e,n,s],lockStaking:(e,n,s)=>[e,n,s],stakingRewards:(e,n)=>[e,n],lockStakingRewards:(e,n,s)=>[e,n,s]});function Mo(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.delegations(e,n||"").queryKey,queryFn:async()=>n?(await z.get(`${e}/initia/mstaking/v1/delegations/${n}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const l=j.denomToMetadata(i.denom),c={denom:i.denom,metadata:l,amount:i.amount,validator:r},d=o.get(l)??[];d.push(c),o.set(l,d)}}return o},staleTime:K.MINUTE})}function Po(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const l=i.validator_address;for(const c of i.entries)for(const d of c.balance){const u=j.denomToMetadata(d.denom),h={denom:d.denom,metadata:u,amount:d.amount,validator:l,completionTime:c.completion_time},m=r.get(u)??[];m.push(h),r.set(u,m)}}return r},staleTime:K.MINUTE})}function Do(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te();return T.useSuspenseQuery({queryKey:Mn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=j.createMoveClient(e);return await o({moduleAddress:n,moduleName:Zc,functionName:"get_locked_delegations",typeArgs:[],args:[ie.toBase64(j.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},l=a.get(r.metadata)??[];l.push(i),a.set(r.metadata,l)}return a},staleTime:K.MINUTE})}function Pr(e){const n=new Map;if(!e.total||!Array.isArray(e.total))return n;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=j.denomToMetadata(s.denom);let a=new B(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=n.get(o);if(r){const i=new B(r.amount);a=a.plus(i)}n.set(o,{denom:s.denom,amount:a.toString()})}return n}function Dr(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await z.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Br(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Bo(){const e=ae(),n=gt(e),{data:s,isLoading:o}=_t(e),{data:a}=Mo(),{data:r}=Po(),{data:i}=Do(),l=_.useMemo(()=>{const f=new Set;for(const p of a.keys())f.add(p);for(const p of i.keys())f.add(p);for(const p of r.keys())f.add(p);return Array.from(f)},[a,i,r]),c=Io(l),d=_.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),u=_.useMemo(()=>{const f=new Map;for(const p of n)f.set(p.denom,p);return f},[n]),h=_.useMemo(()=>{const f=[],p=g=>{const x=u.get(g);return x?{symbol:x.symbol,decimals:x.decimals}:null};for(const[g,x]of a){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C};f.push({type:"staking",validator:v.validator,balance:q})}}for(const[g,x]of i){const y=c.get(g);if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(V)?0:V,balance:q})}}for(const[g,x]of r){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=new Date(v.completionTime).getTime(),M=Number.isNaN(V)?0:Math.floor(V/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:M,balance:q})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Se)},[a,i,r,c,u,d]),m=_.useMemo(()=>h.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[h]);return{positions:h,totalValue:m,isLoading:o}}const Ro=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function Jc(e){const n=new Map;for(const s of e){const o=j.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function Xc(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.checkLpTokens(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${n}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:K.MINUTE})}function Rr(){const e=ae(),n=An(e),s=_.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=Xc(s);return _.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return Jc(a)},[n,o])}function Fr(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.lpPrices(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${n}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:K.MINUTE})}function el(e){const{dexUrl:n}=Y(),s=ae(),o=gt(s),a=_.useMemo(()=>{const l=new Map;for(const c of o)l.set(c.denom,c);return l},[o]),i=T.useSuspenseQueries({queries:e.map(l=>({queryKey:Ro.pool(n,l).queryKey,queryFn:async()=>{try{const c=j.denomToMetadata(l);return(await z.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(c)}`).json()).pool}catch{return null}},staleTime:K.MINUTE}))}).map(l=>l.data);return _.useMemo(()=>{const l=new Map;return e.forEach((c,d)=>{const u=i[d];if(!u){l.set(c,null);return}if(c===wc){l.set(c,{...u,symbol:vc});return}const h=u.coins.map(m=>a.get(m.denom)?.symbol||m.denom).join("-");l.set(c,{...u,symbol:h})}),l},[e,i,a])}function tl(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}return Array.from(a)}function nl(e){const n=[];for(const[,s]of e)s&&s!==Se&&n.push(s);return n}function sl(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function ol(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=sl(o,s),i=r.length>0&&r.some(c=>c),l=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:l,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Fs(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r)??i[0]?.denom;if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function al(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r);if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function rl(e,n,s,o){for(const[a,r]of e){const i=j.denomToMetadata(a),l=n?.get(i),c=l?j.fromBaseUnit(l.amount,{decimals:Pe}):"0",d=s?.get(i),u=d?j.fromBaseUnit(d.amount,{decimals:Pe}):"0",h=Number(c)+Number(u);h>0&&(r.claimableInit={staking:c,lockStaking:u,total:String(h),totalValue:h*o})}}function Fo(){const e=ae(),n=gt(e),s=Rr(),{data:o}=Mo(),{data:a}=Do(),{data:r}=Po(),{data:i}=Dr(),{data:l}=Br(),{data:c}=_t(e),d=_.useMemo(()=>{const y=new Map;for(const b of n)y.set(b.denom,b);return y},[n]),u=_.useMemo(()=>tl(s,o,a,r),[s,o,a,r]),h=Io(u),m=_.useMemo(()=>nl(h),[h]),{data:f}=Fr(m),p=el(m),{rows:g,totalValue:x}=_.useMemo(()=>{const y=c?.find(N=>N.id===Se)?.price??0,b=new Map;for(const N of m)b.set(N,ol(N,p,d));Fs(s,h,f,b,"deposit"),Fs(o,h,f,b,"staking"),al(a,h,f,b,"lockStaking"),Fs(r,h,f,b,"unstaking"),rl(b,i,l,y);const C=Array.from(b.values()).filter(N=>N.totalAmount>0).sort((N,k)=>k.totalValue-N.totalValue),v=C.reduce((N,k)=>N+k.totalValue,0);return{rows:C,totalValue:v}},[m,p,d,s,o,a,r,h,f,i,l,c]);return{totalValue:x,rows:g}}const il=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function cl(e){return e.filter(n=>n.data.length>0).map(n=>{const s=n.data[0].bridge_id,o=n.data[0].version,a=n.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:n.total_claimable_reward,claimedReward:a,initialReward:n.total_vesting_reward,lockedReward:n.total_locked_reward,requiredScore:n.required_score,rollup:{bridgeId:s,version:o}}}).filter(n=>n.initialReward>0).toSorted((n,s)=>s.initialReward-n.initialReward)}function Ur(){const{vipUrl:e}=Y(),n=te();return T.useQuery({queryKey:il.allVestingPositions(e,n).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${n}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:K.MINUTE,enabled:!!n})}function ll(){const e=de();return _.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Cs(){const{data:e}=Ur(),n=ae(),{data:s}=_t(n),o=ll(),a=_.useMemo(()=>s?.find(c=>c.id===Se)?.price??0,[s]),r=_.useMemo(()=>e?cl(e).map(c=>{const d=o(c.rollup.bridgeId),u=Number(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})),h=Number(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})),m=B(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})).times(a).toNumber(),f=B(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})).times(a).toNumber();return{bridgeId:c.rollup.bridgeId,version:c.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:m,claimableReward:h,claimableRewardValue:f}}):[],[e,a,o]),i=_.useMemo(()=>r.reduce((l,c)=>l+c.lockedRewardValue+c.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Or(){const e=Rr(),{data:n}=Mo(),{data:s}=Do(),{data:o}=Po(),{data:a}=Ur(),r=ae(),{data:i}=_t(r),l=_.useMemo(()=>i?.find(g=>g.id===Se)?.price??0,[i]),c=_.useMemo(()=>{const p=new Set;for(const[g]of e)p.add(g);for(const[g]of n)p.add(g);for(const[g]of s)p.add(g);for(const[g]of o)p.add(g);return Array.from(p)},[e,n,s,o]),d=Io(c),u=_.useMemo(()=>Array.from(d.values()).filter(p=>p!==Se),[d]),{data:h}=Fr(u),m=gt(r),f=_.useMemo(()=>{const p=new Map;for(const g of m)p.set(g.denom,{decimals:g.decimals});return p},[m]);return _.useMemo(()=>{let p=0,g=0;const x=l??0,y=(C,v)=>{const N=d.get(C)??C;if(N===Se)return 0;const k=f.get(N)?.decimals??Pe;return Number(j.fromBaseUnit(v,{decimals:k}))*(h.get(N)??0)};for(const[,C]of n)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of s){const k=(d.get(C)??C)===Se;for(const{amount:$}of v)k?p+=Number(j.fromBaseUnit($,{decimals:Pe}))*x:g+=y(C,$)}for(const[,C]of o)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of e)for(const{amount:N}of v)g+=y(C,String(N));let b=0;if(a)for(const C of a){const v=C.total_locked_reward??0,N=C.total_claimable_reward??0;b+=Number(j.fromBaseUnit(String(v+N),{decimals:Pe}))*x}return p+g+b},[n,s,o,e,a,l,d,h,f])}function dl(){const 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"],n={"initia-wallet-widget:ethereum-public-keys":{prefix:oe.PUBLIC_KEY,getSuffix:s=>j.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(n)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[l,c]of Object.entries(i)){const d=`${o}:${a(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(s)}catch{}}}const co=ye.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,n)=>[e,n],balances:(e,n,s)=>[e,n,s],initiaPositions:(e,n)=>[e,"initia",n],echelonPositions:(e,n)=>[e,"echelon",n],inertiaPositions:(e,n)=>[e,"inertia",n],ravePositions:(e,n,s)=>[e,"rave",n,s],civitiaPositions:(e,n)=>[e,"civitia",n],yominetPositions:(e,n)=>[e,"yominet",n],chainPositions:(e,n,s)=>[e,n,s]});function Uo(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],l=r.data;if(!(!i||!l)){for(const c of l)if(c.logoUrl&&!c.logoUrl.includes("undefined")){const d=`${i.chainId}:${c.denom}`;s.has(d)||s.set(d,c.logoUrl);const u=c.symbol.toUpperCase();o.has(u)||o.set(u,c.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function an(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const n=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-n:n}function ul(e){return e.type==="fungible-position"?null:e.type==="staking"||e.type==="unstaking"||e.type==="lockstaking"?"staking":e.type==="lending"?e.direction==="supply"?"lending":"borrowing":null}function ml(e,n=!1){switch(e){case"staking":return n?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function hl(e){const n=new Map;for(const d of e){const u=ul(d);if(!u)continue;const h=n.get(u)??[];h.push(d),n.set(u,h)}const s=new Map,o=new Map;for(const[d,u]of n){const h=u.reduce((f,p)=>f+an(p),0),m=u.reduce((f,p)=>f+Math.abs(an(p)),0);s.set(d,h),o.set(d,m)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,l=[...n.keys()].sort((d,u)=>{const h=d==="lending"||d==="borrowing"?i:o.get(d)??0,m=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:m-h}),c=new Map;for(const d of l)c.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return c}function pl(e){return e.type==="fungible-position"?e.title:e.balance.denom}function fl(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function gl(e){return e.type==="fungible-position"?null:e.balance}function _l(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";default:return""}}function xl(e){const n=new Map;for(const s of e){const o=n.get(s.type)??[];o.push(s),n.set(s.type,o)}return n}function yl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function jl(e){const n=new Map;for(const o of e){const a=pl(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=gl(a[0]);let i=0;for(const l of a)l.type!=="fungible-position"&&l.balance.type!=="unknown"&&(i+=l.balance.formattedAmount);return{denom:o,symbol:fl(a[0]),positions:a,totalValue:a.reduce((l,c)=>l+an(c),0),totalAmount:i,balance:r}}).toSorted(yl)}function Vr(e,n){const s=new Map;return e.forEach((o,a)=>{const r=n[a]?.data;if(r&&r.length>0){const i=new Map(r.map(l=>[l.id,l.price]));s.set(o.chainId,i)}}),s}function bl(e,n){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=n.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function wl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function vl(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const l=i.symbol.toUpperCase(),c=`${i.chain.chainId}:${i.denom}`,d=n.get(c)??s.get(l)??"";return d!==i.logoUrl?{...i,logoUrl:d}:i});let r="";for(const i of a)if(i.logoUrl){r=i.logoUrl;break}return r||(r=s.get(o.symbol.toUpperCase())??""),r!==o.logoUrl||a!==o.assets?{...o,logoUrl:r,assets:a}:o})}function Cl(e,n,s){const o=n?e.filter(i=>{const{symbol:l,assets:c}=i,d=n.toLowerCase();return l.toLowerCase().includes(d)||c.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const l=i.assets.filter(({chain:c})=>c.chainId===s);return{...i,assets:l,totalValue:l.reduce((c,d)=>c+(d.value??0),0),totalAmount:l.reduce((c,d)=>c+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,l)=>i+l.assets.reduce((c,d)=>c+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Nl(e,n,s){const o=n?e.filter(({denom:a,address:r})=>{const i=n.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Il(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Cl(e,s,o),i=Nl(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function kl(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const l of e){const{chainName:c,chainId:d,balances:u}=l;if(!Array.isArray(u))continue;const h=n.get(c.toLowerCase()),m=h?.chainId??d??c,f=h?.prettyName??c,p=h?.logoUrl??"",g=s.get(m);for(const x of u){if(x.type==="unknown"){if(!x.amount||x.amount==="0")continue;r.push({symbol:x.denom,logoUrl:"",denom:x.denom,amount:x.amount,decimals:0,quantity:x.amount,value:void 0,unlisted:!0,chain:{chainId:m,name:f,logoUrl:p}});continue}if(x.type==="lp"||(x.value??0)<=0&&(x.formattedAmount??0)<=0)continue;let y=x.value;if((y==null||y<=0)&&g){const v=g.get(x.denom)??0;v>0&&(y=x.formattedAmount*v)}const b={symbol:x.symbol,logoUrl:"",denom:x.denom,amount:x.amount,decimals:x.decimals,quantity:String(x.formattedAmount),value:y,chain:{chainId:m,name:f,logoUrl:p}},C=a.get(x.symbol);C?C.push(b):a.set(x.symbol,[b])}}r.sort((l,c)=>{const d=l.chain.chainId===o,u=c.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const h=l.chain.name.localeCompare(c.chain.name);if(h!==0)return h;try{const m=BigInt(l.amount),f=BigInt(c.amount);if(m>f)return-1;if(m<f)return 1}catch{const m=l.amount.localeCompare(c.amount);if(m!==0)return-m}return l.denom.localeCompare(c.denom)});const i=[];for(const[l,c]of a){c.sort((h,m)=>(m.value??0)-(h.value??0));let d=0,u=0;for(const h of c)d+=h.value??0,u+=Number(h.quantity);i.push({symbol:l,logoUrl:"",assets:c,totalValue:d,totalAmount:u})}return i.sort(wl),{listedGroups:i,unlistedAssets:r}}function Oo(){return ae().network_type==="testnet"}function St(){return _e.useFormContext()}function Sl(){const e=Je(),n=Oo(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},r=A.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(oe.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(oe.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(oe.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(oe.BRIDGE_DST_DENOM),quantity:localStorage.getItem(oe.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(oe.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Al={balances:[],positions:[],isLoading:!0,isComplete:!1},Kr=W.atom(0),Tl=1e3;let ga=0;function $l(){const e=W.useSetAtom(Kr);_.useEffect(()=>{const n=Date.now();n-ga>=Tl&&(ga=n,e(s=>s+1))},[e])}function El(){const e=T.useQueryClient(),n=te(),{minityUrl:s}=Y(),o=Oo(),a=W.useAtomValue(Kr),r=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.balances)?c.balances:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,balances:u})}),i=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.positions)?c.positions:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,positions:u})}),l=_.useEffectEvent((c,d)=>{const u=co.ssePortfolio(n??"",s).queryKey,h=e.getQueryData(u)??Al,m=c.size>0||d.size>0;e.setQueryData(u,{...h,balances:Array.from(c.values()),positions:Array.from(d.values()),isLoading:m?!1:h.isLoading,isComplete:!1})});_.useEffect(()=>{if(!n||o)return;const c=co.ssePortfolio(n,s).queryKey,d=e.getQueryData(c),u=new Map,h=new Map;for(const x of d?.balances??[])u.set(x.chainName,x);for(const x of d?.positions??[])h.set(x.chainName,x);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,g=!1;return e.setQueryData(c,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),p=new EventSource(f),p.onmessage=x=>{if(!g)try{const y=JSON.parse(x.data);y.type==="balances"?r(y,u):y.type==="positions"&&i(y,h),l(u,h)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[n,o,a])}const _a={balances:[],positions:[],isLoading:!0,isComplete:!1};function Pn(){const e=te(),{minityUrl:n}=Y(),s=co.ssePortfolio(e??"",n).queryKey,{data:o}=T.useQuery({queryKey:s,queryFn:()=>_a,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??_a}function ql(){const e=de();return _.useMemo(()=>{const n=new Map;for(const s of e){const o=s.chain_name.toLowerCase();n.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return n},[e])}function Ll(){const{balances:e,positions:n}=Pn(),s=de(),o=_.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return _.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((p,g)=>{if(g.type==="fungible-position")return p+(g.value??0);if(g.balance.type==="unknown")return p;const x=g.balance.value??0;return g.type==="lending"&&g.direction==="borrow"?p-x:p+x},0),l=new Map,c=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:p}of c){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+r(y),0);l.set(f,(l.get(f)||0)+g)}for(const{chainName:f,positions:p}of d){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+i(y),0);l.set(f,(l.get(f)||0)+g)}const u=Array.from(l.values()).reduce((f,p)=>f+p,0),h=Array.from(l.entries()).filter(([,f])=>f>0).map(([f,p])=>{const g=o.get(f.toLowerCase());return{chainId:g?.chainId||"",chainName:g?.name||f,logoUrl:g?.logoUrl||"",totalBalance:p,percentage:u>0?p/u:0}}).filter(f=>f.chainId!==""),m=f=>f.chainName.toLowerCase()==="initia";return A.sortWith([A.descend(m),A.descend(A.prop("totalBalance"))],h)},[e,n,o])}function Ml(){const{balances:e}=Pn(),n=de(),s=Co(),o=_.useMemo(()=>Vr(n,s),[n,s]);return _.useMemo(()=>{const a=c=>c.type==="unknown"?0:c.value??0;let r=0;const i=Array.isArray(e)?e:[],l=bl(i,o);for(const{balances:c}of l)if(Array.isArray(c))for(const d of c)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function Pl(){const{positions:e}=Pn();return _.useMemo(()=>{const n=r=>r.positions.reduce((i,l)=>{if(l.type==="fungible-position")return i+(l.value??0);if(l.balance.type==="unknown")return i;const c=l.balance.value??0;return l.type==="lending"&&l.direction==="borrow"?i-c:i+c},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const l=r.toLowerCase();s.includes(l)||Array.isArray(i)&&(o+=i.reduce((c,d)=>c+n(d),0))}return o},[e])}const qe=ye.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,n)=>[e,n],allBalances:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[{...e,quantity:B(e.quantity||0).toString()},n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function Xe(){const{routerApiUrl:e}=Y();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function zr(){const e=de();return n=>e.some(s=>s.chain_id===n)}function Dn(){const e=zr();return n=>e(n.chain_id)?"initia":n.chain_type}function Cn(e){return Dn()(e)}function Bn(){const e=Xe(),{data:n}=T.useSuspenseQuery({queryKey:qe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>A.sortWith([A.descend(({chain_name:o})=>o==="initia"),A.ascend(({pretty_name:o})=>o)],s),staleTime:K.MINUTE});return n}function yt(){const e=Bn(),n=er();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=n.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function ze(e){return yt()(e)}function Kt(){const e=Xe(),n=Bn(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),select:({chain_to_assets_map:a})=>{const r=[];for(const i in a){if(!n.find(c=>c.chain_id===i))continue;const{assets:l}=a[i]??{assets:[]};s.setQueryData(qe.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...l);for(const c of l)s.setQueryData(qe.asset(i,c.denom).queryKey,c)}return r},staleTime:K.MINUTE});return o}function is(e){const n=Xe(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(qe.asset(e,i.denom).queryKey,i);return r.toSorted(A.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function Wr(e){const n=is(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function it(e,n){return Wr(n)(e)}const Dl=()=>(jc(),bc(),null),Bl="_loader_1vxch_1",Rl={loader:Bl},ct=({size:e=24,color:n="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:Rl.loader,style:o})},Fl="_button_1q027_1",Ul="_outline_1q027_28",Ol="_sm_1q027_46",Vl="_full_1q027_53",Kl="_small_1q027_57",zl="_unpadded_1q027_88",Bt={button:Fl,outline:Ul,sm:Ol,full:Vl,small:Kl,unpadded:zl},Hr=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...l}=e;return t.jsx("button",{...l,className:L(Bt.button,{[Bt.sm]:n,[Bt.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(ct,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Bt.loading,children:o})]}):r})},Wl=({className:e,...n})=>t.jsx(Hr,{...n,className:L(Bt.outline,e)}),Hl=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:L(Bt.small,{[Bt.unpadded]:n},e)}),le={White:Hr,Outline:Wl,Small:Hl},Ql="_footer_1vp4h_1",Gl="_actions_1vp4h_10",xa={footer:Ql,actions:Gl},xe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:L(xa.footer,n),children:[e,t.jsx("div",{className:xa.actions,children:s})]}),Yl="_scrollable_13su7_1",Zl={scrollable:Yl},et=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:L(Zl.scrollable,e),children:n});function Ns(){return Le.useMediaQuery("(max-width: 576px)")}const lo="interwoven-kit";function Qr(){const e=document.querySelector(lo)||document.body.appendChild(document.createElement(lo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Gr(){const{theme:e,container:n}=Y();return _.useEffect(()=>{document.querySelector(lo)?.setAttribute("data-theme",e)},[e]),n??Qr()}function Jl(e){const n=Qr(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const Is=_.createContext(null);function Ot(){const{container:e}=_.useContext(Is);return e}function Yr(e){const n=Ot();return n?getComputedStyle(n).getPropertyValue(e):""}function Xl(){return Le.useScrollLock(),null}function ed(e){return/^[A-F0-9]{64}$/i.test(e)}function td(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return ed(s)?A.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!j.InitiaAddress.validate(o))return;const i=A.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function nd(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const sd="_link_j1lkz_1",ya={link:sd},ks=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:l,onClick:c,...d}=a,u=Ze(e),h=td(u,{txHash:n,accountAddress:s,pathSuffix:o}),m=n?j.truncate(n):s?j.truncate(s):"",f=l??m;return h?t.jsxs("a",{...d,href:Xi(nd(h)),className:L(ya.link,i),onClick:c,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:L(ya.link,i),children:f})},Zr=_.createContext(null),Ss=()=>_.useContext(Zr),od=()=>{const[e,n]=W.useAtom(Sr),{showNotification:s,updateNotification:o,hideNotification:a}=Ss();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(ks,{txHash:l,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,o,a]),null},cs=({value:e,children:n})=>{const[s,o]=_.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},ad="_placeholder_10r3x_1",rd="_logo_10r3x_5",ja={placeholder:ad,logo:rd},X=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[l,c]=_.useState(void 0),{width:d,height:u}=i,h=s??t.jsx("div",{className:L(ja.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||l===e?h:t.jsx("img",{...i,className:L(i.className,{[ja.logo]:r}),style:{width:d,height:u,...a},src:e,alt:n,loading:"lazy",onError:()=>c(e)})};function Jr(){const{connector:e}=ve.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const id="_header_1q8ju_1",cd="_account_1q8ju_17",ld="_name_1q8ju_28",dd="_address_1q8ju_32",ud="_icon_1q8ju_36",md="_copied_1q8ju_43",hd="_button_1q8ju_58",pd="_settings_1q8ju_69",fd="_disconnect_1q8ju_73",gd="_label_1q8ju_83",_d="_expanded_1q8ju_91",Fe={header:id,account:cd,name:ld,address:dd,icon:ud,copied:md,button:hd,settings:pd,disconnect:fd,label:gd,expanded:_d},xd=()=>{const e=Ao(),{address:n,username:s}=De(),o=Jr(),a=s??n,[r,i]=_.useState(!1),l=_.useRef(null),c=rt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(l.current=setTimeout(()=>{i(!1)},500))},h=()=>{l.current&&(clearTimeout(l.current),l.current=null)};return _.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),n?t.jsxs("header",{className:Fe.header,children:[t.jsx(cs,{value:n,children:({copy:m,copied:f})=>t.jsxs("button",{className:L(Fe.account,{[Fe.copied]:f}),onClick:m,children:[t.jsx(X,{src:o,width:18,height:18}),t.jsx("div",{className:Fe.address,children:j.truncate(n)}),t.jsx("div",{className:Fe.name,children:j.truncate(a)}),t.jsx(S.IconCopy,{className:Fe.icon,size:12}),f?"Copied!":""]})}),t.jsx(nn,{to:"/settings",className:L(Fe.button,Fe.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(rt.animated.button,{className:L(Fe.button,Fe.disconnect,{[Fe.expanded]:r}),style:c,onClick:d,onMouseLeave:u,onMouseEnter:h,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Fe.label,children:"Disconnect"})]})]}):null},yd="_overlay_jij9g_1",jd="_content_jij9g_28",bd="_inner_jij9g_60",Us={overlay:yd,content:jd,inner:bd},wd=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=xt(),{setContainer:o}=_.useContext(Is),a=Ns(),r=Gr(),i=W.useAtomValue(ws),l=W.useAtomValue(Ln),c=T.useIsMutating({mutationKey:[kr]}),d=()=>{const p=c?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(p)),l?.reject(new Error("User rejected"))},u=_s(),h=Ce(),m=T.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const x=()=>{u==="/bridge"&&(localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM)),h("/"),m.clear(),g()};return t.jsxs(et,{children:[t.jsx(he,{error:!0,children:p.message}),t.jsx(xe,{children:t.jsx(le.White,{onClick:x,children:"Retry"})})]})}};return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:p=>!p&&d(),modal:!1,children:t.jsxs(ke.Dialog.Portal,{container:r,children:[a&&t.jsx(ke.Dialog.Backdrop,{className:Us.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.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"}),t.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"})]})}),t.jsx(ke.Dialog.Popup,{className:Us.content,children:t.jsxs("div",{className:L(Us.inner,"body"),ref:o,children:[a&&t.jsx(Xl,{}),t.jsx(od,{}),t.jsx(xd,{}),t.jsx(me,{errorBoundaryProps:f,children:e})]})})]})})},vd="_backdrop_1bqx9_1",Cd="_modal_1bqx9_12",Nd="_closeButton_1bqx9_44",Os={backdrop:vd,modal:Cd,closeButton:Nd},Id=({children:e})=>{const{isModalOpen:n,closeModal:s}=cn(),{setContainer:o}=_.useContext(Is),a=Gr();return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:r=>!r&&s(),children:t.jsxs(ke.Dialog.Portal,{container:a,children:[t.jsx(ke.Dialog.Backdrop,{className:Os.backdrop,onClick:s}),t.jsxs(ke.Dialog.Popup,{className:L(Os.modal),ref:o,children:[t.jsx("button",{className:Os.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},Xr=_.createContext(!1),kd="_overlay_1iyfl_1",Sd="_fullscreen_1iyfl_15",Ad="_content_1iyfl_19",Td="_header_1iyfl_56",$d="_title_1iyfl_65",Ed="_close_1iyfl_70",$t={overlay:kd,fullscreen:Sd,content:Ad,header:Td,title:$d,close:Ed},ei=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ot(),l=_.useContext(Xr);return i?t.jsxs(ke.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&t.jsx(ke.Dialog.Trigger,{className:o,children:s}),t.jsxs(ke.Dialog.Portal,{container:i,children:[t.jsx(ke.Dialog.Backdrop,{className:L($t.overlay,{[$t.fullscreen]:l}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(ke.Dialog.Popup,{className:L($t.content,{[$t.fullscreen]:l}),children:[e&&t.jsxs("header",{className:$t.header,children:[t.jsx(ke.Dialog.Title,{className:$t.title,children:e}),t.jsx(ke.Dialog.Close,{className:$t.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},Nn=({children:e})=>{const n=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=rt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>{const{height:u}=l.getBoundingClientRect();o(u),r(!0)};c();const d=new ResizeObserver(c);return d.observe(l),()=>d.disconnect()},[e]),e?t.jsx(rt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},qd="_help_qcmtq_1",Ld="_icon_qcmtq_10",Md="_info_qcmtq_19",Pd="_warning_qcmtq_23",Dd="_error_qcmtq_27",Bd="_success_qcmtq_33",Vs={help:qd,icon:Ld,info:Md,warning:Pd,error:Dd,success:Bd},Jt=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(ct,{size:12});case"info":return t.jsx(S.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(S.IconWarningFilled,{size:12});default:return t.jsx(S.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:L(Vs.help,e&&Vs[e],n),style:{marginTop:s},children:[t.jsx("div",{className:Vs.icon,children:a()}),o]})},Rd="_stack_a6m7u_1",Fd="_help_a6m7u_6",Ud="_info_a6m7u_14",Od="_warning_a6m7u_19",Vd="_error_a6m7u_24",Kd="_success_a6m7u_29",uo={stack:Rd,help:Fd,info:Ud,warning:Od,error:Vd,success:Kd},zd=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(Nn,{children:t.jsx("div",{className:uo.stack,children:e})}),fe=({mt:e=0,...n})=>t.jsx(Jt,{...n,className:L(uo.help,uo[n.level]),mt:e});fe.Stack=zd;const Wd="_root_16p5j_1",Hd="_item_16p5j_10",Qd="_chevron_16p5j_14",Gd="_trigger_16p5j_19",Yd="_content_16p5j_39",mn={root:Wd,item:Hd,chevron:Qd,trigger:Gd,content:Yd};function Zd(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(J.Accordion.Root,{className:mn.root,type:"multiple",...i,children:[n.map((l,c)=>t.jsxs(J.Accordion.Item,{className:mn.item,value:s?.(l)??String(c),children:[t.jsx(J.Accordion.Header,{children:t.jsxs(J.Accordion.Trigger,{className:mn.trigger,children:[o(l),t.jsx(S.IconChevronDown,{className:mn.chevron,size:16})]})}),t.jsx(J.Accordion.Content,{className:mn.content,children:a(l)})]},s?.(l)??c)),r]})}const Jd=10;function ti(){const e=te();return(n,s)=>T.queryOptions({queryKey:fs.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Jd},{txs:a}=await z.create({prefixUrl:n.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:K.SECOND})}function Xd(e,n){const s=ti();return T.useSuspenseQuery(s(e,n))}function eu(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return A.sortWith([A.descend(o=>new Date(o.timestamp).getTime())])(s)}const tu=()=>{const e=de(),n=ti(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(A.prop("data")),a=eu(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};function Vo(e){const{data:n}=T.useSuspenseQuery({queryKey:ps.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:s}=e,{gas_prices:o}=await z.create({prefixUrl:s}).get("initia/tx/v1/gas_prices").json();return o.toSorted(A.descend(({denom:a})=>a==="uinit")).map(({denom:a,amount:r})=>{const i=a==="uinit"?1:Za;return{amount:B(r).times(i).toFixed(18),denom:a}})}return e.fees.fee_tokens.map(({denom:s,fixed_min_gas_price:o})=>{if(A.isNil(o))throw new Error(`${s} has no price`);return{amount:String(o),denom:s}})},staleTime:K.SECOND});return n}function Ko(e){const n=te(),{data:s}=Xd(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>j.InitiaAddress.equals(n,pt.computeAddress(`0x${ie.toHex(ro.Secp256k1.uncompressPubkey(ie.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const nu="_trigger_u613p_1",su="_icon_u613p_18",ou="_content_u613p_27",au="_item_u613p_36",ru="_itemText_u613p_52",iu="_itemIndicator_u613p_57",cu="_active_u613p_60",vt={trigger:nu,icon:su,content:ou,item:au,itemText:ru,itemIndicator:iu,active:cu};function zo({options:e,value:n,onChange:s,classNames:o}){const a=Ot(),r=e.find(l=>l.value===n);if(!r)throw new Error("Selected option not found");const i=l=>{const c=e.find(d=>String(d.value)===l);if(!c)throw new Error(`Option not found: ${l}`);s(c.value)};return t.jsxs(ut.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ut.Select.Trigger,{className:L(vt.trigger,o?.trigger),children:[t.jsx(ut.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ut.Select.Icon,{className:vt.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(ut.Select.Portal,{container:a,children:t.jsx(ut.Select.Positioner,{className:vt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ut.Select.Popup,{className:vt.popup,children:e.map(l=>t.jsxs(ut.Select.Item,{className:L(vt.item,o?.item),value:String(l.value),children:[t.jsx(ut.Select.ItemText,{className:L(vt.itemText,o?.itemText),children:l.label}),t.jsx(S.IconCheck,{size:12,className:L(vt.itemIndicator,{[vt.active]:l.value===n})})]},String(l.value)))})})})]})}const lu="_root_1t37n_1",du="_trigger_1t37n_7",uu="_item_1t37n_11",mu="_itemText_1t37n_17",ba={root:lu,trigger:du,item:uu,itemText:mu},hu=({options:e,value:n,onChange:s})=>{const{txRequest:o}=Ar(),a=Ze(o.chainId),r=lt(a),i=(p,g)=>{if(j.formatAmount(p,{decimals:g})==="0.000000")return 8},l=({amount:[{amount:p,denom:g}]})=>{if(B(p).isZero())return"0";const{symbol:x,decimals:y}=r(g),b=i(p,y);return`${j.formatAmount(p,{decimals:y,dp:b})} ${x}`},c=e.map(p=>{const[{denom:g}]=p.amount,{symbol:x}=r(g);return{value:g,label:l(p),triggerLabel:x}});if(e.length===1)return t.jsx("span",{className:"monospace",children:l(e[0])});const d=e.find(p=>p.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:h}]=d.amount,{decimals:m}=r(h),f=i(u,m);return t.jsxs("div",{className:ba.root,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(u,{decimals:m,dp:f})}),t.jsx(zo,{options:c,value:n,onChange:s,classNames:ba})]})},pu="_root_16nr2_1",fu="_trigger_16nr2_5",gu="_chevron_16nr2_13",_u="_panel_16nr2_27",xu="_details_16nr2_39",yu="_row_16nr2_48",Gt={root:pu,trigger:fu,chevron:gu,panel:_u,details:xu,row:yu},ju=({spend:e,fee:n,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:n},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),l=r===6?void 0:8;return t.jsxs(Ps.Collapsible.Root,{className:Gt.root,children:[t.jsxs(Ps.Collapsible.Trigger,{className:Gt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:Gt.chevron,size:16})]}),t.jsx(Ps.Collapsible.Panel,{className:Gt.panel,children:t.jsx("div",{className:Gt.details,children:i.map(({label:c,value:d})=>t.jsxs("div",{className:Gt.row,children:[t.jsx("span",{children:c}),t.jsxs("span",{children:[j.formatAmount(d,{decimals:r,dp:l})," ",a]})]},c))})})]})};function ls(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?ie.toBase64(e):Array.isArray(e)?`[${e.map(ls).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const bu="_container_1xzyq_1",wu="_toggle_1xzyq_5",vu="_list_1xzyq_11",Cu="_arg_1xzyq_16",Nu="_type_1xzyq_21",hn={container:bu,toggle:wu,list:vu,arg:Cu,type:Nu},Iu=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),ku=({type:e,arg:n})=>ls(j.resolveBcsType(e).parse(n)),Su=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Le.useToggle(!1),{restUrl:r}=Ze(n),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=T.useQuery({queryKey:Iu.abi(r,i,l,c).queryKey,queryFn:async()=>{const m=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(m.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:K.INFINITY});if(!u)return s;const h=(m,f)=>{const p=u[f];return t.jsxs("div",{className:hn.arg,children:[t.jsx("div",{className:hn.type,children:p}),t.jsx(Ga.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ku,{type:p,arg:m})})]},f)};return t.jsxs("div",{className:hn.container,children:[t.jsx(le.Small,{className:hn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:hn.list,children:d.map(h)}):s]})},Au="_list_oip9m_1",Tu="_key_oip9m_9",$u="_value_oip9m_14",Ks={list:Au,key:Tu,value:$u},Eu=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:Ks.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:Ks.key,children:a}),t.jsx("div",{className:Ks.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Su,{msg:o,chainId:n,fallback:ls(r)}):ls(r)})]},a))})},qu="_item_1n572_1",Lu="_title_1n572_10",Mu="_content_1n572_14",zs={item:qu,title:Lu,content:Mu},Ws=({title:e,content:n})=>t.jsxs("div",{className:zs.item,children:[t.jsx("div",{className:zs.title,children:e}),t.jsx("div",{className:zs.content,children:n})]});function ee(e){const n=e?B(e).abs():void 0;if(n&&n.gt(0)&&n.lt(.01))return"< $0.01";const s=e&&B(e).lt(0),o=j.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function ni(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(l=>l.key==="spender")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d-BigInt(l)}}}if(o.type==="coin_received"){const r=o.attributes.find(l=>l.key==="receiver")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d+BigInt(l)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function si(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(c=>c.key==="type_tag")?.value,i=o.attributes.find(c=>c.key==="data")?.value;if(!r||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const oi=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=T.useSuspenseQuery({queryKey:wn.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:K.INFINITY});return s(a)},Pu="_root_1p8a4_1",Du="_title_1p8a4_8",Bu="_changes_1p8a4_14",Ru="_change_1p8a4_14",Fu="_amount_1p8a4_35",Uu="_text_1p8a4_42",Ou="_value_1p8a4_49",Rt={root:Pu,title:Du,changes:Bu,change:Ru,amount:Fu,text:Uu,value:Ou},ai=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,l=j.formatAmount(e,{decimals:r}),c=s&&B(j.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Rt.change,children:[t.jsxs("div",{className:Rt.amount,children:[t.jsx(X,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Rt.text,children:[l," ",a||o]})]}),c&&t.jsx("div",{className:Rt.value,children:ee(c)})]})},Vu=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,denom:r},i)=>{const l=s(r),c=o?.find(({id:d})=>d===r)?.price;return t.jsx(ai,{amount:a,asset:l,price:c},i)})},Ku=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(oi,{metadata:r,chain:n,children:l=>{const c=o?.find(({id:d})=>d===l)?.price;return t.jsx(ai,{amount:a,asset:s(l),price:c})}},i))};function zu(e,n){return typeof n=="bigint"?n.toString():n}const Wu=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,zu)]}),Hu=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=De(),r=Ze(s),{simulateTx:i}=vs(),{data:l}=T.useSuspenseQuery({queryKey:Wu.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:K.SECOND}),c=m=>t.jsxs("div",{className:Rt.root,children:[t.jsx("h2",{className:Rt.title,children:"Estimated changes"}),t.jsx("div",{className:Rt.changes,children:m})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const m=si(d,a),[f]=wa(m);return f.length===0?null:c(t.jsx(Ku,{changes:f,chain:r}))}const u=ni(d,o),[h]=wa(u);return h.length===0?null:c(t.jsx(Vu,{changes:h,chain:r}))};function wa(e){return A.partition(n=>new B(n.amount).isNegative(),e)}const Qu="_title_1d032_1",Gu="_meta_1d032_7",Yu="_footer_1d032_14",Zu="_rejectButton_1d032_19",Gn={title:Qu,meta:Gu,footer:Yu,rejectButton:Zu},ri=()=>{const{txRequest:e,resolve:n,reject:s}=Ar(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:l,spendCoins:c}=e,d=te(),u=xs(),h=Ze(r),m=An(h),f=Vo(h),p=Ko(h),g=lt(h),x=Cr(),y=vr(),b=(e.gasPrices??f).map(({amount:w,denom:E})=>Ke.calculateFee(Math.ceil(i*l),Ke.GasPrice.fromString(w+E))),C=b.map(w=>w.amount[0]),v=w=>{const E=m.find(P=>P.denom===w)?.amount??"0",U=C.find(P=>P.denom===w)?.amount??"0",F=c.filter(P=>P.denom===w).reduce((P,Ne)=>B(P).plus(Ne.amount),B("0")),O=B(U).plus(F),Z=B(E).gte(O),{symbol:H,decimals:R}=g(w);return{symbol:H,decimals:R,spend:F.gt(0)?F.toFixed():null,fee:U,total:O.toFixed(),balance:E,isSufficient:Z}},N=()=>{if(p&&v(p).isSufficient)return p;for(const{denom:w}of C)if(v(w).isSufficient)return w;return C[0]?.denom},[k,$]=_.useState(N),{mutate:q,isPending:V}=T.useMutation({mutationKey:[kr],mutationFn:async()=>{const w=b.find(F=>F.amount[0].denom===k);if(!w)throw new Error("Fee not found");const U=!e.internal&&await x(r,o)?await y(r,d,o,w,a||""):await u(r,d,o,w,a);await n(U)},onError:async w=>{s(w)}}),M=v(k),I=!M.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{children:[t.jsx("h1",{className:Gn.title,children:"Confirm tx"}),t.jsxs("div",{className:Gn.meta,children:[t.jsx(Ws,{title:"Chain",content:r}),t.jsx(Ws,{title:"Tx fee",content:t.jsx(hu,{options:b,value:k,onChange:$})}),a&&t.jsx(Ws,{title:"Memo",content:a}),I&&t.jsx(fe,{level:"error",children:t.jsx(ju,{...M})})]}),t.jsx(Hu,{messages:o,memo:a,chainId:r}),t.jsx(Zd,{list:o,renderHeader:({typeUrl:w})=>hs.sentenceCase(w.split(".").pop().replace(/^Msg/,"")),renderContent:w=>t.jsx(Eu,{message:w,chainId:r})})]}),t.jsxs(xe,{className:Gn.footer,children:[t.jsx(le.Outline,{onClick:()=>s(new Error("User rejected")),disabled:V,className:Gn.rejectButton,children:t.jsx(S.IconClose,{size:16})}),t.jsx(le.White,{onClick:()=>q(),disabled:I,loading:V,children:"Approve"})]})]})},Ju=({children:e})=>{const[{title:n,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),l=W.useAtomValue(ws),c=_.useCallback(h=>{a(h),i(!0)},[]),d=_.useCallback(()=>{a({}),i(!1)},[]),u=_.useCallback(h=>{h||(l?.reject(new Error("User rejected")),a({})),i(h)},[l]);return t.jsxs(Nr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(ei,{title:n,open:r,onOpenChange:u,children:t.jsx(me,{children:o==="/tx"?t.jsx(ri,{}):s})})]})},Xu="_container_1w1hx_1",em="_toast_1w1hx_11",tm="_info_1w1hx_24",nm="_success_1w1hx_28",sm="_error_1w1hx_32",om="_icon_1w1hx_37",am="_content_1w1hx_45",rm="_title_1w1hx_48",im="_description_1w1hx_53",cm="_close_1w1hx_75",Ct={container:Xu,toast:em,info:tm,success:nm,error:sm,icon:om,content:am,title:rm,description:im,close:cm},lm=({notification:e,onClose:n,...s})=>{const o=rt.useTransition(e,{keys:r=>r?.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}}),a=r=>{switch(r){case"loading":return t.jsx(ct,{size:16});case"info":case"success":return t.jsx(S.IconCheckCircleFilled,{size:16});case"error":return t.jsx(S.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=a(l);return t.jsx(rt.animated.div,{style:r,className:Ct.container,children:t.jsxs("div",{className:L(Ct.toast,l&&Ct[l]),...s,children:[u&&t.jsx("div",{className:Ct.icon,children:u}),t.jsxs("div",{className:Ct.content,children:[t.jsx("p",{className:Ct.title,children:c}),d&&t.jsx("div",{className:Ct.description,children:d})]}),t.jsx("button",{className:Ct.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},Hs=5e3,dm=({children:e})=>{const n=Ot(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=_.useCallback(()=>{i(),o(null)},[]),c=_.useCallback(m=>{i(),o({...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),d=_.useCallback(m=>{i(),o(f=>f?{...f,...m}:{...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),u=()=>{i(),r.current=!0},h=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>l(),Hs))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Zr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,n&&ec.createPortal(t.jsx(lm,{notification:s,onClose:l,onMouseEnter:u,onMouseLeave:h}),n)]})},um=({children:e})=>{const[n,s]=_.useState(null);return t.jsx(Is.Provider,{value:{container:n,setContainer:s},children:e})},ii=[{value:10*hr,label:"for 10 minutes"},{value:pr,label:"for 1 hour"},{value:ha,label:"for 1 day"},{value:7*ha,label:"for 7 days"},{value:0,label:"until revoked"}],mm=ii[0].value,hm="_container_1422v_1",pm="_title_1422v_7",fm="_description_1422v_14",gm="_sectionTitle_1422v_20",_m="_websiteInfo_1422v_27",xm="_favicon_1422v_37",ym="_websiteTitle_1422v_42",jm="_websiteHost_1422v_48",bm="_warningContent_1422v_54",wm="_ignoreButton_1422v_61",vm="_infoList_1422v_65",Cm="_infoItem_1422v_75",Nm="_label_1422v_84",Im="_infoValue_1422v_94",km="_durationTrigger_1422v_100",Sm="_durationItem_1422v_101",Am="_featureList_1422v_105",Tm="_featureItem_1422v_113",$m="_checkIcon_1422v_123",Em="_learnMoreLink_1422v_127",qm="_feedbackContainer_1422v_140",Lm="_footer_1422v_146",re={container:hm,title:pm,description:fm,sectionTitle:gm,websiteInfo:_m,favicon:xm,websiteTitle:ym,websiteHost:jm,warningContent:bm,ignoreButton:wm,infoList:vm,infoItem:Cm,label:Nm,infoValue:Im,durationTrigger:km,durationItem:Sm,featureList:Am,featureItem:Tm,checkIcon:$m,learnMoreLink:Em,feedbackContainer:qm,footer:Lm},Mm=ye.createQueryKeys("interwovenkit:account",{info:(e,n)=>({queryKey:[e,n],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${n}`;return s.get(o).json()}})}),Pm=()=>{const[e,n]=_.useState(mm),[s,o]=W.useAtom(Ln),[a,r]=_.useState(!1),i=Ye(),l=de(),{address:c,username:d}=De(),{mutate:u,isPending:h}=Fc(),{closeDrawer:m}=xt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:x,isLoading:y}=T.useQuery(Mm.info(g,c)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},C=l.some($=>{if(!$.website)return!1;const q=va(new URL($.website).hostname),V=va(window.location.hostname);return q===V}),v=()=>{u(e)},N=()=>{s?.reject(new Error("User cancelled")),o(null),m()},k=!C&&!a;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{className:re.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:re.title,children:"Enable auto-signing"}),t.jsx("p",{className:re.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:re.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:re.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:re.websiteTitle,children:b.title}),t.jsx("div",{className:re.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:re.infoList,children:[t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Address"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:j.truncate(d??c)})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Chain"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(X,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:p})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Duration"}),t.jsx(zo,{options:ii,value:e,onChange:n,classNames:{trigger:re.durationTrigger,item:re.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:re.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map($=>t.jsxs("li",{className:re.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:re.checkIcon}),t.jsx("span",{children:$})]},$))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:re.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(xe,{className:re.footer,extra:t.jsxs("div",{className:re.feedbackContainer,children:[!y&&!x&&t.jsx(fe,{level:"error",children:"Insufficient balance for fee"}),!C&&!a&&t.jsx(fe,{level:"warning",children:t.jsxs("div",{className:re.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:re.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(le.Outline,{onClick:N,children:"Cancel"}),t.jsx(le.White,{onClick:v,disabled:k||!x||y,loading:h,children:"Enable"})]})]})},Dm=()=>W.useAtomValue(Ln)?t.jsx(Pm,{}):null;function va(e){const n=e.split(".");return n.length<2?e:n.slice(-2).join(".")}const Bm="_container_mqvhs_1",Rm="_badge_mqvhs_5",Ca={container:Bm,badge:Rm},ci=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:L(Ca.container,a),children:[o,!s&&t.jsx("div",{className:Ca.badge,style:{right:n,top:n}})]})},Fm="_header_s7mee_1",Um="_back_s7mee_12",Om="_title_s7mee_24",Qs={header:Fm,back:Um,title:Om},dt=({title:e,backButton:n,extra:s,children:o})=>{const a=dr();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Qs.header,children:[t.jsx(nn,{to:n??(a.length>1?-1:"/"),className:Qs.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:Qs.title,children:e}),s]}),t.jsx(et,{children:o})]})};function li(){const{initiaAddress:e,hexAddress:n}=De(),s=yt(),o=Dn();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function di(){const e=yt(),n=Dn();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return j.InitiaAddress.validate(s);case"evm":return pt.isAddress(s);case"cosmos":try{return ie.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function Vm(){const e=yt(),n=Dn();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),l=n(i),c=e(a),d=n(c);if(l==="evm"&&d==="initia")return j.InitiaAddress(s).bech32;if(l==="initia"&&d==="evm")return j.InitiaAddress(s).hex;if(l===d)return s;if(r){if(d==="initia")return j.InitiaAddress(r).bech32;if(d==="evm")return j.InitiaAddress(r).hex}return""}}const Km="_root_ekn9t_1",zm="_header_ekn9t_6",Wm="_title_ekn9t_12",Hm="_warning_ekn9t_18",Qm="_content_ekn9t_22",Gm="_footer_ekn9t_26",Ym="_secondary_ekn9t_36",Et={root:Km,header:zm,title:Wm,warning:Hm,content:Qm,footer:Gm,secondary:Ym},ui=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(et,{className:Et.root,children:[t.jsxs("header",{className:L(Et.header,n&&Et[n]),children:[s,t.jsx("h1",{className:Et.title,children:o})]}),t.jsx("div",{className:Et.content,children:a}),t.jsxs("footer",{className:Et.footer,children:[t.jsx(le.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Et.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},Zm="_list_k4n3k_1",Jm="_row_k4n3k_9",Xm="_dt_k4n3k_20",eh="_asset_k4n3k_26",Yn={list:Zm,row:Jm,dt:Xm,asset:eh},th=({list:e,onNavigate:n,onDismiss:s})=>{const o=ae(),a=Ye(),r=lt(o);return t.jsx(ui,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:Yn.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=a(l),{decimals:h,symbol:m}=r(d),f=j.formatAmount(c,{decimals:h});return t.jsxs("div",{className:Yn.row,children:[t.jsxs("div",{className:Yn.dt,children:[t.jsx(X,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Yn.asset,children:[f," ",m]})]},i)})})})};function Gs(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const Zn=({chainId:e,txHash:n})=>`${oe.OP_REMINDER}:${e}:${n}`,nh=tc.atomWithStorage(oe.OP_REMINDER,[]);function dn(){const e=te(),[n=[],s]=W.useAtom(nh),o=_.useMemo(()=>n.map(c=>{const d=localStorage.getItem(Zn(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Ge.isPast(u)}),[e,n]),a=_.useCallback((c,d)=>{n.some(u=>Gs(u,c))||(s((u=[])=>[...u,c]),localStorage.setItem(Zn(c),JSON.stringify(d)))},[n,s]),r=_.useCallback(c=>{s((d=[])=>d.filter(u=>!Gs(u,c))),localStorage.removeItem(Zn(c))},[s]),i=_.useCallback(c=>{const d=c.filter(u=>!n.some(h=>Gs(h,u)));d.length!==0&&s((u=[])=>[...u,...d])},[n,s]),l=_.useCallback((c,d)=>{localStorage.setItem(Zn(c),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:l}}function mi(){const e=Ce(),{openModal:n,closeModal:s}=bs(),{reminders:o,setReminder:a}=dn();_.useEffect(()=>{const r=o.filter(c=>!c.dismissed);if(r.length===0)return;const i=()=>{const c=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{s();for(const c of r)a(c,{...c,dismissed:!0})};n({content:_.createElement(th,{list:r,onNavigate:i,onDismiss:l})})},[o,s,e,n,a])}const sh="_wrapper_5ssm8_1",oh="_balance_5ssm8_11",ah="_button_5ssm8_15",Ys={wrapper:sh,balance:oh,button:ah},hi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:Ys.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:Ys.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:Ys.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),rh="_fieldset_up6fh_1",ih="_upper_up6fh_9",ch="_select_up6fh_14",lh="_account_up6fh_20",dh="_lower_up6fh_25",uh="_wrapper_up6fh_26",mh="_balance_up6fh_33",hh="_value_up6fh_37",ph="_error_up6fh_50",mt={fieldset:rh,upper:ih,select:ch,account:lh,lower:dh,wrapper:uh,balance:mh,value:hh,error:ph},mo=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:mt.fieldset,children:[t.jsxs("div",{className:mt.upper,children:[t.jsx("div",{className:mt.select,children:n}),t.jsx("div",{className:mt.account,children:s})]}),!l&&t.jsxs("div",{className:mt.lower,children:[o,t.jsxs("div",{className:mt.wrapper,children:[t.jsx("div",{className:mt.balance,children:a}),r&&t.jsx("div",{className:mt.value,children:r})]}),i&&t.jsxs("footer",{className:mt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Rn(){const e=_.useRef(null),n=Ns();return _.useEffect(()=>{n||e.current?.focus()},[n]),e}const fh="_input_h8073_1",gh={input:fh};function pi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,l=Rn();return t.jsx(_e.Controller,{name:n,control:s,rules:r,render:({field:c})=>t.jsx(nc.NumericFormat,{value:c.value,getInputRef:Ya.mergeRefs([c.ref,l]),className:L(gh.input,a),onValueChange:d=>{c.onChange(d.value)},onBlur:c.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const _h="_input_19r9r_1",xh="_placeholder_19r9r_18",ho={input:_h,placeholder:xh},yh=({children:e})=>t.jsx("p",{className:L(ho.input,{[ho.placeholder]:B(e).isZero()}),children:e}),In=({balance:e,decimals:n,className:s})=>{const{control:o}=_e.useFormContext(),a={required:"Enter amount",validate:r=>B(r).isZero()?"Enter amount":B(j.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(pi,{name:"quantity",control:o,className:L(ho.input,s),rules:a})};In.ReadOnly=yh;const rn=({title:e,content:n,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return t.jsx(ei,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},jh="_tooltip_19kvs_1",bh="_arrow_19kvs_44",Na={tooltip:jh,arrow:bh},Fn=({label:e,children:n,small:s,...o})=>t.jsxs(J.Tooltip.Root,{...o,children:[t.jsx(J.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(J.Tooltip.Portal,{container:Ot(),children:t.jsxs(J.Tooltip.Content,{className:L(Na.tooltip,{small:s}),collisionBoundary:Ot(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(J.Tooltip.Arrow,{className:Na.arrow})]})})]});function Wo(e,n){const s=Xe();return T.useQuery({queryKey:qe.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[n].denoms??{}:{}:{},enabled:!!e,staleTime:K.SECOND})}function wh(e,n,s){const{data:o={}}=Wo(e,n);return A.path([s],o)}const vh=[["d",1440*60],["h",3600],["m",60],["s",1]];function kn(e){if(!e)return;const{formattedParts:n}=vh.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function Ho(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${j.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function po(e,n){const{watch:s}=St(),o=s(),a=Xe(),r=Tn(),i={...o,quantity:e},l=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,c=B(i.quantity||0),d=c.isFinite()&&c.gt(0),u=T.useQueryClient();return T.useQuery({queryKey:qe.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:h,srcDenom:m,quantity:f,dstChainId:p,dstDenom:g}=i,{decimals:x}=u.getQueryData(qe.asset(h,m).queryKey)??{decimals:0},y={amount_in:j.toBaseUnit(f,{decimals:x}),source_asset_chain_id:h,source_asset_denom:m,dest_asset_chain_id:p,dest_asset_denom:g,is_op_withdraw:n?.isOpWithdraw},b=await a.post("v2/fungible/route",{json:y}).json(),C={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return r("Bridge Simulation Success",C),b},enabled:d&&!n?.disabled&&!l,staleTime:K.MINUTE})}function Ch(e){return T.useQuery({queryKey:qe.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null},enabled:!!e})}function Nh(){const{watch:e}=St(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=ze(n),i=Cn(r),l=it(s,n),c=it(a,o),d=ae(),u=de();return i==="initia"&&o===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===n)?.metadata?.op_denoms?.includes(c.denom)}const Ih="_label_t93ix_1",kh="_wrapper_t93ix_7",Sh="_input_t93ix_10",Ah="_clear_t93ix_18",Jn={label:Ih,wrapper:kh,input:Sh,clear:Ah},Qo=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=j.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,l=Rn(),{control:c,getValues:d,setValue:u,formState:h}=_e.useFormContext(),m=d("recipient"),[f,p]=_.useState(m),g=rr(),{data:x,isLoading:y,error:b}=T.useQuery({queryKey:fs.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:K.MINUTE,enabled:g.validateUsername(f)}),C=x??(o(f)?f:""),v=n&&j.InitiaAddress.equals(C,n),N=async()=>{try{const q=await navigator.clipboard.readText();p(q.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!h.dirtyFields.recipient||u("recipient",x??f,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,f,e,u,x]);const k=()=>{y||b||(u("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},$=()=>{if(y)return t.jsx(Jt,{level:"loading",children:"Resolving username..."});if(b)return t.jsx(Jt,{level:"error",children:b.message});if(x)return t.jsx(Jt,{level:"success",className:"monospace",children:x});if(e==="onSubmit"&&f&&!C)return t.jsx(Jt,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:Jn.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(le.Small,{type:"button",tabIndex:-1,onClick:N,children:"Paste"})]}),t.jsxs("div",{className:Jn.wrapper,children:[t.jsx(_e.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:q=>o(q)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:L(Jn.input,"monospace"),value:f,onChange:q=>p(q.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Ya.mergeRefs([i,l]):i})}),!!f&&t.jsx("button",{type:"button",className:Jn.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),$(),v&&t.jsx(Jt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(xe,{extra:(!n||!!C&&!v)&&t.jsx(fe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(le.White,{type:"button",onClick:k,disabled:y||!!b||!C,children:"Apply"})})]})},Th="_scrollable_vgj3r_1",$h="_list_vgj3r_5",Eh="_item_vgj3r_9",qh="_name_vgj3r_22",Xn={scrollable:Th,list:$h,item:Eh,name:qh};function fi({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:l}=s;return t.jsx(et,{className:Xn.scrollable,children:t.jsx("div",{className:Xn.list,children:n.map(c=>t.jsxs("button",{className:Xn.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(X,{src:o(c),width:28,height:28}),t.jsx("span",{className:Xn.name,children:a(c)}),i?.(c)&&t.jsx(ct,{size:16})]},r(c)))})})}function As(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(o=>o.name===s)}}const Lh="_account_h04x1_8",Mh="_clear_h04x1_28",Ph="_white_h04x1_39",pn={account:Lh,clear:Mh,white:Ph},Ia=({type:e})=>{const{watch:n,setValue:s}=St(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),l=n(e==="src"?"sender":"recipient"),c=Cn(ze(a)),{list:d,find:u}=As(),h=u(r),m=li(),f=di(),p=m(a),g=j.InitiaAddress.equals(l,p),x=()=>t.jsx(rn,{title:"Connect wallet",content:C=>t.jsx(fi,{onSelect:async v=>{const N=v.getProvider();if(!N)return window.open(v.fallbackUrl,"_blank");const k=N.getOfflineSigner(o),[{address:$}]=await k.getAccounts();s("sender",$),s("cosmosWalletName",v.name),C()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:L(pn.account,{[pn.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(X,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:j.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=C=>t.jsx(rn,{title:"Recipient",content:v=>t.jsx(et,{children:t.jsx(Qo,{mode:"onSubmit",myAddress:p,chainType:c,validate:N=>f(N,a),onApply:v})}),className:pn.account,children:C}),b=()=>{switch(c){case"initia":case"evm":return g?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:pn.account,children:[t.jsx("span",{className:"monospace",children:j.truncate(l)}),t.jsx("button",{type:"button",className:pn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(S.IconCloseCircleFilled,{size:14})})]});case"cosmos":return y(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:j.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return x();case"dst":return b()}},Dh="_images_cj4xz_1",Zs={images:Dh},Ts=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:L(Zs.images,r),style:{position:"relative"},children:[t.jsx(X,{src:e,width:n,height:n,className:Zs.asset,logo:!0}),t.jsx(X,{src:s,width:o,height:o,className:Zs.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Bh="_root_6187w_1",Rh="_content_6187w_10",Fh="_details_6187w_20",Uh="_symbol_6187w_26",Oh="_chain_6187w_34",Vh="_chevron_6187w_43",qt={root:Bh,content:Rh,details:Fh,symbol:Uh,chain:Oh,chevron:Vh},gi=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:qt.content,children:[t.jsx(Ts,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:qt.details,children:[t.jsx("div",{className:qt.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:qt.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:qt.root,children:o}):t.jsxs("div",{className:qt.root,children:[o,t.jsx(S.IconChevronDown,{size:16,className:qt.chevron})]})};function Kh(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return A.any(A.includes(n.toLowerCase()),a)})}const zh="_root_1sh27_1",Wh="_label_1sh27_8",Hh="_input_1sh27_21",Qh="_hasValue_1sh27_31",Gh="_clear_1sh27_35",fn={root:zh,label:Wh,input:Hh,hasValue:Qh,clear:Gh},Un=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:L(fn.root,n,{[fn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:fn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:fn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:fn.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},Yh="_container_5tajg_1",Zh="_search_5tajg_7",Jh="_list_5tajg_11",Xh="_item_5tajg_15",ep="_logo_5tajg_37",tp="_info_5tajg_41",np="_symbol_5tajg_47",sp="_name_5tajg_56",op="_balance_5tajg_62",ap="_value_5tajg_69",Ve={container:Yh,search:Zh,list:Jh,item:Xh,logo:ep,info:tp,symbol:np,name:sp,balance:op,value:ap},On=e=>{const{assets:n,onSelect:s,renderAsset:o=(l,c)=>c(l)}=e,[a,r]=_.useState(""),i=Kh(["symbol"],a,n);return t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{value:a,onChange:l=>r(l.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:Ve.search,padding:20,ref:Rn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:Ve.list,children:i.map(l=>t.jsx("button",{type:"button",className:Ve.item,onClick:()=>s(l.denom),children:o(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:f,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(X,{src:u,width:32,height:32,className:Ve.logo,logo:!0}),t.jsxs("div",{className:Ve.info,children:[t.jsx("div",{className:Ve.symbol,children:h||d}),t.jsx("div",{className:Ve.name,children:m})]}),t.jsxs("div",{className:Ve.balance,children:[f&&t.jsx("div",{children:j.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:Ve.value,children:ee(g)})]})]})})},l.denom))})]})},rp=()=>t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{rootClassName:Ve.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});On.Placeholder=rp;const ip="_stack_16oqn_1",cp="_title_16oqn_9",lp="_grid_16oqn_16",dp="_item_16oqn_22",up="_button_16oqn_26",mp="_active_16oqn_44",Xt={stack:ip,title:cp,grid:lp,item:dp,button:up,active:mp},Ft=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Xt.title,children:e}),t.jsx("div",{className:Xt.grid,children:n.map(({chainId:r,name:i,logoUrl:l})=>t.jsx(ci,{offset:-2,disabled:!a?.(r),className:Xt.item,children:t.jsx(Fn,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:L(Xt.button,{[Xt.active]:r===s}),onClick:()=>o(r),children:t.jsx(X,{src:l,width:28,height:28,logo:!0})})})},r))})]}),hp=({children:e})=>t.jsx("div",{className:Xt.stack,children:e});Ft.Stack=hp;const pp=({address:e,chain:n,onSelect:s})=>{const o=is(n.chain_id),{data:a={}}=Wo(e,n.chain_id);return t.jsx(On,{assets:A.sortWith([A.descend(r=>r.symbol==="INIT"),A.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>B(i).comparedTo(r)??0,A.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:l=j.truncate(i),logo_uri:c}=r,d=a[i]??{};return{...r,symbol:l,decimals:r.decimals??0,logoUrl:c??"",name:r.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},fp=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=kt(),i=Bn(),{watch:l,setValue:c}=St(),d=l(a),u=l(s),h=l(o),[m,f]=_.useState(u),p=ze(m),g=Vm(),x=zr(),[y,b]=A.partition(v=>x(v.chain_id),i.filter(v=>!v.hidden)),C=v=>{if(u===m&&h===v){n();return}c(s,m),c(o,v),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Ft.Stack,{children:[t.jsx(Ft,{label:"Interwoven Economy",chains:y.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f}),t.jsx(Ft,{label:"Chains",chains:b.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f})]}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(pp,{address:g({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:C})},m)]})},ka=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=St(),r=a(n),i=a(s),l=ze(r),c=it(i,r);return t.jsx(rn,{title:o,content:d=>t.jsx(fp,{type:e,afterSelect:d}),children:t.jsx(gi,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})},gp="_skeleton_1l4jn_1",_p={skeleton:gp},Ut=({width:e="100%",height:n})=>t.jsx("div",{className:_p.skeleton,style:{width:e,height:n}}),xp="_stack_oq1ir_1",yp="_button_oq1ir_6",jp="_isLoading_oq1ir_19",bp="_disabled_oq1ir_19",wp="_checked_oq1ir_23",vp="_header_oq1ir_37",Cp="_title_oq1ir_43",Np="_duration_oq1ir_52",Ip="_warning_oq1ir_62",kp="_amount_oq1ir_66",Sp="_value_oq1ir_67",Oe={stack:xp,button:yp,isLoading:jp,disabled:bp,checked:wp,header:vp,title:Cp,duration:Np,warning:Ip,amount:kp,value:Sp},Ap=({children:e})=>t.jsx("div",{className:Oe.stack,children:e}),os=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:l}=St(),{dstChainId:c,dstDenom:d}=l(),u=it(d,c),h=!i&&a.checked,m=!i&&!r;return t.jsxs("button",{type:"button",className:L(Oe.button,{[Oe.isLoading]:i,[Oe.disabled]:m,[Oe.checked]:h}),onClick:()=>{i||m||o(s)},children:[t.jsxs("div",{className:Oe.header,children:[t.jsxs("div",{className:Oe.title,children:[t.jsx("span",{children:e}),h&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(Ut,{width:80,height:16}):r?t.jsxs("div",{className:L(Oe.duration,{[Oe.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:kn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:Oe.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Oe.amount,children:i?t.jsx(Ut,{width:260,height:40}):r?j.formatAmount(r.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:Oe.value,children:i?t.jsx(Ut,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};os.Stack=Ap;const Tp="_description_nuyvt_1",$p="_presets_nuyvt_8",Ep="_preset_nuyvt_8",qp="_active_nuyvt_29",Lp="_custom_nuyvt_40",Mp="_wrapper_nuyvt_47",Pp="_percent_nuyvt_58",ot={description:Tp,presets:$p,preset:Ep,active:qp,custom:Lp,wrapper:Mp,percent:Pp},Sa=["0.1","0.5","1.0"],Dp=({afterConfirm:e})=>{const n=St(),s=n.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:l,setValue:c}=_e.useForm({defaultValues:{value:s}}),d=i("value");_.useEffect(()=>{const g=Sa.findIndex(x=>x===s);a(g>=0?g:null)},[s]);const u=(g,x)=>{c("value",g),a(x)},h=()=>{a(null)},m=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=m?.type==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(et,{children:[t.jsx("p",{className:ot.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."}),t.jsxs("div",{className:ot.presets,children:[Sa.map((g,x)=>t.jsxs("button",{type:"button",className:L(ot.preset,{[ot.active]:o===x}),onClick:()=>u(g,x),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:L(ot.preset,ot.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:ot.wrapper,children:[t.jsx(pi,{name:"value",control:r,dp:2,onFocus:h,placeholder:"",className:L(ot.preset,ot.active)}),t.jsx("span",{className:ot.percent,children:"%"})]})]}),m&&t.jsx(fe,{level:m.type,children:m.text}),t.jsx(xe,{children:t.jsx(le.White,{type:"button",onClick:()=>p(l()),disabled:f,children:"Confirm"})})]})},Bp="_form_1owk5_1",Rp="_arrow_1owk5_5",Fp="_divider_1owk5_14",Up="_flip_1owk5_23",Op="_meta_1owk5_41",Vp="_row_1owk5_54",Kp="_title_1owk5_60",zp="_description_1owk5_64",Wp="_icon_1owk5_71",Hp="_edit_1owk5_76",Qp="_warning_1owk5_99",Me={form:Bp,arrow:Rp,divider:Fp,flip:Up,meta:Op,row:Vp,title:Kp,description:zp,icon:Wp,edit:Hp,warning:Qp},Gp=()=>{const e=Ce(),n=Ns(),[s,o]=Le.useLocalStorage(oe.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:l}=St(),c=a(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:f,sender:p,slippagePercent:g}=c,x=Ye(),y=ze(d),b=Cn(y),C=ze(h),v=Cn(C),N=it(u,d),k=it(m,h),{data:$}=Wo(p,d),q=wh(p,d,u),V=!q?.amount||B(q.amount).isZero(),[M]=Le.useDebounceValue(f,300),I=b!=="initia"&&v!=="initia",w=Nh(),E=po(M,{disabled:I}),U=po(M,{isOpWithdraw:!0,disabled:!w}),F=w&&s==="op",O=F?U:E,Z=F?E:U,H=F?!I:w,R=O.error&&H?Z:O,{data:P,isLoading:Ne,isFetching:je,error:tt}=R,{data:Be}=Ch(tt),Wt=M&&(Ne||je),un=()=>{r("srcChainId",h),r("srcDenom",m),r("dstChainId",d),r("dstDenom",u),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:Kn,closeModal:zn}=bs(),nt=i(ne=>{if(P?.warning){const{type:Tt="",message:Ms}=P.warning??{};Kn({content:t.jsx(ui,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:hs.sentenceCase(Tt),primaryButton:{label:"Cancel",onClick:zn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:P,values:ne}),zn()}},children:t.jsx("p",{className:Me.warning,children:Ms})})});return}e("/bridge/preview",{route:P,values:ne})}),Re=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[P]),bt=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[P]),Ht=_.useMemo(()=>{for(const ne of bt){const Tt=$?.[ne.origin_asset.denom]?.amount??"0",Ms=P?.source_asset_denom===ne.origin_asset.denom?P.amount_in:"0";if(B(Tt).lt(B(Ms).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[$,P,bt]),Wn=_.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!M)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!P)return"Route not found";if(Ht)return Ht},[M,Ht,l,P,c]),Wi=P?j.formatAmount(P.amount_out,{decimals:k.decimals}):"0",Hi=B(f).gt(0)&&B(f).isEqualTo(j.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),Qi=(()=>{switch(b){case"initia":return x(d).fees.fee_tokens.some(({denom:ne})=>ne===u);case"cosmos":return y.fee_assets.some(({denom:ne})=>ne===u);case"evm":return!pt.isAddress(u);default:return!1}})(),Ls=_.useCallback((ne,Tt)=>ne.length?t.jsxs("div",{className:Me.description,children:[Ho(ne),!n&&t.jsx(Fn,{label:Tt,children:t.jsx("span",{className:Me.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Hn=B(f).gt(0)&&w&&E.data&&U.data&&U.data.estimated_route_duration_seconds>E.data.estimated_route_duration_seconds,aa=_.useMemo(()=>P?[{condition:!!P.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ls(Re,"Fee deducted from the amount you receive"),Ls(bt,"Fee charged in addition to the amount you enter")]})},{condition:!Hn&&!!kn(P.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Me.description,children:kn(P.estimated_route_duration_seconds)})},{condition:P.does_swap,title:"Slippage",content:t.jsxs("span",{className:Me.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(rn,{title:"Slippage tolerance",content:ne=>t.jsx(Dp,{afterConfirm:ne}),className:Me.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(ne=>ne.condition):[],[bt,Re,Ls,P,Hn,g]);return t.jsxs("form",{className:Me.form,onSubmit:nt,children:[t.jsx(mo,{selectButton:t.jsx(ka,{type:"src"}),accountButton:b==="cosmos"&&t.jsx(Ia,{type:"src"}),quantityInput:t.jsx(In,{balance:q?.amount,decimals:N?.decimals}),balanceButton:t.jsx(hi,{onClick:()=>r("quantity",j.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:V,children:j.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:P?ee(P.usd_amount_in):"$-"}),t.jsxs("div",{className:Me.arrow,children:[t.jsx("div",{className:Me.divider}),t.jsx("button",{type:"button",className:Me.flip,onClick:()=>un(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(mo,{selectButton:t.jsx(ka,{type:"dst"}),accountButton:t.jsx(Ia,{type:"dst"}),quantityInput:t.jsx(In.ReadOnly,{children:Wi}),value:P?ee(P.usd_amount_out):"$-",hideNumbers:Hn}),t.jsx(Nn,{children:Hn?t.jsxs(os.Stack,{children:[t.jsx(os,{label:"Fast",query:E,value:"default",onSelect:o,checked:s==="default"}),t.jsx(os,{label:"Lossless",query:U,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(xe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(fe.Stack,{children:[P?.extra_infos?.map(ne=>t.jsx(fe,{level:"info",children:ne},ne)),Be&&t.jsx(fe,{level:"info",children:Be}),Hi&&Qi&&t.jsx(fe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),P?.warning&&t.jsx(fe,{level:"warning",children:P.warning.message}),P?.extra_warnings?.map(ne=>t.jsx(fe,{level:"warning",children:ne},ne))]}),t.jsx(Nn,{children:aa.length>0&&t.jsx("div",{className:Me.meta,children:aa.map((ne,Tt)=>t.jsxs("div",{className:Me.row,children:[t.jsx("span",{className:Me.title,children:ne.title}),ne.content]},Tt))})})]}),children:t.jsx(le.White,{loading:Wt&&"Simulating...",disabled:!!Wn,children:Wn??"Preview route"})})]})},Yp=()=>{mi();const e=dr(),n=Ce(),s=kt(),o=Sl(),a=_e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:l,dstChainId:c,srcDenom:d,dstDenom:u,quantity:h,slippagePercent:m,recipient:f}=r();r((w,{name:E})=>{(E==="srcChainId"||E==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=li(),g=p(l),x=p(c),b=di()(f,c);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[l,g,i]),_.useEffect(()=>{b||i("recipient",x)},[x,b,i]);const{showNotification:C}=Ss(),v=ze(l),N=ze(c),k=is(l),$=is(c),q=k.some(w=>w.denom===d),V=$.some(w=>w.denom===u);_.useEffect(()=>{k.length>0&&!q&&(i("srcDenom",k[0].denom),C({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[k,q,i,C,v.pretty_name]),_.useEffect(()=>{$.length>0&&!V&&(i("dstDenom",$[0].denom),C({type:"info",title:`Switched to ${$[0].symbol}`,description:`The selected asset is not available on ${N.pretty_name}.`,autoHide:!0}))},[$,V,i,C,N.pretty_name]),_.useEffect(()=>{!q||!V||(localStorage.setItem(oe.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(oe.BRIDGE_SRC_DENOM,d),localStorage.setItem(oe.BRIDGE_DST_CHAIN_ID,c),localStorage.setItem(oe.BRIDGE_DST_DENOM,u),localStorage.setItem(oe.BRIDGE_QUANTITY,h),localStorage.setItem(oe.BRIDGE_SLIPPAGE_PERCENT,m))},[l,d,c,u,h,m,q,V]);const M=e[0].path==="/bridge",{reminders:I}=dn();return t.jsx(dt,{title:"Bridge/Swap",backButton:M?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(le.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.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"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(ci,{offset:0,disabled:I.length===0,children:t.jsx(le.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:q&&V&&t.jsx(_e.FormProvider,{...a,children:t.jsx(me,{children:t.jsx(Gp,{})})})})},Zp="_button_1crvp_1",Jp="_checkbox_1crvp_11",Xp="_checked_1crvp_25",es={button:Zp,checkbox:Jp,checked:Xp},ef=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:L(es.button,o),onClick:n,children:[t.jsx("div",{className:L(es.checkbox,{[es.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:es.label,children:s})]}),tf="_button_aoxv2_1",nf={button:tf},_i=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=sc.useInView();return _.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:nf.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function xi(e,n){return e.reduce((s,o)=>{const a=n(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const as=({chainId:e,txHash:n})=>`${oe.BRIDGE_HISTORY}:${e}:${n}`,ds=100,Aa=10;function yi(){const[e,n]=Le.useLocalStorage(oe.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(as(a),JSON.stringify(r));for(const i of e.slice(ds-1))localStorage.removeItem(as(i));n((i=[])=>[a,...i.slice(0,ds-1)])},[e,n]),o=_.useCallback(a=>{const r=localStorage.getItem(as(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function ji(e){return Le.useLocalStorage(as(e),null)}const zt=ye.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function $s(){const{restUrl:e}=ae();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function sf(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Ta=20;function of(e){const n=te();return T.useSuspenseInfiniteQuery({queryKey:zt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Ta,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=A.last(s)?.sequence;return s.length<Ta||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function af(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:K.SECOND});return s}function rf({bridge_id:e,output_index:n}){const s=$s(),{data:o}=T.useSuspenseQuery({queryKey:zt.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:K.SECOND});return o}function cf({bridge_id:e,sequence:n}){const o=de().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Ye()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:l}=T.useSuspenseQuery({queryKey:zt.outputResponse(i,n).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:K.SECOND});return l}function bi(e,n){const{bridge_id:s}=e,o=$s(),{data:a}=T.useSuspenseQuery({queryKey:zt.withdrawalClaimed(s,n).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:K.SECOND});return a}function gn(e){return oc.sha3_256.create().update(e).digest()}function Js(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function wi(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=Js(n.toString(),8),l=Js(s.toString(),8),c=Js(o.amount,8),d=Dt.concatBytes(i,l,gn(Dt.utf8ToBytes(a)),gn(Dt.utf8ToBytes(r)),gn(Dt.utf8ToBytes(o.denom)),c);return gn(gn(d))}async function lf(e,n,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${n}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function df(e,n){const s=z.create({prefixUrl:n}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function fo(e,n){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(l){if(A.path(["error","code"],l)!==4902)throw l;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function jt(){return Je()}function uf(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ce(),{showNotification:r,updateNotification:i,hideNotification:l}=Ss(),{addHistoryItem:c}=yi(),d=Tn(),{route:u,values:h}=jt(),{srcChainId:m,sender:f,recipient:p,cosmosWalletName:g}=h,x=jr(),{requestTxSync:y,submitTxSync:b,waitForTxConfirmation:C}=De(),{find:v}=As(),N=$n(),k=En(),$=ze(m),q=Cn($),V=Wr(m),M=T.useQueryClient(),{registryUrl:I}=Y(),w=Ye(),E=ae(),{addReminder:U}=dn(),F=Xe();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const O=e.cosmos_tx.msgs.map(({msg_type_url:nt,msg:Re})=>{if(!(nt&&Re))throw new Error("Invalid transaction data");return k.fromAmino({type:sn.aminoConverters[nt].aminoType,value:JSON.parse(Re)})});if(q==="initia"){const{srcDenom:nt,quantity:Re}=h,{decimals:bt}=V(nt),Ht=s?await b({messages:O,chainId:m,fee:s}):await y({messages:O,chainId:m,internal:1,spendCoins:[{denom:nt,amount:j.toBaseUnit(Re,{decimals:bt})}]}),Wn=C({txHash:Ht,chainId:m});return{txHash:Ht,wait:Wn}}const Z=v(g)?.getProvider();if(!Z)throw new Error("Wallet not connected");const H=Z.getOfflineSignerOnlyAmino(m),R=await Ke.SigningStargateClient.connectWithSigner($.rpc,H,{registry:N,aminoTypes:k}),P=await R.getAllBalances(f),Ne=$.fee_assets.find(nt=>P.some(Re=>Re.denom===nt.denom&&B(Re.amount).gt(0)));if(!Ne){const Re=["Insufficient balance for fees.",`Available fee assets: ${$.fee_assets.map(bt=>V(bt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:je,gas_price:tt}=Ne;if(!tt)throw new Error(`Gas price not found for ${je}`);const Be=await R.simulate(f,O,""),Wt=Ke.GasPrice.fromString(tt.average+je),un=Ke.calculateFee(Math.ceil(Be*on),Wt),Kn=await R.signAndBroadcastSync(f,O,un),zn=Tr({txHash:Kn,client:R});return{txHash:Kn,wait:zn}}if("evm_tx"in e){const{chain_id:O,to:Z,value:H,data:R}=e.evm_tx,P=await x(),Ne=await P.getSigner();await fo(P,$);const je=await Ne.sendTransaction({chainId:O,to:Z,value:H,data:`0x${R}`});return{txHash:je.hash,wait:je.wait()}}throw new Error("Unlisted chain type")}catch(O){throw await ft(O)}},onSuccess:async({txHash:O,wait:Z})=>{localStorage.removeItem(oe.BRIDGE_QUANTITY),o?o({txhash:O,chainId:m,timestamp:Date.now(),success:!0,route:u,values:h}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Z;const H=Go(u)==="OP Bridge withdrawal",R=H?{success:!0,error:null}:await gf(F,O,m);if(!o&&!R.success&&R.error){const Be=R.error instanceof Error?R.error.message:String(R.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Be}. The transaction may still be processing.`,autoHide:!0})}const P=R.success,je=pf({txHash:O,srcChainId:m,route:u,values:h,recipient:p},P);c(je.tx,je.details),o||i(hf(l));const tt=Xs(h,O);if(d("Bridge Transaction Success",tt),H){const Be=w(m).metadata?.op_bridge_id;if(Be&&!await lf(E.restUrl,Number(Be),u.dest_asset_denom)){const un=ff(je.tx,u,p);U(je.tx,un)}}}catch(H){const R=H instanceof Error?H.message:String(H);o?o({success:!1,error:R,route:u,values:h}):i({type:"error",title:"Transaction not confirmed",description:R});const P={...Xs(h,O),error:R};d("Bridge Confirmation Failed",P)}finally{M.invalidateQueries({queryKey:qe.balances(m,f).queryKey})}},onError:async O=>{const Z=q==="initia"?await Zt(O,w(m),I):O;o?o({success:!1,error:Z.message,route:u,values:h}):r({type:"error",title:"Transaction failed",description:Z.message});const H=Xs(h);d("Bridge Transaction Failed",{...H,error:Z.message})}})}function mf(){const e=Xe(),n=te(),s=xs(),{route:o,values:a}=jt(),r=yt();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:j.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await df(n,r(o.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>sn.aminoTypes.fromAmino({type:sn.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await s(i,n,c,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=It.Tx.fromPartial({body:It.TxBody.decode(d.bodyBytes),authInfo:It.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:ie.toBase64(It.Tx.encode(u).finish())}}catch(i){throw await ft(i)}}})}function hf(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Xs(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function pf(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},l=Go(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:l?"success":void 0,tracked:n},isOpWithdraw:l}}function ff(e,n,s){return{...e,recipient:j.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function gf(e,n,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await ft(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function vi(e){const{chainId:n,txHash:s,tracked:o}=e,a=Xe();return T.useQuery({queryKey:qe.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(r){throw await ft(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Ci(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=Xe();return T.useQuery({queryKey:qe.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:K.INFINITY})}var rs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(rs||{});function Go(e){const{operations:n,dest_asset_denom:s}=e;return A.has("op_init_transfer",A.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const _f="_success_t4dfk_1",xf="_error_t4dfk_5",$a={success:_f,error:xf},yf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Ci(n),a=n.state??jf(o);switch(_.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:$a.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:$a.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(ct,{size:14})}};function jf(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"}}const bf="_link_104m3_1",wf="_header_104m3_23",vf="_title_104m3_31",Cf="_date_104m3_37",Nf="_explorer_104m3_41",If="_fees_104m3_57",kf="_label_104m3_65",Sf="_content_104m3_69",Af="_route_104m3_75",Tf="_row_104m3_80",$f="_asset_104m3_86",Ef="_amount_104m3_94",qf="_chain_104m3_99",Lf="_account_104m3_108",Mf="_arrow_104m3_115",be={link:bf,header:wf,title:vf,date:Cf,explorer:Nf,fees:If,label:kf,content:Sf,route:Af,row:Tf,asset:$f,amount:Ef,chain:qf,account:Lf,arrow:Mf},Pf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:l,tracked:c}=n,{data:d}=vi(n),{address:u="",connector:h}=ve.useAccount(),{find:m}=As();_.useEffect(()=>{d&&s(F=>{if(!F)throw new Error("Bridge history details not found");return{...F,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:x,dest_asset_chain_id:y,dest_asset_denom:b,estimated_fees:C=[]}=r,v=ze(g),N=ze(y),k=it(x,g),$=it(b,y),q=(F,O)=>O?t.jsx(X,{src:O,width:12,height:12}):j.InitiaAddress.equals(F,u)?t.jsx(X,{src:h?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),V=(F,{symbol:O,decimals:Z,logo_uri:H},{chain_name:R,pretty_name:P,...Ne},je,tt)=>t.jsxs("div",{className:be.row,children:[t.jsx(Ts,{assetLogoUrl:H,chainLogoUrl:Ne.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:j.formatAmount(F,{decimals:Z})}),t.jsx("span",{children:O})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",P||R]}),t.jsxs("div",{className:be.account,children:[tt,t.jsx("span",{className:"monospace",children:j.truncate(je)})]})]})]})]}),M=Go(r),I=_.useMemo(()=>{switch(M){case rs.SKIP:return"Skip Explorer";case rs.OP_WITHDRAW:return"Initia Scan"}},[M]),w=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[c?t.jsx(yf,{tx:e}):t.jsx(ct,{size:14}),t.jsx("div",{className:be.date,children:Ge.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:I}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[V(f,k,v,i.sender,q(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),V(p,$,N,i.recipient,q(i.recipient))]}),C.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:Ho(C)})]})]});if(M===rs.OP_WITHDRAW)return t.jsx(ks,{chainId:o,txHash:a,className:be.link,children:w});const E=new URLSearchParams({tx_hash:a,chain_id:o}),U=new URL(`?${E.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:U.toString(),className:be.link,target:"_blank",children:w})},Df="_history_13u9z_1",Bf="_header_13u9z_5",Rf="_checkbox_13u9z_9",Ff="_groups_13u9z_13",Uf="_dateGroup_13u9z_21",Of="_dateHeader_13u9z_26",Vf="_list_13u9z_32",Lt={history:Df,header:Bf,checkbox:Rf,groups:Ff,dateGroup:Uf,dateHeader:Of,list:Vf},Kf=()=>{const{initiaAddress:e,hexAddress:n}=De(),{history:s,getHistoryDetails:o}=yi(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:x,recipient:y}=g;return[x,y].some(b=>[e,n].includes(b))}),[i,l]=_.useState(1),[c,d]=Le.useToggle(!r.length),u=c?a:r,h=u.slice(0,i*Aa),m=_.useMemo(()=>xi(h,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[h,o]);return t.jsx(dt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Lt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Lt.header,children:t.jsx(ef,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:Lt.checkbox})}),u.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:Lt.groups,children:Object.entries(m).map(([f,p])=>t.jsxs("div",{className:Lt.dateGroup,children:[t.jsx("div",{className:Lt.dateHeader,children:f}),t.jsx("div",{className:Lt.list,children:p.map(g=>t.jsx(me,{children:t.jsx(Pf,{tx:g})},g.txHash))})]},f))}),u.length>i*Aa?t.jsx(_i,{onClick:()=>l(f=>f+1)}):s.length>=ds&&t.jsxs(he,{children:["Only the latest ",ds," items are stored. Older entries will be removed automatically."]})]})})},Yo=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=uf(e,{customFee:n,onCompleted:s});return t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>r(),loading:i&&"Signing transaction...",disabled:!!a,children:a||o||"Confirm"})})},zf="_content_1hzj2_1",Wf="_info_1hzj2_6",Hf="_arrow_1hzj2_11",Qf="_divider_1hzj2_19",Gf="_type_1hzj2_27",Yf="_asset_1hzj2_47",Zf="_amount_1hzj2_55",Jf="_lower_1hzj2_60",Xf="_chain_1hzj2_66",eg="_address_1hzj2_72",Ue={content:zf,info:Wf,arrow:Hf,divider:Qf,type:Gf,asset:Yf,amount:Zf,lower:Jf,chain:Xf,address:eg},Ni=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:l}=e,{symbol:c=j.truncate(a),decimals:d=0,logo_uri:u=No}=e,{chain_name:h,pretty_name:m,...f}=ze(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:Ue.arrow,children:[t.jsx("div",{className:Ue.divider}),s?t.jsx(Fn,{label:s,children:t.jsx("button",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:Ue.divider})]}),t.jsxs("div",{className:Ue.content,children:[t.jsx(Ts,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:Ue.info,children:[t.jsxs("div",{className:Ue.asset,children:[t.jsx("span",{className:Ue.amount,children:j.formatAmount(o,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:Ue.lower,children:[t.jsxs("div",{className:Ue.chain,children:["on ",m||h]}),i&&t.jsx(cs,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:Ue.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:j.truncate(i)})]})})]})]})]})]})},en=e=>{const n=it(e.denom,e.chainId);return t.jsx(Ni,{...e,...n})};en.Placeholder=Ni;const tg="_root_1hbar_1",ng="_flexEnd_1hbar_6",sg="_toggle_1hbar_11",og="_route_1hbar_36",ag="_content_1hbar_43",_n={root:tg,flexEnd:ng,toggle:sg,route:og,content:ag};function rg(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":hs.capitalCase(A.head(s?.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){const s=e.swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"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){const s=e.evm_swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"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 new Error("Unknown operation type")}const ig=({addressList:e})=>{const{values:n,route:s}=jt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,l=A.zipObj(s.required_chain_addresses,e),{find:c}=As(),{connector:d,address:u=""}=ve.useAccount(),[h,m]=Le.useToggle(!1),f=i.length>1,p=t.jsx(X,{src:n.cosmosWalletName?c(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:p},x=N=>j.InitiaAddress.equals(N,u)?p:t.jsx(S.IconWallet,{size:11}),y=N=>{const{label:k,amount_out:$,denom:q,denom_out:V=q,chain_id:M,from_chain_id:I,to_chain_id:w=M??I}=N,E=l[w];return{label:f&&!h?void 0:k,amount:$,denom:V,chainId:w,address:E,walletIcon:x(E)}},b=i.map(rg).map(y),C=b.slice(0,-1),v=b[b.length-1];return t.jsxs(J.Collapsible.Root,{className:_n.root,open:h,onOpenChange:m,children:[f&&t.jsx("div",{className:_n.flexEnd,children:t.jsx(J.Collapsible.Trigger,{className:_n.toggle,children:h?t.jsxs(t.Fragment,{children:[t.jsx(S.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(S.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:_n.route,children:[t.jsx(en,{...g,source:!0}),t.jsx(J.Collapsible.Content,{className:_n.content,children:C.map((N,k)=>t.jsx(me,{suspenseFallback:t.jsx(en.Placeholder,{...N}),errorBoundaryProps:{fallback:t.jsx(en.Placeholder,{...N})},children:t.jsx(en,{...N})},k))}),t.jsx(en,{...v})]})]})},Ii=({error:e})=>{const n=Ce();return t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:e.message}),children:t.jsx(le.White,{onClick:()=>n("/bridge"),children:"Home"})})},ki=({children:e})=>{const n=jt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:l,recipient:c}=o,{initiaAddress:d,hexAddress:u}=De(),h=qn(),m=yt(),f=Dn(),p=m(r),g=f(p),x=a.slice(0,-1).some($=>{const q=m($);return f(q)==="cosmos"})&&g!=="cosmos",[y,b]=_.useState(void 0),[C,v]=_.useState(!1),[N,k]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!x)return;if(!h)throw new Error("Wallet not connected");v(!0),k(null);const[{pubkey:q}]=await h.getAccounts();b(q)}catch(q){k(await ft(q))}finally{v(!1)}})()},[x,h]),N)return t.jsx(Ii,{error:N});if(C)return t.jsx(xe,{children:t.jsx(le.White,{loading:C&&"Generating intermediary addresses..."})});if(!x||y){const $=a.map((q,V)=>{if(V===a.length-1){const U=m(i);return f(U)==="initia"?j.InitiaAddress(c).bech32:c}const M=m(q),I=f(M),w=m(r),E=f(w);switch(I){case"initia":return d;case"evm":return u;case"cosmos":{if(E==="cosmos")return ie.toBech32(M.bech32_prefix,ie.fromBech32(l).data);if(!y)throw new Error("Pubkey not found");return jn.pubkeyToAddress(jn.encodeSecp256k1Pubkey(y),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e($)}return null},Zo=({tx:e,children:n})=>{const s=jr(),o=yt(),{data:a,isLoading:r}=T.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:h}=e.evm_tx,m=await s();await fo(m,o(u));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:x,spender:y}=g,C=await new pt.ethers.Contract(x,f,m).allowance(h,y);return{approval:g,currentAllowance:BigInt(C.toString())}}))).filter(({approval:g,currentAllowance:x})=>x<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,error:d}=T.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,h=await s(),m=await h.getSigner();await fo(h,o(u));for(const f of a){const{token_contract:p,spender:g,amount:x}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new pt.ethers.Contract(p,y,m).approve(g,x)).wait()}return!0}catch(u){throw await ft(u)}}});return r?t.jsx(xe,{children:t.jsx(le.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!l?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:d?.message}),children:t.jsx(le.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):n},Si=({addressList:e,signedOpHook:n,children:s})=>{const o=Xe(),{route:a,values:r}=jt(),[i,l]=_.useState(void 0),[c,d]=_.useState(!1),[u,h]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),h(null);const f={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:r.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:p}=await o.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;l(g)}catch(f){h(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),u?t.jsx(Ii,{error:u}):c||!i?t.jsx(xe,{children:t.jsx(le.White,{loading:"Fetching messages..."})}):s(i)},Ai=({children:e})=>{const{route:n}=jt(),s=mf();return n.required_op_hook&&!s.data?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:s.error?.message}),children:t.jsx(le.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},cg=()=>t.jsx(dt,{title:"Route preview",children:t.jsx(ki,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(ig,{addressList:e}),t.jsx(Ai,{children:n=>t.jsx(Si,{addressList:e,signedOpHook:n,children:s=>t.jsx(Zo,{tx:s,children:t.jsx(Yo,{tx:s})})})})]})})}),Ti=_.createContext(null);function Es(){return _.useContext(Ti)}const lg="_button_17r1o_1",dg="_claimed_17r1o_24",Ea={button:lg,claimed:dg},ug=()=>{const{withdrawalTx:e}=Es(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:l,to:c,version:d}=e,u=ae(),h=te(),{requestTxSync:m,waitForTxConfirmation:f}=De(),p=cf(e),g=ie.toBase64(wi(e)),x=bi(e,g),y=T.useQueryClient(),{mutate:b,isPending:C}=T.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:v}=p;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(ie.fromBase64),from:l,to:c,sequence:BigInt(s),amount:o,version:ie.fromBase64(d),storageRoot:ie.fromBase64(i),lastBlockHash:ie.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:u.chain_id,txHash:v}),y.invalidateQueries({queryKey:zt.withdrawalClaimed(n,g).queryKey})}});return x?t.jsxs("div",{className:Ea.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ea.button,onClick:()=>b(),disabled:C,children:"Claim"})},mg=({children:e})=>{const{withdrawalTx:n}=Es(),s=sf(n.bridge_id),o=rf(n),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ge.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},$i=1e3,hg=60,pg=60,fg=24,go=$i*hg,_o=go*pg,qa=_o*fg,gg=({date:e})=>{const n=_.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/qa),f=Math.floor(h%qa/_o),p=Math.floor(h%_o/go),g=Math.floor(h%go/$i);return{days:m,hours:f,minutes:p,seconds:g}},[e]),[s,o]=_.useState(n());_.useEffect(()=>{const d=window.setInterval(()=>{o(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:l,seconds:c}=s;return t.jsx(Fn,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(l),"m ",a(c),"s"]})})},_g="_container_1lz3w_1",xg="_title_1lz3w_5",La={container:_g,title:xg},yg=({date:e})=>t.jsxs("div",{className:La.container,children:[t.jsx("div",{className:La.title,children:"Claimable in"}),t.jsx(gg,{date:e})]}),jg="_container_1oldz_1",bg="_icon_1oldz_7",Ma={container:jg,icon:bg},wg="Withdrawal will begin within an hour",Pa=()=>{const e=Ns();return t.jsxs("div",{className:Ma.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Fn,{label:wg,children:t.jsx("span",{className:Ma.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},vg=({children:e})=>{const{withdrawalTx:n}=Es(),s=af(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},Cg=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=Es(),a=ie.toBase64(wi(o)),r=bi(o,a),{setReminder:i,removeReminder:l}=dn();return _.useEffect(()=>{const c={chainId:s,txHash:o.tx_hash};r?l(c):i(c,{...c,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Ge.isPast(e.getTime())?!0:void 0})},[s,r,e,l,i,o]),n},Ng=()=>t.jsx(vg,{children:e=>e?t.jsx(Pa,{}):t.jsx(mg,{children:n=>n?t.jsx(Cg,{date:n,children:Ge.isFuture(n)?t.jsx(yg,{date:n}):t.jsx(ug,{})}):t.jsx(Pa,{})})}),Ig="_asset_6h8u2_1",kg="_info_6h8u2_7",Sg="_symbol_6h8u2_11",eo={asset:Ig,info:kg,symbol:Sg},Ag=({amount:e,denom:n})=>{const s=ae(),o=sr(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:eo.asset,children:[t.jsx(X,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:eo.info,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(e,{decimals:i})}),t.jsx("span",{className:eo.symbol,children:a})]})]})},Tg="_item_km5w2_1",$g={item:Tg},Eg=({chain:e})=>{const n=e.metadata?.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=of(n),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:l}=dn();return _.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:$g.item,children:[t.jsx(Ag,{...d}),t.jsx(me,{suspenseFallback:null,children:t.jsx(Ti.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(Ng,{})})})]},c.sequence)}),a&&t.jsx(_i,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},qg="_content_dj1qm_1",Lg="_title_dj1qm_5",Da={content:qg,title:Lg},Mg=()=>{const{chainId:e}=Je(),n=de(),s=Vt(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ye(),{reminders:i}=dn(),l=o?r(o):void 0;return t.jsxs(dt,{title:"OP Bridge withdrawals",children:[t.jsx(Ft,{chains:n.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:Da.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Da.title,children:l.name}),t.jsx(me,{children:t.jsx(Eg,{chain:l})},o)]}):t.jsx(fe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},us=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Pg="5722e7dffb709492cf5312446ceeff73",Dg=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Pg}`,Ei=["walletconnect-wallets"],Bg=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",qi=async e=>{const n=await z.get(Dg,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(Bg)},Rg=()=>T.useQuery({queryKey:Ei,queryFn:({signal:e})=>qi(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),Fg="_page_13y8q_1",Ug="_pageTop_13y8q_19",Og="_backButtonFixed_13y8q_63",Vg="_listItem_13y8q_64",Kg="_socialButton_13y8q_65",zg="_arrowIcon_13y8q_66",Wg="_searchInputUnderline_13y8q_67",Hg="_header_13y8q_72",Qg="_title_13y8q_81",Gg="_headerSpacer_13y8q_116",Yg="_icon_13y8q_120",Zg="_installedText_13y8q_124",Jg="_divider_13y8q_131",Xg="_dividerText_13y8q_152",e_="_loading_13y8q_193",t_="_socialIcons_13y8q_198",n_="_socialText_13y8q_204",s_="_searchWrapper_13y8q_214",o_="_scrollable_13y8q_248",a_="_list_13y8q_64",r_="_listIconWrapper_13y8q_332",i_="_moreIconSmall_13y8q_342",c_="_externalLinkIcon_13y8q_364",l_="_listName_13y8q_368",d_="_listNameMuted_13y8q_381",u_="_recentBadge_13y8q_394",m_="_learnMoreLink_13y8q_408",D={page:Fg,pageTop:Ug,backButtonFixed:Og,listItem:Vg,socialButton:Kg,arrowIcon:zg,searchInputUnderline:Wg,header:Hg,title:Qg,headerSpacer:Gg,icon:Yg,installedText:Zg,divider:Jg,dividerText:Xg,loading:e_,socialIcons:t_,socialText:n_,searchWrapper:s_,scrollable:o_,list:a_,listIconWrapper:r_,moreIconSmall:i_,externalLinkIcon:c_,listName:l_,listNameMuted:d_,recentBadge:u_,learnMoreLink:m_},h_=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},p_=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,l]=_.useState(""),{data:c=[],isError:d,isLoading:u,isFetching:h}=Rg(),m=u||h&&c.length===0,f=_.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(x=>x.name.toLowerCase().includes(g))},[e,i]),p=_.useMemo(()=>{const g=new Set(e.map(y=>us(y.name))),x=i.toLowerCase();return c.filter(y=>!g.has(us(y.name))).filter(y=>!i||y.name.toLowerCase().includes(x)).sort((y,b)=>y.name.localeCompare(b.name))},[c,e,i]);return t.jsxs("div",{className:D.pageTop,children:[t.jsx("button",{type:"button",className:D.backButtonFixed,onClick:r,"aria-label":"Back",children:t.jsx(S.IconBack,{size:16,"aria-hidden":"true"})}),t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"All Wallets"}),t.jsx("div",{className:D.headerSpacer})]}),t.jsx("div",{className:D.searchWrapper,children:t.jsx(Un,{rootClassName:D.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>l(g.target.value),onClear:()=>l("")})}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[f.map(g=>{const{name:x,icon:y,id:b}=g,C=o===b,v=s===b,N="ready"in g?!!g.ready:!0;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:v}),onClick:()=>a(g),disabled:n||!N,"aria-busy":v,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:x}),v?t.jsx(ct,{size:16}):C?t.jsx("span",{className:D.recentBadge,children:"Recent"}):N?t.jsx("span",{className:D.installedText,children:"Installed"}):null]},`connector:${b}`)}),m&&t.jsxs("div",{className:L(D.listItem,D.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(ct,{size:16})}),t.jsx("span",{className:D.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const x=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,y=x&&h_(x)?x:void 0;return t.jsxs("button",{type:"button",className:D.listItem,disabled:!0,"aria-label":`${g.name} (not installed)`,children:[t.jsx("div",{className:D.listIconWrapper,children:y&&t.jsx(X,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:g.name})]},`wc:${g.id}`)}),d&&t.jsx(fe,{level:"error",children:"Couldn't load additional wallets."})]})})]})},f_=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),g_=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[t.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"}),t.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"}),t.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"}),t.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"})]}),__=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.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"})}),x_=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),y_=[{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.leapwallet",name:"Leap",icon:"https://assets.initia.xyz/images/wallets/Leap.webp",url:"https://leapwallet.io"},{id:"io.metamask",name:"MetaMask",icon:"https://assets.initia.xyz/images/wallets/MetaMask.webp",url:"https://metamask.io"}],j_=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:l})=>{const c=e.filter(p=>!("ready"in p)||!!p.ready),d=c.slice(0,5),u=new Set(c.map(p=>p.id)),h=new Set(c.map(p=>us(p.name))),m=Math.max(0,5-d.length),f=y_.filter(p=>!u.has(p.id)&&!h.has(us(p.name))).slice(0,m);return t.jsxs("div",{className:D.page,children:[t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"Sign In"}),t.jsx("div",{className:D.headerSpacer})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:L(D.socialButton,{[D.loading]:o===n.id}),onClick:()=>r(n),disabled:s,"aria-busy":o===n.id,children:[t.jsx("span",{className:D.socialText,children:"Email / Socials"}),o===n.id?t.jsx(ct,{size:16}):t.jsxs("div",{className:D.socialIcons,children:[t.jsx(g_,{}),t.jsx(x_,{}),t.jsx(__,{})]})]}),t.jsx("div",{className:D.divider,children:t.jsx("span",{className:D.dividerText,children:"or"})})]}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[d.map(p=>{const{name:g,icon:x,id:y}=p,b=o===y,C=a===y;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:b}),onClick:()=>r(p),disabled:s,"aria-busy":b,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:x,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:g}),b?t.jsx(ct,{size:16}):C?t.jsx("span",{className:D.recentBadge,children:"Recent"}):t.jsx("span",{className:D.installedText,children:"Installed"})]},y)}),f.map(p=>t.jsxs("a",{className:D.listItem,href:p.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${p.name} (opens in new tab)`,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:p.icon,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:p.name}),t.jsx(S.IconExternalLink,{size:10,className:D.externalLinkIcon,"aria-hidden":"true"})]},p.id)),t.jsxs("button",{type:"button",className:D.listItem,onClick:i,onMouseEnter:l,onFocus:l,disabled:s,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx("div",{className:D.moreIconSmall,children:t.jsx(f_,{})})}),t.jsx("span",{className:D.listNameMuted,children:"More wallets"}),t.jsx("span",{className:D.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),t.jsxs("a",{className:D.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",t.jsx(S.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Ba=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=ve.useConnect(),o=Le.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,l]=_.useState("signin"),c=T.useQueryClient(),d=()=>c.prefetchQuery({queryKey:Ei,queryFn:({signal:g})=>qi(g),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:u,isPending:h}=T.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(x){throw await ft(x)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),m=_.useMemo(()=>[...n].sort((g,x)=>g.id===o?-1:x.id===o?1:g.name.localeCompare(x.name)),[n,o]),f=_.useMemo(()=>m.find(g=>g.id===bn.id),[m]),p=_.useMemo(()=>m.filter(g=>g.id!==bn.id),[m]);return i==="all"?t.jsx(p_,{walletConnectors:p,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onBack:()=>l("signin")}):t.jsx(j_,{walletConnectors:p,privyConnector:f,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onShowAll:()=>l("all"),onPrefetchWallets:d})},b_={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 Vn(e){return b_[e]}function Jo(){const e=Xe(),n=ln(),s=te(),o=Bn(),a=Object.fromEntries(o.filter(({chain_type:r,bech32_prefix:i})=>r==="evm"||r==="cosmos"&&i==="init").map(r=>[r.chain_id,{address:r.chain_type==="evm"?n:s,denoms:[]}]));return T.useQuery({queryKey:qe.allBalances(Object.keys(a),[n,s]).queryKey,queryFn:()=>e.post("v2/info/balances",{json:{chains:a}}).json(),select:({chains:r})=>r?Object.fromEntries(Object.entries(r).map(([i,{denoms:l}])=>[i,l||{}])):{},enabled:!!s,staleTime:K.SECOND})}function Xo(){const{localOptions:e=[]}=Je();return Kt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function ea(e){const{local:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function w_(e){const{external:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function v_(e){const n=Kt(),s=yt(),{data:o,isLoading:a}=Jo(),{remoteOptions:r=[]}=Je(),i=ea(e);return i?{data:n.filter(({symbol:c,denom:d,chain_id:u})=>r.length?r.some(h=>h.denom===d&&h.chainId===u):c===i.symbol).map(c=>{if(c.hidden||c.chain_id===i.chain_id)return null;const d=s(c.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const u=o?.[d.chain_id]?.[c.denom];return e==="deposit"&&(!u||!Number(u.amount))?null:{asset:c,chain:d,balance:u}}).filter(c=>c!==null),isLoading:a}:{data:[],isLoading:a}}function At(){return _e.useFormContext()}const C_="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",N_="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",I_="_container_uxgnj_1",k_="_title_uxgnj_5",S_="_close_uxgnj_12",A_="_emptyIcon_uxgnj_24",T_="_empty_uxgnj_24",$_="_list_uxgnj_51",E_="_asset_uxgnj_66",q_="_placeholder_uxgnj_82",L_="_activeAsset_uxgnj_95",M_="_iconContainer_uxgnj_99",P_="_assetIcon_uxgnj_109",D_="_chainIcon_uxgnj_119",B_="_assetPlaceholder_uxgnj_133",R_="_assetName_uxgnj_154",F_="_assetChain_uxgnj_169",U_="_balance_uxgnj_177",O_="_value_uxgnj_186",ue={container:I_,title:k_,close:S_,emptyIcon:A_,empty:T_,list:$_,asset:E_,placeholder:q_,activeAsset:L_,iconContainer:M_,assetIcon:P_,chainIcon:D_,assetPlaceholder:B_,assetName:R_,assetChain:F_,balance:U_,value:O_},V_=({mode:e})=>{const{external:n}=Vn(e),{data:s,isLoading:o}=v_(e),{setValue:a,watch:r}=At(),i=ea(e),l=Xo(),{theme:c}=Y(),d=r(),u=d[n.denomKey],h=d[n.chainIdKey];function m(){const f=u&&h;return!f&&l.length<=1&&e==="deposit"?null:t.jsx("button",{className:ue.close,onClick:()=>{e==="withdraw"||f?a("page","fields"):a("page","select-local")},children:t.jsx(S.IconBack,{size:20})})}return i?!o&&!s.length?t.jsxs("div",{className:ue.container,children:[m(),t.jsx("h4",{className:ue.title,children:"No available assets"}),t.jsx("img",{src:c==="dark"?C_:N_,alt:"No assets",className:ue.emptyIcon}),t.jsx("p",{className:ue.empty,children:e==="withdraw"?`No supported destinations to withdraw ${i.symbol}.`:`No supported assets to deposit ${i.symbol}.`})]}):t.jsxs("div",{className:ue.container,children:[m(),t.jsxs("h4",{className:ue.title,children:[e==="withdraw"?"Select destination":`Deposit ${i.symbol}`," "]}),t.jsxs("div",{className:ue.list,children:[o&&Array.from({length:5}).map((f,p)=>t.jsxs("div",{className:L(ue.asset,ue.placeholder),children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("div",{className:ue.assetIcon}),t.jsx("div",{className:ue.chainIcon})]}),t.jsx("div",{className:ue.assetPlaceholder})]},p)),!o&&s.sort(({balance:f},{balance:p})=>Number(p?.value_usd??0)-Number(f?.value_usd??0)).map(({asset:f,chain:p,balance:g})=>{const x=u===f.denom&&h===p.chain_id;return t.jsxs("button",{className:L(ue.asset,x&&ue.activeAsset),onClick:()=>{a(n.denomKey,f.denom),a(n.chainIdKey,p.chain_id),e==="deposit"&&a("quantity",""),a("page","fields")},children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("img",{src:f.logo_uri,alt:f.symbol,className:ue.assetIcon}),t.jsx("img",{src:p.logo_uri||"",alt:p.chain_name,className:ue.chainIcon})]}),t.jsxs("p",{className:ue.assetName,children:[f.symbol," ",x&&t.jsx("span",{children:t.jsx(S.IconCheck,{size:16})})]}),t.jsxs("p",{className:ue.assetChain,children:["on ",p.pretty_name]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:ue.balance,children:j.formatAmount(g.amount,{decimals:g.decimals||6})}),t.jsx("p",{className:ue.value,children:ee(g.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},K_="_title_9ovji_1",z_="_list_9ovji_7",W_="_asset_9ovji_15",to={title:K_,list:z_,asset:W_},H_=({mode:e})=>{const{local:n,external:s}=Vn(e),{setValue:o}=At(),a=Xo(),r=(l,c)=>{o(n.denomKey,l),o(n.chainIdKey,c),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=_.useEffectEvent(()=>{const{denom:l,chain_id:c}=a[0];r(l,c)});return _.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:to.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:to.list,children:a.map(({denom:l,chain_id:c,symbol:d,logo_uri:u})=>t.jsxs("button",{className:to.asset,onClick:()=>r(l,c),children:[t.jsx("img",{src:u,alt:d}),d]},`${l}-${c}`))})]}):t.jsx("div",{children:"No assets found"})},Q_="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",G_="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",Y_="_container_9k4hs_1",Z_="_title_9k4hs_8",J_="_subtitle_9k4hs_14",X_="_linkContainer_9k4hs_30",ex="_link_9k4hs_30",tx="_separator_9k4hs_51",nx="_errorIcon_9k4hs_62",sx="_error_9k4hs_62",we={container:Y_,title:Z_,subtitle:J_,linkContainer:X_,link:ex,separator:tx,errorIcon:nx,error:sx};function ox(e){if(!e)return"pending";const n=e.state;return n==="STATE_COMPLETED_SUCCESS"?"success":n==="STATE_ABANDONED"||n==="STATE_COMPLETED_ERROR"||n==="STATE_PENDING_ERROR"?"failed":"pending"}function xo({type:e}){const{closeModal:n}=cn(),{theme:s}=Y(),{watch:o}=At(),{result:a}=o(),{openDrawer:r}=xt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,l=i?"":a.txhash,c=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:h}=a,{srcDenom:m,srcChainId:f,quantity:p}=h,g=it(m,f),x=e==="deposit"?"Deposit":"Withdraw",{data:y}=vi({chainId:c,txHash:l,tracked:!1}),{data:b}=Ci({chainId:c,txHash:l,tracked:!!y,timestamp:d,route:u}),C=ox(b),v=s==="dark"?Q_:G_,N=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:we.container,children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:a?.error}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]});const $=kn(u.estimated_route_duration_seconds),q=new URLSearchParams({tx_hash:l,chain_id:c}),V=new URL(`?${q.toString()}`,"https://explorer.skip.build"),M=()=>t.jsxs("div",{className:we.linkContainer,children:[t.jsx("a",{href:V.toString(),target:"_blank",rel:"noopener noreferrer",className:we.link,children:"View transaction"}),t.jsx("div",{className:we.separator}),t.jsx("button",{className:we.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:we.container,children:[C==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),t.jsx("video",{src:N,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:we.subtitle,children:["Estimated time: ",t.jsx("span",{children:$})]}),M(),t.jsx("p",{className:we.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," complete"]}),t.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:I=>{const w=I.currentTarget;w.duration-w.currentTime<.1&&w.pause()}}),M(),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]}),C==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:"Your transaction could not be completed"}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const ax=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),rx=({tx:e,children:n})=>{const{values:s}=jt(),{srcChainId:o}=s,a=te(),r=En(),i=$o(),{data:l,isLoading:c}=T.useQuery({queryKey:ax.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const u=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:p})=>{if(!(f&&p))throw new Error("Invalid transaction data");return r.fromAmino({type:sn.aminoConverters[f].aminoType,value:JSON.parse(p)})});return{estimatedGas:await(await i(o)).simulate(a,u,""),messages:u}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(c)return t.jsx(xe,{children:t.jsx(le.White,{loading:"Estimating gas..."})});const d=l?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},ix="_container_eg177_1",cx="_back_eg177_6",lx="_title_eg177_18",dx="_divider_eg177_26",ux="_label_eg177_30",mx="_asset_eg177_37",hx="_assetIcon_eg177_55",px="_chainIcon_eg177_67",fx="_assetName_eg177_80",gx="_chevron_eg177_92",_x="_input_eg177_96",xx="_balanceContainer_eg177_108",yx="_value_eg177_116",jx="_maxButton_eg177_126",bx="_detail_eg177_142",wx="_detailsContainer_eg177_153",vx="_detailsButton_eg177_163",Cx="_detailValue_eg177_180",Nx="_detailToken_eg177_190",Ix="_minimumReceived_eg177_198",Q={container:ix,back:cx,title:lx,divider:dx,label:ux,asset:mx,assetIcon:hx,chainIcon:px,assetName:fx,chevron:gx,input:_x,balanceContainer:xx,value:yx,maxButton:jx,detail:bx,detailsContainer:wx,detailsButton:vx,detailValue:Cx,detailToken:Nx,minimumReceived:Ix},Li=({renderFee:e})=>{const{route:n}=Je(),{values:s}=jt(),{dstDenom:o,dstChainId:a}=s,i=Kt().find(({denom:f,chain_id:p})=>f===o&&p===a),l=te(),c=Jr(),[d,u]=Le.useToggle(!1),h=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const m=n.does_swap?BigInt(n.amount_out||n.estimated_amount_out)*BigInt(1e4-Number(s.slippagePercent)*100)/BigInt(1e4):BigInt(n.amount_out||n.estimated_amount_out);return t.jsx(Nn,{children:t.jsxs("div",{className:Q.detailsContainer,children:[t.jsxs("button",{className:Q.detailsButton,onClick:u,children:["Transaction details"," ",t.jsx(S.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&t.jsxs(t.Fragment,{children:[n.does_swap&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Slippage"}),t.jsxs("p",{className:Q.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:Q.detailValue,children:Ho(n.estimated_fees)})]}),e&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Tx fee"}),t.jsx("div",{className:Q.detailValue,children:e()})]}),l&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:c,alt:"Wallet",height:12,width:12})," ",j.truncate(l)]})]})]}),t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Estimated time"}),t.jsx("p",{className:L(Q.detailValue),style:h?{color:"var(--warning)"}:void 0,children:kn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:L(Q.detail,Q.minimumReceived),children:[t.jsx("p",{className:Q.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Q.detailToken})," ",j.formatAmount(m,{decimals:i.decimals})," ",i.symbol]})]})]})})},kx="_trigger_1c7d7_1",Sx="_item_1c7d7_5",Ax="_itemText_1c7d7_13",Tx={trigger:kx,item:Sx,itemText:Ax},$x=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=jt(),{srcChainId:r,srcDenom:i,quantity:l}=a,d=Kt().find(({denom:I,chain_id:w})=>I===i&&w===r),u=Ze(r),h=An(u),m=Vo(u),f=Ko(u),p=lt(u),g=m.map(({amount:I,denom:w})=>Ke.calculateFee(Math.ceil(n*on),Ke.GasPrice.fromString(I+w))),x=g.map(I=>I.amount[0]),y=I=>{const w=h.find(R=>R.denom===I)?.amount??"0",E=x.find(R=>R.denom===I)?.amount??"0",U=d&&i===I?B(l||"0").times(B(10).pow(d.decimals)).toFixed(0):"0",F=B(E).plus(U),O=B(w).gte(F),{symbol:Z,decimals:H}=p(I);return{symbol:Z,decimals:H,spend:B(U).gt(0)?U:null,fee:E,total:F.toFixed(),balance:w,isSufficient:O}},b=()=>{if(!x.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:I}of x)if(y(I).isSufficient)return I;return x[0]?.denom},[C,v]=_.useState(b),N=g.find(I=>I.amount[0].denom===C)??void 0,k=C?y(C):null,$=k&&!k.isSufficient?"Insufficient balance":void 0,q=(I,w)=>{if(j.formatAmount(I,{decimals:w})==="0.000000")return 8},V=I=>{const[{amount:w,denom:E}]=I.amount;if(B(w).isZero())return"0";const{symbol:U,decimals:F}=p(E),O=q(w,F);return`${j.formatAmount(w,{decimals:F,dp:O})} ${U}`},M=()=>{if(g.length===0)return null;if(g.length===1)return t.jsx("span",{className:"monospace",children:V(g[0])});if(!N||!C)return null;const I=g.map(O=>{const[{denom:Z}]=O.amount,{symbol:H}=p(Z);return{value:Z,label:V(O),triggerLabel:H}}),[{amount:w,denom:E}]=N.amount,{decimals:U}=p(E),F=q(w,U);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:j.formatAmount(w,{decimals:U,dp:F})}),t.jsx(zo,{options:I,value:C,onChange:v,classNames:Tx})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Li,{renderFee:g.length>0?M:void 0}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:N,onCompleted:o,confirmMessage:s,error:$})})]})},Ex=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(Li,{}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),qx=({tx:e,gas:n,mode:s})=>{const{setValue:o}=At(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(Ex,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx($x,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},Lx=({mode:e})=>{const n=Vn(e),s=Ce(),o=Je(),a=Xo(),r=yt(),{data:i}=Jo(),l=ln(),{watch:c,setValue:d,getValues:u}=At(),h=c(),{srcChainId:m,srcDenom:f,quantity:p=""}=h,g=ea(e),x=w_(e),y=h[n.external.chainIdKey],b=y?r(y):null,C=i?.[m]?.[f]?.amount,v=i?.[m]?.[f]?.price||0,N=B(v||0).times(p||0),[k]=Le.useDebounceValue(p,300),$=e==="withdraw"?g:x,q=_.useMemo(()=>{if(e==="deposit"&&!x)return"Select asset";const H=B(p||0);if(!H.isFinite()||H.lte(0))return"Enter amount";const R=j.fromBaseUnit(C??"0",{decimals:$?.decimals||6});if(H.gt(R))return"Insufficient balance";if(e==="withdraw"&&!x)return"Select destination"},[e,p,C,$,x]),{data:V,error:M}=po(k,{disabled:!!q}),I=!M&&!q?V:void 0,w=_.useEffectEvent(()=>{s(0,{...o,route:I,values:{sender:l,recipient:o.recipientAddress?j.InitiaAddress(o.recipientAddress).hex:l,slippagePercent:"1",...u()}})});if(_.useEffect(()=>{w()},[I,l]),!g||e==="deposit"&&!x)return null;const E=$?.decimals||6,U=e==="withdraw"?"Select chain":"Select asset",F=()=>{d("quantity",""),d(n.external.denomKey,""),d(n.external.chainIdKey,""),e==="withdraw"&&(d(n.local.denomKey,""),d(n.local.chainIdKey,"")),d("page",e==="withdraw"?"select-local":"select-external")},O=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:Q.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:Q.assetIcon,children:x?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:x.logo_uri,alt:x.symbol}),t.jsx("img",{src:b?.logo_uri||"",alt:b?.pretty_name,className:Q.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:Q.chainIcon})}),t.jsx("p",{className:Q.assetName,children:x?t.jsxs(t.Fragment,{children:[x.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",b?.pretty_name]})]}):U}),t.jsx(S.IconChevronDown,{className:Q.chevron,size:16})]})]}),Z=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:"Amount"}),t.jsx(In,{balance:C,decimals:E,className:Q.input}),Number(C)>0&&t.jsxs("div",{className:Q.balanceContainer,children:[t.jsx("p",{className:Q.value,children:N.gt(0)?ee(N.toString()):"$-"}),t.jsxs("button",{className:Q.maxButton,onClick:()=>{const H=j.fromBaseUnit(C??"0",{decimals:E});B(p||0).eq(H)||d("quantity",H)},children:[t.jsx(S.IconWallet,{size:16})," ",j.formatAmount(C,{decimals:E})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:Q.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:Q.back,onClick:F,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:Q.title,children:[n.label," ",g.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[Z,t.jsx("div",{className:Q.divider}),O]}):t.jsxs(t.Fragment,{children:[O,t.jsx("div",{className:Q.divider}),Z]}),!o.route||q?t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:!M&&!q&&"Fetching route...",disabled:!0,fullWidth:!0,children:M?"No route found":q})}):t.jsx(ki,{children:H=>t.jsx(Ai,{children:R=>t.jsx(Si,{addressList:H,signedOpHook:R,children:P=>t.jsx(rx,{tx:P,children:Ne=>t.jsx(qx,{tx:P,gas:Ne,mode:e})})})})})]})},Mx="_container_7nl9j_1",Px="_page_7nl9j_5",Ra={container:Mx,page:Px},Mi=({mode:e})=>{const n=_e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Jo(),t.jsx(_e.FormProvider,{...n,children:t.jsx(Dx,{mode:e})})},Dx=({mode:e})=>{const{watch:n}=At(),s=n("page"),o=rt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return t.jsx(H_,{mode:e});case"select-external":return t.jsx(V_,{mode:e});case"fields":return t.jsx(Lx,{mode:e});case"completed":return t.jsx(xo,{type:e})}};return t.jsx(Nn,{children:t.jsx("div",{className:Ra.container,children:o((r,i)=>t.jsx(rt.animated.div,{style:r,className:Ra.page,children:a(i)}))})})},Bx=()=>t.jsx(Mi,{mode:"deposit"}),Rx=()=>t.jsx(Mi,{mode:"withdraw"}),Fx="_root_1lo0i_1",Ux="_address_1lo0i_9",Ox="_copy_1lo0i_19",Vx="_labelWrapper_1lo0i_33",Kx="_labelCopy_1lo0i_43",zx="_labelCopied_1lo0i_47",Wx="_copied_1lo0i_55",Hx="_derived_1lo0i_65",Qx="_derivedLabel_1lo0i_79",Gx="_derivedAddress_1lo0i_83",Yx="_hexAddress_1lo0i_89",Zx="_derivedCopy_1lo0i_94",Ae={root:Fx,address:Ux,copy:Ox,labelWrapper:Vx,labelCopy:Kx,labelCopied:zx,copied:Wx,derived:Hx,derivedLabel:Qx,derivedAddress:Gx,hexAddress:Yx,derivedCopy:Zx},Jx=()=>{const e=_.useRef(null),n=_.useRef(null),{initiaAddress:s,hexAddress:o}=De(),a=Yr("--gray-0");return _.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new ac({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),n.current.append(e.current)))},[s,a]),t.jsx(dt,{title:"Receive",children:t.jsxs("div",{className:Ae.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:Ae.address,children:s}),t.jsx(cs,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(Ae.copy,{[Ae.copied]:i}),onClick:r,children:[t.jsx(S.IconCopy,{size:12}),t.jsxs("div",{className:Ae.labelWrapper,children:[t.jsx("span",{className:Ae.labelCopy,children:"Copy address"}),t.jsx("span",{className:Ae.labelCopied,children:"Copied!"})]})]})}),t.jsx(cs,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(Ae.derived,{[Ae.copied]:i}),onClick:r,children:[t.jsx("span",{className:Ae.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:Ae.derivedAddress,children:[t.jsx("span",{className:Ae.hexAddress,children:j.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Ae.derivedCopy}),i&&t.jsx("span",{className:Ae.copiedText,children:"Copied!"})]})]})})]})})};function Xx(){const e=te(),n=de();return T.useQueries({queries:n.map(s=>({queryKey:vn.grants(s.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await z.create({prefixUrl:s.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:s.chainId,grants:o}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const e1="_countdown_vfms8_1",t1={countdown:e1},n1=({expiration:e})=>{const n=()=>{const a=new Date,r=Ge.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),l=Math.floor(r%(1440*60)/3600),c=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(l>0||i>0)&&u.push(`${l}h`),(c>0||l>0||i>0)&&u.push(`${c}m`),u.push(`${d}s`),u.join(" ")},[s,o]=_.useState(n());return Le.useInterval(()=>{o(n())},1e3),Ge.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:t1.countdown,children:s})]})},s1="_container_1l528_1",o1="_info_1l528_11",a1="_header_1l528_17",r1="_chainName_1l528_23",i1="_expiration_1l528_29",c1="_revokeButton_1l528_35",Yt={container:s1,info:o1,header:a1,chainName:r1,expiration:i1,revokeButton:c1},l1=({chainId:e,grantee:n,messageTypes:s,expiration:o})=>{const a=Ze(e),{mutate:r,isPending:i}=Er({grantee:n,internal:!0});return t.jsxs("div",{className:Yt.container,children:[t.jsxs("div",{className:Yt.info,children:[t.jsxs("div",{className:Yt.header,children:[t.jsx(X,{src:a.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:Yt.chainName,children:a.name})]}),t.jsx("div",{className:Yt.expiration,children:o?t.jsx(n1,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:Yt.revokeButton,onClick:()=>r(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},d1=({chainId:e,grants:n})=>Object.values(n.reduce((o,a)=>{const r=o[a.grantee];return r?{...o,[a.grantee]:{...r,messageTypes:[...r.messageTypes,a.authorization.msg],expiration:qo([r.expiration,a.expiration?new Date(a.expiration):void 0])}}:{...o,[a.grantee]:{grantee:a.grantee,messageTypes:[a.authorization.msg],expiration:a.expiration?new Date(a.expiration):void 0}}},{})).map(o=>_.createElement(l1,{...o,chainId:e,key:o.grantee})),u1="_content_q36qs_1",m1={content:u1},h1=()=>{const e=Xx(),n=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?t.jsx(he,{children:"No permissions found"}):t.jsx("div",{className:m1.content,children:s.map(({chainId:o,grants:a})=>t.jsx(d1,{chainId:o,grants:a},o))})};return t.jsx(dt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},p1="2.2.5",f1="_version_1sf5y_1",g1={version:f1},_1=()=>t.jsxs("aside",{className:g1.version,children:["v",p1]}),x1="_link_se23z_1",y1="_title_se23z_17",j1="_subtitle_se23z_23",b1="_icon_se23z_30",ts={link:x1,title:y1,subtitle:j1,icon:b1},Pi=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:ts.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:ts.title,children:e}),n&&t.jsx("p",{className:ts.subtitle,children:n})]}),t.jsx("div",{className:ts.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),w1="https://export.initia.xyz/",v1=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Pi,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(w1,"_blank",e)})},C1="_container_1vxr7_1",N1="_separator_1vxr7_7",Fa={container:C1,separator:N1},I1=()=>{const e=Ce(),{connector:n}=ve.useAccount();return t.jsx(dt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Fa.container,children:[t.jsx(Pi,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===vo&&t.jsx(v1,{}),t.jsx(ht.Separator,{className:Fa.separator}),t.jsx(_1,{})]})})},k1="_trigger_1yjkd_1",S1="_icon_1yjkd_23",A1="_full_1yjkd_27",T1="_triggerContent_1yjkd_32",$1="_triggerText_1yjkd_40",E1="_popoverBackdrop_1yjkd_51",q1="_popoverPositioner_1yjkd_70",L1="_popoverPopup_1yjkd_74",M1="_search_1yjkd_99",P1="_viewport_1yjkd_105",D1="_item_1yjkd_111",B1="_highlighted_1yjkd_127",R1="_active_1yjkd_131",F1="_itemContent_1yjkd_136",U1="_extra_1yjkd_142",O1="_connectedTag_1yjkd_149",ge={trigger:k1,icon:S1,full:A1,triggerContent:T1,triggerText:$1,popoverBackdrop:E1,popoverPositioner:q1,popoverPopup:L1,search:M1,viewport:P1,item:D1,highlighted:B1,active:R1,itemContent:F1,extra:U1,connectedTag:O1},qs=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=Y(),[i,l]=_.useState(""),[c,d]=_.useState(!1),[u,h]=_.useState(0),[m,f]=_.useState(),p=_.useRef([]),g=_.useRef(null),x=de(),y=s.map(I=>x.find(w=>w.chainId===I)).filter(Boolean),b=I=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:I,height:I,viewBox:"0 0 14 14",children:[t.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"}),t.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"})]}),C=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const I=[C,...y];if(!i)return I;const w=i.toLowerCase();return I.filter(E=>E.name.toLowerCase().includes(w)||E.chainId.toLowerCase().includes(w))},[y,i,C]),N=y.find(I=>I.chainId===e)||C,k=parseInt(Yr("--drawer-offset")),$=6,q=()=>{if(l(""),h(-1),g.current){const w=g.current.getBoundingClientRect().bottom+$,E=window.innerHeight-w-2*k;f(E)}d(!0)};_.useEffect(()=>{u>=0&&u<p.current.length&&p.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const V=_.useCallback(I=>{switch(I.key){case"ArrowDown":I.preventDefault(),h(w=>(w+1)%v.length);break;case"ArrowUp":I.preventDefault(),h(w=>(w-1+v.length)%v.length);break;case"Enter":I.preventDefault(),v[u]&&(n(v[u].chainId),d(!1));break;case"Escape":I.preventDefault(),d(!1);break}},[v,u,n,d]),M=I=>{n(I),d(!1)};return t.jsxs(Qt.Popover.Root,{open:c,onOpenChange:q,modal:"trap-focus",children:[t.jsx(Qt.Popover.Trigger,{render:t.jsxs("button",{className:L(ge.trigger,{[ge.full]:a}),"aria-expanded":c,role:"listbox",ref:g,children:[t.jsxs("div",{className:ge.triggerContent,children:[typeof N.logoUrl=="string"?t.jsx(X,{src:N.logoUrl,width:14,height:14,logo:!0}):N.logoUrl(14),t.jsx("span",{className:ge.triggerText,children:N.name})]}),t.jsx(S.IconChevronDown,{size:16,className:ge.icon})]})}),t.jsxs(Qt.Popover.Portal,{container:Ot(),children:[t.jsx(Qt.Popover.Backdrop,{className:ge.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Qt.Popover.Positioner,{className:ge.popoverPositioner,align:"end",side:"bottom",sideOffset:$,collisionAvoidance:{side:"none"},children:t.jsxs(Qt.Popover.Popup,{className:L(ge.popoverPopup,{[ge.full]:a}),style:{maxHeight:m},children:[t.jsx(Un,{value:i,onChange:I=>{l(I.target.value),h(0)},onClear:()=>l(""),onKeyDown:V,placeholder:"Search appchains",rootClassName:ge.search,ref:Rn()}),t.jsx("div",{className:ge.viewport,role:"listbox",children:v.length===0?t.jsx(he,{children:"No appchains found"}):v.map(({chainId:I,name:w,logoUrl:E},U)=>t.jsxs("div",{className:L(ge.item,{[ge.highlighted]:U===u,[ge.active]:e===I}),onClick:()=>M(I),onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),M(I))},onMouseEnter:()=>h(U),role:"option","aria-selected":e===I,tabIndex:-1,ref:F=>{F&&(p.current[U]=F)},children:[t.jsxs("div",{className:ge.itemContent,children:[typeof E=="string"?t.jsx(X,{src:E,width:16,height:16,logo:!0}):E(16),t.jsx("span",{className:ge.name,children:w}),I===r&&t.jsx("span",{className:ge.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:ge.extra,children:o(I)})]},I))})]})})]})]})},V1="_container_1nap1_1",K1="_controls_1nap1_7",z1="_search_1nap1_13",ta={container:V1,controls:K1,search:z1},W1=({children:e})=>t.jsx("div",{className:ta.container,children:e}),H1=({children:e})=>t.jsx("div",{className:ta.controls,children:e}),Q1=e=>t.jsx(Un,{...e,rootClassName:ta.search}),Qe={Root:W1,Controls:H1,SearchInput:Q1},Di=W.atom(""),Bi=W.atom(""),G1=W.atom(""),Y1=W.atom(""),Z1=W.atom(""),J1="_change_1x9v4_1",X1="_positive_1x9v4_10",ey="_negative_1x9v4_14",no={change:J1,positive:X1,negative:ey},Ri=({amount:e,asset:n})=>{const{denom:s,symbol:o,decimals:a}=n,r=new B(e).isPositive(),i=new B(e).abs().toString();return t.jsxs("div",{className:L(no.change,r?no.positive:no.negative),children:[r?"+":"-",j.formatAmount(i,{decimals:a})," ",o||s]})},ty=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Ri,{amount:o,asset:s(a)},r))},ny=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(oi,{metadata:a,chain:n,children:i=>t.jsx(Ri,{amount:o,asset:s(i)})},r))},sy=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=De();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(ny,{changes:si(e,o),chain:n}):t.jsx(ty,{changes:ni(e,s),chain:n})},oy="_message_1g2hc_1",ay="_more_1g2hc_8",Ua={message:oy,more:ay},ry=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Ua.message,children:hs.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Ua.more,children:`+${e.length-3} more`})]}),iy="_link_fuhbt_1",cy="_inner_fuhbt_16",ly="_header_fuhbt_21",dy="_time_fuhbt_30",uy="_error_fuhbt_36",my="_timestamp_fuhbt_40",hy="_chainInfo_fuhbt_45",py="_content_fuhbt_53",fy="_messages_fuhbt_61",gy="_changes_fuhbt_67",at={link:iy,inner:cy,header:ly,time:dy,error:uy,timestamp:my,chainInfo:hy,content:py,messages:fy,changes:gy},_y=({txItem:e,chain:n})=>t.jsx(ks,{txHash:e.txhash,chainId:n.chainId,className:at.link,children:t.jsxs("div",{className:at.inner,children:[t.jsxs("div",{className:at.header,children:[t.jsxs("div",{className:at.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:at.error}),t.jsx("span",{className:at.timestamp,children:Ge.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:at.chainInfo,children:[t.jsx(X,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:at.content,children:[t.jsx("div",{className:at.messages,children:t.jsx(ry,{messages:e.tx.body.messages})}),t.jsx("div",{className:at.changes,children:t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(sy,{...e,chain:n})})})]})]})}),xy="_list_1mv55_1",yy="_dateGroup_1mv55_7",jy="_dateHeader_1mv55_12",by="_more_1mv55_18",ns={list:xy,dateGroup:yy,dateHeader:jy,more:by},wy=({list:e,chainId:n})=>{const s=te(),o=_.useMemo(()=>xi(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?t.jsx(he,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ns.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:ns.dateGroup,children:[t.jsx("div",{className:ns.dateHeader,children:a}),r.map(i=>t.jsx(me,{errorBoundaryProps:{fallback:null},children:t.jsx(_y,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(ks,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:ns.more,showIcon:!0,children:"View more on Initia Scan"})]})},vy=()=>{const{activities:e,isLoading:n}=tu(),[s,o]=W.useAtom(Z1),a=ae(),r=_.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(l=>l.chain.chainId===s):e,[e,s]);return n&&e.length===0?t.jsx(he,{children:"Loading activities..."}):!e.length&&!n?t.jsx(he,{children:"No activity yet"}):t.jsxs(Qe.Root,{children:[t.jsx(Qe.Controls,{children:t.jsx(qs,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(wy,{list:i,chainId:s||a.chainId})]})},Cy="_thumbnail_1xyqw_1",Ny="_placeholder_1xyqw_18",Iy="_clickable_1xyqw_24",xn={thumbnail:Cy,placeholder:Ny,clickable:Iy},ky=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:l}=Y(),c=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,l).toString();return s?t.jsx("button",{className:L(xn.thumbnail,xn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})}):t.jsx("div",{className:xn.thumbnail,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})})},Sy="_collectionName_qs5tw_1",Ay="_nftName_qs5tw_6",Ty="_chainInfo_qs5tw_10",so={collectionName:Sy,nftName:Ay,chainInfo:Ty},na=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:l}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(ky,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:L(so.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:L(so.nftName,a?.nftName),children:i}),t.jsxs("div",{className:L(so.chainInfo,a?.chainInfo),children:[t.jsx(X,{src:l.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:l.name})]})]})]})},sa=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function $y(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function Ey(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const qy=()=>{const e=te(),n=de(),s=T.useQueries({queries:n.map(c=>({queryKey:sa.nfts(c.indexerUrl,e).queryKey,queryFn:()=>ar(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:c.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map(A.prop("data")),a=Ey(n,o),r=a.reduce((c,{chain:d})=>({...c,[d.chainId]:(c[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((c,d)=>c+d,0),l=s.some(c=>c.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}};function Ly(e){const n=Oa(e);return T.useQuery({queryKey:sa.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await z.get(n).json();return{...s,image:Oa(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function Oa(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const My=({nftInfo:e,children:n})=>{const{data:s={}}=Ly(e.nft.uri),o=$y(e,s);return n(o)},Py="_grid_1wwdn_1",Dy="_root_1wwdn_7",By="_collectionName_1wwdn_15",Ry="_nftName_1wwdn_23",Fy="_chainInfo_1wwdn_32",Va={grid:Py,root:Dy,collectionName:By,nftName:Ry,chainInfo:Fy},Uy=()=>{const[e,n]=W.useAtom(G1),[s,o]=W.useAtom(Y1),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}=qy(),c=Ce(),d=_.useMemo(()=>a.filter(({collection_addr:h,collection_name:m,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const x=e.trim().toLowerCase();return h.toLowerCase().includes(x)||m.toLowerCase().includes(x)||f.token_id.toLowerCase().includes(x)||p.toLowerCase().includes(x)}return!0}),[a,s,e]),u=_.useMemo(()=>Array.from(new Set(a.map(({chain:h})=>h.chainId))),[a]);return l&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!l?t.jsx(he,{children:"No NFTs"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(qs,{value:s,onChange:o,chainIds:u,renderExtra:h=>h?r[h]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:Va.grid,children:d.map(h=>{const{collection_addr:m,nft:f}=h;return t.jsx(My,{nftInfo:h,children:p=>t.jsx(na,{normalizedNft:p,onThumbnailClick:()=>c("/nft",p),classNames:Va})},m+f.token_id)})})]})},Fi=_.createContext(null);function Ui(){return _.useContext(Fi)}const Oy="_popup_nbecp_1",Vy="_item_nbecp_19",ss={popup:Oy,item:Vy},Oi=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=_.useState(!1),m=Ce(),f=Ui(),{showNotification:p}=Ss(),{defaultChainId:g}=Y(),{evm_chain_id:x}=Vt(),y=ve.useChainId(),{switchChainAsync:b}=ve.useSwitchChain(),{watchAssetAsync:C}=ve.useWatchAsset(),v=()=>{h(!1),m("/send",{denom:s,chain:c})},N=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=T.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const $=r;return await b({chainId:Number(x)}),C({type:"ERC20",options:{address:l,symbol:a,decimals:o,image:$}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:$=>{p({type:"error",title:"Asset addition failed",description:$.message})}});return t.jsxs(ht.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(ht.Menu.Trigger,{render:n}),t.jsx(ht.Menu.Portal,{container:f,children:t.jsx(ht.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(ht.Menu.Popup,{className:ss.popup,children:[t.jsxs(ht.Menu.Item,{className:ss.item,onClick:v,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(ht.Menu.Item,{className:ss.item,onClick:N,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&x===y&&!!l&&t.jsxs(ht.Menu.Item,{className:ss.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},Ky="_item_38qhm_1",zy="_info_38qhm_23",Wy="_images_38qhm_29",Hy="_name_38qhm_33",Qy="_value_38qhm_39",Gy="_amount_38qhm_47",Yy="_usd_38qhm_53",Mt={item:Ky,info:zy,images:Wy,name:Hy,value:Qy,amount:Gy,usd:Yy},Zy=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=j.formatAmount(n,{decimals:e.decimals});return t.jsx(Oi,{asset:e,children:t.jsxs("button",{className:Mt.item,children:[t.jsxs("div",{className:Mt.info,children:[t.jsx(Ts,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Mt.images}),t.jsx("span",{className:Mt.name,children:a.name})]}),t.jsxs("div",{className:Mt.value,children:[t.jsx("span",{className:Mt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Mt.usd,children:ee(s)})]})]})})},Jy="_container_ytg3p_1",Xy="_assetItem_ytg3p_6",e2="_expandIcon_ytg3p_22",t2="_assetInfo_ytg3p_27",n2="_logo_ytg3p_33",s2="_details_ytg3p_37",o2="_symbol_ytg3p_42",a2="_chainName_ytg3p_53",r2="_chainInfos_ytg3p_59",i2="_chainLogos_ytg3p_65",c2="_chainLogo_ytg3p_65",l2="_moreChains_ytg3p_76",d2="_expanded_ytg3p_93",u2="_valueColumn_ytg3p_98",m2="_amount_ytg3p_108",h2="_value_ytg3p_98",p2="_collapsibleContent_ytg3p_121",f2="_chainsList_ytg3p_151",pe={container:Jy,assetItem:Xy,expandIcon:e2,assetInfo:t2,logo:n2,details:s2,symbol:o2,chainName:a2,chainInfos:r2,chainLogos:i2,chainLogo:c2,moreChains:l2,expanded:d2,valueColumn:u2,amount:m2,value:h2,collapsibleContent:p2,chainsList:f2},g2=W.atom([]),oa=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=W.useAtom(g2),l=_.useMemo(()=>Oc(e),[e]),c=_.useMemo(()=>qr(e),[e]),d=r.includes(n),u=()=>{i(m=>d?m.filter(f=>f!==n):[...new Set([...m,n])])},h=()=>t.jsxs("button",{className:pe.assetItem,children:[t.jsxs("div",{className:pe.assetInfo,children:[s&&t.jsx(X,{src:s,width:32,height:32,className:pe.logo,logo:!0}),t.jsxs("div",{className:pe.details,children:[t.jsx("div",{className:pe.symbol,children:n}),a?t.jsx("div",{className:pe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:pe.chainInfos,children:[t.jsx("div",{className:pe.chainLogos,children:o.slice(0,5).map(({chain:m})=>t.jsx(X,{src:m.logoUrl,width:16,height:16,className:pe.chainLogo,logo:!0},m.chainId))}),o.length>5&&t.jsxs("span",{className:pe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:L(pe.expandIcon,{[pe.expanded]:d})})]})]})]}),t.jsxs("div",{className:pe.valueColumn,children:[t.jsx("div",{className:pe.amount,children:j.formatNumber(l,{dp:o[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:pe.value,children:ee(c)})]})]});if(a){const[m]=o;return t.jsx("div",{className:pe.container,children:t.jsx(Oi,{asset:m,children:h()})})}return t.jsx("div",{className:pe.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(J.Collapsible.Content,{className:pe.collapsibleContent,children:t.jsx("div",{className:pe.chainsList,children:o.map(m=>t.jsx(Zy,{asset:m},m.chain.chainId))})})]})})},_2="_collapsible_1g7rh_1",x2="_trigger_1g7rh_5",y2="_divider_1g7rh_20",j2="_label_1g7rh_28",b2="_chevron_1g7rh_33",w2="_content_1g7rh_41",v2="_list_1g7rh_45",Nt={collapsible:_2,trigger:x2,divider:y2,label:j2,chevron:b2,content:w2,list:v2},Vi=({unlistedAssets:e})=>{const[n,s]=_.useState(!1),o=Ui(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const h=a.current.scrollHeight;i(h)}},[e]);const l=_.useRef(null),c=h=>{s(h),h&&l.current&&o?.current&&window.setTimeout(()=>{if(!l.current||!a.current||!o?.current)return;const m=o.current,f=m.getBoundingClientRect(),p=l.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const y=p.top-f.top+m.scrollTop-16;m.scrollTo({top:y,behavior:"smooth"})}},50)},d=rt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),u=_.useMemo(()=>e.map(h=>({...h,assets:[h],totalValue:h.value??0,totalAmount:Number(h.quantity)})),[e]);return e.length===0?null:t.jsxs(J.Collapsible.Root,{open:n,onOpenChange:c,className:Nt.collapsible,children:[t.jsxs(J.Collapsible.Trigger,{ref:l,className:Nt.trigger,children:[t.jsx("div",{className:Nt.divider}),t.jsxs("span",{className:Nt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:Nt.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:Nt.divider})]}),t.jsx(J.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(rt.animated.div,{className:Nt.content,style:d,children:t.jsx("div",{className:Nt.list,ref:a,children:u.map(h=>t.jsx(oa,{assetGroup:h},h.assets[0].denom))})})})]})},C2="_container_15xfg_1",N2="_header_15xfg_7",I2="_title_15xfg_13",k2="_totalValue_15xfg_19",S2="_list_15xfg_26",tn={container:C2,header:N2,title:I2,totalValue:k2,list:S2},A2=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:l,isLoading:c}=Lo(),d=i.map(({chainId:m})=>m),u=_.useMemo(()=>{const m=e?a.filter(p=>{const{symbol:g,assets:x}=p;return g.toLowerCase().includes(e.toLowerCase())||x.some(({denom:y,address:b})=>y.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?m.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===s)})).filter(p=>p.assets.length>0):m},[a,e,s]),h=_.useMemo(()=>{const m=e?r.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):r;return s?m.filter(({chain:p})=>p.chainId===s):m},[r,e,s]);return c&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!u.length&&!h.length&&!e&&!s&&!c?t.jsx(he,{children:"No assets"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:m=>n(m.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(qs,{value:s,onChange:o,chainIds:d,renderExtra:m=>{if(!m)return ee(l);const f=i.find(p=>p.chainId===m);return f?ee(f.value):null}})]}),t.jsx("div",{children:u.length===0&&h.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tn.list,children:u.map(m=>t.jsx(oa,{assetGroup:m},m.symbol))}),t.jsx(Vi,{unlistedAssets:h})]})})]})},T2="_container_11k2x_1",$2={container:T2},He=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Ut,{height:e,width:s}):t.jsx("div",{className:$2.container,children:o.map(a=>t.jsx(Ut,{height:e,width:s},a))})},E2=_.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:l}=Pn(),c=ae(),{listedGroups:d,unlistedAssets:u}=_.useMemo(()=>kl(i,a,r,c.chainId),[i,a,r,c.chainId]),h=_.useMemo(()=>vl(d,s,o),[d,s,o]),{filteredAssets:m,totalAssetsValue:f,filteredUnlistedAssets:p}=_.useMemo(()=>Il(h,u,e,n),[h,u,e,n]);return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.header,children:[t.jsx("span",{className:tn.title,children:"Assets"}),m.length>0&&t.jsx("span",{className:tn.totalValue,children:ee(f)})]}),m.length>0?t.jsxs("div",{children:[t.jsx("div",{className:tn.list,children:m.map(g=>t.jsx(oa,{assetGroup:g},g.symbol))}),t.jsx(Vi,{unlistedAssets:p})]}):h.length===0&&l?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),q2=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function Ki(){const{civitiaUrl:e}=Y(),n=te();return T.useQuery({enabled:!!n,queryKey:q2.player(e,n??"").queryKey,queryFn:async()=>{if(!n)throw new Error("address is not available");return z.get(`${e}/players/${n}`).json()},staleTime:K.MINUTE,throwOnError:!1})}const L2="_section_xdyfz_2",M2="_row_xdyfz_15",P2="_rowLeft_xdyfz_23",D2="_rowIcon_xdyfz_29",B2="_goldIcon_xdyfz_38",R2="_silverIcon_xdyfz_46",F2="_rowTitle_xdyfz_54",U2="_rowValue_xdyfz_60",O2="_rowSubtitle_xdyfz_67",Ie={section:L2,row:M2,rowLeft:P2,rowIcon:D2,goldIcon:B2,silverIcon:R2,rowTitle:F2,rowValue:U2,rowSubtitle:O2},V2=()=>{const{data:e,isLoading:n}=Ki();if(n)return t.jsx(He,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ie.section,children:[t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.goldIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Gold"})]}),t.jsx("span",{className:L(Ie.rowValue,s===0&&Ie.rowSubtitle),children:s===0?"—":j.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.silverIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Silver"})]}),t.jsx("span",{className:L(Ie.rowValue,o===0&&Ie.rowSubtitle),children:o===0?"—":j.formatNumber(o,{dp:6})})]})]})},K2="_container_1n61l_1",z2="_section_1n61l_7",W2="_sectionHeader_1n61l_19",H2="_sectionTitle_1n61l_25",Q2="_sectionLabel_1n61l_31",G2="_externalLink_1n61l_37",Y2="_sectionValue_1n61l_49",Z2="_tokenList_1n61l_56",J2="_stakingTokenList_1n61l_62",X2="_tokenRow_1n61l_72",e0="_tokenMain_1n61l_78",t0="_tokenTrigger_1n61l_84",n0="_tokenChevron_1n61l_100",s0="_expanded_1n61l_111",o0="_triggerValue_1n61l_115",a0="_tokenInfo_1n61l_122",r0="_tokenInfoLabel_1n61l_128",i0="_tokenLogo_1n61l_134",c0="_tokenSymbol_1n61l_138",l0="_tokenValues_1n61l_144",d0="_tokenAmount_1n61l_150",u0="_tokenValue_1n61l_144",m0="_typeBreakdown_1n61l_164",h0="_typeRow_1n61l_172",p0="_typeLabel_1n61l_180",f0="_typeValues_1n61l_186",g0="_typeAmount_1n61l_192",_0="_typeValue_1n61l_186",x0="_collapsibleContent_1n61l_206",G={container:K2,section:z2,sectionHeader:W2,sectionTitle:H2,sectionLabel:Q2,externalLink:G2,sectionValue:Y2,tokenList:Z2,stakingTokenList:J2,tokenRow:X2,tokenMain:e0,tokenTrigger:t0,tokenChevron:n0,expanded:s0,triggerValue:o0,tokenInfo:a0,tokenInfoLabel:r0,tokenLogo:i0,tokenSymbol:c0,tokenValues:l0,tokenAmount:d0,tokenValue:u0,typeBreakdown:m0,typeRow:h0,typeLabel:p0,typeValues:f0,typeAmount:g0,typeValue:_0,collapsibleContent:x0},zi=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const l=e.flatMap(c=>c.positions);return hl(l)},[e]);return i.size===0?null:t.jsx("div",{className:G.container,children:Array.from(i.entries()).map(([l,c])=>t.jsx(y0,{sectionKey:l,sectionGroup:c,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},l))})},y0=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:l,totalValue:c}=n,d=ml(e,o),u=_.useMemo(()=>jl(l),[l]),h=e==="staking";return t.jsxs("div",{className:G.section,children:[t.jsxs("div",{className:G.sectionHeader,children:[t.jsxs("div",{className:G.sectionTitle,children:[t.jsx("span",{className:G.sectionLabel,children:d}),h&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:G.externalLink,onClick:m=>m.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:G.sectionValue,children:ee(c)})]}),t.jsx("div",{className:L(G.tokenList,{[G.stakingTokenList]:h}),children:u.map(m=>t.jsx(j0,{group:m,showTypeBreakdown:h,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},m.denom))})]})},j0=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:l,totalValue:c,positions:d}=e,u=s.get(r),[h,m]=_.useState(!1),f=_.useMemo(()=>{if(!n)return null;const p=xl(d);return p.size>0?p:null},[d,n]);return f?t.jsxs(J.Collapsible.Root,{open:h,onOpenChange:m,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:G.tokenTrigger,children:[t.jsxs("div",{className:G.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(G.tokenChevron,{[G.expanded]:h})}),t.jsxs("div",{className:G.tokenInfoLabel,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]})]}),t.jsx("span",{className:G.triggerValue,children:ee(c)})]})}),t.jsx(J.Collapsible.Content,{className:G.collapsibleContent,children:t.jsx(b0,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:G.tokenRow,children:t.jsxs("div",{className:G.tokenMain,children:[t.jsxs("div",{className:G.tokenInfo,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]}),t.jsxs("div",{className:G.tokenValues,children:[t.jsx("span",{className:G.tokenAmount,children:j.formatNumber(l,{dp:6})}),t.jsx("span",{className:G.tokenValue,children:ee(c)})]})]})})},b0=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([c,d])=>{const u=d.reduce((m,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?m:m+f.balance.formattedAmount,0),h=d.reduce((m,f)=>m+an(f),0);return{type:c,typeAmount:u,typeValue:h}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let c=0;for(const{type:d}of r){const u=o(s,d);c+=Number(u)}return c},[s,o,r]),l=i>0;return t.jsxs("div",{className:G.typeBreakdown,children:[r.map(({type:c,typeAmount:d,typeValue:u})=>t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:_l(c)}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:G.typeValue,children:ee(u)})]})]},c)),l&&t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:"Claimable"}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(i,{dp:6})," ",We]}),t.jsx("span",{className:G.typeValue,children:ee(i*(a??0))})]})]})]})},w0="_container_ymkoc_1",v0="_trigger_ymkoc_6",C0="_expandIcon_ymkoc_22",N0="_chainInfo_ymkoc_27",I0="_logo_ymkoc_33",k0="_chainNameContainer_ymkoc_37",S0="_chainName_ymkoc_37",A0="_externalLink_ymkoc_49",T0="_externalIcon_ymkoc_53",$0="_valueColumn_ymkoc_63",E0="_value_ymkoc_63",q0="_expanded_ymkoc_80",L0="_collapsibleContent_ymkoc_85",M0="_content_ymkoc_97",Te={container:w0,trigger:v0,expandIcon:C0,chainInfo:N0,logo:I0,chainNameContainer:k0,chainName:S0,externalLink:A0,externalIcon:T0,valueColumn:$0,value:E0,expanded:q0,collapsibleContent:L0,content:M0},P0=W.atom([]),D0=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=_.useMemo(()=>{const d=new Map;for(const u of o)for(const h of u.positions){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:m,symbol:f}=h.balance,p=f.toUpperCase(),g=`${n}:${m}`,x=i.get(g)??l.get(p);x&&d.set(m,{assetLogo:x,chainLogo:s??""})}return d},[o,i,l,n,s]);return t.jsx(zi,{protocols:o,denomLogoMap:c})},B0=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=W.useAtom(P0),l=_.useMemo(()=>o.reduce((p,g)=>p+g.positions.reduce((x,y)=>x+an(y),0),0),[o]),c=["civitia","yominet"],d=r.includes(n),u=n?.toLowerCase(),h=u==="civitia",m=c.includes(u),f=()=>{i(p=>d?p.filter(g=>g!==n):[...new Set([...p,n])])};return t.jsx("div",{className:Te.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[s&&t.jsx(X,{src:s,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:p=>p.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[!m&&t.jsx("span",{className:Te.value,children:ee(l)}),t.jsx(S.IconChevronDown,{size:16,className:L(Te.expandIcon,{[Te.expanded]:d})})]})]})}),t.jsx(J.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(D0,{chainGroup:e}),h&&t.jsx(V2,{})]})})]})})},R0="_container_1gqx9_1",F0="_section_1gqx9_6",U0="_sectionHeader_1gqx9_14",O0="_sectionTitle_1gqx9_20",V0="_sectionLabel_1gqx9_26",K0="_externalLink_1gqx9_32",z0="_sectionValue_1gqx9_44",W0="_tokenList_1gqx9_51",H0="_tokenTrigger_1gqx9_63",Q0="_tokenChevron_1gqx9_79",G0="_expanded_1gqx9_90",Y0="_tokenInfo_1gqx9_94",Z0="_tokenInfoLabel_1gqx9_100",J0="_tokenLogo_1gqx9_106",X0="_pairedLogos_1gqx9_110",ej="_coinLogo_1gqx9_115",tj="_tokenSymbol_1gqx9_133",nj="_triggerValue_1gqx9_139",sj="_breakdownContent_1gqx9_146",oj="_breakdownRow_1gqx9_154",aj="_breakdownLabel_1gqx9_162",rj="_breakdownValues_1gqx9_168",ij="_breakdownAmount_1gqx9_174",cj="_breakdownValue_1gqx9_168",lj="_collapsibleContent_1gqx9_195",se={container:R0,section:F0,sectionHeader:U0,sectionTitle:O0,sectionLabel:V0,externalLink:K0,sectionValue:z0,tokenList:W0,tokenTrigger:H0,tokenChevron:Q0,expanded:G0,tokenInfo:Y0,tokenInfoLabel:Z0,tokenLogo:J0,pairedLogos:X0,coinLogo:ej,tokenSymbol:tj,triggerValue:nj,breakdownContent:sj,breakdownRow:oj,breakdownLabel:aj,breakdownValues:rj,breakdownAmount:ij,breakdownValue:cj,collapsibleContent:lj},dj=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:se.container,children:t.jsxs("div",{className:se.section,children:[t.jsxs("div",{className:se.sectionHeader,children:[t.jsxs("div",{className:se.sectionTitle,children:[t.jsx("span",{className:se.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:se.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:se.sectionValue,children:ee(s)})]}),t.jsx("div",{className:se.tokenList,children:o.map(a=>t.jsx(mj,{row:a,denomLogoMap:n},a.denom))})]})})},uj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},mj=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:l,claimableInit:c}=e,[d,u]=_.useState(!1),h=n.get(s),m=i||h?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),g=l&&l.length>0&&l.some(y=>y),x=c&&Number(c.total)>0;return t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:se.tokenTrigger,children:[t.jsxs("div",{className:se.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(se.tokenChevron,{[se.expanded]:d})}),t.jsxs("div",{className:se.tokenInfoLabel,children:[g?t.jsx("div",{className:se.pairedLogos,children:l.map((y,b)=>t.jsx(X,{src:y,width:20,height:20,className:se.coinLogo,logo:!0},b))}):m&&t.jsx(X,{src:m,width:20,height:20,className:se.tokenLogo}),t.jsx("span",{className:se.tokenSymbol,children:o})]})]}),t.jsx("span",{className:se.triggerValue,children:ee(a)})]})}),t.jsx(J.Collapsible.Content,{className:se.collapsibleContent,children:t.jsxs("div",{className:se.breakdownContent,children:[p.map(([y,b])=>{const C=b*f;return t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:uj[y]}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(b,{dp:6})," LP"]}),t.jsx("span",{className:se.breakdownValue,children:ee(C)})]})]},y)}),x&&t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(Number(c.total),{dp:6})," ",We]}),t.jsx("span",{className:se.breakdownValue,children:ee(c.totalValue)})]})]})]})})]})},hj="_container_1nijk_1",pj="_section_1nijk_6",fj="_sectionHeader_1nijk_14",gj="_sectionTitle_1nijk_20",_j="_sectionLabel_1nijk_26",xj="_externalLink_1nijk_32",yj="_sectionValue_1nijk_44",jj="_tokenList_1nijk_51",bj="_tokenTrigger_1nijk_63",wj="_tokenChevron_1nijk_79",vj="_expanded_1nijk_90",Cj="_tokenInfo_1nijk_94",Nj="_tokenInfoLabel_1nijk_100",Ij="_tokenLogo_1nijk_106",kj="_tokenName_1nijk_110",Sj="_triggerValue_1nijk_116",Aj="_breakdownContent_1nijk_123",Tj="_breakdownRow_1nijk_131",$j="_breakdownLabel_1nijk_139",Ej="_breakdownValues_1nijk_145",qj="_breakdownAmount_1nijk_151",Lj="_breakdownValue_1nijk_145",Mj="_collapsibleContent_1nijk_165",ce={container:hj,section:pj,sectionHeader:fj,sectionTitle:gj,sectionLabel:_j,externalLink:xj,sectionValue:yj,tokenList:jj,tokenTrigger:bj,tokenChevron:wj,expanded:vj,tokenInfo:Cj,tokenInfoLabel:Nj,tokenLogo:Ij,tokenName:kj,triggerValue:Sj,breakdownContent:Aj,breakdownRow:Tj,breakdownLabel:$j,breakdownValues:Ej,breakdownAmount:qj,breakdownValue:Lj,collapsibleContent:Mj},Pj=({data:e})=>{const{totalValue:n,rows:s}=e;return s.length===0?null:t.jsx("div",{className:ce.container,children:t.jsxs("div",{className:ce.section,children:[t.jsxs("div",{className:ce.sectionHeader,children:[t.jsxs("div",{className:ce.sectionTitle,children:[t.jsx("span",{className:ce.sectionLabel,children:"VIP"}),t.jsx("a",{href:Cc,target:"_blank",rel:"noopener noreferrer",className:ce.externalLink,onClick:o=>o.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:ce.sectionValue,children:ee(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(Dj,{row:o},`${o.bridgeId}-${o.version}`))})]})})},Dj=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[l,c]=_.useState(!1),d=a+i;return t.jsxs(J.Collapsible.Root,{open:l,onOpenChange:c,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:ce.tokenTrigger,children:[t.jsxs("div",{className:ce.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(ce.tokenChevron,{[ce.expanded]:l})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(X,{src:s,width:20,height:20,className:ce.tokenLogo,logo:!0}),t.jsx("span",{className:ce.tokenName,children:n})]})]}),t.jsx("span",{className:ce.triggerValue,children:ee(d)})]})}),t.jsx(J.Collapsible.Content,{className:ce.collapsibleContent,children:t.jsxs("div",{className:ce.breakdownContent,children:[o>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Locked"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[j.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(a)})]})]}),r>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[j.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(i)})]})]})]})})]})},Bj="_container_ymkoc_1",Rj="_trigger_ymkoc_6",Fj="_expandIcon_ymkoc_22",Uj="_chainInfo_ymkoc_27",Oj="_logo_ymkoc_33",Vj="_chainNameContainer_ymkoc_37",Kj="_chainName_ymkoc_37",zj="_externalLink_ymkoc_49",Wj="_externalIcon_ymkoc_53",Hj="_valueColumn_ymkoc_63",Qj="_value_ymkoc_63",Gj="_expanded_ymkoc_80",Yj="_collapsibleContent_ymkoc_85",Zj="_content_ymkoc_97",$e={container:Bj,trigger:Rj,expandIcon:Fj,chainInfo:Uj,logo:Oj,chainNameContainer:Vj,chainName:Kj,externalLink:zj,externalIcon:Wj,valueColumn:Hj,value:Qj,expanded:Gj,collapsibleContent:Yj,content:Zj},Jj=W.atom(!1),Xj=()=>{const{totalValue:e}=Bo(),{totalValue:n}=Fo(),{totalValue:s}=Cs(),o=e+n+s;return t.jsx("span",{className:$e.value,children:ee(o)})},eb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Bo(),{data:i}=Dr(),{data:l}=Br(),c=_.useMemo(()=>{const h=new Map;for(const m of r){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:f,symbol:p}=m.balance,g=p.toUpperCase(),x=`${e}:${f}`,y=s.get(x)??o.get(g);y&&h.set(f,{assetLogo:y,chainLogo:n})}return h},[r,s,o,e,n]),d=_.useMemo(()=>(h,m)=>{const f=j.denomToMetadata(h);if(m==="staking"){const p=i?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}if(m==="lockstaking"){const p=l?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}return"0"},[i,l]),u=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:So,positions:r}],[r]);return u.length===0?null:t.jsx(zi,{protocols:u,denomLogoMap:c,isInitia:!0,getClaimableInitByType:d,initPrice:a})},tb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=Fo(),r=_.useMemo(()=>{const i=new Map;for(const l of a.rows){const{denom:c,symbol:d}=l,u=d.toUpperCase(),h=`${e}:${c}`,m=s.get(h)??o.get(u);m&&i.set(c,{assetLogo:m,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(dj,{data:a,denomLogoMap:r})},nb=()=>{const e=Cs();return e.rows.length===0?null:t.jsx(Pj,{data:e})},sb=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=W.useAtom(Jj),i=de(),l=Sn(),{denomLogos:c,symbolLogos:d}=_.useMemo(()=>Uo(l,i),[l,i]),u=ae(),{data:h}=_t(u),m=_.useMemo(()=>h?.find(p=>p.id===Se)?.price??0,[h]);return t.jsx("div",{className:$e.container,children:t.jsxs(J.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:$e.trigger,children:[t.jsxs("div",{className:$e.chainInfo,children:[o&&t.jsx(X,{src:o,width:32,height:32,className:$e.logo,logo:!0}),t.jsxs("div",{className:$e.chainNameContainer,children:[t.jsx("span",{className:$e.chainName,children:s}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:$e.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:$e.externalIcon})})]})]}),t.jsxs("div",{className:$e.valueColumn,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(Xj,{})}),t.jsx(S.IconChevronDown,{size:16,className:L($e.expandIcon,{[$e.expanded]:a})})]})]})}),t.jsx(J.Collapsible.Content,{className:$e.collapsibleContent,children:t.jsxs("div",{className:$e.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(eb,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d,initPrice:m})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(tb,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:1}),children:t.jsx(nb,{})})]})})]})})},ob="_totalValue_1v2ca_1",ab={totalValue:ob},rb=({filteredChainGroups:e})=>{const{totalValue:n}=Bo(),{totalValue:s}=Fo(),{totalValue:o}=Cs(),a=n+s+o,r=_.useMemo(()=>{const i=e.some(c=>c.isInitia);return e.reduce((c,d)=>d.isInitia?c:c+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:ab.totalValue,children:ee(r)})},ib="_container_1eubu_1",cb="_header_1eubu_7",lb="_title_1eubu_13",db="_list_1eubu_19",ub="_skeletonWrapper_1eubu_24",yn={container:ib,header:cb,title:lb,list:db,skeletonWrapper:ub},mb=_.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Pn(),r=ae(),{data:i,isLoading:l}=Ki(),c=_.useMemo(()=>{const u=[];for(const m of o){if(!Array.isArray(m.positions))continue;const f=s.get(m.chainName.toLowerCase()),p=m.chainName.toLowerCase(),g=p==="civitia";if(n&&f?.chainId!==n)continue;const x=m.positions.some(N=>N.positions.some(k=>k.type!=="fungible-position")),y=g&&!l&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!x&&!y||e&&!p.includes(e.toLowerCase()))continue;const b=m.positions.filter(N=>e&&!N.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(N.positions)&&N.positions.length>0),C=r.chainId===f?.chainId,v=b.reduce((N,k)=>N+k.positions.reduce(($,q)=>$+an(q),0),0);u.push({chainId:f?.chainId??"",chainName:f?.prettyName??m.chainName,chainLogo:f?.logoUrl??"",protocols:b,isInitia:C,totalValue:v})}const h=["civitia","yominet"];return A.sortWith([A.descend(m=>m.isInitia??!1),A.ascend(m=>h.includes(m.chainName.toLowerCase())),A.descend(m=>m.totalValue??0),A.ascend(m=>m.chainName.toLowerCase())],u)},[o,s,e,n,r.chainId,i,l]),d=c.length>0;return t.jsxs("div",{className:yn.container,children:[t.jsxs("div",{className:yn.header,children:[t.jsx("span",{className:yn.title,children:"Positions"}),d&&t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(rb,{filteredChainGroups:c})})]}),d?t.jsx("div",{className:yn.list,children:c.map(u=>u.isInitia?t.jsx(me,{suspenseFallback:t.jsx("div",{className:yn.skeletonWrapper,children:t.jsx(He,{height:56,length:1})}),children:t.jsx(sb,{chainGroup:u})},u.chainName):t.jsx(B0,{chainGroup:u},u.chainName))}):o.length===0&&a?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),hb="_content_1w1ad_1",pb={content:hb},fb=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=Y(),o=ae(),a=Ll(),{totalValue:r}=Cs(),{chainIds:i,chainIdToValueMap:l,totalBalance:c}=_.useMemo(()=>{const d=new Map;let u=0;for(const m of a)d.set(m.chainId,m.totalBalance),u+=m.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),u+=r),{chainIds:A.sortWith([A.descend(m=>m===s),A.descend(m=>m===o.chainId),A.descend(m=>d.get(m)??0)],a.map(m=>m.chainId)),chainIdToValueMap:d,totalBalance:u}},[a,s,o,r]);return t.jsx(qs,{value:e,onChange:n,chainIds:i,renderExtra:d=>ee(d?l.get(d)??0:c)})},gb=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=Co(),d=_.useMemo(()=>Vr(a,c),[a,c]),u=ql();return t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(me,{suspenseFallback:t.jsx(Ut,{height:44,width:132}),children:t.jsx(fb,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:pb.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:48,length:5}),children:t.jsx(E2,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:l,chainInfoMap:u,chainPrices:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:56,length:3}),children:t.jsx(mb,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},_b="_totalValue_5pf7e_1",xb="_totalLabel_5pf7e_7",yb="_totalAmount_5pf7e_13",jb="_loading_5pf7e_18",bb="_skeletonWrapper_5pf7e_23",wb="_nav_5pf7e_28",vb="_item_5pf7e_34",Cb="_tabs_5pf7e_59",Nb="_tab_5pf7e_59",Ee={totalValue:_b,totalLabel:xb,totalAmount:yb,loading:jb,skeletonWrapper:bb,nav:wb,item:vb,tabs:Cb,tab:Nb},Ib=()=>{const{totalValue:e,isLoading:n}=Lo();return t.jsx("div",{className:L(Ee.totalAmount,{[Ee.loading]:n}),children:ee(e)})},kb=()=>{const e=Ml(),n=Pl(),s=Or(),o=e+s+n;return t.jsx("div",{className:Ee.totalAmount,children:ee(o)})},Sb=()=>{mi(),$l();const e=Oo(),n=Ce(),s=_s(),o=_.useRef(null);return t.jsx(Fi.Provider,{value:o,children:t.jsxs(et,{ref:o,children:[t.jsxs("div",{className:Ee.totalValue,children:[t.jsx("div",{className:Ee.totalLabel,children:"Total value"}),t.jsx(me,{suspenseFallback:t.jsx("div",{className:Ee.skeletonWrapper,children:t.jsx(Ut,{height:48,width:120})}),children:e?t.jsx(Ib,{}):t.jsx(kb,{})})]}),t.jsxs("div",{className:Ee.nav,children:[t.jsxs(nn,{to:"/send",className:Ee.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(nn,{to:"/bridge",className:Ee.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(nn,{to:"/receive",className:Ee.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(wt.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(wt.Tabs.List,{className:Ee.tabs,children:[t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/nfts",children:"NFTs"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/activity",children:"Activity"})]}),t.jsx(wt.Tabs.Panel,{value:"/",children:e?t.jsx(A2,{}):t.jsx(gb,{})}),t.jsx(wt.Tabs.Panel,{value:"/nfts",children:t.jsx(Uy,{})}),t.jsx(wt.Tabs.Panel,{value:"/activity",children:t.jsx(vy,{})})]})]})})},Ab="_root_th990_1",Tb="_collectionName_th990_9",$b="_nftName_th990_13",Eb="_chainInfo_th990_17",qb="_attributes_th990_21",Lb="_title_th990_24",Mb="_count_th990_29",Pb="_item_th990_33",Db="_type_th990_39",Bb="_value_th990_45",Pt={root:Ab,collectionName:Tb,nftName:$b,chainInfo:Eb,attributes:qb,title:Lb,count:Mb,item:Pb,type:Db,value:Bb},Rb=()=>{const e=Ce(),n=Je(),{attributes:s}=n;return t.jsxs(dt,{title:"NFT details",children:[t.jsx(na,{normalizedNft:n,chainIconSize:14,classNames:Pt}),t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Pt.attributes,children:[t.jsxs("header",{className:Pt.title,children:["Traits ",t.jsxs("span",{className:Pt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Pt.item,children:[t.jsx("div",{className:Pt.type,children:o}),t.jsx("div",{className:Pt.value,children:a})]},o))})]})]})};function Fb({balances:e,gasPrices:n,gas:s}){return n.map(({denom:o,amount:a})=>{const r=B(a).times(s).toFixed(0,B.ROUND_CEIL),i=e.find(l=>l.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>B(a).gte(o))}function Ub({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=Fb({balances:n,gasPrices:s,gas:a}),l=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&l){const d=B(r).minus(l.amount);return B.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=B(r).minus(c.amount);return B.max(d,0).toString()}return B(r).toString()}const Ob=({chain:e,onSelect:n})=>{const s=xc(e);return t.jsx(On,{assets:s,onSelect:n})},Vb=({afterSelect:e})=>{const{watch:n,setValue:s}=_e.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,l]=_.useState(r),c=Ze(i),d=de(),u=h=>{if(o===i&&a===h){e();return}s("chainId",i),s("denom",h),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Ft.Stack,{children:t.jsx(Ft,{chains:d,value:i,onSelect:l})}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(Ob,{chain:c,onSelect:u})},i)]})},Kb="_fields_brpej_1",zb="_divider_brpej_11",Ka={fields:Kb,divider:zb},Wb=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Hb=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=De(),{register:a,watch:r,setValue:i,handleSubmit:l,formState:c}=_e.useFormContext(),{errors:d}=c,{chainId:u,denom:h,recipient:m,quantity:f,memo:p}=r(),g=Ze(u),x=An(g),y=Vo(g),b=Ko(g),C=sr(h,g),{data:v}=_t(g),{decimals:N}=C,k=x.find(R=>R.denom===h)?.amount??"0",$=v?.find(({id:R})=>R===h)?.price,{data:q=0,isLoading:V}=T.useQuery({queryKey:Wb.gas({chainId:u,denom:h,recipient:m,initiaAddress:n}).queryKey,queryFn:()=>{const R=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(m).bech32,amount:[{denom:h,amount:"1"}]})}];return s({messages:R,chainId:u})},enabled:j.InitiaAddress.validate(m),staleTime:K.INFINITY}),M=Math.ceil(q*on),I=Ub({denom:h,balances:x,gasPrices:y,lastFeeDenom:b,gas:M}),w=B(k).isZero(),U=y.some(({denom:R})=>R===h)&&V,F=w||U,{mutate:O,isPending:Z}=T.useMutation({mutationFn:({chainId:R,denom:P,quantity:Ne,recipient:je,memo:tt})=>{const Be=j.toBaseUnit(Ne,{decimals:N}),Wt=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(je).bech32,amount:[{denom:P,amount:Be}]})}];return o({messages:Wt,memo:tt,chainId:R,gas:q,gasAdjustment:on,gasPrices:y,spendCoins:[{denom:P,amount:Be}],internal:"/"})}}),H=_.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!m)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,m,d.quantity,d.recipient,d.memo]);return t.jsx(dt,{title:"Send",children:t.jsxs("form",{onSubmit:l(R=>O(R)),children:[t.jsxs("div",{className:Ka.fields,children:[t.jsx(mo,{selectButton:t.jsx(rn,{title:"Select chain and asset",content:R=>t.jsx(Vb,{afterSelect:R}),children:t.jsx(gi,{asset:C,chain:g})}),quantityInput:t.jsx(In,{balance:k,decimals:N}),balanceButton:t.jsx(hi,{onClick:()=>i("quantity",j.fromBaseUnit(I,{decimals:N}),{shouldValidate:!0}),disabled:F,children:j.formatAmount(k??"0",{decimals:N})}),value:f?$?ee(B(f).times($)):"$-":"$0"}),t.jsx("div",{className:Ka.divider}),t.jsx(Qo,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:R=>!R||new Blob([R]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(fe.Stack,{children:!p&&t.jsx(fe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:(V?"Estimating gas...":!1)||Z,disabled:!!H,children:H??"Confirm"})})]})})},Qb=()=>{const e=Je(),n=Vt(),s=gt(n),{chain:o=n}=e,a=A.head(s);if(!e.denom&&!a)throw new 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.");const r=e.denom??a?.denom,i=_e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(_e.FormProvider,{...i,children:t.jsx(Hb,{})})};async function yo(e,n){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function Gb(e,n){const s=new pt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:j.InitiaAddress("0x1").bech32,contract_addr:j.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function Yb(e,n,s){if(n.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function Zb({collection_addr:e},{restUrl:n}){const s=await Gb(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await yo(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Jb(e,n){const{data:s}=await z.create({prefixUrl:n}).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(s)}async function Xb({object_addr:e,collection_addr:n},{restUrl:s}){const o=await Jb(n,s);return o.startsWith("ibc/")?j.InitiaAddress.equals(j.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await yo(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await yo(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function ew(e,n){const s=ie.toBase64(Dt.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function tw(e,n){const{collection:s}=await z.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function nw(e,n){const s=ie.toBase64(Dt.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function za(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function sw({collection_addr:e},n,s){const o=j.InitiaAddress(e).bech32,a=await ew(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:g,version:x})=>g===s.chain_id&&x.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,l=i.split(".")[1],c=ie.toBase64(Dt.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${l}/smart/${c}`).json(),u=d??o,h=await nw(l,n.restUrl),m=await tw(o,n.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:h};if(d&&m!==i.replace("wasm.","")){const[g,x]=za(d);return{class_id:o,class_trace:{path:g,base_class_id:x},outgoing_proxy:h}}const[f,p]=za(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:h}}const ow={minimove:Xb,minievm:Zb,miniwasm:sw};async function aw({nft:e,srcChain:n,intermediaryChain:s}){const o=n.metadata?.is_l1?"minimove":n.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await ow[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await Yb([e.token_id],a.class_id,n.restUrl)})}const rw="_root_1tyvn_1",iw="_collectionName_1tyvn_10",cw="_nftName_1tyvn_15",lw="_chainInfo_1tyvn_19",dw="_fields_1tyvn_24",uw="_chain_1tyvn_19",oo={root:rw,collectionName:iw,nftName:cw,chainInfo:lw,fields:dw,chain:uw},mw=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),hw=()=>{const e=de(),n=Je(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=Y(),r=En(),i=ae(),{address:l,initiaAddress:c,requestTxSync:d}=De(),{watch:u,setValue:h,handleSubmit:m,formState:f}=_e.useFormContext(),{errors:p}=f,g=u(),{recipient:x,dstChainId:y}=g,b=Ze(y),C=T.useQuery({queryKey:mw.simulation({collection_addr:o,nft:n,sender:c,recipient:x,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const I=Object.assign({from_address:c,from_chain_id:s.chainId,to_address:j.InitiaAddress(x).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==b.chainId&&await aw({nft:n,srcChain:s,intermediaryChain:i})),{msgs:w}=await z.create({prefixUrl:a}).post("nft",{json:I}).json();return w.map(E=>r.fromAmino(E))},enabled:j.InitiaAddress.validate(x)}),{data:v,isLoading:N,error:k}=C,$=T.useQueryClient(),{mutate:q,isPending:V}=T.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await d({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{$.invalidateQueries({queryKey:sa.nfts._def})}}),M=_.useMemo(()=>{if(!x)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(k)return"Route not found"},[x,p.recipient,k]);return t.jsxs("form",{onSubmit:m(()=>q()),children:[t.jsx(na,{normalizedNft:n,thumbnailSize:80,classNames:oo}),t.jsxs("div",{className:oo.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(rn,{title:"Destination appchain",content:I=>t.jsx(fi,{onSelect:({chainId:w})=>{h("dstChainId",w),I()},list:e,getImage:w=>w.logoUrl,getName:w=>w.name,getKey:w=>w.chainId}),className:L("input",oo.chain),children:[t.jsx(X,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]}),t.jsx(Qo,{myAddress:l,ref:Rn()})]}),t.jsx(xe,{children:t.jsx(le.White,{loading:(N?"Finding route...":!1)||V,disabled:!!M,children:M??"Confirm"})})]})},pw=()=>{const{chain:e}=Je(),n=_e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(dt,{title:"Send NFT",children:t.jsx(_e.FormProvider,{...n,children:t.jsx(hw,{})})})},jo=()=>{const e=Ce(),n=_s(),s=kt(),{closeDrawer:o}=xt(),{closeModal:a}=bs();_.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=Tn();if(_.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ba,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ba,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(Sb,{});case"/send":return t.jsx(Qb,{},s);case"/receive":return t.jsx(Jx,{});case"/nft":return t.jsx(Rb,{});case"/nft/send":return t.jsx(pw,{},s);case"/bridge":return t.jsx(Yp,{},s);case"/bridge/preview":return t.jsx(cg,{});case"/bridge/history":return t.jsx(Kf,{});case"/op/withdrawals":return t.jsx(Mg,{});case"/tx":return t.jsx(ri,{});case"/autosign/enable":return t.jsx(Dm,{});case"/settings":return t.jsx(I1,{});case"/settings/autosign":return t.jsx(h1,{});case"/deposit":return t.jsx(Bx,{});case"/deposit/completed":return t.jsx(xo,{type:"deposit"});case"/withdraw":return t.jsx(Rx,{});case"/withdraw/completed":return t.jsx(xo,{type:"withdraw"})}},fw="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",gw=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:fw}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),_w=()=>(Sc(),Mc(),de(),El(),Or(),Sn(),Bn(),Kt(),null),xw=({children:e,...n})=>(_.useEffect(()=>{dl()},[]),Le.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(gw,{}),t.jsx(Xa.Provider,{value:{...Ja,...n},children:t.jsx(ur,{children:t.jsx(um,{children:t.jsx(J.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(dm,{children:t.jsxs(Ju,{children:[e,t.jsx(Dl,{}),t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(_w,{})}),t.jsx(Id,{children:t.jsx(jo,{})}),t.jsx(wd,{children:t.jsx(jo,{})})]})})})})})})]}):null),yw=({bridge:e})=>t.jsx(ur,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Xr.Provider,{value:!!e,children:t.jsx(me,{children:t.jsx(jo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Za;exports.InterwovenKit=yw;exports.InterwovenKitProvider=xw;exports.MAINNET=Ja;exports.MoveError=Ir;exports.PRIVY_APP_ID=vo;exports.TESTNET=ic;exports.initiaPrivyWallet=lc;exports.initiaPrivyWalletConnector=cc;exports.initiaPrivyWalletOptions=bn;exports.injectStyles=Jl;exports.useAddress=kt;exports.useHexAddress=ln;exports.useInitiaAddress=te;exports.useInterwovenKit=De;exports.usePortfolio=Lo;exports.useUsernameQuery=Lr;
|