@initia/interwovenkit-react 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.js +2117 -2130
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wa=require("@privy-io/cross-app-connect/rainbow-kit"),we=require("wagmi"),T=require("@tanstack/react-query"),j=require("@initia/utils"),U=require("bignumber.js"),A=require("ramda"),ye=require("@lukemorales/query-key-factory"),V=require("ky"),g=require("react"),re=require("@cosmjs/encoding"),Ki=require("@mysten/bcs"),H=require("jotai"),Ha=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),oo=require("@cosmjs/amino/build/signdoc"),ao=require("@cosmjs/crypto"),ra=require("@cosmjs/math"),ds=require("@cosmjs/proto-signing"),Ve=require("@cosmjs/stargate"),ia=require("@cosmjs/tendermint-rpc"),Wi=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Nt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),gt=require("ethers"),sn=require("@initia/amino-converter"),wn=require("@cosmjs/amino"),Hi=require("cosmjs-types/cosmos/auth/v1beta1/auth"),ro=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Qi=require("cosmjs-types/google/protobuf/any"),Ze=require("date-fns"),xo=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"),Y=require("radix-ui"),Ie=require("usehooks-ts"),Ga=require("react-error-boundary"),L=require("clsx"),pe=require("react-hook-form"),Ne=require("@base-ui/react/dialog"),Gi=require("xss"),I=require("@initia/icons-react"),ze=require("@react-spring/web"),us=require("change-case"),ht=require("@base-ui/react/select"),Ms=require("@base-ui/react/collapsible"),da=require("nanoid"),Yi=require("react-dom"),Zi=require("jotai/utils"),Ya=require("react-merge-refs"),Ji=require("react-number-format"),Xi=require("react-intersection-observer"),ec=require("@noble/hashes/sha3"),Dt=require("@noble/hashes/utils"),tc=require("qr-code-styling"),ft=require("@base-ui/react"),bt=require("@base-ui/react/tabs"),Qt=require("@base-ui/react/popover"),ua=require("cosmjs-types/cosmos/bank/v1beta1/tx");function nc(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 yo=nc(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"},sc={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},jo="cmbq1ozyc006al70lx4uciz0q",ms={id:jo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},oc=Wa.toPrivyWalletConnector(ms),ac=Wa.toPrivyWallet(ms),Xa=g.createContext(null);function G(){const e=g.useContext(Xa);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const z={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function rc(e){if(e instanceof V.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 _t(e){return new Error(await rc(e))}const hs=ye.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Kn(e){const n=A.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function ic(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:d,rest:u,["json-rpc"]:m,indexer:h}=r,p=Kn(d),f=Kn(u),_=Kn(h),x=i?.minitia?.type==="minievm"?Kn(m):void 0;return{...e,chainId:n,name:c,logoUrl:l,rpcUrl:p,restUrl:f,indexerUrl:_,jsonRpcUrl:x}}function ue(){const{defaultChainId:e,registryUrl:n,customChain:s}=G(),{data:o}=T.useSuspenseQuery({queryKey:hs.list(n).queryKey,queryFn:()=>V.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(ic).toSorted(A.descend(i=>i.chainId===e)),staleTime:z.MINUTE});return o}function er(){const{registryUrl:e}=G(),{data:n}=T.useSuspenseQuery({queryKey:hs.profiles(e).queryKey,queryFn:()=>V.create({prefixUrl:e}).get("profiles.json").json(),staleTime:z.MINUTE});return n}function Je(){const e=ie(),n=ue(),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 Xe(e){return Je()(e)}function Ot(){const{defaultChainId:e}=G();return Xe(e)}function ie(){const n=ue().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:hs.prices(e).queryKey,queryFn:()=>V.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:z.SECOND})}function yt(e){const n=tr();return T.useQuery(n(e))}function bo(){const e=ue(),n=tr();return T.useQueries({queries:e.map(s=>n(s))})}const cc=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ha=require("@privy-io/cross-app-connect/rainbow-kit"),we=require("wagmi"),T=require("@tanstack/react-query"),j=require("@initia/utils"),U=require("bignumber.js"),A=require("ramda"),ye=require("@lukemorales/query-key-factory"),V=require("ky"),g=require("react"),re=require("@cosmjs/encoding"),Hi=require("@mysten/bcs"),K=require("jotai"),Qa=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),oo=require("@cosmjs/amino/build/signdoc"),ao=require("@cosmjs/crypto"),ra=require("@cosmjs/math"),ds=require("@cosmjs/proto-signing"),Ve=require("@cosmjs/stargate"),ia=require("@cosmjs/tendermint-rpc"),Qi=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Nt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),gt=require("ethers"),sn=require("@initia/amino-converter"),wn=require("@cosmjs/amino"),Gi=require("cosmjs-types/cosmos/auth/v1beta1/auth"),ro=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Yi=require("cosmjs-types/google/protobuf/any"),Ze=require("date-fns"),xo=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"),Ga=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),Y=require("radix-ui"),Ie=require("usehooks-ts"),Ya=require("react-error-boundary"),L=require("clsx"),pe=require("react-hook-form"),Ne=require("@base-ui/react/dialog"),Zi=require("xss"),I=require("@initia/icons-react"),ze=require("@react-spring/web"),us=require("change-case"),ht=require("@base-ui/react/select"),Ms=require("@base-ui/react/collapsible"),da=require("nanoid"),Ji=require("react-dom"),Xi=require("jotai/utils"),Za=require("react-merge-refs"),ec=require("react-number-format"),tc=require("react-intersection-observer"),nc=require("@noble/hashes/sha3"),Dt=require("@noble/hashes/utils"),sc=require("qr-code-styling"),ft=require("@base-ui/react"),bt=require("@base-ui/react/tabs"),Qt=require("@base-ui/react/popover"),ua=require("cosmjs-types/cosmos/bank/v1beta1/tx");function oc(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 yo=oc(Qa),on=1.4,Ja=1.05,Xa={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"},ac={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},jo="cmbq1ozyc006al70lx4uciz0q",ms={id:jo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},rc=Ha.toPrivyWalletConnector(ms),ic=Ha.toPrivyWallet(ms),er=g.createContext(null);function G(){const e=g.useContext(er);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const z={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function cc(e){if(e instanceof V.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 _t(e){return new Error(await cc(e))}const hs=ye.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Kn(e){const n=A.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function lc(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:d,rest:u,["json-rpc"]:m,indexer:h}=r,p=Kn(d),f=Kn(u),_=Kn(h),x=i?.minitia?.type==="minievm"?Kn(m):void 0;return{...e,chainId:n,name:c,logoUrl:l,rpcUrl:p,restUrl:f,indexerUrl:_,jsonRpcUrl:x}}function ue(){const{defaultChainId:e,registryUrl:n,customChain:s}=G(),{data:o}=T.useSuspenseQuery({queryKey:hs.list(n).queryKey,queryFn:()=>V.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(lc).toSorted(A.descend(i=>i.chainId===e)),staleTime:z.MINUTE});return o}function tr(){const{registryUrl:e}=G(),{data:n}=T.useSuspenseQuery({queryKey:hs.profiles(e).queryKey,queryFn:()=>V.create({prefixUrl:e}).get("profiles.json").json(),staleTime:z.MINUTE});return n}function Je(){const e=ie(),n=ue(),s=tr();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 Xe(e){return Je()(e)}function Ot(){const{defaultChainId:e}=G();return Xe(e)}function ie(){const n=ue().find(s=>s.metadata?.is_l1);if(!n)throw new Error("Layer 1 not found");return n}function nr(){return({chainId:e})=>T.queryOptions({queryKey:hs.prices(e).queryKey,queryFn:()=>V.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:z.SECOND})}function yt(e){const n=nr();return T.useQuery(n(e))}function bo(){const e=ue(),n=nr();return T.useQueries({queries:e.map(s=>n(s))})}const dc=`<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>`,lc=encodeURIComponent(cc),vo=`data:image/svg+xml;utf8,${lc}`,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 dc(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 nr(){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(dc);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=nr(),{data:s}=T.useSuspenseQuery(n(e));return s}function An(){const e=ue(),n=nr();return T.useQueries({queries:e.map(s=>n(s))})}function ct(e){const n=xt(e),s=ie(),o=xt(s),a=or(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 sr(e,n){const s=ct(n),a=T.useQueryClient().getQueryData(Cn.item(n.chainId,e).queryKey);return a||s(e)}function or(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:async()=>(await s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json()).denom,queryKey:Cn.denom(n.restUrl,a).queryKey,select:r=>[a,r],staleTime:z.INFINITY}))});return new Map(o.map(({data:a})=>a))}function uc(e){return e.pagination?.next_key??null}async function ar(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=uc(c),u=[...r,...l];return d?a(u,d):u};return a([],null)}const ma="usernames";function mc({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:[Ki.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 rr(){const{restUrl:e}=ie(),{usernamesModuleAddress:n}=G();return mc({restUrl:e,moduleAddress:n})}function ir(){const e=X();return n=>T.queryOptions({queryKey:ps.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?ar(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:z.SECOND})}function Sn(e){const n=ir(),{data:s}=T.useSuspenseQuery(n(e));return s}function hc(){const e=ue(),n=ir();return T.useQueries({queries:e.map(s=>n(s))})}function pc(e){const n=Sn(e),s=xt(e),o=ct(e),a=or(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 cr=g.createContext(null);function fs(){return g.useContext(cr)}function lr(){const{location:e}=fs();return e}function et(){const{path:e}=lr();return e}function Ke(){const{state:e={}}=lr();return e}function dr(){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})},ur=({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(cr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},fc="c33b940c24c17e95f7d9d525d508ac61";function gc(){const{disableAnalytics:e}=G();g.useEffect(()=>{e||yo.init(fc,{autocapture:!1})},[e])}function _c(){const{connector:e}=we.useAccount(),{defaultChainId:n,disableAnalytics:s}=G();g.useEffect(()=>{const o=new Ha.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,xc="uoinit",yc="omniINIT",mr="https://app.initia.xyz",No=`${mr}/liquidity/my`,jc=`${mr}/vip/my`,bc=1e3,hr=60*bc,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=H.atom(!1),gr=H.atom(!1);function lt(){const e=Co(),[n,s]=H.useAtom(fr),o=H.useSetAtom(gr),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]=H.useAtom(gr),o=H.useSetAtom(fr),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 vc(){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 wc(){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 Cc(){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 Nc(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 kc({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Hi.BaseAccount.decode(n),i=Nc(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ve.accountFromAny({typeUrl:e,value:n})}function Ic(e){return e.type==="initia/PubKeyEthSecp256k1"}const Ac={...wn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Sc(e){if(Ic(e)){const n=ro.PubKey.fromPartial({key:re.fromBase64(e.value)});return Qi.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(ro.PubKey.encode(n).finish())})}return ds.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:Ac.ethsecp256k1,value:re.toBase64(e)}}function $c(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: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 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=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=$c(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=Sc(_r(_.pubkey)),y=Wi.SignMode.SIGN_MODE_EIP_191,b=i.map(N=>n.toAmino(N)),C=oo.makeSignDoc(b,c,a,l,h,f),{signature:w,signed:v}=await u.signAmino(r,C),S={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:v.msgs.map(N=>n.fromAmino(N)),memo:l}},M=e.encode(S),F=ra.Int53.fromString(v.fee.gas).toNumber(),E=ra.Int53.fromString(v.sequence).toNumber(),$=ds.makeAuthInfoBytes([{pubkey:x,sequence:E}],v.fee.amount,F,v.fee.granter,v.fee.payer,y);return Nt.TxRaw.fromPartial({bodyBytes:M,authInfoBytes:$,signatures:[re.fromBase64(w.signature)]})}}function qn(){const e=X(),{signMessageAsync:n}=we.useSignMessage(),s=ie();return g.useMemo(()=>new xr(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Ds=new Map,Ps=new Map;function yr(){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=yr();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:kc,broadcastPollIntervalMs:500});return Ps.set(i,l),l}}function jr(){const{connector:e}=we.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new gt.BrowserProvider(await e.getProvider())}}function br(){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 vr(){const{privyContext:e}=G(),n=Io();if(!(!e||!n))return e.wallets.find(s=>s.connectorType==="embedded")}function _s(){const e=vr();return e?.address?j.InitiaAddress(e.address).bech32:void 0}function wr(){const e=vr(),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 xr(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 Cr(){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}=br();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 Tc(){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 Nr=g.createContext(null),ys=()=>g.useContext(Nr);class kr 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 Ec=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Rs=new Map;function qc(e){const n=e.match(Ec);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 Lc(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 Mc(e,n,s,o,a,r,i){return new kr(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=qc(e.message);if(!o)return await _t(e);const a=await Lc(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 Mc(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Ir="approve",js=H.atom(),Ar=H.atom(null);function Sr(){const e=H.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=H.useSetAtom(js),u=H.useSetAtom(Ar),m=yr(),h=Ao(),p=qn(),f=Tn(),_=Cr(),x=wr(),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)}},C=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(),W=wn.encodeSecp256k1Pubkey(D.pubkey),K=await h(N),{sequence:O}=await K.getSequence(n);return P.tx.simulate(q,$,W,O)},w=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 W=>{try{const K=await h(R.chainId),O=await $(K,Nt.TxRaw.encode(W).finish());P(O),typeof R.internal=="string"&&e(R.internal)}catch(K){q(await Zt(K,a(R.chainId),o))}finally{D()}},reject:W=>{q(W),D()}}),R.internal?c({path:"/tx"}):r("/tx");const D=()=>{if(!R.internal){e("/blank"),i();return}l()}})},v=async E=>{const $=E.chainId??s;try{const N=await w({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)=>w({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($),W=await _($,N)?await x($,n,N,P,R):await y($,n,N,P,R);return await q.broadcastTxSync(Nt.TxRaw.encode(W).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,W=await h(R),O=await _(R,P)?await x(R,n,P,D,q):await y(R,n,P,D,q),ee=await W.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 $r({...$,client:N})}catch(N){throw await Zt(N,a(E),o)}};return{estimateGas:b,simulateTx:C,requestTxSync:v,requestTxBlock:k,submitTxSync:S,submitTxBlock:M,waitForTxConfirmation:F}}async function $r({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=H.atom(null);function Tr(){const e=X(),n=xs(),{fetchFeegrant:s,fetchGrants:o}=br();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:Qa.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 Dc(){const{privyContext:e}=G(),n=X(),s=_s(),o=xs(),{requestTxBlock:a}=bs(),r=T.useQueryClient(),[i,c]=H.useAtom(Ln),{closeDrawer:l}=lt(),d=Tr(),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:Qa.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(C=>({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:C})).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 Er(e){const n=G(),s=_s(),o=e?.grantee||s,{requestTxBlock:a}=bs(),r=T.useQueryClient(),i=Tr();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 Pc(){const{defaultChainId:e}=G(),{openDrawer:n}=lt(),s=H.useSetAtom(Ln),o=Er(),{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 qr(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function Rc(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),U(0)).toString()}function Bc(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??vo}}function pa(e){return A.pick(["chainId","name","logoUrl"],e)}function Uc(e){return A.sortWith([A.descend(({symbol:n})=>n===Qe),A.descend(qr),A.descend(({assets:n})=>n.length),A.ascend(({symbol:n})=>n)])(e)}function Fc(e){return A.sortWith([A.descend(({value:n})=>n??0),A.descend(({quantity:n})=>Number(n)),A.ascend(({chain:n})=>n.name)])(e)}function Oc(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 Vc(e,n){return A.sortWith([A.descend(({chainId:s})=>s===n),A.descend(A.prop("value"))])(e)}function zc(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 C=f?.find(M=>M.denom===b),w=_?.find(M=>M.id===b)?.price,v=C?.decimals??0,k=j.fromBaseUnit(y,{decimals:v}),S=w?U(k).times(w).toNumber():void 0;x.push({...Bc(b,C),amount:y,denom:b,decimals:v,quantity:k,price:w,value:S,address:C?.address,unlisted:!C,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=Fc(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:Vc(Array.from(c.values()),a),assetGroups:Uc(d),unlistedAssets:Oc(u,r),totalValue:d.reduce((m,h)=>m+h.totalValue,0)}}function To(){const{defaultChainId:e}=G(),n=ue(),s=hc(),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=zc(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 Lr(){const e=kt(),n=rr();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}=Lr(),a=qn(),r=ko(),i=Pc(),{isDrawerOpen:c,openDrawer:l}=lt(),{isModalOpen:d}=dn(),u=()=>{l("/")},m=()=>{l("/connect")},h=b=>{l("/bridge",b)},p=vc(),f=wc(),_=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 Kc="_status_tn9m1_1",Wc="_error_tn9m1_9",fa={status:Kc,error:Wc},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(Ga.ErrorBoundary,{...e,children:t.jsx(g.Suspense,{fallback:n,children:s})}),Hc="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 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?Mr(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:Hc,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 Dr(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 Pr(){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:Dr,staleTime:z.MINUTE})}function Rr(){const{restUrl:e}=ie(),{lockStakeModuleAddress:n}=G(),s=X(),o=s?Mr(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:Dr,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 C=d.get(y)??0;for(const w of x){const{symbol:v,decimals:k}=b,S=Number(j.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:y,symbol:v,amount:w.amount,formattedAmount:S,decimals:k,value:S*C};p.push({type:"staking",validator:w.validator,balance:M})}}for(const[_,x]of i){const y=l.get(_);if(!y)continue;const b=f(y);if(!b)continue;const C=d.get(y)??0;for(const w of x){const{symbol:v,decimals:k}=b,S=Number(j.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:y,symbol:v,amount:w.amount,formattedAmount:S,decimals:k,value:S*C},F=Number(w.releaseTime);p.push({type:"lockstaking",validator:w.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 C=d.get(y)??0;for(const w of x){const{symbol:v,decimals:k}=b,S=Number(j.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:y,symbol:v,amount:w.amount,formattedAmount:S,decimals:k,value:S*C},F=new Date(w.completionTime).getTime(),E=Number.isNaN(F)?0:Math.floor(F/1e3);p.push({type:"unstaking",validator:w.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 Qc(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 Gc(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 Br(){const e=ie(),n=Sn(e),s=g.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=Gc(s);return g.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return Qc(a)},[n,o])}function Ur(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 Yc(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===xc){c.set(l,{...u,symbol:yc});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 Zc(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 Jc(e){const n=[];for(const[,s]of e)s&&s!==ke&&n.push(s);return n}function Xc(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function el(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=Xc(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 tl(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 nl(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=Br(),{data:o}=Eo(),{data:a}=Lo(),{data:r}=qo(),{data:i}=Pr(),{data:c}=Rr(),{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(()=>Zc(s,o,a,r),[s,o,a,r]),m=wo(u),h=g.useMemo(()=>Jc(m),[m]),{data:p}=Ur(h),f=Yc(h),{rows:_,totalValue:x}=g.useMemo(()=>{const y=l?.find(v=>v.id===ke)?.price??0,b=new Map;for(const v of h)b.set(v,el(v,f,d));Bs(s,m,p,b,"deposit"),Bs(o,m,p,b,"staking"),tl(a,m,p,b,"lockStaking"),Bs(r,m,p,b,"unstaking"),nl(b,i,c,y);const C=Array.from(b.values()).filter(v=>v.totalAmount>0).sort((v,k)=>k.totalValue-v.totalValue),w=C.reduce((v,k)=>v+k.totalValue,0);return{rows:C,totalValue:w}},[h,f,d,s,o,a,r,m,p,i,c,l]);return{totalValue:x,rows:_}}const sl=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function ol(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 Fr(){const{vipUrl:e}=G(),n=X();return T.useQuery({queryKey:sl.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 al(){const e=ue();return g.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Ro(){const{data:e}=Fr(),n=ie(),{data:s}=yt(n),o=al(),a=g.useMemo(()=>s?.find(l=>l.id===ke)?.price??0,[s]),r=g.useMemo(()=>e?ol(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 Or(){const e=Br(),{data:n}=Eo(),{data:s}=Lo(),{data:o}=qo(),{data:a}=Fr(),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}=Ur(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=(C,w)=>{const v=d.get(C)??C;if(v===ke)return 0;const k=p.get(v)?.decimals??Me;return Number(j.fromBaseUnit(w,{decimals:k}))*(m.get(v)??0)};for(const[,C]of n)for(const{denom:w,metadata:v,amount:k}of C)w===ke?f+=Number(j.fromBaseUnit(k,{decimals:Me}))*x:_+=y(v,k);for(const[C,w]of s){const k=(d.get(C)??C)===ke;for(const{amount:S}of w)k?f+=Number(j.fromBaseUnit(S,{decimals:Me}))*x:_+=y(C,S)}for(const[,C]of o)for(const{denom:w,metadata:v,amount:k}of C)w===ke?f+=Number(j.fromBaseUnit(k,{decimals:Me}))*x:_+=y(v,k);for(const[C,w]of e)for(const{amount:v}of w)_+=y(C,String(v));let b=0;if(a)for(const C of a){const w=C.total_locked_reward??0,v=C.total_claimable_reward??0;b+=Number(j.fromBaseUnit(String(w+v),{decimals:Me}))*x}return f+_+b},[n,s,o,e,a,c,d,m,p])}function rl(){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 il=1e3,cl=1e4,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 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(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 w=_.get(x.denom)??0;w>0&&(y=x.formattedAmount*w)}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}},C=a.get(x.symbol);C?C.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};function Al(){const e=T.useQueryClient(),n=X(),{minityUrl:s}=G(),o=Uo(),a=g.useEffectEvent((c,l)=>{const d=Array.isArray(c.balances)?c.balances:[];l.set(c.chain,{chainName:c.chain,chainId:c.chainId,balances:d})}),r=g.useEffectEvent((c,l)=>{const d=Array.isArray(c.positions)?c.positions:[];l.set(c.chain,{chainName:c.chain,chainId:c.chainId,positions:d})}),i=g.useEffectEvent((c,l)=>{const d=io.ssePortfolio(n??"",s).queryKey,u=e.getQueryData(d)??Il,m=c.size>0||l.size>0;e.setQueryData(d,{...u,balances:Array.from(c.values()),positions:Array.from(l.values()),isLoading:m?!1:u.isLoading,isComplete:!1})});g.useEffect(()=>{if(!n||o)return;const c=io.ssePortfolio(n,s).queryKey,l=e.getQueryData(c),d=new Map,u=new Map;for(const v of l?.balances??[])d.set(v.chainName,v);for(const v of l?.positions??[])u.set(v.chainName,v);const h=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,f=null,_=0,x=!1;const y=()=>{const v=e.getQueryData(c);e.setQueryData(c,{balances:v?.balances??[],positions:v?.positions??[],isLoading:!0,isComplete:!1})},b=()=>{x=!0,f&&(clearTimeout(f),f=null),p&&(p.close(),p=null)},C=()=>{if(x||f)return;y();const v=Math.min(cl,il*2**_);_+=1,f=setTimeout(()=>{f=null,w()},v)},w=()=>{x||(y(),p&&p.close(),p=new EventSource(h),p.onopen=()=>{_=0},p.onmessage=v=>{if(!x)try{const k=JSON.parse(v.data);k.type==="balances"?a(k,d):k.type==="positions"&&r(k,u),i(d,u)}catch{C()}},p.onerror=()=>{C()})};return w(),()=>{b()}},[n,o])}const ga={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:()=>ga,enabled:!!e,staleTime:z.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??ga}function Sl(){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 $l(){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 Tl(){const{balances:e}=Dn(),n=ue(),s=bo(),o=g.useMemo(()=>Vr(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 El(){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 zr(){const e=ue();return n=>e.some(s=>s.chain_id===n)}function Pn(){const e=zr();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=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 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 Kr(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 Kr(n)(e)}const ql=()=>(gc(),_c(),null),Ll="_loader_1vxch_1",Ml={loader:Ll},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:Ml.loader,style:o})},Dl="_button_1q027_1",Pl="_outline_1q027_28",Rl="_sm_1q027_46",Bl="_full_1q027_53",Ul="_small_1q027_57",Fl="_unpadded_1q027_88",Pt={button:Dl,outline:Pl,sm:Rl,full:Bl,small:Ul,unpadded:Fl},Wr=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})},Ol=({className:e,...n})=>t.jsx(Wr,{...n,className:L(Pt.outline,e)}),Vl=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:L(Pt.small,{[Pt.unpadded]:n},e)}),ne={White:Wr,Outline:Ol,Small:Vl},zl="_footer_1vp4h_1",Kl="_actions_1vp4h_10",_a={footer:zl,actions:Kl},fe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:L(_a.footer,n),children:[e,t.jsx("div",{className:_a.actions,children:s})]}),Wl="_scrollable_13su7_1",Hl={scrollable:Wl},ut=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:L(Hl.scrollable,e),children:n});function vs(){return Ie.useMediaQuery("(max-width: 576px)")}const co="interwoven-kit";function Hr(){const e=document.querySelector(co)||document.body.appendChild(document.createElement(co));return e.shadowRoot||e.attachShadow({mode:"open"})}function Qr(){const{theme:e,container:n}=G();return g.useEffect(()=>{document.querySelector(co)?.setAttribute("data-theme",e)},[e]),n??Hr()}function Ql(e){const n=Hr(),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 Gr(e){const n=Ft();return n?getComputedStyle(n).getPropertyValue(e):""}function Gl(){return Ie.useScrollLock(),null}function Yl(e){return/^[A-F0-9]{64}$/i.test(e)}function Zl(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return Yl(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 Jl(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 Xl="_link_j1lkz_1",xa={link:Xl},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=Zl(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:Gi(Jl(m)),className:L(xa.link,i),onClick:l,target:"_blank",children:[p,r&&t.jsx(I.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:L(xa.link,i),children:p})},Yr=g.createContext(null),Fo=()=>g.useContext(Yr),ed=()=>{const[e,n]=H.useAtom(Ar),{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})},td="_placeholder_10r3x_1",nd="_logo_10r3x_5",ya={placeholder:td,logo:nd},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(ya.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||c===e?m:t.jsx("img",{...i,className:L(i.className,{[ya.logo]:r}),style:{width:d,height:u,...a},src:e,alt:n,loading:"lazy",onError:()=>l(e)})};function Zr(){const{connector:e}=we.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const sd="_header_1q8ju_1",od="_account_1q8ju_17",ad="_name_1q8ju_28",rd="_address_1q8ju_32",id="_icon_1q8ju_36",cd="_copied_1q8ju_43",ld="_button_1q8ju_58",dd="_settings_1q8ju_69",ud="_disconnect_1q8ju_73",md="_label_1q8ju_83",hd="_expanded_1q8ju_91",Be={header:sd,account:od,name:ad,address:rd,icon:id,copied:cd,button:ld,settings:dd,disconnect:ud,label:md,expanded:hd},pd=()=>{const e=ko(),{address:n,username:s}=De(),o=Zr(),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},fd="_overlay_jij9g_1",gd="_content_jij9g_28",_d="_inner_jij9g_60",Us={overlay:fd,content:gd,inner:_d},xd=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=lt(),{setContainer:o}=g.useContext(ws),a=vs(),r=Qr(),i=H.useAtomValue(js),c=H.useAtomValue(Ln),l=T.useIsMutating({mutationKey:[Ir]}),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(Gl,{}),t.jsx(ed,{}),t.jsx(pd,{}),t.jsx(de,{errorBoundaryProps:p,children:e})]})})]})})},yd="_backdrop_1bqx9_1",jd="_modal_1bqx9_12",bd="_closeButton_1bqx9_44",Fs={backdrop:yd,modal:jd,closeButton:bd},vd=({children:e})=>{const{isModalOpen:n,closeModal:s}=dn(),{setContainer:o}=g.useContext(ws),a=Qr();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]})]})})},Jr=g.createContext(!1),wd="_overlay_1iyfl_1",Cd="_fullscreen_1iyfl_15",Nd="_content_1iyfl_19",kd="_header_1iyfl_56",Id="_title_1iyfl_65",Ad="_close_1iyfl_70",$t={overlay:wd,fullscreen:Cd,content:Nd,header:kd,title:Id,close:Ad},Xr=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ft(),c=g.useContext(Jr);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},Sd="_help_qcmtq_1",$d="_icon_qcmtq_10",Td="_info_qcmtq_19",Ed="_warning_qcmtq_23",qd="_error_qcmtq_27",Ld="_success_qcmtq_33",Os={help:Sd,icon:$d,info:Td,warning:Ed,error:qd,success:Ld},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]})},Md="_stack_a6m7u_1",Dd="_help_a6m7u_6",Pd="_info_a6m7u_14",Rd="_warning_a6m7u_19",Bd="_error_a6m7u_24",Ud="_success_a6m7u_29",lo={stack:Md,help:Dd,info:Pd,warning:Rd,error:Bd,success:Ud},Fd=({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=Fd;const Od="_root_16p5j_1",Vd="_item_16p5j_10",zd="_chevron_16p5j_14",Kd="_trigger_16p5j_19",Wd="_content_16p5j_39",fn={root:Od,item:Vd,chevron:zd,trigger:Kd,content:Wd};function Hd(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 Qd=10;function ei(){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":Qd},{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 Gd(e,n){const s=ei();return T.useSuspenseQuery(s(e,n))}function Yd(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 Zd=()=>{const e=ue(),n=ei(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(A.prop("data")),a=Yd(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:Za;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}=Gd(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 Jd="_trigger_u613p_1",Xd="_icon_u613p_18",eu="_content_u613p_27",tu="_item_u613p_36",nu="_itemText_u613p_52",su="_itemIndicator_u613p_57",ou="_active_u613p_60",vt={trigger:Jd,icon:Xd,content:eu,item:tu,itemText:nu,itemIndicator:su,active:ou};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 au="_root_1t37n_1",ru="_trigger_1t37n_7",iu="_item_1t37n_11",cu="_itemText_1t37n_17",ja={root:au,trigger:ru,item:iu,itemText:cu},lu=({options:e,value:n,onChange:s})=>{const{txRequest:o}=Sr(),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:ja.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:ja})]})},du="_root_16nr2_1",uu="_trigger_16nr2_5",mu="_chevron_16nr2_13",hu="_panel_16nr2_27",pu="_details_16nr2_39",fu="_row_16nr2_48",Gt={root:du,trigger:uu,chevron:mu,panel:hu,details:pu,row:fu},gu=({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 _u="_container_1xzyq_1",xu="_toggle_1xzyq_5",yu="_list_1xzyq_11",ju="_arg_1xzyq_16",bu="_type_1xzyq_21",gn={container:_u,toggle:xu,list:yu,arg:ju,type:bu},vu=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),wu=({type:e,arg:n})=>rs(j.resolveBcsType(e).parse(n)),Cu=({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:vu.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(Ga.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(wu,{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]})},Nu="_list_oip9m_1",ku="_key_oip9m_9",Iu="_value_oip9m_14",Vs={list:Nu,key:ku,value:Iu},Au=({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(Cu,{msg:o,chainId:n,fallback:rs(r)}):rs(r)})]},a))})},Su="_item_1n572_1",$u="_title_1n572_10",Tu="_content_1n572_14",zs={item:Su,title:$u,content:Tu},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 ti(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 ni(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 si=({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)},Eu="_root_1p8a4_1",qu="_title_1p8a4_8",Lu="_changes_1p8a4_14",Mu="_change_1p8a4_14",Du="_amount_1p8a4_35",Pu="_text_1p8a4_42",Ru="_value_1p8a4_49",Rt={root:Eu,title:qu,changes:Lu,change:Mu,amount:Du,text:Pu,value:Ru},oi=({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)})]})},Bu=({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(oi,{amount:a,asset:c,price:l},i)})},Uu=({changes:e,chain:n})=>{const s=ct(n),{data:o}=yt(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(si,{metadata:r,chain:n,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(oi,{amount:a,asset:s(c),price:l})}},i))};function Fu(e,n){return typeof n=="bigint"?n.toString():n}const Ou=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Fu)]}),Vu=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=De(),r=Xe(s),{simulateTx:i}=bs(),{data:c}=T.useSuspenseQuery({queryKey:Ou.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=ni(d,a),[p]=ba(h);return p.length===0?null:l(t.jsx(Uu,{changes:p,chain:r}))}const u=ti(d,o),[m]=ba(u);return m.length===0?null:l(t.jsx(Bu,{changes:m,chain:r}))};function ba(e){return A.partition(n=>new U(n.amount).isNegative(),e)}const zu="_title_1d032_1",Ku="_meta_1d032_7",Wu="_footer_1d032_14",Hu="_rejectButton_1d032_19",Wn={title:zu,meta:Ku,footer:Wu,rejectButton:Hu},ai=()=>{const{txRequest:e,resolve:n,reject:s}=Sr(),{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=Cr(),y=wr(),b=(e.gasPrices??p).map(({amount:N,denom:R})=>Ve.calculateFee(Math.ceil(i*c),Ve.GasPrice.fromString(N+R))),C=b.map(N=>N.amount[0]),w=N=>{const R=h.find(ee=>ee.denom===N)?.amount??"0",P=C.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),W=U(R).gte(D),{symbol:K,decimals:O}=_(N);return{symbol:K,decimals:O,spend:q.gt(0)?q.toFixed():null,fee:P,total:D.toFixed(),balance:R,isSufficient:W}},v=()=>{if(f&&w(f).isSufficient)return f;for(const{denom:N}of C)if(w(N).isSufficient)return N;return C[0]?.denom},[k,S]=g.useState(v),{mutate:M,isPending:F}=T.useMutation({mutationKey:[Ir],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=w(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(lu,{options:b,value:k,onChange:S})}),a&&t.jsx(Ks,{title:"Memo",content:a}),$&&t.jsx(xe,{level:"error",children:t.jsx(gu,{...E})})]}),t.jsx(Vu,{messages:o,memo:a,chainId:r}),t.jsx(Hd,{list:o,renderHeader:({typeUrl:N})=>us.sentenceCase(N.split(".").pop().replace(/^Msg/,"")),renderContent:N=>t.jsx(Au,{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"})]})]})},Qu=({children:e})=>{const[{title:n,content:s,path:o},a]=g.useState({}),[r,i]=g.useState(!1),c=H.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(Nr.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(Xr,{title:n,open:r,onOpenChange:u,children:t.jsx(de,{children:o==="/tx"?t.jsx(ai,{}):s})})]})},Gu="_container_1w1hx_1",Yu="_toast_1w1hx_11",Zu="_info_1w1hx_24",Ju="_success_1w1hx_28",Xu="_error_1w1hx_32",em="_icon_1w1hx_37",tm="_content_1w1hx_45",nm="_title_1w1hx_48",sm="_description_1w1hx_53",om="_close_1w1hx_75",wt={container:Gu,toast:Yu,info:Zu,success:Ju,error:Xu,icon:em,content:tm,title:nm,description:sm,close:om},am=({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,rm=({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(Yr.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,n&&Yi.createPortal(t.jsx(am,{notification:s,onClose:c,onMouseEnter:u,onMouseLeave:m}),n)]})},im=({children:e})=>{const[n,s]=g.useState(null);return t.jsx(ws.Provider,{value:{container:n,setContainer:s},children:e})},ri=[{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"}],cm=ri[0].value,lm="_container_1422v_1",dm="_title_1422v_7",um="_description_1422v_14",mm="_sectionTitle_1422v_20",hm="_websiteInfo_1422v_27",pm="_favicon_1422v_37",fm="_websiteTitle_1422v_42",gm="_websiteHost_1422v_48",_m="_warningContent_1422v_54",xm="_ignoreButton_1422v_61",ym="_infoList_1422v_65",jm="_infoItem_1422v_75",bm="_label_1422v_84",vm="_infoValue_1422v_94",wm="_durationTrigger_1422v_100",Cm="_durationItem_1422v_101",Nm="_featureList_1422v_105",km="_featureItem_1422v_113",Im="_checkIcon_1422v_123",Am="_learnMoreLink_1422v_127",Sm="_feedbackContainer_1422v_140",$m="_footer_1422v_146",ae={container:lm,title:dm,description:um,sectionTitle:mm,websiteInfo:hm,favicon:pm,websiteTitle:fm,websiteHost:gm,warningContent:_m,ignoreButton:xm,infoList:ym,infoItem:jm,label:bm,infoValue:vm,durationTrigger:wm,durationItem:Cm,featureList:Nm,featureItem:km,checkIcon:Im,learnMoreLink:Am,feedbackContainer:Sm,footer:$m},Tm=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()}})}),Em=()=>{const[e,n]=g.useState(cm),[s,o]=H.useAtom(Ln),[a,r]=g.useState(!1),i=Je(),c=ue(),{address:l,username:d}=De(),{mutate:u,isPending:m}=Dc(),{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(Tm.info(_,l)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},C=c.some(S=>{if(!S.website)return!1;const M=va(new URL(S.website).hostname),F=va(window.location.hostname);return M===F}),w=()=>{u(e)},v=()=>{s?.reject(new Error("User cancelled")),o(null),h()},k=!C&&!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:ri,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"}),!C&&!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:v,children:"Cancel"}),t.jsx(ne.White,{onClick:w,disabled:k||!x||y,loading:m,children:"Enable"})]})]})},qm=()=>H.useAtomValue(Ln)?t.jsx(Em,{}):null;function va(e){const n=e.split(".");return n.length<2?e:n.slice(-2).join(".")}const Lm="_container_mqvhs_1",Mm="_badge_mqvhs_5",wa={container:Lm,badge:Mm},ii=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:L(wa.container,a),children:[o,!s&&t.jsx("div",{className:wa.badge,style:{right:n,top:n}})]})},Dm="_header_s7mee_1",Pm="_back_s7mee_12",Rm="_title_s7mee_24",Hs={header:Dm,back:Pm,title:Rm},mt=({title:e,backButton:n,extra:s,children:o})=>{const a=dr();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 ci(){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 li(){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 Bm(){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 Um="_root_ekn9t_1",Fm="_header_ekn9t_6",Om="_title_ekn9t_12",Vm="_warning_ekn9t_18",zm="_content_ekn9t_22",Km="_footer_ekn9t_26",Wm="_secondary_ekn9t_36",Tt={root:Um,header:Fm,title:Om,warning:Vm,content:zm,footer:Km,secondary:Wm},di=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})]})]})]})},Hm="_list_k4n3k_1",Qm="_row_k4n3k_9",Gm="_dt_k4n3k_20",Ym="_asset_k4n3k_26",Hn={list:Hm,row:Qm,dt:Gm,asset:Ym},Zm=({list:e,onNavigate:n,onDismiss:s})=>{const o=ie(),a=Je(),r=ct(o);return t.jsx(di,{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}`,Jm=Zi.atomWithStorage(oe.OP_REMINDER,[]);function un(){const e=X(),[n=[],s]=H.useAtom(Jm),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 ui(){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(Zm,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,n,a])}const Xm="_wrapper_5ssm8_1",eh="_balance_5ssm8_11",th="_button_5ssm8_15",Gs={wrapper:Xm,balance:eh,button:th},mi=({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"})]}),nh="_fieldset_up6fh_1",sh="_upper_up6fh_9",oh="_select_up6fh_14",ah="_account_up6fh_20",rh="_lower_up6fh_25",ih="_wrapper_up6fh_26",ch="_balance_up6fh_33",lh="_value_up6fh_37",dh="_error_up6fh_50",pt={fieldset:nh,upper:sh,select:oh,account:ah,lower:rh,wrapper:ih,balance:ch,value:lh,error:dh},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 uh="_input_h8073_1",mh={input:uh};function hi(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(Ji.NumericFormat,{value:l.value,getInputRef:Ya.mergeRefs([l.ref,c]),className:L(mh.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const hh="_input_19r9r_1",ph="_placeholder_19r9r_18",mo={input:hh,placeholder:ph},fh=({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(hi,{name:"quantity",control:o,className:L(mo.input,s),rules:a})};cn.ReadOnly=fh;const ln=({title:e,content:n,children:s,className:o})=>{const[a,r]=g.useState(!1),i=()=>r(!1);return t.jsx(Xr,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},gh="_tooltip_19kvs_1",_h="_arrow_19kvs_44",Ca={tooltip:gh,arrow:_h},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(Ca.tooltip,{small:s}),collisionBoundary:Ft(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Y.Tooltip.Arrow,{className:Ca.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 xh(e,n,s){const{data:o={}}=Ko(e,n);return A.path([s],o)}const yh=[["d",1440*60],["h",3600],["m",60],["s",1]];function In(e){if(!e)return;const{formattedParts:n}=yh.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 jh(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 bh(){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 vh="_label_t93ix_1",wh="_wrapper_t93ix_7",Ch="_input_t93ix_10",Nh="_clear_t93ix_18",Gn={label:vh,wrapper:wh,input:Ch,clear:Nh},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),_=rr(),{data:x,isLoading:y,error:b}=T.useQuery({queryKey:ps.address(_.restUrl,p).queryKey,queryFn:()=>_.getAddress(p),staleTime:z.MINUTE,enabled:_.validateUsername(p)}),C=x??(o(p)?p:""),w=n&&j.InitiaAddress.equals(C,n),v=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",C,{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&&!C)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:v,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"?Ya.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(),w&&t.jsx(Jt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(fe,{extra:(!n||!!C&&!w)&&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||!C,children:"Apply"})})]})},kh="_scrollable_vgj3r_1",Ih="_list_vgj3r_5",Ah="_item_vgj3r_9",Sh="_name_vgj3r_22",Yn={scrollable:kh,list:Ih,item:Ah,name:Sh};function pi({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 $h="_account_h04x1_8",Th="_clear_h04x1_28",Eh="_white_h04x1_39",_n={account:$h,clear:Th,white:Eh},Na=({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=ci(),p=li(),f=h(a),_=j.InitiaAddress.equals(c,f),x=()=>t.jsx(ln,{title:"Connect wallet",content:C=>t.jsx(pi,{onSelect:async w=>{const v=w.getProvider();if(!v)return window.open(w.fallbackUrl,"_blank");const k=v.getOfflineSigner(o),[{address:S}]=await k.getAccounts();s("sender",S),s("cosmosWalletName",w.name),C()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.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=C=>t.jsx(ln,{title:"Recipient",content:w=>t.jsx(ut,{children:t.jsx(Ho,{mode:"onSubmit",myAddress:f,chainType:l,validate:v=>p(v,a),onApply:w})}),className:_n.account,children:C}),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()}},qh="_images_cj4xz_1",Ys={images:qh},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})]}),Lh="_root_6187w_1",Mh="_content_6187w_10",Dh="_details_6187w_20",Ph="_symbol_6187w_26",Rh="_chain_6187w_34",Bh="_chevron_6187w_43",Et={root:Lh,content:Mh,details:Dh,symbol:Ph,chain:Rh,chevron:Bh},fi=({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 Uh(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 Fh="_root_1sh27_1",Oh="_label_1sh27_8",Vh="_input_1sh27_21",zh="_hasValue_1sh27_31",Kh="_clear_1sh27_35",xn={root:Fh,label:Oh,input:Vh,hasValue:zh,clear:Kh},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})})]})},Wh="_container_5tajg_1",Hh="_search_5tajg_7",Qh="_list_5tajg_11",Gh="_item_5tajg_15",Yh="_logo_5tajg_37",Zh="_info_5tajg_41",Jh="_symbol_5tajg_47",Xh="_name_5tajg_56",ep="_balance_5tajg_62",tp="_value_5tajg_69",Oe={container:Wh,search:Hh,list:Qh,item:Gh,logo:Yh,info:Zh,symbol:Jh,name:Xh,balance:ep,value:tp},Fn=e=>{const{assets:n,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=g.useState(""),i=Uh(["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))})]})},np=()=>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=np;const sp="_stack_16oqn_1",op="_title_16oqn_9",ap="_grid_16oqn_16",rp="_item_16oqn_22",ip="_button_16oqn_26",cp="_active_16oqn_44",Xt={stack:sp,title:op,grid:ap,item:rp,button:ip,active:cp},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(ii,{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))})]}),lp=({children:e})=>t.jsx("div",{className:Xt.stack,children:e});Bt.Stack=lp;const dp=({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})},up=({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),_=Bm(),x=zr(),[y,b]=A.partition(w=>x(w.chain_id),i.filter(w=>!w.hidden)),C=w=>{if(u===h&&m===w){n();return}l(s,h),l(o,w),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Bt.Stack,{children:[t.jsx(Bt,{label:"Interwoven Economy",chains:y.map(({chain_id:w,chain_name:v,pretty_name:k,logo_uri:S})=>({chainId:w,name:k||v,logoUrl:S??""})),value:h,onSelect:p}),t.jsx(Bt,{label:"Chains",chains:b.map(({chain_id:w,chain_name:v,pretty_name:k,logo_uri:S})=>({chainId:w,name:k||v,logoUrl:S??""})),value:h,onSelect:p})]}),t.jsx(de,{suspenseFallback:t.jsx(Fn.Placeholder,{}),children:t.jsx(dp,{address:_({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:f,onSelect:C})},h)]})},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}=It(),r=a(n),i=a(s),c=rt(r),l=it(i,r);return t.jsx(ln,{title:o,content:d=>t.jsx(up,{type:e,afterSelect:d}),children:t.jsx(fi,{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??""}})})},mp="_skeleton_1l4jn_1",hp={skeleton:mp},Ut=({width:e="100%",height:n})=>t.jsx("div",{className:hp.skeleton,style:{width:e,height:n}}),pp="_stack_oq1ir_1",fp="_button_oq1ir_6",gp="_isLoading_oq1ir_19",_p="_disabled_oq1ir_19",xp="_checked_oq1ir_23",yp="_header_oq1ir_37",jp="_title_oq1ir_43",bp="_duration_oq1ir_52",vp="_warning_oq1ir_62",wp="_amount_oq1ir_66",Cp="_value_oq1ir_67",Fe={stack:pp,button:fp,isLoading:gp,disabled:_p,checked:xp,header:yp,title:jp,duration:bp,warning:vp,amount:wp,value:Cp},Np=({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=Np;const kp="_description_nuyvt_1",Ip="_presets_nuyvt_8",Ap="_preset_nuyvt_8",Sp="_active_nuyvt_29",$p="_custom_nuyvt_40",Tp="_wrapper_nuyvt_47",Ep="_percent_nuyvt_58",ot={description:kp,presets:Ip,preset:Ap,active:Sp,custom:$p,wrapper:Tp,percent:Ep},Ia=["0.1","0.5","1.0"],qp=({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 _=Ia.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:[Ia.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(hi,{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"})})]})},Lp="_form_1owk5_1",Mp="_arrow_1owk5_5",Dp="_divider_1owk5_14",Pp="_flip_1owk5_23",Rp="_meta_1owk5_41",Bp="_row_1owk5_54",Up="_title_1owk5_60",Fp="_description_1owk5_64",Op="_icon_1owk5_71",Vp="_edit_1owk5_76",zp="_warning_1owk5_99",Le={form:Lp,arrow:Mp,divider:Dp,flip:Pp,meta:Rp,row:Bp,title:Up,description:Fp,icon:Op,edit:Vp,warning:zp},Kp=()=>{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),C=rt(m),w=kn(C),v=it(u,d),k=it(h,m),{data:S}=Ko(f,d),M=xh(f,d,u),F=!M?.amount||U(M.amount).isZero(),[E]=Ie.useDebounceValue(p,300),$=b!=="initia"&&w!=="initia",N=bh(),R=is(E,{disabled:$}),P=is(E,{isOpWithdraw:!0,disabled:!N}),q=N&&s==="op"?P:R,{data:D,isLoading:W,isFetching:K,error:O}=q,{data:ee}=jh(O),me=E&&(W||K),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(di,{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})),zi=(()=>{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(qp,{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(ka,{type:"src"}),accountButton:b==="cosmos"&&t.jsx(Na,{type:"src"}),quantityInput:t.jsx(cn,{balance:M?.amount,decimals:v?.decimals}),balanceButton:t.jsx(mi,{onClick:()=>r("quantity",j.fromBaseUnit(M?.amount,{decimals:v?.decimals??0}),{shouldValidate:!0}),disabled:F,children:j.formatAmount(M?.amount??"0",{decimals:v.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(ka,{type:"dst"}),accountButton:t.jsx(Na,{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&&zi&&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"})})]})},Wp=()=>{ui();const e=dr(),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 _=ci(),x=_(l),y=_(d),C=li()(f,d);g.useEffect(()=>{c("cosmosWalletName",void 0),c("sender",x)},[l,x,c]),g.useEffect(()=>{C||c("recipient",y)},[y,C,c]);const w=os(l),v=os(d),k=g.useMemo(()=>{if(!w.find(E=>E.denom===u))return`${u} is not available for bridge/swap on ${l}`;if(!v.find(E=>E.denom===m))return`${m} is not available for bridge/swap on ${d}`},[v,d,m,w,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(ii,{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(Kp,{})})})})},Hp="_button_1crvp_1",Qp="_checkbox_1crvp_11",Gp="_checked_1crvp_25",Zn={button:Hp,checkbox:Qp,checked:Gp},Yp=({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})]}),Zp="_button_aoxv2_1",Jp={button:Zp},gi=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=Xi.useInView();return g.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:Jp.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(I.IconChevronDown,{size:12})]})};function _i(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,Aa=10;function xi(){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 yi(e){return Ie.useLocalStorage(ns(e),null)}async function Xp(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 ef(e,n){const{customFee:s,onCompleted:o}=n??{},a=je(),{showNotification:r,updateNotification:i,hideNotification:c}=Fo(),{addHistoryItem:l}=xi(),d=$n(),{route:u,values:m}=jt(),{srcChainId:h,sender:p,recipient:f,cosmosWalletName:_}=m,x=jr(),{requestTxSync:y,submitTxSync:b,waitForTxConfirmation:C}=De(),{find:w}=Ns(),v=Tn(),k=En(),S=rt(h),M=kn(S),F=Kr(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=C({txHash:Vn,chainId:h});return{txHash:Vn,wait:oa}}const D=w(_)?.getProvider();if(!D)throw new Error("Wallet not connected");const W=D.getOfflineSignerOnlyAmino(h),K=await Ve.SigningStargateClient.connectWithSigner(S.rpc,W,{registry:v,aminoTypes:k}),O=await K.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 K.simulate(p,q,""),At=Ve.GasPrice.fromString(Ae.average+me),mn=Ve.calculateFee(Math.ceil(We*on),At),hn=await K.signAndBroadcastSync(p,q,mn),Ht=$r({txHash:hn,client:K});return{txHash:hn,wait:Ht}}if("evm_tx"in e){const{chain_id:q,to:D,value:W,data:K}=e.evm_tx,O=await x(),ee=await O.getSigner();await ho(O,S);const me=await ee.sendTransaction({chainId:q,to:D,value:W,data:`0x${K}`});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 W=Qo(u)==="OP Bridge withdrawal",K=W?{success:!0,error:null}:await af(P,q,h);if(!o&&!K.success&&K.error){const We=K.error instanceof Error?K.error.message:String(K.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${We}. The transaction may still be processing.`,autoHide:!0})}const O=K.success,me=sf({txHash:q,srcChainId:h,route:u,values:m,recipient:f},O);l(me.tx,me.details),o||i(nf(c));const Ae=Zs(m,q);if(d("Bridge Transaction Success",Ae),W){const We=of(me.tx,u,f);R(me.tx,We)}}catch(W){const K=W instanceof Error?W.message:String(W);o?o({success:!1,error:K,route:u,values:m}):i({type:"error",title:"Transaction not confirmed",description:K});const O={...Zs(m,q),error:K};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 W=Zs(m);d("Bridge Transaction Failed",{...W,error:D.message})}})}function tf(){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 Xp(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 nf(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 sf(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 of(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 af(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 ji(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 bi(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 rf="_success_t4dfk_1",cf="_error_t4dfk_5",Sa={success:rf,error:cf},lf=({tx:e})=>{const[n,s]=yi(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=bi(n),a=n.state??df(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:Sa.error,children:t.jsx(I.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:Sa.success,children:t.jsx(I.IconCheckCircleFilled,{size:14})});default:return t.jsx(Kt,{size:14})}};function df(e){if(!e)return"loading";switch(e.state){case"STATE_ABANDONED":case"STATE_COMPLETED_ERROR":case"STATE_PENDING_ERROR":return"error";case"STATE_COMPLETED_SUCCESS":return"success";default:return"loading"}}const uf="_link_104m3_1",mf="_header_104m3_23",hf="_title_104m3_31",pf="_date_104m3_37",ff="_explorer_104m3_41",gf="_fees_104m3_57",_f="_label_104m3_65",xf="_content_104m3_69",yf="_route_104m3_75",jf="_row_104m3_80",bf="_asset_104m3_86",vf="_amount_104m3_94",wf="_chain_104m3_99",Cf="_account_104m3_108",Nf="_arrow_104m3_115",be={link:uf,header:mf,title:hf,date:pf,explorer:ff,fees:gf,label:_f,content:xf,route:yf,row:jf,asset:bf,amount:vf,chain:wf,account:Cf,arrow:Nf},kf=({tx:e})=>{const[n,s]=yi(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}=ji(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:C=[]}=r,w=rt(_),v=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:W,logo_uri:K},{chain_name:O,pretty_name:ee,...me},Ae,We)=>t.jsxs("div",{className:be.row,children:[t.jsx(ks,{assetLogoUrl:K,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:W})}),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(lf,{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,w,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,v,i.recipient,M(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:Wo(C)})]})]});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})},If="_history_13u9z_1",Af="_header_13u9z_5",Sf="_checkbox_13u9z_9",$f="_groups_13u9z_13",Tf="_dateGroup_13u9z_21",Ef="_dateHeader_13u9z_26",qf="_list_13u9z_32",qt={history:If,header:Af,checkbox:Sf,groups:$f,dateGroup:Tf,dateHeader:Ef,list:qf},Lf=()=>{const{initiaAddress:e,hexAddress:n}=De(),{history:s,getHistoryDetails:o}=xi(),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*Aa),h=g.useMemo(()=>_i(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(Yp,{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(kf,{tx:_})},_.txHash))})]},p))}),u.length>i*Aa?t.jsx(gi,{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}=ef(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"})})},Mf="_content_1hzj2_1",Df="_info_1hzj2_6",Pf="_arrow_1hzj2_11",Rf="_divider_1hzj2_19",Bf="_type_1hzj2_27",Uf="_asset_1hzj2_47",Ff="_amount_1hzj2_55",Of="_lower_1hzj2_60",Vf="_chain_1hzj2_66",zf="_address_1hzj2_72",Ue={content:Mf,info:Df,arrow:Pf,divider:Rf,type:Bf,asset:Uf,amount:Ff,lower:Of,chain:Vf,address:zf},vi=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(vi,{...e,...n})};en.Placeholder=vi;const Kf="_root_1hbar_1",Wf="_flexEnd_1hbar_6",Hf="_toggle_1hbar_11",Qf="_route_1hbar_36",Gf="_content_1hbar_43",yn={root:Kf,flexEnd:Wf,toggle:Hf,route:Qf,content:Gf};function Yf(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 Zf=({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=v=>j.InitiaAddress.equals(v,u)?f:t.jsx(I.IconWallet,{size:11}),y=v=>{const{label:k,amount_out:S,denom:M,denom_out:F=M,chain_id:E,from_chain_id:$,to_chain_id:N=E??$}=v,R=c[N];return{label:p&&!m?void 0:k,amount:S,denom:F,chainId:N,address:R,walletIcon:x(R)}},b=i.map(Yf).map(y),C=b.slice(0,-1),w=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:C.map((v,k)=>t.jsx(de,{suspenseFallback:t.jsx(en.Placeholder,{...v}),errorBoundaryProps:{fallback:t.jsx(en.Placeholder,{...v})},children:t.jsx(en,{...v})},k))}),t.jsx(en,{...w})]})]})},wi=({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),[C,w]=g.useState(!1),[v,k]=g.useState(null);if(g.useEffect(()=>{(async()=>{try{if(!x)return;if(!m)throw new Error("Wallet not connected");w(!0),k(null);const[{pubkey:M}]=await m.getAccounts();b(M)}catch(M){k(await _t(M))}finally{w(!1)}})()},[x,m]),v)return t.jsx(wi,{error:v});if(C)return t.jsx(fe,{children:t.jsx(ne.White,{loading:C&&"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=jr(),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}=_,C=await new gt.ethers.Contract(x,p,h).allowance(m,y);return{approval:_,currentAllowance:BigInt(C.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(wi,{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=tf();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)},Jf=()=>t.jsx(mt,{title:"Route preview",children:t.jsx(Yo,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Zf,{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})})})})]})})}),Ci=g.createContext(null);function As(){return g.useContext(Ci)}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 Xf(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 $a=20;function eg(e){const n=X();return T.useSuspenseInfiniteQuery({queryKey:Wt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:$a,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<$a||!o||o<=1?null:o-1},initialPageParam:0,staleTime:z.SECOND})}function tg(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 ng({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 sg({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 Ni(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 ec.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 ki(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 og="_button_17r1o_1",ag="_claimed_17r1o_24",Ta={button:og,claimed:ag},rg=()=>{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=sg(e),_=re.toBase64(ki(e)),x=Ni(e,_),y=T.useQueryClient(),{mutate:b,isPending:C}=T.useMutation({mutationFn:async()=>{if(!f)throw new Error("Output not found");const{last_block_hash:w}=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(w)}}],internal:!0})},onSuccess:async w=>{await p({chainId:u.chain_id,txHash:w}),y.invalidateQueries({queryKey:Wt.withdrawalClaimed(n,_).queryKey})}});return x?t.jsxs("div",{className:Ta.claimed,children:[t.jsx(I.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ta.button,onClick:()=>b(),disabled:C,children:"Claim"})},ig=({children:e})=>{const{withdrawalTx:n}=As(),s=Xf(n.bridge_id),o=ng(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)},Ii=1e3,cg=60,lg=60,dg=24,po=Ii*cg,fo=po*lg,Ea=fo*dg,ug=({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/Ea),p=Math.floor(m%Ea/fo),f=Math.floor(m%fo/po),_=Math.floor(m%po/Ii);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"]})})},mg="_container_1lz3w_1",hg="_title_1lz3w_5",qa={container:mg,title:hg},pg=({date:e})=>t.jsxs("div",{className:qa.container,children:[t.jsx("div",{className:qa.title,children:"Claimable in"}),t.jsx(ug,{date:e})]}),fg="_container_1oldz_1",gg="_icon_1oldz_7",La={container:fg,icon:gg},_g="Withdrawal will begin within an hour",Ma=()=>{const e=vs();return t.jsxs("div",{className:La.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Un,{label:_g,children:t.jsx("span",{className:La.icon,children:t.jsx(I.IconInfoFilled,{size:12})})})]})},xg=({children:e})=>{const{withdrawalTx:n}=As(),s=tg(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},yg=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=As(),a=re.toBase64(ki(o)),r=Ni(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},jg=()=>t.jsx(xg,{children:e=>e?t.jsx(Ma,{}):t.jsx(ig,{children:n=>n?t.jsx(yg,{date:n,children:Ze.isFuture(n)?t.jsx(pg,{date:n}):t.jsx(rg,{})}):t.jsx(Ma,{})})}),bg="_asset_6h8u2_1",vg="_info_6h8u2_7",wg="_symbol_6h8u2_11",Xs={asset:bg,info:vg,symbol:wg},Cg=({amount:e,denom:n})=>{const s=ie(),o=sr(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})]})]})},Ng="_item_km5w2_1",kg={item:Ng},Ig=({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}=eg(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:kg.item,children:[t.jsx(Cg,{...d}),t.jsx(de,{suspenseFallback:null,children:t.jsx(Ci.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(jg,{})})})]},l.sequence)}),a&&t.jsx(gi,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},Ag="_content_dj1qm_1",Sg="_title_dj1qm_5",Da={content:Ag,title:Sg},$g=()=>{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:Da.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Da.title,children:c.name}),t.jsx(de,{children:t.jsx(Ig,{chain:c})},o)]}):t.jsx(xe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Tg="_page_1g5uz_1",Eg="_title_1g5uz_11",qg="_scrollable_1g5uz_18",Lg="_list_1g5uz_24",Mg="_item_1g5uz_35",Dg="_name_1g5uz_59",Pg="_dimmed_1g5uz_67",Rg="_recent_1g5uz_71",Bg="_installed_1g5uz_72",He={page:Tg,title:Eg,scrollable:qg,list:Lg,item:Mg,name:Dg,dimmed:Pg,recent:Rg,installed:Bg},Ug=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Pa=({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)}),Ug.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)})]})})]})},Fg=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),Ai=({tx:e,children:n})=>{const{values:s}=jt(),{srcChainId:o}=s,a=X(),r=En(),i=Ao(),{data:c,isLoading:l}=T.useQuery({queryKey:Fg.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 Si(){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 Og(){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 Vg="_container_eg177_1",zg="_back_eg177_6",Kg="_title_eg177_18",Wg="_divider_eg177_26",Hg="_label_eg177_30",Qg="_asset_eg177_37",Gg="_assetIcon_eg177_55",Yg="_chainIcon_eg177_67",Zg="_assetName_eg177_80",Jg="_chevron_eg177_92",Xg="_input_eg177_96",e_="_balanceContainer_eg177_108",t_="_value_eg177_116",n_="_maxButton_eg177_126",s_="_detail_eg177_142",o_="_detailsContainer_eg177_153",a_="_detailsButton_eg177_163",r_="_detailValue_eg177_180",i_="_detailToken_eg177_190",c_="_minimumReceived_eg177_198",B={container:Vg,back:zg,title:Kg,divider:Wg,label:Hg,asset:Qg,assetIcon:Gg,chainIcon:Yg,assetName:Zg,chevron:Jg,input:Xg,balanceContainer:e_,value:t_,maxButton:n_,detail:s_,detailsContainer:o_,detailsButton:a_,detailValue:r_,detailToken:i_,minimumReceived:c_},$i=({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=Zr(),[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]})]})]})})},l_="_trigger_1c7d7_1",d_="_item_1c7d7_5",u_="_itemText_1c7d7_13",m_={trigger:l_,item:d_,itemText:u_},h_=({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,C=b?.map(P=>P.amount[0])??[],w=P=>{const q=f.find(Ae=>Ae.denom===P)?.amount??"0",D=C.find(Ae=>Ae.denom===P)?.amount??"0",W=h&&d===P?U(u||"0").times(U(10).pow(h.decimals)).toFixed(0):"0",K=U(D).plus(W),O=U(q).gte(K),{symbol:ee,decimals:me}=y(P);return{symbol:ee,decimals:me,spend:U(W).gt(0)?W:null,fee:D,total:K.toFixed(),balance:q,isSufficient:O}},v=()=>{if(!C.length)return null;if(x&&w(x).isSufficient)return x;for(const{denom:P}of C)if(w(P).isSufficient)return P;return C[0]?.denom},[k,S]=g.useState(v),M=b?.find(P=>P.amount[0].denom===k)??void 0,F=k?w(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:W,decimals:K}=y(D),O=$(q,K);return`${j.formatAmount(q,{decimals:K,dp:O})} ${W}`},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:W}=y(D),K=$(q,W);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:j.formatAmount(q,{decimals:W,dp:K})}),t.jsx(zo,{options:P,value:k,onChange:S,classNames:m_})]})};return t.jsxs(t.Fragment,{children:[t.jsx($i,{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})})]})},Ti=({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($i,{}),t.jsx(Zo,{tx:e,children:t.jsx(Go,{tx:e,fee:void 0,onCompleted:a,confirmMessage:i})})]}):t.jsx(h_,{tx:e,gas:n})},p_=()=>{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=Si(),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),C=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:w,error:v}=is(b.toString(),{disabled:!!C}),k=g.useEffectEvent(()=>{e(0,{...n,route:w,values:{sender:r,recipient:n.recipientAddress?j.InitiaAddress(n.recipientAddress).hex:r,slippagePercent:"1",...l()}})});return g.useEffect(()=>{k()},[w,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||C?t.jsx(fe,{children:t.jsx(ne.White,{type:"submit",loading:!v&&!C&&"Fetching route...",disabled:!0,fullWidth:!0,children:v?"No route found":C})}):t.jsx(Yo,{children:S=>t.jsx(Xo,{children:M=>t.jsx(Jo,{addressList:S,signedOpHook:M,children:F=>t.jsx(Ai,{tx:F,children:E=>t.jsx(Ti,{tx:F,gas:E})})})})})]})},f_="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",g_="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",__="_container_uxgnj_1",x_="_title_uxgnj_5",y_="_close_uxgnj_12",j_="_emptyIcon_uxgnj_24",b_="_empty_uxgnj_24",v_="_list_uxgnj_51",w_="_asset_uxgnj_66",C_="_placeholder_uxgnj_82",N_="_activeAsset_uxgnj_95",k_="_iconContainer_uxgnj_99",I_="_assetIcon_uxgnj_109",A_="_chainIcon_uxgnj_119",S_="_assetPlaceholder_uxgnj_133",$_="_assetName_uxgnj_154",T_="_assetChain_uxgnj_169",E_="_balance_uxgnj_177",q_="_value_uxgnj_186",le={container:__,title:x_,close:y_,emptyIcon:j_,empty:b_,list:v_,asset:w_,placeholder:C_,activeAsset:N_,iconContainer:k_,assetIcon:I_,chainIcon:A_,assetPlaceholder:S_,assetName:$_,assetChain:T_,balance:E_,value:q_},Ei=()=>{const e=et(),{data:n,isLoading:s}=Og(),{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"?f_:g_,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 C=h?u:l,w=h?m:d,v=C===x.denom&&w===y.chain_id;return t.jsxs("button",{className:L(le.asset,v&&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," ",v&&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"})},L_="_title_9ovji_1",M_="_list_9ovji_7",D_="_asset_9ovji_15",eo={title:L_,list:M_,asset:D_},qi=()=>{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}`))})]})},P_="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",R_="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",B_="_container_9k4hs_1",U_="_title_9k4hs_8",F_="_subtitle_9k4hs_14",O_="_linkContainer_9k4hs_30",V_="_link_9k4hs_30",z_="_separator_9k4hs_51",K_="_errorIcon_9k4hs_62",W_="_error_9k4hs_62",ve={container:B_,title:U_,subtitle:F_,linkContainer:O_,link:V_,separator:z_,errorIcon:K_,error:W_};function H_(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}=ji({chainId:l,txHash:c,tracked:!1}),{data:b}=bi({chainId:l,txHash:c,tracked:!!y,timestamp:d,route:u}),C=H_(b),w=s==="dark"?P_:R_,v=`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:w,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:[C==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",f," ",_.symbol]}),t.jsx("video",{src:v,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"})]}),C==="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"})]}),C==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[x," failed"]}),t.jsx("img",{src:w,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 Q_="_container_7nl9j_1",G_="_page_7nl9j_5",Ra={container:Q_,page:G_},Y_=()=>{const e=pe.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:""}});return On(),t.jsx(pe.FormProvider,{...e,children:t.jsx(Z_,{})})},Z_=()=>{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(qi,{});case"select-external":return t.jsx(Ei,{});case"fields":return t.jsx(p_,{});case"completed":return t.jsx(ls,{type:"deposit"})}};return t.jsx(rn,{children:t.jsx("div",{className:Ra.container,children:s((a,r)=>t.jsx(ze.animated.div,{style:a,className:Ra.page,children:o(r)}))})})},J_=()=>{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=Si(),_=a?.[d]?.[u]?.amount,x=a?.[d]?.[u]?.price||0,y=Number(x)*Number(h||0),[b]=Ie.useDebounceValue(Number(h),300),C=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:w,error:v}=is(b.toString(),{disabled:!!C}),k=g.useEffectEvent(()=>{e(0,{...n,route:w,values:{sender:r,recipient:n.recipientAddress?j.InitiaAddress(n.recipientAddress).hex:r,slippagePercent:"1",...l()}})});return g.useEffect(()=>{k()},[w,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||C?t.jsx(fe,{children:t.jsx(ne.White,{type:"submit",loading:!v&&!C&&"Fetching route...",disabled:!0,fullWidth:!0,className:B.submit,children:v?"No route found":C})}):t.jsx(Yo,{children:S=>t.jsx(Xo,{children:M=>t.jsx(Jo,{addressList:S,signedOpHook:M,children:F=>t.jsx(Ai,{tx:F,children:E=>t.jsx(Ti,{tx:F,gas:E})})})})})]}):null},X_="_container_7nl9j_1",ex="_page_7nl9j_5",Ba={container:X_,page:ex},tx=()=>{const e=pe.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:""}});return On(),t.jsx(pe.FormProvider,{...e,children:t.jsx(nx,{})})},nx=()=>{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(qi,{});case"select-external":return t.jsx(Ei,{});case"fields":return t.jsx(J_,{});case"completed":return t.jsx(ls,{type:"withdraw"})}};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)}))})})},sx="_root_1lo0i_1",ox="_address_1lo0i_9",ax="_copy_1lo0i_19",rx="_labelWrapper_1lo0i_33",ix="_labelCopy_1lo0i_43",cx="_labelCopied_1lo0i_47",lx="_copied_1lo0i_55",dx="_derived_1lo0i_65",ux="_derivedLabel_1lo0i_79",mx="_derivedAddress_1lo0i_83",hx="_hexAddress_1lo0i_89",px="_derivedCopy_1lo0i_94",Se={root:sx,address:ox,copy:ax,labelWrapper:rx,labelCopy:ix,labelCopied:cx,copied:lx,derived:dx,derivedLabel:ux,derivedAddress:mx,hexAddress:hx,derivedCopy:px},fx=()=>{const e=g.useRef(null),n=g.useRef(null),{initiaAddress:s,hexAddress:o}=De(),a=Gr("--gray-0");return g.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new tc({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 gx(){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 _x="_countdown_vfms8_1",xx={countdown:_x},yx=({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:xx.countdown,children:s})]})},jx="_container_1l528_1",bx="_info_1l528_11",vx="_header_1l528_17",wx="_chainName_1l528_23",Cx="_expiration_1l528_29",Nx="_revokeButton_1l528_35",Yt={container:jx,info:bx,header:vx,chainName:wx,expiration:Cx,revokeButton:Nx},kx=({chainId:e,grantee:n,messageTypes:s,expiration:o})=>{const a=Xe(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(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(yx,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:Yt.revokeButton,onClick:()=>r(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},Ix=({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(kx,{...o,chainId:e,key:o.grantee})),Ax="_content_q36qs_1",Sx={content:Ax},$x=()=>{const e=gx(),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:Sx.content,children:s.map(({chainId:o,grants:a})=>t.jsx(Ix,{chainId:o,grants:a},o))})};return t.jsx(mt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},Tx="2.2.1",Ex="_version_1sf5y_1",qx={version:Ex},Lx=()=>t.jsxs("aside",{className:qx.version,children:["v",Tx]}),Mx="_link_se23z_1",Dx="_title_se23z_17",Px="_subtitle_se23z_23",Rx="_icon_se23z_30",Jn={link:Mx,title:Dx,subtitle:Px,icon:Rx},Li=({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})})]}),Bx="https://export.initia.xyz/",Ux=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Li,{title:"Export private key",rightSection:t.jsx(I.IconExternalLink,{size:16}),onClick:()=>window.open(Bx,"_blank",e)})},Fx="_container_1vxr7_1",Ox="_separator_1vxr7_7",Ua={container:Fx,separator:Ox},Vx=()=>{const e=je(),{connector:n}=we.useAccount();return t.jsx(mt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Ua.container,children:[t.jsx(Li,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===jo&&t.jsx(Ux,{}),t.jsx(ft.Separator,{className:Ua.separator}),t.jsx(Lx,{})]})})},zx="_trigger_1yjkd_1",Kx="_icon_1yjkd_23",Wx="_full_1yjkd_27",Hx="_triggerContent_1yjkd_32",Qx="_triggerText_1yjkd_40",Gx="_popoverBackdrop_1yjkd_51",Yx="_popoverPositioner_1yjkd_70",Zx="_popoverPopup_1yjkd_74",Jx="_search_1yjkd_99",Xx="_viewport_1yjkd_105",ey="_item_1yjkd_111",ty="_highlighted_1yjkd_127",ny="_active_1yjkd_131",sy="_itemContent_1yjkd_136",oy="_extra_1yjkd_142",ay="_connectedTag_1yjkd_149",_e={trigger:zx,icon:Kx,full:Wx,triggerContent:Hx,triggerText:Qx,popoverBackdrop:Gx,popoverPositioner:Yx,popoverPopup:Zx,search:Jx,viewport:Xx,item:ey,highlighted:ty,active:ny,itemContent:sy,extra:oy,connectedTag:ay},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"})]}),C=g.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),w=g.useMemo(()=>{const $=[C,...y];if(!i)return $;const N=i.toLowerCase();return $.filter(R=>R.name.toLowerCase().includes(N)||R.chainId.toLowerCase().includes(N))},[y,i,C]),v=y.find($=>$.chainId===e)||C,k=parseInt(Gr("--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)%w.length);break;case"ArrowUp":$.preventDefault(),m(N=>(N-1+w.length)%w.length);break;case"Enter":$.preventDefault(),w[u]&&(n(w[u].chainId),d(!1));break;case"Escape":$.preventDefault(),d(!1);break}},[w,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 v.logoUrl=="string"?t.jsx(J,{src:v.logoUrl,width:14,height:14,logo:!0}):v.logoUrl(14),t.jsx("span",{className:_e.triggerText,children:v.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:w.length===0?t.jsx(he,{children:"No appchains found"}):w.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($)})]},$))})]})})]})]})},ry="_container_1nap1_1",iy="_controls_1nap1_7",cy="_search_1nap1_13",ea={container:ry,controls:iy,search:cy},ly=({children:e})=>t.jsx("div",{className:ea.container,children:e}),dy=({children:e})=>t.jsx("div",{className:ea.controls,children:e}),uy=e=>t.jsx(Is,{...e,rootClassName:ea.search}),Ye={Root:ly,Controls:dy,SearchInput:uy},Mi=H.atom(""),Di=H.atom(""),my=H.atom(""),hy=H.atom(""),py=H.atom(""),fy="_change_1x9v4_1",gy="_positive_1x9v4_10",_y="_negative_1x9v4_14",to={change:fy,positive:gy,negative:_y},Pi=({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]})},xy=({changes:e,chain:n})=>{const s=ct(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Pi,{amount:o,asset:s(a)},r))},yy=({changes:e,chain:n})=>{const s=ct(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(si,{metadata:a,chain:n,children:i=>t.jsx(Pi,{amount:o,asset:s(i)})},r))},jy=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=De();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(yy,{changes:ni(e,o),chain:n}):t.jsx(xy,{changes:ti(e,s),chain:n})},by="_message_1g2hc_1",vy="_more_1g2hc_8",Fa={message:by,more:vy},wy=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Fa.message,children:us.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Fa.more,children:`+${e.length-3} more`})]}),Cy="_link_fuhbt_1",Ny="_inner_fuhbt_16",ky="_header_fuhbt_21",Iy="_time_fuhbt_30",Ay="_error_fuhbt_36",Sy="_timestamp_fuhbt_40",$y="_chainInfo_fuhbt_45",Ty="_content_fuhbt_53",Ey="_messages_fuhbt_61",qy="_changes_fuhbt_67",at={link:Cy,inner:Ny,header:ky,time:Iy,error:Ay,timestamp:Sy,chainInfo:$y,content:Ty,messages:Ey,changes:qy},Ly=({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(wy,{messages:e.tx.body.messages})}),t.jsx("div",{className:at.changes,children:t.jsx(de,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(jy,{...e,chain:n})})})]})]})}),My="_list_1mv55_1",Dy="_dateGroup_1mv55_7",Py="_dateHeader_1mv55_12",Ry="_more_1mv55_18",Xn={list:My,dateGroup:Dy,dateHeader:Py,more:Ry},By=({list:e,chainId:n})=>{const s=X(),o=g.useMemo(()=>_i(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(Ly,{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"})]})},Uy=()=>{const{activities:e,isLoading:n}=Zd(),[s,o]=H.useAtom(py),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(By,{list:i,chainId:s||a.chainId})]})},Fy="_thumbnail_1xyqw_1",Oy="_placeholder_1xyqw_18",Vy="_clickable_1xyqw_24",bn={thumbnail:Fy,placeholder:Oy,clickable:Vy},zy=({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}})})},Ky="_collectionName_qs5tw_1",Wy="_nftName_qs5tw_6",Hy="_chainInfo_qs5tw_10",no={collectionName:Ky,nftName:Wy,chainInfo:Hy},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(zy,{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 Qy(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function Gy(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const Yy=()=>{const e=X(),n=ue(),s=T.useQueries({queries:n.map(l=>({queryKey:na.nfts(l.indexerUrl,e).queryKey,queryFn:()=>ar(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:z.SECOND}))}),o=s.map(A.prop("data")),a=Gy(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 Zy(e){const n=Oa(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:Oa(s.image)}}catch{return{}}},staleTime:z.INFINITY})}function Oa(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Jy=({nftInfo:e,children:n})=>{const{data:s={}}=Zy(e.nft.uri),o=Qy(e,s);return n(o)},Xy="_grid_1wwdn_1",e1="_root_1wwdn_7",t1="_collectionName_1wwdn_15",n1="_nftName_1wwdn_23",s1="_chainInfo_1wwdn_32",Va={grid:Xy,root:e1,collectionName:t1,nftName:n1,chainInfo:s1},o1=()=>{const[e,n]=H.useAtom(my),[s,o]=H.useAtom(hy),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=Yy(),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:Va.grid,children:d.map(m=>{const{collection_addr:h,nft:p}=m;return t.jsx(Jy,{nftInfo:m,children:f=>t.jsx(ta,{normalizedNft:f,onThumbnailClick:()=>l("/nft",f),classNames:Va})},h+p.token_id)})})]})},Ri=g.createContext(null);function Bi(){return g.useContext(Ri)}const a1="_popup_nbecp_1",r1="_item_nbecp_19",es={popup:a1,item:r1},Ui=({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=Bi(),{showNotification:f}=Fo(),{defaultChainId:_}=G(),{evm_chain_id:x}=Ot(),y=we.useChainId(),{switchChainAsync:b}=we.useSwitchChain(),{watchAssetAsync:C}=we.useWatchAsset(),w=()=>{m(!1),h("/send",{denom:s,chain:l})},v=()=>{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)}),C({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:w,children:[t.jsx(I.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(ft.Menu.Item,{className:es.item,onClick:v,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"})]})]})})})]})},i1="_item_38qhm_1",c1="_info_38qhm_23",l1="_images_38qhm_29",d1="_name_38qhm_33",u1="_value_38qhm_39",m1="_amount_38qhm_47",h1="_usd_38qhm_53",Lt={item:i1,info:c1,images:l1,name:d1,value:u1,amount:m1,usd:h1},p1=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=j.formatAmount(n,{decimals:e.decimals});return t.jsx(Ui,{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)})]})]})})},f1="_container_ytg3p_1",g1="_assetItem_ytg3p_6",_1="_expandIcon_ytg3p_22",x1="_assetInfo_ytg3p_27",y1="_logo_ytg3p_33",j1="_details_ytg3p_37",b1="_symbol_ytg3p_42",v1="_chainName_ytg3p_53",w1="_chainInfos_ytg3p_59",C1="_chainLogos_ytg3p_65",N1="_chainLogo_ytg3p_65",k1="_moreChains_ytg3p_76",I1="_expanded_ytg3p_93",A1="_valueColumn_ytg3p_98",S1="_amount_ytg3p_108",$1="_value_ytg3p_98",T1="_collapsibleContent_ytg3p_121",E1="_chainsList_ytg3p_151",ge={container:f1,assetItem:g1,expandIcon:_1,assetInfo:x1,logo:y1,details:j1,symbol:b1,chainName:v1,chainInfos:w1,chainLogos:C1,chainLogo:N1,moreChains:k1,expanded:I1,valueColumn:A1,amount:S1,value:$1,collapsibleContent:T1,chainsList:E1},q1=H.atom([]),sa=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(q1),c=g.useMemo(()=>Rc(e),[e]),l=g.useMemo(()=>qr(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(Ui,{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(p1,{asset:h},h.chain.chainId))})})]})})},L1="_collapsible_1g7rh_1",M1="_trigger_1g7rh_5",D1="_divider_1g7rh_20",P1="_label_1g7rh_28",R1="_chevron_1g7rh_33",B1="_content_1g7rh_41",U1="_list_1g7rh_45",Ct={collapsible:L1,trigger:M1,divider:D1,label:P1,chevron:R1,content:B1,list:U1},Fi=({unlistedAssets:e})=>{const[n,s]=g.useState(!1),o=Bi(),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))})})})]})},F1="_container_15xfg_1",O1="_header_15xfg_7",V1="_title_15xfg_13",z1="_totalValue_15xfg_19",K1="_list_15xfg_26",tn={container:F1,header:O1,title:V1,totalValue:z1,list:K1},W1=()=>{const[e,n]=H.useAtom(Mi),[s,o]=H.useAtom(Di),{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(Fi,{unlistedAssets:m})]})})]})},H1="_container_11k2x_1",Q1={container:H1},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:Q1.container,children:o.map(a=>t.jsx(Ut,{height:e,width:s},a))})},G1=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(Fi,{unlistedAssets:f})]}):m.length===0&&c?t.jsx(Ge,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),Y1=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function Oi(){const{civitiaUrl:e}=G(),n=X();return T.useQuery({enabled:!!n,queryKey:Y1.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 Z1="_section_xdyfz_2",J1="_row_xdyfz_15",X1="_rowLeft_xdyfz_23",e2="_rowIcon_xdyfz_29",t2="_goldIcon_xdyfz_38",n2="_silverIcon_xdyfz_46",s2="_rowTitle_xdyfz_54",o2="_rowValue_xdyfz_60",a2="_rowSubtitle_xdyfz_67",Ce={section:Z1,row:J1,rowLeft:X1,rowIcon:e2,goldIcon:t2,silverIcon:n2,rowTitle:s2,rowValue:o2,rowSubtitle:a2},r2=()=>{const{data:e,isLoading:n}=Oi();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})})]})]})},i2="_container_1n61l_1",c2="_section_1n61l_7",l2="_sectionHeader_1n61l_19",d2="_sectionTitle_1n61l_25",u2="_sectionLabel_1n61l_31",m2="_externalLink_1n61l_37",h2="_sectionValue_1n61l_49",p2="_tokenList_1n61l_56",f2="_stakingTokenList_1n61l_62",g2="_tokenRow_1n61l_72",_2="_tokenMain_1n61l_78",x2="_tokenTrigger_1n61l_84",y2="_tokenChevron_1n61l_100",j2="_expanded_1n61l_111",b2="_triggerValue_1n61l_115",v2="_tokenInfo_1n61l_122",w2="_tokenInfoLabel_1n61l_128",C2="_tokenLogo_1n61l_134",N2="_tokenSymbol_1n61l_138",k2="_tokenValues_1n61l_144",I2="_tokenAmount_1n61l_150",A2="_tokenValue_1n61l_144",S2="_typeBreakdown_1n61l_164",$2="_typeRow_1n61l_172",T2="_typeLabel_1n61l_180",E2="_typeValues_1n61l_186",q2="_typeAmount_1n61l_192",L2="_typeValue_1n61l_186",M2="_collapsibleContent_1n61l_206",Q={container:i2,section:c2,sectionHeader:l2,sectionTitle:d2,sectionLabel:u2,externalLink:m2,sectionValue:h2,tokenList:p2,stakingTokenList:f2,tokenRow:g2,tokenMain:_2,tokenTrigger:x2,tokenChevron:y2,expanded:j2,triggerValue:b2,tokenInfo:v2,tokenInfoLabel:w2,tokenLogo:C2,tokenSymbol:N2,tokenValues:k2,tokenAmount:I2,tokenValue:A2,typeBreakdown:S2,typeRow:$2,typeLabel:T2,typeValues:E2,typeAmount:q2,typeValue:L2,collapsibleContent:M2},Vi=({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(D2,{sectionKey:c,sectionGroup:l,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},D2=({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(P2,{group:h,showTypeBreakdown:m,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},P2=({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(R2,{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)})]})]})})},R2=({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))})]})]})]})},B2="_container_ymkoc_1",U2="_trigger_ymkoc_6",F2="_expandIcon_ymkoc_22",O2="_chainInfo_ymkoc_27",V2="_logo_ymkoc_33",z2="_chainNameContainer_ymkoc_37",K2="_chainName_ymkoc_37",W2="_externalLink_ymkoc_49",H2="_externalIcon_ymkoc_53",Q2="_valueColumn_ymkoc_63",G2="_value_ymkoc_63",Y2="_expanded_ymkoc_80",Z2="_collapsibleContent_ymkoc_85",J2="_content_ymkoc_97",$e={container:B2,trigger:U2,expandIcon:F2,chainInfo:O2,logo:V2,chainNameContainer:z2,chainName:K2,externalLink:W2,externalIcon:H2,valueColumn:Q2,value:G2,expanded:Y2,collapsibleContent:Z2,content:J2},X2=H.atom([]),e0=({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(Vi,{protocols:s,denomLogoMap:i})},t0=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(X2),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(e0,{chainGroup:e}),m&&t.jsx(r2,{})]})})]})})},n0="_container_1gqx9_1",s0="_section_1gqx9_6",o0="_sectionHeader_1gqx9_14",a0="_sectionTitle_1gqx9_20",r0="_sectionLabel_1gqx9_26",i0="_externalLink_1gqx9_32",c0="_sectionValue_1gqx9_44",l0="_tokenList_1gqx9_51",d0="_tokenTrigger_1gqx9_63",u0="_tokenChevron_1gqx9_79",m0="_expanded_1gqx9_90",h0="_tokenInfo_1gqx9_94",p0="_tokenInfoLabel_1gqx9_100",f0="_tokenLogo_1gqx9_106",g0="_pairedLogos_1gqx9_110",_0="_coinLogo_1gqx9_115",x0="_tokenSymbol_1gqx9_133",y0="_triggerValue_1gqx9_139",j0="_breakdownContent_1gqx9_146",b0="_breakdownRow_1gqx9_154",v0="_breakdownLabel_1gqx9_162",w0="_breakdownValues_1gqx9_168",C0="_breakdownAmount_1gqx9_174",N0="_breakdownValue_1gqx9_168",k0="_collapsibleContent_1gqx9_195",se={container:n0,section:s0,sectionHeader:o0,sectionTitle:a0,sectionLabel:r0,externalLink:i0,sectionValue:c0,tokenList:l0,tokenTrigger:d0,tokenChevron:u0,expanded:m0,tokenInfo:h0,tokenInfoLabel:p0,tokenLogo:f0,pairedLogos:g0,coinLogo:_0,tokenSymbol:x0,triggerValue:y0,breakdownContent:j0,breakdownRow:b0,breakdownLabel:v0,breakdownValues:w0,breakdownAmount:C0,breakdownValue:N0,collapsibleContent:k0},I0=({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(S0,{row:a,denomLogoMap:n},a.denom))})]})})},A0={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},S0=({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 C=b*p;return t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:A0[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(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(l.total),{dp:6})," ",Qe]}),t.jsx("span",{className:se.breakdownValue,children:Z(l.totalValue)})]})]})]})})]})},$0="_container_1nijk_1",T0="_section_1nijk_6",E0="_sectionHeader_1nijk_14",q0="_sectionTitle_1nijk_20",L0="_sectionLabel_1nijk_26",M0="_externalLink_1nijk_32",D0="_sectionValue_1nijk_44",P0="_tokenList_1nijk_51",R0="_tokenTrigger_1nijk_63",B0="_tokenChevron_1nijk_79",U0="_expanded_1nijk_90",F0="_tokenInfo_1nijk_94",O0="_tokenInfoLabel_1nijk_100",V0="_tokenLogo_1nijk_106",z0="_tokenName_1nijk_110",K0="_triggerValue_1nijk_116",W0="_breakdownContent_1nijk_123",H0="_breakdownRow_1nijk_131",Q0="_breakdownLabel_1nijk_139",G0="_breakdownValues_1nijk_145",Y0="_breakdownAmount_1nijk_151",Z0="_breakdownValue_1nijk_145",J0="_collapsibleContent_1nijk_165",ce={container:$0,section:T0,sectionHeader:E0,sectionTitle:q0,sectionLabel:L0,externalLink:M0,sectionValue:D0,tokenList:P0,tokenTrigger:R0,tokenChevron:B0,expanded:U0,tokenInfo:F0,tokenInfoLabel:O0,tokenLogo:V0,tokenName:z0,triggerValue:K0,breakdownContent:W0,breakdownRow:H0,breakdownLabel:Q0,breakdownValues:G0,breakdownAmount:Y0,breakdownValue:Z0,collapsibleContent:J0},X0=({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:jc,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(ej,{row:o},`${o.bridgeId}-${o.version}`))})]})})},ej=({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)})]})]})]})})]})},tj="_container_ymkoc_1",nj="_trigger_ymkoc_6",sj="_expandIcon_ymkoc_22",oj="_chainInfo_ymkoc_27",aj="_logo_ymkoc_33",rj="_chainNameContainer_ymkoc_37",ij="_chainName_ymkoc_37",cj="_externalLink_ymkoc_49",lj="_externalIcon_ymkoc_53",dj="_valueColumn_ymkoc_63",uj="_value_ymkoc_63",mj="_expanded_ymkoc_80",hj="_collapsibleContent_ymkoc_85",pj="_content_ymkoc_97",Te={container:tj,trigger:nj,expandIcon:sj,chainInfo:oj,logo:aj,chainNameContainer:rj,chainName:ij,externalLink:cj,externalIcon:lj,valueColumn:dj,value:uj,expanded:mj,collapsibleContent:hj,content:pj},fj=H.atom(!1),gj=()=>{const{totalValue:e}=Mo(),{totalValue:n}=Po(),{totalValue:s}=Ro(),o=e+n+s;return t.jsx("span",{className:Te.value,children:Z(o)})},_j=({chainLogo:e,denomLogos:n,symbolLogos:s,initPrice:o})=>{const{positions:a}=Mo(),{data:r}=Pr(),{data:i}=Rr(),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(Vi,{protocols:d,denomLogoMap:c,isInitia:!0,getClaimableInitByType:l,initPrice:o})},xj=({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(I0,{data:o,denomLogoMap:a})},yj=()=>{const e=Ro();return e.rows.length===0?null:t.jsx(X0,{data:e})},jj=({chainGroup:e})=>{const{chainName:n,chainLogo:s}=e,[o,a]=H.useAtom(fj),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(gj,{})}),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(_j,{chainLogo:s,denomLogos:i,symbolLogos:c,initPrice:u})}),t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:36,length:2}),children:t.jsx(xj,{chainLogo:s,denomLogos:i,symbolLogos:c})}),t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:36,length:1}),children:t.jsx(yj,{})})]})})]})})},bj="_totalValue_1v2ca_1",vj={totalValue:bj},wj=({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:vj.totalValue,children:Z(r)})},Cj="_container_1eubu_1",Nj="_header_1eubu_7",kj="_title_1eubu_13",Ij="_list_1eubu_19",Aj="_skeletonWrapper_1eubu_24",vn={container:Cj,header:Nj,title:kj,list:Ij,skeletonWrapper:Aj},Sj=g.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Dn(),r=ie(),{data:i,isLoading:c}=Oi(),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(v=>v.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(v=>e&&!v.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(v.positions)&&v.positions.length>0),C=r.chainId===p?.chainId,w=b.reduce((v,k)=>v+k.positions.reduce((S,M)=>S+an(M),0),0);u.push({chainName:p?.prettyName??h.chainName,chainLogo:p?.logoUrl??"",protocols:b,isInitia:C,totalValue:w})}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(wj,{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(jj,{chainGroup:u})},u.chainName):t.jsx(t0,{chainGroup:u},u.chainName))}):o.length===0&&a?t.jsx(Ge,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),$j="_content_1w1ad_1",Tj={content:$j},Ej=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=G(),o=ie(),a=$l(),{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)})},qj=()=>{const[e,n]=H.useAtom(Mi),[s,o]=H.useAtom(Di),a=ue(),r=An(),{denomLogos:i,symbolLogos:c}=g.useMemo(()=>Bo(r),[r]),l=bo(),d=g.useMemo(()=>Vr(a,l),[a,l]),u=Sl();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(Ej,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:Tj.content,children:[t.jsx(de,{suspenseFallback:t.jsx(Ge,{height:48,length:5}),children:t.jsx(G1,{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(Sj,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},Lj="_totalValue_5pf7e_1",Mj="_totalLabel_5pf7e_7",Dj="_totalAmount_5pf7e_13",Pj="_loading_5pf7e_18",Rj="_skeletonWrapper_5pf7e_23",Bj="_nav_5pf7e_28",Uj="_item_5pf7e_34",Fj="_tabs_5pf7e_59",Oj="_tab_5pf7e_59",Ee={totalValue:Lj,totalLabel:Mj,totalAmount:Dj,loading:Pj,skeletonWrapper:Rj,nav:Bj,item:Uj,tabs:Fj,tab:Oj},Vj=()=>{const{totalValue:e,isLoading:n}=To();return t.jsx("div",{className:L(Ee.totalAmount,{[Ee.loading]:n}),children:Z(e)})},zj=()=>{const e=Tl(),n=El(),s=Or(),o=e+s+n;return t.jsx("div",{className:Ee.totalAmount,children:Z(o)})},Kj=()=>{ui();const e=Uo(),n=je(),s=et(),o=g.useRef(null);return t.jsx(Ri.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(Vj,{}):t.jsx(zj,{})})]}),t.jsxs("div",{className:Ee.nav,children:[t.jsxs(nn,{to:"/send",className:Ee.item,children:[t.jsx(I.IconSend,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(nn,{to:"/bridge",className:Ee.item,children:[t.jsx(I.IconBridge,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(nn,{to:"/receive",className:Ee.item,children:[t.jsx(I.IconQrCode,{size:16}),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(W1,{}):t.jsx(qj,{})}),t.jsx(bt.Tabs.Panel,{value:"/nfts",children:t.jsx(o1,{})}),t.jsx(bt.Tabs.Panel,{value:"/activity",children:t.jsx(Uy,{})})]})]})})},Wj="_root_th990_1",Hj="_collectionName_th990_9",Qj="_nftName_th990_13",Gj="_chainInfo_th990_17",Yj="_attributes_th990_21",Zj="_title_th990_24",Jj="_count_th990_29",Xj="_item_th990_33",eb="_type_th990_39",tb="_value_th990_45",Mt={root:Wj,collectionName:Hj,nftName:Qj,chainInfo:Gj,attributes:Yj,title:Zj,count:Jj,item:Xj,type:eb,value:tb},nb=()=>{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 sb({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 ob({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=sb({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 ab=({chain:e,onSelect:n})=>{const s=pc(e);return t.jsx(Fn,{assets:s,onSelect:n})},rb=({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(ab,{chain:l,onSelect:u})},i)]})},ib="_fields_brpej_1",cb="_divider_brpej_11",za={fields:ib,divider:cb},lb=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),db=()=>{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(_),C=sr(m,_),{data:w}=yt(_),{decimals:v}=C,k=x.find(O=>O.denom===m)?.amount??"0",S=w?.find(({id:O})=>O===m)?.price,{data:M=0,isLoading:F}=T.useQuery({queryKey:lb.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),$=ob({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:W}=T.useMutation({mutationFn:({chainId:O,denom:ee,quantity:me,recipient:Ae,memo:We})=>{const At=j.toBaseUnit(me,{decimals:v}),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:"/"})}}),K=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:za.fields,children:[t.jsx(uo,{selectButton:t.jsx(ln,{title:"Select chain and asset",content:O=>t.jsx(rb,{afterSelect:O}),children:t.jsx(fi,{asset:C,chain:_})}),quantityInput:t.jsx(cn,{balance:k,decimals:v}),balanceButton:t.jsx(mi,{onClick:()=>i("quantity",j.fromBaseUnit($,{decimals:v}),{shouldValidate:!0}),disabled:q,children:j.formatAmount(k??"0",{decimals:v})}),value:p?S?Z(U(p).times(S)):"$-":"$0"}),t.jsx("div",{className:za.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)||W,disabled:!!K,children:K??"Confirm"})})]})})},ub=()=>{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(db,{})})};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 mb(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 hb(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 pb({collection_addr:e},{restUrl:n}){const s=await mb(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 fb(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 gb({object_addr:e,collection_addr:n},{restUrl:s}){const o=await fb(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 _b(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 xb(e,n){const{collection:s}=await V.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function yb(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 Ka(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 jb({collection_addr:e},n,s){const o=j.InitiaAddress(e).bech32,a=await _b(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 yb(c,n.restUrl),h=await xb(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]=Ka(d);return{class_id:o,class_trace:{path:_,base_class_id:x},outgoing_proxy:m}}const[p,f]=Ka(a);return{class_id:o,class_trace:{path:p,base_class_id:f},outgoing_proxy:m}}const bb={minimove:gb,minievm:pb,miniwasm:jb};async function vb({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 bb[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await hb([e.token_id],a.class_id,n.restUrl)})}const wb="_root_1tyvn_1",Cb="_collectionName_1tyvn_10",Nb="_nftName_1tyvn_15",kb="_chainInfo_1tyvn_19",Ib="_fields_1tyvn_24",Ab="_chain_1tyvn_19",so={root:wb,collectionName:Cb,nftName:Nb,chainInfo:kb,fields:Ib,chain:Ab},Sb=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),$b=()=>{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),C=T.useQuery({queryKey:Sb.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 vb({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:w,isLoading:v,error:k}=C,S=T.useQueryClient(),{mutate:M,isPending:F}=T.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,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(pi,{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:(v?"Finding route...":!1)||F,disabled:!!E,children:E??"Confirm"})})]})},Tb=()=>{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($b,{})})})},_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(Pa,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Pa,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(Kj,{});case"/send":return t.jsx(ub,{},s);case"/receive":return t.jsx(fx,{});case"/nft":return t.jsx(nb,{});case"/nft/send":return t.jsx(Tb,{},s);case"/bridge":return t.jsx(Wp,{},s);case"/bridge/preview":return t.jsx(Jf,{});case"/bridge/history":return t.jsx(Lf,{});case"/op/withdrawals":return t.jsx($g,{});case"/tx":return t.jsx(ai,{});case"/autosign/enable":return t.jsx(qm,{});case"/settings":return t.jsx(Vx,{});case"/settings/autosign":return t.jsx($x,{});case"/deposit":return t.jsx(Y_,{});case"/deposit/completed":return t.jsx(ls,{type:"deposit"});case"/withdraw":return t.jsx(tx,{});case"/withdraw/completed":return t.jsx(ls,{type:"withdraw"})}},Eb="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",qb=()=>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:Eb}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Lb=()=>(Cc(),Tc(),ue(),Al(),Or(),An(),Rn(),zt(),null),Mb=({children:e,...n})=>(g.useEffect(()=>{rl()},[]),Ie.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(qb,{}),t.jsx(Xa.Provider,{value:{...Ja,...n},children:t.jsx(ur,{children:t.jsx(im,{children:t.jsx(Y.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(rm,{children:t.jsxs(Qu,{children:[e,t.jsx(ql,{}),t.jsx(de,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Lb,{})}),t.jsx(vd,{children:t.jsx(_o,{})}),t.jsx(xd,{children:t.jsx(_o,{})})]})})})})})})]}):null),Db=({bridge:e})=>t.jsx(ur,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Jr.Provider,{value:!!e,children:t.jsx(de,{children:t.jsx(_o,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Za;exports.InterwovenKit=Db;exports.InterwovenKitProvider=Mb;exports.MAINNET=Ja;exports.MoveError=kr;exports.PRIVY_APP_ID=jo;exports.TESTNET=sc;exports.initiaPrivyWallet=ac;exports.initiaPrivyWalletConnector=oc;exports.initiaPrivyWalletOptions=ms;exports.injectStyles=Ql;exports.useAddress=kt;exports.useHexAddress=Vt;exports.useInitiaAddress=X;exports.useInterwovenKit=De;exports.usePortfolio=To;exports.useUsernameQuery=Lr;
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;