@initia/interwovenkit-react 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ii=require("@privy-io/cross-app-connect/rainbow-kit"),Qe=require("wagmi"),E=require("@tanstack/react-query"),k=require("@initia/utils"),q=require("bignumber.js"),L=require("ramda"),qe=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),de=require("@cosmjs/encoding"),Dl=require("@mysten/bcs"),H=require("jotai"),ci=require("@amplitude/analytics-browser"),n=require("react/jsx-runtime"),Zn=require("@cosmjs/amino/build/signdoc"),ht=require("@cosmjs/crypto"),kt=require("ethers"),ha=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),En=require("@cosmjs/amino"),Gs=require("@cosmjs/proto-signing"),Yo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Bl=require("cosmjs-types/google/protobuf/any"),ft=require("viem"),sr=require("@cosmjs/math"),Le=require("@cosmjs/stargate"),or=require("@cosmjs/tendermint-rpc"),li=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ze=require("cosmjs-types/cosmos/tx/v1beta1/tx"),fa=require("@initia/amino-converter"),Fl=require("cosmjs-types/cosmos/auth/v1beta1/auth"),cn=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),ar=require("cosmjs-types/cosmos/tx/v1beta1/service"),Xe=require("date-fns"),rr=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),ui=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),te=require("radix-ui"),Ge=require("usehooks-ts"),di=require("react-error-boundary"),B=require("clsx"),$e=require("react-hook-form"),Be=require("@base-ui/react/dialog"),Ul=require("xss"),M=require("@initia/icons-react"),Nt=require("@react-spring/web"),Ys=require("change-case"),Lt=require("@base-ui/react/select"),Io=require("@base-ui/react/collapsible"),ir=require("nanoid"),Ol=require("react-dom"),Vl=require("psl"),Kl=require("jotai/utils"),mi=require("react-merge-refs"),Wl=require("react-number-format"),zl=require("react-intersection-observer"),Hl=require("@noble/hashes/sha3"),ln=require("@noble/hashes/utils"),Ql=require("qr-code-styling"),Rt=require("@base-ui/react"),Ut=require("@base-ui/react/tabs"),jn=require("@base-ui/react/popover"),cr=require("cosmjs-types/cosmos/bank/v1beta1/tx"),lr=require("viem/accounts"),Gl=require("viem/chains"),Yl=require("wagmi/connectors");function Zl(e){const t=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(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pa=Zl(ci),Ht=1.4,hi=1.05,fi={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",theme:"dark"},Jl={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",theme:"dark",disableAnalytics:!0},ga="cmbq1ozyc006al70lx4uciz0q",Jn={id:ga,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Xl=ii.toPrivyWalletConnector(Jn),eu=ii.toPrivyWallet(Jn),pi=_.createContext(null);function se(){const e=_.useContext(pi);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const V={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function tu(e){if(e instanceof z.HTTPError){const{response:t}=e,s=t.headers.get("content-type")??"";if(L.includes("application/json",s))try{const o=await t.json();if(o.message)return o.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if(L.path(["code"],e)===4001||L.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const t=L.path(["error","message"],e),s=L.path(["cause","message"],e),o=L.path(["shortMessage"],e);return t||s||o||e.message}return String(e)}async function ct(e){return new Error(await tu(e))}const Zs=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function js(e){const t=L.path([0,"address"],e);if(!t)throw new Error("URL not found");return t}function nu(e){const{chain_id:t,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:u,rest:m,["json-rpc"]:d,indexer:h}=r,f=js(u),g=js(m),p=js(h),y=i?.minitia?.type==="minievm"?js(d):void 0;return{...e,chainId:t,name:c,logoUrl:l,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:y}}function su({chainId:e,chains:t,enabled:s,error:o,isLoading:a}){if(!s)return{chain:void 0,error:null,isLoading:!1};const r=t?.find(i=>i.chain_id===e);return r?{chain:r,error:null,isLoading:!1}:o&&!t?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:a||!t?{chain:void 0,error:null,isLoading:!0}:o?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:{chain:void 0,error:new Error(`Chain not found: ${e}`),isLoading:!1}}function gi({customChain:e,defaultChainId:t,registryUrl:s}){return E.queryOptions({queryKey:Zs.list(s).queryKey,queryFn:()=>z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(e?[e,...o.filter(r=>r.chain_id!==e.chain_id)]:o).map(nu).sort(L.descend(r=>r.chainId===t)),staleTime:V.MINUTE})}function _e(){const{defaultChainId:e,registryUrl:t,customChain:s}=se(),{data:o}=E.useSuspenseQuery(gi({customChain:s,defaultChainId:e,registryUrl:t}));return o}function ou(e){const{defaultChainId:t,registryUrl:s,customChain:o}=se();return E.useQuery({...gi({customChain:o,defaultChainId:t,registryUrl:s}),enabled:e})}function _i(){const{registryUrl:e}=se(),{data:t}=E.useSuspenseQuery({queryKey:Zs.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:V.MINUTE});return t}function lt(){const e=ce(),t=_e(),s=_i();return o=>{const a=t.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 _t(e){return lt()(e)}function au(e,t){const s=ou(t);return su({chainId:e,chains:s.data,enabled:t,error:s.error,isLoading:s.isLoading})}function xn(){const{defaultChainId:e}=se();return _t(e)}function ce(){const t=_e().find(s=>s.metadata?.is_l1);if(!t)throw new Error("Layer 1 not found");return t}function yi(){return({chainId:e})=>E.queryOptions({queryKey:Zs.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://indexer.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:V.SECOND})}function Pt(e){const t=yi();return E.useQuery(t(e))}function _a(){const e=_e(),t=yi();return E.useQueries({queries:e.map(s=>t(s))})}const ru=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ui=require("@privy-io/cross-app-connect/rainbow-kit"),He=require("wagmi"),E=require("@tanstack/react-query"),N=require("@initia/utils"),q=require("bignumber.js"),L=require("ramda"),qe=require("@lukemorales/query-key-factory"),H=require("ky"),_=require("react"),de=require("@cosmjs/encoding"),Vl=require("@mysten/bcs"),Q=require("jotai"),di=require("@amplitude/analytics-browser"),n=require("react/jsx-runtime"),Zn=require("@cosmjs/amino/build/signdoc"),ht=require("@cosmjs/crypto"),kt=require("ethers"),ha=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),$n=require("@cosmjs/amino"),Gs=require("@cosmjs/proto-signing"),Yo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Kl=require("cosmjs-types/google/protobuf/any"),ft=require("viem"),or=require("@cosmjs/math"),Le=require("@cosmjs/stargate"),ar=require("@cosmjs/tendermint-rpc"),mi=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ze=require("cosmjs-types/cosmos/tx/v1beta1/tx"),fa=require("@initia/amino-converter"),Wl=require("cosmjs-types/cosmos/auth/v1beta1/auth"),ln=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),rr=require("cosmjs-types/cosmos/tx/v1beta1/service"),Xe=require("date-fns"),ir=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),hi=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),ne=require("radix-ui"),Qe=require("usehooks-ts"),fi=require("react-error-boundary"),P=require("clsx"),$e=require("react-hook-form"),Be=require("@base-ui/react/dialog"),zl=require("xss"),M=require("@initia/icons-react"),It=require("@react-spring/web"),Ys=require("change-case"),qt=require("@base-ui/react/select"),Io=require("@base-ui/react/collapsible"),cr=require("nanoid"),Hl=require("react-dom"),Ql=require("psl"),Gl=require("jotai/utils"),pi=require("react-merge-refs"),Yl=require("react-number-format"),Zl=require("react-intersection-observer"),Jl=require("@noble/hashes/sha3"),un=require("@noble/hashes/utils"),Xl=require("qr-code-styling"),Rt=require("@base-ui/react"),Ot=require("@base-ui/react/tabs"),Cn=require("@base-ui/react/popover"),lr=require("cosmjs-types/cosmos/bank/v1beta1/tx"),ur=require("viem/accounts"),eu=require("viem/chains"),tu=require("wagmi/connectors");function nu(e){const t=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(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pa=nu(di),Qt=1.4,gi=1.05,_i={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",theme:"dark"},su={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",theme:"dark",disableAnalytics:!0},ga="cmbq1ozyc006al70lx4uciz0q",Jn={id:ga,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},ou=ui.toPrivyWalletConnector(Jn),au=ui.toPrivyWallet(Jn),yi=_.createContext(null);function ae(){const e=_.useContext(yi);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const V={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function ru(e){if(e instanceof H.HTTPError){const{response:t}=e,s=t.headers.get("content-type")??"";if(L.includes("application/json",s))try{const o=await t.json();if(o.message)return o.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if(L.path(["code"],e)===4001||L.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const t=L.path(["error","message"],e),s=L.path(["cause","message"],e),o=L.path(["shortMessage"],e);return t||s||o||e.message}return String(e)}async function ct(e){return new Error(await ru(e))}const Zs=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function js(e){const t=L.path([0,"address"],e);if(!t)throw new Error("URL not found");return t}function iu(e){const{chain_id:t,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:u,rest:m,["json-rpc"]:d,indexer:h}=r,f=js(u),g=js(m),p=js(h),y=i?.minitia?.type==="minievm"?js(d):void 0;return{...e,chainId:t,name:c,logoUrl:l,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:y}}function cu({chainId:e,chains:t,enabled:s,error:o,isLoading:a}){if(!s)return{chain:void 0,error:null,isLoading:!1};const r=t?.find(i=>i.chain_id===e);return r?{chain:r,error:null,isLoading:!1}:o&&!t?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:a||!t?{chain:void 0,error:null,isLoading:!0}:o?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:{chain:void 0,error:new Error(`Chain not found: ${e}`),isLoading:!1}}function xi({customChain:e,defaultChainId:t,registryUrl:s}){return E.queryOptions({queryKey:Zs.list(s).queryKey,queryFn:()=>H.create({prefixUrl:s}).get("chains.json").json(),select:o=>(e?[e,...o.filter(r=>r.chain_id!==e.chain_id)]:o).map(iu).sort(L.descend(r=>r.chainId===t)),staleTime:V.MINUTE})}function _e(){const{defaultChainId:e,registryUrl:t,customChain:s}=ae(),{data:o}=E.useSuspenseQuery(xi({customChain:s,defaultChainId:e,registryUrl:t}));return o}function lu(e){const{defaultChainId:t,registryUrl:s,customChain:o}=ae();return E.useQuery({...xi({customChain:o,defaultChainId:t,registryUrl:s}),enabled:e})}function wi(){const{registryUrl:e}=ae(),{data:t}=E.useSuspenseQuery({queryKey:Zs.profiles(e).queryKey,queryFn:()=>H.create({prefixUrl:e}).get("profiles.json").json(),staleTime:V.MINUTE});return t}function lt(){const e=ce(),t=_e(),s=wi();return o=>{const a=t.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 yt(e){return lt()(e)}function uu(e,t){const s=lu(t);return cu({chainId:e,chains:s.data,enabled:t,error:s.error,isLoading:s.isLoading})}function wn(){const{defaultChainId:e}=ae();return yt(e)}function ce(){const t=_e().find(s=>s.metadata?.is_l1);if(!t)throw new Error("Layer 1 not found");return t}function bi(){return({chainId:e})=>E.queryOptions({queryKey:Zs.prices(e).queryKey,queryFn:()=>H.create({prefixUrl:"https://indexer.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:V.SECOND})}function Dt(e){const t=bi();return E.useQuery(t(e))}function _a(){const e=_e(),t=bi();return E.useQueries({queries:e.map(s=>t(s))})}const du=`<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>`,iu=encodeURIComponent(ru),ya=`data:image/svg+xml;utf8,${iu}`,$n=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function cu(e){const{base:t,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,u=o.find(d=>d.denom===a)?.exponent??o.find(d=>d.denom===t)?.exponent??L.head(o)?.exponent??0,m=r?.png??"";return{denom:t,symbol:s,decimals:u,logoUrl:m,name:i,address:c,traces:l}}function xi(){const e=E.useQueryClient();return t=>{const s=t?.metadata?.assetlist;return E.queryOptions({queryKey:$n.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(cu);for(const r of a)e.setQueryData($n.item(t.chainId,r.denom).queryKey,r);return a},staleTime:V.MINUTE})}}function Qt(e){const t=xi(),{data:s}=E.useSuspenseQuery(t(e));return s}function os(){const e=_e(),t=xi();return E.useQueries({queries:e.map(s=>t(s))})}function St(e){const t=Qt(e),s=ce(),o=Qt(s),a=wi(e);return r=>{const i=t.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:ya}}}function bi(e,t){const s=St(t),a=E.useQueryClient().getQueryData($n.item(t.chainId,e).queryKey);return a||s(e)}function wi(e){const t=ce(),s=Qt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===t.chain_name)return i.counterparty.base_denom}}const a=t.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?k.getIbcDenom(a,o):""}}function Bs(e,t){const s=ce(),o=z.create({prefixUrl:s.restUrl}),a=t?.failSoft??!1,r=E.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...$n.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:V.INFINITY}))});return new Map(r.map(({data:i})=>i))}function lu(e){return e.pagination?.next_key??null}async function Js(e,t,s){const o=z.create(t),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],u=lu(c),m=[...r,...l];return u?a(m,u):m};return a([],null)}const ur="usernames";function uu({restUrl:e,moduleAddress:t}){const{viewFunction:s}=k.createMoveClient(e);async function o(i){if(!k.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:t,moduleName:ur,functionName:"get_name_from_address",typeArgs:[],args:[de.toBase64(k.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:t,moduleName:ur,functionName:"get_address_from_name",typeArgs:[],args:[Dl.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?k.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const Xs=qe.createQueryKeys("interwovenkit:account",{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function vi(){const{restUrl:e}=ce(),{usernamesModuleAddress:t}=se();return uu({restUrl:e,moduleAddress:t})}function ji(){const e=ie();return t=>E.queryOptions({queryKey:Xs.balances(t.restUrl,e||"").queryKey,queryFn:()=>e?Js(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},"balances"):[],staleTime:V.SECOND})}function as(e){const t=ji(),{data:s}=E.useSuspenseQuery(t(e));return s}function du(){const e=_e(),t=ji();return E.useQueries({queries:e.map(s=>t(s))})}function mu(e){const t=as(e),s=Qt(e),o=St(e),a=wi(e),{data:r}=Pt(e),i=l=>e.fees.fee_tokens.some(u=>u.denom===l),c=l=>s.some(u=>u.denom===l);return L.sortWith([L.descend(({denom:l})=>a(l)==="uinit"),L.descend(({denom:l})=>i(l)),L.descend(({value:l})=>l),L.descend(({denom:l})=>c(l)),({balance:l},{balance:u})=>q(u).comparedTo(l)??0,L.descend(({symbol:l})=>l.toLowerCase())],t.filter(({amount:l})=>!q(l).isZero()).map(({amount:l,denom:u})=>{const m=o(u),d=r?.find(({id:f})=>f===m?.denom)?.price??0,h=q(l).times(d).div(q(10).pow(m.decimals)).toNumber();return{...m,balance:l,price:d,value:h}}))}const Ci=_.createContext(null);function eo(){return _.useContext(Ci)}function ki(){const{location:e}=eo();return e}function to(){const{path:e}=ki();return e}function et(){const{state:e={}}=ki();return e}function Ni(){const{history:e}=eo();return e}function Me(){const{navigate:e}=eo();return e}function xa(){const{reset:e}=eo();return e}const mn=({to:e,state:t,shouldReset:s,children:o,onClick:a,...r})=>{const i=Me(),c=xa(),l=u=>{u.preventDefault(),a?.(u),s?c(e,t):i(e,t)};return n.jsx("button",{type:"button",...r,onClick:l,children:o})},Ii=({children:e,initialEntry:t})=>{const[s,o]=_.useState([t??{path:"/"}]),a=s[s.length-1],r=_.useCallback((c,l)=>{o(u=>{if(typeof c=="string")return[...u,{path:c,state:l}];const m=u.length+c;if(m<1)return u;const d=L.take(m,u);return l!==void 0?L.adjust(m-1,h=>({...h,state:l}),d):d})},[]),i=_.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return n.jsx(Ci.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},hu="c33b940c24c17e95f7d9d525d508ac61";function fu(){const{disableAnalytics:e}=se();_.useEffect(()=>{e||pa.init(hu,{autocapture:!1})},[e])}function pu(){const{connector:e}=Qe.useAccount(),{defaultChainId:t,disableAnalytics:s}=se();_.useEffect(()=>{const o=new ci.Identify;e?.name&&o.set("connector",e.name),t&&o.set("defaultChainId",t),pa.identify(o)},[t,e?.name,s])}function Pn(){const e=to();return _.useCallback((s,o)=>{pa.track(s,{path:e,...o})},[e])}function gu(e){return e.type==="initia/PubKeyEthSecp256k1"}const _u={...En.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Ai(e){if(gu(e)){const t=Yo.PubKey.fromPartial({key:de.fromBase64(e.value)});return Bl.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Yo.PubKey.encode(t).finish())})}return Gs.encodePubkey(e)}function ba(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:_u.ethsecp256k1,value:de.toBase64(e)}}function Si(e,t){if(t.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:ba(e),signature:de.toBase64(t)}}function yu(e){return`Enable Auto-Sign for InterwovenKit
4
+ </svg>`,mu=encodeURIComponent(du),ya=`data:image/svg+xml;utf8,${mu}`,Mn=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function hu(e){const{base:t,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,u=o.find(d=>d.denom===a)?.exponent??o.find(d=>d.denom===t)?.exponent??L.head(o)?.exponent??0,m=r?.png??"";return{denom:t,symbol:s,decimals:u,logoUrl:m,name:i,address:c,traces:l}}function vi(){const e=E.useQueryClient();return t=>{const s=t?.metadata?.assetlist;return E.queryOptions({queryKey:Mn.list(s).queryKey,queryFn:async()=>s?H.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(hu);for(const r of a)e.setQueryData(Mn.item(t.chainId,r.denom).queryKey,r);return a},staleTime:V.MINUTE})}}function Gt(e){const t=vi(),{data:s}=E.useSuspenseQuery(t(e));return s}function os(){const e=_e(),t=vi();return E.useQueries({queries:e.map(s=>t(s))})}function Tt(e){const t=Gt(e),s=ce(),o=Gt(s),a=Ci(e);return r=>{const i=t.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:ya}}}function ji(e,t){const s=Tt(t),a=E.useQueryClient().getQueryData(Mn.item(t.chainId,e).queryKey);return a||s(e)}function Ci(e){const t=ce(),s=Gt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===t.chain_name)return i.counterparty.base_denom}}const a=t.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?N.getIbcDenom(a,o):""}}function Fs(e,t){const s=ce(),o=H.create({prefixUrl:s.restUrl}),a=t?.failSoft??!1,r=E.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...Mn.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:V.INFINITY}))});return new Map(r.map(({data:i})=>i))}function fu(e){return e.pagination?.next_key??null}async function Js(e,t,s){const o=H.create(t),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],u=fu(c),m=[...r,...l];return u?a(m,u):m};return a([],null)}const dr="usernames";function pu({restUrl:e,moduleAddress:t}){const{viewFunction:s}=N.createMoveClient(e);async function o(i){if(!N.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:t,moduleName:dr,functionName:"get_name_from_address",typeArgs:[],args:[de.toBase64(N.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:t,moduleName:dr,functionName:"get_address_from_name",typeArgs:[],args:[Vl.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?N.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const Xs=qe.createQueryKeys("interwovenkit:account",{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function Ni(){const{restUrl:e}=ce(),{usernamesModuleAddress:t}=ae();return pu({restUrl:e,moduleAddress:t})}function ki(){const e=ie();return t=>E.queryOptions({queryKey:Xs.balances(t.restUrl,e||"").queryKey,queryFn:()=>e?Js(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},"balances"):[],staleTime:V.SECOND})}function as(e){const t=ki(),{data:s}=E.useSuspenseQuery(t(e));return s}function gu(){const e=_e(),t=ki();return E.useQueries({queries:e.map(s=>t(s))})}function _u(e){const t=as(e),s=Gt(e),o=Tt(e),a=Ci(e),{data:r}=Dt(e),i=l=>e.fees.fee_tokens.some(u=>u.denom===l),c=l=>s.some(u=>u.denom===l);return L.sortWith([L.descend(({denom:l})=>a(l)==="uinit"),L.descend(({denom:l})=>i(l)),L.descend(({value:l})=>l),L.descend(({denom:l})=>c(l)),({balance:l},{balance:u})=>q(u).comparedTo(l)??0,L.descend(({symbol:l})=>l.toLowerCase())],t.filter(({amount:l})=>!q(l).isZero()).map(({amount:l,denom:u})=>{const m=o(u),d=r?.find(({id:f})=>f===m?.denom)?.price??0,h=q(l).times(d).div(q(10).pow(m.decimals)).toNumber();return{...m,balance:l,price:d,value:h}}))}const Ii=_.createContext(null);function eo(){return _.useContext(Ii)}function Ai(){const{location:e}=eo();return e}function to(){const{path:e}=Ai();return e}function et(){const{state:e={}}=Ai();return e}function Si(){const{history:e}=eo();return e}function Me(){const{navigate:e}=eo();return e}function xa(){const{reset:e}=eo();return e}const hn=({to:e,state:t,shouldReset:s,children:o,onClick:a,...r})=>{const i=Me(),c=xa(),l=u=>{u.preventDefault(),a?.(u),s?c(e,t):i(e,t)};return n.jsx("button",{type:"button",...r,onClick:l,children:o})},Ti=({children:e,initialEntry:t})=>{const[s,o]=_.useState([t??{path:"/"}]),a=s[s.length-1],r=_.useCallback((c,l)=>{o(u=>{if(typeof c=="string")return[...u,{path:c,state:l}];const m=u.length+c;if(m<1)return u;const d=L.take(m,u);return l!==void 0?L.adjust(m-1,h=>({...h,state:l}),d):d})},[]),i=_.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return n.jsx(Ii.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},yu="c33b940c24c17e95f7d9d525d508ac61";function xu(){const{disableAnalytics:e}=ae();_.useEffect(()=>{e||pa.init(yu,{autocapture:!1})},[e])}function wu(){const{connector:e}=He.useAccount(),{defaultChainId:t,disableAnalytics:s}=ae();_.useEffect(()=>{const o=new di.Identify;e?.name&&o.set("connector",e.name),t&&o.set("defaultChainId",t),pa.identify(o)},[t,e?.name,s])}function Rn(){const e=to();return _.useCallback((s,o)=>{pa.track(s,{path:e,...o})},[e])}function bu(e){return e.type==="initia/PubKeyEthSecp256k1"}const vu={...$n.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Ei(e){if(bu(e)){const t=Yo.PubKey.fromPartial({key:de.fromBase64(e.value)});return Kl.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Yo.PubKey.encode(t).finish())})}return Gs.encodePubkey(e)}function wa(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:vu.ethsecp256k1,value:de.toBase64(e)}}function $i(e,t){if(t.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:wa(e),signature:de.toBase64(t)}}function ju(e){return`Enable Auto-Sign for InterwovenKit
5
5
 
6
6
  Origin: ${e}
7
7
 
8
- Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function xu(e,t){const s=ft.hexToBytes(e);if(s.length!==65)throw new Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${s.length}`);const o=s.slice(0,64),a=ft.hexToBytes(ft.keccak256(ft.bytesToHex(o))),r=ht.Bip39.encode(a),i=await ht.Bip39.mnemonicToSeed(r),c=ht.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=ht.Slip10.derivePath(ht.Slip10Curve.Secp256k1,i,c),u=await ht.Secp256k1.makeKeypair(l),m=ht.Secp256k1.compressPubkey(u.pubkey),h=u.pubkey.slice(1),f=ft.bytesToHex(h),g=ft.keccak256(f),p=ft.hexToBytes(g).slice(-20),y=de.toBech32(t,p);return{privateKey:l,publicKey:m,address:y}}function Cs(e,t){return`${e}:${t}`}const rs=H.atom(null),Xn=H.atom({}),es=H.atom({}),no=H.atom({}),dr=H.atom(0),bu="autosign:";function wu(e,t){const s=e.get(dr)+1;return e.set(dr,s),`${t}:${s}`}function Fs(e,t){return e.get(no)[t]}function vu(e,t,s){e.set(no,o=>({...o,[t]:s}))}function Ti(e,t){e.set(no,s=>{const o={...s};return delete o[t],o})}function ju(e,t,s){const o=Fs(e,t);!o||o.token!==s||Ti(e,t)}function Cu(e,t,s){const o=Fs(e,t);return!!o&&o.token===s}function ks(e,t){return e.get(es)[t]}function ku(e,t,s){e.set(es,o=>({...o,[t]:s}))}function Nu(e,t){e.set(es,s=>{const o={...s};return delete o[t],o})}function Iu(e,t,s){e.set(Xn,o=>({...o,[t]:s}))}function Au(e,t){e.set(Xn,s=>{const o={...s};return delete o[t],o})}function Ei(e,t){return`${bu}${e}:${t}`}function Su(e,t,s){try{return e.getItem(Ei(t,s))}catch{return null}}function Tu(e,t,s,o){try{e.setItem(Ei(t,s),o)}catch{}}function $i(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function wa(e,t){const s=$i();if(s)return Su(s,e,t)}function Eu(e,t,s){const o=$i();o&&Tu(o,e,t,s)}function $u(e){return{publicKey:e.publicKey,address:e.address}}function Us(e){e&&e.fill(0)}function Mi(e){e.set(no,{});const t=e.get(es);for(const s of Object.values(t))Us(s);e.set(es,{}),e.set(Xn,{})}function Mu(e,t){return e!==""&&e!==t}function Lu(){const e=ie(),t=H.useStore(),s=_.useRef(e);_.useEffect(()=>{const o=s.current;Mu(o,e)&&Mi(t),s.current=e},[t,e])}class qu{constructor(t,s){this.wallet=t,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(t,s){if(this.wallet.address!==t)throw new Error("Signer address does not match the derived wallet address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=kt.ethers.hashMessage(o),r=de.fromHex(a.replace("0x","")),i=await ht.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=Si(this.wallet.publicKey,c);return{signed:s,signature:l}}}function so(){const e=H.useStore(),{signMessageAsync:t}=Qe.useSignMessage(),s=lt(),o=ie();return{deriveWallet:async u=>{if(!o)throw new Error("User address not available");const m=s(u),d=Cs(o,m.bech32_prefix),h=e.get(Xn)[d];if(h&&ks(e,d))return h;const f=Fs(e,d);if(f)return f.promise;const g=wu(e,d),p=(async()=>{try{const y=window.location.origin,x=yu(y),b=await t({message:x}),j=await xu(b,m.bech32_prefix),v=$u(j);if(Cu(e,d,g))return ku(e,d,j.privateKey),Iu(e,d,v),v;throw Us(j.privateKey),new Error("Wallet derivation was cancelled")}finally{ju(e,d,g)}})();return vu(e,d,{promise:p,token:g}),p},getWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);if(ks(e,d))return e.get(Xn)[d]},getWalletPrivateKey:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);return ks(e,d)},clearWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix),h=ks(e,d);Fs(e,d)&&Ti(e,d),Us(h),Nu(e,d),Au(e,d)},clearAllWallets:()=>{Mi(e)}}}function Li({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:ha.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function Ru({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const u=Li({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:t},d=new Uint8Array(i),h=new qu(r,d);try{return await l(e,r.address,u,m,a,{customSigner:h})}finally{Us(d)}}const wt="interwovenkit",Je="uinit",pt="INIT",it=6,Pu="uoinit",Du="omniINIT",qi="https://app.initia.xyz",va=`${qi}/liquidity/my`,Bu=`${qi}/vip/my`,Fu=1e3,Ri=60*Fu,Pi=60*Ri,mr=24*Pi,he={PUBLIC_KEY:`${wt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${wt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${wt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${wt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${wt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${wt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${wt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${wt}:bridge:route-type`,BRIDGE_HISTORY:`${wt}:bridge:history`,OP_REMINDER:`${wt}:op:reminder`},Di=H.atom(!1),Bi=H.atom(!1);function Dt(){const e=xa(),[t,s]=H.useAtom(Di),o=H.useSetAtom(Bi),a=Pn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function Dn(){const e=xa(),[t,s]=H.useAtom(Bi),o=H.useSetAtom(Di),a=Pn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Fi(){const e=Me(),{closeDrawer:t}=Dt(),{closeModal:s}=Dn(),{disconnect:o}=Qe.useDisconnect(),{clearAllWallets:a}=so();return()=>{e("/blank"),t(),s(),o(),a(),localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM),localStorage.removeItem(he.BRIDGE_QUANTITY),localStorage.removeItem(he.BRIDGE_SLIPPAGE_PERCENT)}}function Uu(){const e=Yt(),t=xn(),{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??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Ou(){const e=Yt(),t=xn(),{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??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Vu(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Yo.PubKey.decode(e.value);return En.encodeSecp256k1Pubkey(t)}return Gs.decodeOptionalPubkey(e)}function Ku({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Fl.BaseAccount.decode(t),i=Vu(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Le.accountFromAny({typeUrl:e,value:t})}const Ui="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Oi="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Vi="cosmos-sdk/AllowedMsgAllowance";function Wu(){const e=fa.aminoConverters[Ui];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Os=Wu();function Ki(e){if(e.typeUrl===Oi){const t=cn.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Vi,value:{allowance:Ki(t.allowance),allowed_messages:t.allowedMessages}}}return Os.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Wi(e){if(e.type===Vi){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Wi(t.allowance);return{typeUrl:Oi,value:cn.AllowedMsgAllowance.encode(cn.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Os.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const zu={...fa.aminoConverters,[Ui]:{...Os,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Ki(e.allowance)}:Os.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Wi(e.allowance)})}},is=()=>{const e=se();return new Gs.Registry([...fa.protoRegistry,...e.protoTypes??[]])},cs=()=>{const e=se();return{...zu,...e.aminoConverters}},bn=()=>{const e=cs();return new Le.AminoTypes(e)};class Hu{constructor(t,s,o){this.address=t,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const t=`${he.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(t);if(s)return this.cachedPublicKey=de.fromHex(s),de.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,de.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,de.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?de.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=kt.ethers.hashMessage(t),a=kt.ethers.SigningKey.recoverPublicKey(o,s);return ht.Secp256k1.compressPubkey(de.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(t,s){if(this.address!==t)throw new Error("Signer address does not match the provided address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=await this.signMessage(o),r=de.fromHex(a.replace("0x","")).subarray(0,-1),c=ht.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Si(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function zi(){const e=is(),t=bn(),s=ls(),o=us();return async function(a,r,i,c,l,u){const m=u?.customSigner??s;if(!m)throw new Error("Signer not initialized");const d=await o(a),{accountNumber:h,sequence:f}=await Hi({getSequence:N=>d.getSequence(N),signerAddress:r,incrementSequence:u?.incrementSequence??0,allowMissingAccount:!!u?.customSigner}),[g]=await m.getAccounts(),p=Ai(ba(g.pubkey)),y=li.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),b=Zn.makeSignDoc(x,c,a,l,h,f),{signature:j,signed:v}=await m.signAmino(r,b),C={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:v.msgs.map(N=>t.fromAmino(N)),memo:l}},I=e.encode(C),T=sr.Int53.fromString(v.fee.gas).toNumber(),A=sr.Int53.fromString(v.sequence).toNumber(),$=Gs.makeAuthInfoBytes([{pubkey:p,sequence:A}],v.fee.amount,T,v.fee.granter,v.fee.payer,y);return Ze.TxRaw.fromPartial({bodyBytes:I,authInfoBytes:$,signatures:[de.fromBase64(j.signature)]})}}function Qu(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Hi({getSequence:e,signerAddress:t,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(t);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Qu(a,t))return{accountNumber:0,sequence:s};throw a}}function ls(){const e=ie(),{signMessageAsync:t}=Qe.useSignMessage(),s=ce();return _.useMemo(()=>new Hu(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const Ao=new Map,Rs=new Map;function Gu(e,t){const s=`${e}:${t}`;Rs.delete(s)}function ja(){const e=lt();return async t=>{if(Ao.has(t))return Ao.get(t);const{rpcUrl:s}=e(t),o=await or.Comet38Client.create(new or.HttpClient(s));return Ao.set(t,o),o}}function us(){const e=is(),t=bn(),s=ls(),o=ie(),a=ja();return async r=>{const i=`${o}:${r}`;if(Rs.has(i))return Rs.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Le.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:Ku,broadcastPollIntervalMs:500});return Rs.set(i,l),l}}function Qi(){const{connector:e}=Qe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new kt.BrowserProvider(await e.getProvider())}}class hn extends Error{constructor(t){super(t),this.name="TimeoutError"}}function Gi(e,t,s){let o;const a=new Promise((r,i)=>{o=setTimeout(()=>i(new hn(s)),t)});return Promise.race([e,a]).finally(()=>{clearTimeout(o)})}function Yi(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Zi(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function Yu(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Ji(){const e=ie(),t=lt();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:u}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return u}catch(u){if(u instanceof z.HTTPError&&[404,500].includes(u.response.status))return null;throw u}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=z.create({prefixUrl:c.restUrl}),{grants:u}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return u},fetchAllGrants:async r=>{const i=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,u=await Js(l,{prefixUrl:i.restUrl},"grants");return Yi(u)}}}const Vs=qe.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),Zu=4,Xi=4;function Ju(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function Ca(){const e=se(),t=xn(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(t.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 Xu(){const{data:e}=oo(),t=Ca();return(s,o)=>{const a=o.every(i=>{const c=t[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function oo(){const e=ie(),t=Ca(),s=Ju(t),{fetchFeegrant:o,fetchAllGrants:a}=Ji();return E.useQuery({queryKey:Vs.expirations(e,s,t).queryKey,queryFn:()=>ed({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:V.MINUTE,retry:1})}async function ed(e){const{initiaAddress:t,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},u=[];for(const[d,h]of Object.entries(s))r[d]=null,i[d]=void 0,c[d]=!1,h.length>0&&u.push([d,h]);if(u.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await ec(u,Zu,async([d,h])=>{const f=wa(t,d);try{const g=await o(d),p=f===void 0?g:f===null?[]:g.filter(C=>C.grantee===f),y=sd(p,h);if(y.length===0)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const x=await nd({chainId:d,candidates:y,fetchFeegrant:a,concurrency:Xi});if(!x)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const b=x.grantee.grants.filter(C=>h.includes(C.authorization.msg)).map(C=>C.expiration),j=Zi(x.feegrant.allowance),v=[...b,j],w=ka(v);return{chainId:d,expectedAddress:f,expiration:w?new Date(w):void 0,grantee:x.grantee.grantee}}catch{return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0}}});for(const d of m)l[d.chainId]=d.expectedAddress,r[d.chainId]=d.expiration,i[d.chainId]=d.grantee;for(const[d]of u)c[d]=od({expiration:r[d],grantee:i[d],expectedAddress:l[d]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function ec(e,t,s){const o=new Array(e.length),a=Math.max(1,t);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function td(e){const t=Yu(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Zi(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Xe.isFuture(a)}async function nd(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Xi}=e,r=await ec(s,a,async i=>{const c=await o(t,i.grantee);return c&&td(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function sd(e,t){if(t.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(u=>!u.expiration||Xe.isFuture(new Date(u.expiration))),c=i.map(u=>u.authorization.msg);t.every(u=>c.includes(u))&&o.push({grantee:a,grants:i})}return o}function od(e){const{expiration:t,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(t){case null:return!1;case void 0:return a;default:return a&&Xe.isFuture(t)}}function ad(){const{data:e,refetch:t}=oo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Xe.isFuture(c));if(o.length===0)return;const a=ka(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{t()},r+100);return()=>clearTimeout(i)},[e,t])}function ka(e){const t=e.filter(s=>s!==void 0);if(t.length!==0)return[...t].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const tc=_.createContext(null),ao=()=>_.useContext(tc);class nc extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(t,s,o,a,r,i,c){super(t),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const rd=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,So=new Map;function id(e){const t=e.match(rd);if(!t)return null;const[,s,o,a]=t;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function cd(e,t,s){const o=`${e}:${t}`;if(So.has(o))return So.get(o);try{const a=t==="0x1"?"0x1.json":`${e}/${t}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return So.set(o,i),i}catch{return null}}function ld(e,t,s,o,a,r,i){return new nc(e,t,s,o,a,r,i)}async function Nn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await ct(e);const o=id(e.message);if(!o)return await ct(e);const a=await cd(t.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,u=!!c;return ld(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,u)}const ud=10;function sc(){const e=ie();return(t,s)=>E.queryOptions({queryKey:Xs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":ud},{txs:a}=await z.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:V.SECOND})}function dd(e,t){const s=sc();return E.useSuspenseQuery(s(e,t))}function md(e,t){const s=e.flatMap((o,a)=>(t[a]??[]).map(i=>({...i,chain:o})));return L.sortWith([L.descend(o=>new Date(o.timestamp).getTime())])(s)}const hd=()=>{const e=_e(),t=sc(),s=E.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map(L.prop("data")),a=md(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Na(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await z.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.slice().sort(L.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:hi;return{amount:q(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:t,fixed_min_gas_price:s})=>{if(L.isNil(s))throw new Error(`${t} has no price`);return{amount:String(s),denom:t}})}function Ia(e){const{data:t}=E.useSuspenseQuery({queryKey:Zs.gasPrices(e).queryKey,queryFn:()=>Na(e),staleTime:V.SECOND});return t}function Aa(e){const t=ie(),{data:s}=dd(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=>k.InitiaAddress.equals(t,kt.computeAddress(`0x${de.toHex(ht.Secp256k1.uncompressPubkey(de.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const oc="approve",ro=H.atom(),ac=H.atom(null),fd=Ht,pd=1.5;function gd({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(t)??r(s)??a[0]}function _d({simulatedGas:e,gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),u=gd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Le.calculateFee(l,Le.GasPrice.fromString(`${u.amount}${u.denom}`))}function yd({derivedAddress:e,messages:t,encoder:s}){return{messages:Li({granteeAddress:e,messages:t,encoder:s})}}function xd(e){if(!(e instanceof Error))return!1;const t=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=t.includes("user rejected")||t.includes("rejected the request")||t.includes("user denied")||t.includes("denied by user")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("cancelled by user")||t.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function bd({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Le.createProtobufRpcClient(e),i=new ar.ServiceClientImpl(r),c=Ze.Tx.fromPartial({authInfo:Ze.AuthInfo.fromPartial({fee:Ze.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:li.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ze.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(ar.SimulateRequest.fromPartial({txBytes:Ze.Tx.encode(c).finish()}))}function wd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function vd({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},u){const m=async()=>u.signWithEthSecp256k1(t,e,s,a,o),d=(y,x)=>{u.onAutoSignFallback?.({chainId:t,reason:y,errorMessage:wd(x)})};if(!c)return m();if(!u.validateAutoSign(t,s))return d("validation_failed"),m();let f=u.getWallet(t),g=!1;if(!f&&l)try{f=await u.deriveWallet(t)}catch(y){if(xd(y))throw y;d("derive_wallet_failed",y),g=!0,f=void 0}if(!f)return g||d("missing_derived_wallet"),m();let p;try{const y=i??await u.getSigningClient(t);p=await u.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:y})}catch(y){return d("fee_computation_failed",y),m()}try{return await u.signWithDerivedWallet(t,e,s,p,o,f)}catch(y){return d("derived_wallet_sign_failed",y),m()}}function rc(){const e=ie(),{autoSignFeePolicy:t}=se(),s=lt(),o=ja(),a=us(),r=is(),i=Xu(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:u}=so(),m=zi(),d=Pn(),h=p=>{const y=t?.[p];return{gasMultiplier:y?.gasMultiplier??fd,maxGasMultiplierFromSim:y?.maxGasMultiplierFromSim??pd,allowedFeeDenoms:y?.allowedFeeDenoms}},f=async({chainId:p,messages:y,memo:x,derivedWallet:b,preferredFeeDenom:j,fallbackFeeDenom:v,client:w})=>{const C=s(p),I=await Na(C),A=yd({derivedAddress:b.address,messages:y,encoder:r}).messages.map(K=>r.encodeAsAny(K)),$=Ai(ba(b.publicKey)),{sequence:N}=await Hi({getSequence:K=>w.getSequence(K),signerAddress:b.address,incrementSequence:0,allowMissingAccount:!0}),S=await o(p),P=Le.QueryClient.withExtensions(S,Le.setupTxExtension),{gasInfo:F}=await bd({queryClient:P,messages:A,memo:x,pubkey:$,sequence:N}),D=F?Number(F.gasUsed.toString()):0,Z=h(p);return _d({simulatedGas:D,gasPrices:I,preferredFeeDenom:j,fallbackFeeDenom:v,policy:Z})},g=async(p,y,x,b,j,v)=>{let w=v??c(p);w||(w=await l(p));const C=u(p);if(!C)throw new Error("Derived wallet key not initialized");return await Ru({chainId:p,granterAddress:y,messages:x,fee:b,memo:j,derivedWallet:w,privateKey:C,encoder:r,signWithEthSecp256k1:m})};return p=>vd({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:y,reason:x,errorMessage:b})=>{d("AutoSign Fallback",{chainId:y,reason:x,errorMessage:b})}})}function ic(){const e=H.useAtomValue(ro);if(!e)throw new Error("Tx request not found");return e}function io(){const e=Me(),t=ie(),{defaultChainId:s,registryUrl:o}=se(),a=lt(),{openDrawer:r,closeDrawer:i}=Dt(),{openModal:c,closeModal:l}=ao(),u=H.useSetAtom(ro),m=H.useSetAtom(ac),d=ja(),h=us(),f=ls(),g=is(),p=rc(),y=async({messages:A,memo:$,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,$)}catch(S){throw await Nn(S,a(N),o)}},x=async({messages:A,memo:$,chainId:N=s})=>{const S=await d(N),P=Le.QueryClient.withExtensions(S,Le.setupTxExtension),F=A.map(O=>g.encodeAsAny(O)),[D]=await f.getAccounts(),Z=En.encodeSecp256k1Pubkey(D.pubkey),K=await h(N),{sequence:W}=await K.getSequence(t);return P.tx.simulate(F,$,Z,W)},b=async({txRequest:A,broadcaster:$})=>{const S={...{memo:"",chainId:s,gas:A.gas||await y(A),gasAdjustment:Ht,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((P,F)=>{u({txRequest:S,resolve:async Z=>{try{const K=await h(S.chainId),W=await $(K,Ze.TxRaw.encode(Z).finish());P(W),typeof S.internal=="string"&&e(S.internal)}catch(K){F(await Nn(K,a(S.chainId),o))}finally{D()}},reject:Z=>{F(Z),D()}}),S.internal?c({path:"/tx"}):r("/tx");const D=()=>{if(!S.internal){e("/blank"),i();return}l()}})},j=async A=>{const $=A.chainId??s;try{const N=await b({txRequest:A,broadcaster:async(S,P)=>await S.broadcastTxSync(P)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:$,status:"loading"}),T({txHash:N,chainId:A.chainId}).then(S=>{m({status:S.code===0?"success":"error",chainId:$,txHash:N})}).catch(()=>{m({status:"error",chainId:$,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:$,error:N}),N}},v=(A,$=30*1e3,N=.5*1e3)=>b({txRequest:A,broadcaster:async(S,P)=>{const F=await S.broadcastTx(P,$,N);if(F.code!==0)throw new Error(F.rawLog);return F}}),w=async({chainId:A,messages:$,memo:N="",fee:S,preferredFeeDenom:P})=>{const F=await h(A),D=await p({chainId:A,messages:$,memo:N,fee:S,preferredFeeDenom:P,client:F,allowWalletDerivation:!0});return{client:F,signedTx:D}},C=async A=>{const $=A.chainId??s;try{const{client:N,signedTx:S}=await w({...A,chainId:$});return await N.broadcastTxSync(Ze.TxRaw.encode(S).finish())}catch(N){throw await Nn(N,a($),o)}},I=async(A,$=30*1e3,N=.5*1e3)=>{const S=A.chainId??s;try{const{client:P,signedTx:F}=await w({...A,chainId:S}),D=await P.broadcastTx(Ze.TxRaw.encode(F).finish(),$,N);if(D.code!==0)throw new Error(D.rawLog);return D}catch(P){throw await Nn(P,a(S),o)}},T=async({chainId:A=s,...$})=>{try{const N=await h(A);return await cc({...$,client:N})}catch(N){throw N instanceof hn?N:await Nn(N,a(A),o)}};return{estimateGas:y,simulateTx:x,requestTxSync:j,requestTxBlock:v,submitTxSync:C,submitTxBlock:I,waitForTxConfirmation:T}}async function cc({txHash:e,client:t,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await t.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new hn(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const jd="/cosmos.authz.v1beta1.MsgExec";function Cd(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function kd(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function Nd(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function Id(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function lc(e){const t=[Vs.expirations._def,Vs.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function uc(){const e=ie(),{fetchFeegrant:t,fetchGrants:s}=Ji();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await t(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:ui.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=Id(c).map(d=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:ha.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:d})}));return[...l,...m]}}function Ad(){const e=ie(),t=Ca(),{requestTxBlock:s}=io(),o=E.useQueryClient(),[a,r]=H.useAtom(rs),{closeDrawer:i}=Dt(),c=uc(),{deriveWallet:l}=so();return E.useMutation({mutationFn:async u=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const d=t[m];if(!d||d.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Gu(e,m);const f=wa(e,m),g=kd({currentGrantee:h.address,expectedGrantee:f}),y=(await Promise.all(g.map(C=>c({chainId:m,grantee:C})))).flat(),x=u===0?void 0:Xe.addMilliseconds(new Date,u),b={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:cn.BasicAllowance.encode(cn.BasicAllowance.fromPartial({expiration:x})).finish()},j={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:ui.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:cn.AllowedMsgAllowance.encode(cn.AllowedMsgAllowance.fromPartial({allowance:b,allowedMessages:[jd]})).finish()}})},v=d.map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:ha.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:rr.GenericAuthorization.encode(rr.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:x}})})),w=[...y,j,...v];return await s({messages:w,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:u,derivedWallet:m})=>{e&&Eu(e,u,m.address),await lc(o),a?.resolve()},onError:u=>{a?.reject(u)},onSettled:()=>{r(null),i()}})}function dc(e){const t=se(),s=_e(),o=lt(),{getWallet:a,clearWallet:r}=so(),{requestTxBlock:i}=io(),c=E.useQueryClient(),l=uc(),{data:u,refetch:m}=oo();return E.useMutation({mutationFn:async(d=t.defaultChainId)=>{const h=a(d),f=u?.granteeByChain[d];let g;e?.grantee||(g=(await m()).data?.granteeByChain[d]);const p=Cd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const x=(await Promise.all(p.map(b=>l({chainId:d,grantee:b})))).flat();return x.length===0?{chainId:d,didBroadcast:!1}:(await i({messages:x,chainId:d,internal:e?.internal}),{chainId:d,didBroadcast:!0})},onSuccess:async({chainId:d,didBroadcast:h})=>{await lc(c);const f=o(d),g=s.filter(v=>v.bech32_prefix===f.bech32_prefix).map(v=>v.chain_id).filter(v=>v!==d);let p;try{p=(await m()).data}catch{p=void 0}const y=p??u;let x=!1;g.length>0&&y&&(x=g.some(v=>y?.isEnabledByChain[v]));const b=h?p?.isEnabledByChain[d]:(p??u)?.isEnabledByChain[d];Nd({isEnabledOnTargetChain:b,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(d)}})}const Sa=[{value:10*Ri,label:"for 10 minutes"},{value:Pi,label:"for 1 hour"},{value:mr,label:"for 1 day"},{value:7*mr,label:"for 7 days"},{value:0,label:"until revoked"}],Zo=Sa[0].value;function Sd(e){return e===void 0?Zo:Sa.some(t=>t.value===e)?e:Zo}function Td(){const{defaultChainId:e}=se(),{openDrawer:t}=Dt(),s=H.useSetAtom(rs),o=dc(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=oo();return{...a,isLoading:r,enable:async(l=e,u)=>new Promise((m,d)=>{s({chainId:l,defaultDuration:Sd(u?.defaultDuration),resolve:m,reject:d}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function mc(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function Ed(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),q(0)).toString()}function $d(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??ya}}function hr(e){return L.pick(["chainId","name","logoUrl"],e)}function Md(e){return L.sortWith([L.descend(({symbol:t})=>t===pt),L.descend(mc),L.descend(({assets:t})=>t.length),L.ascend(({symbol:t})=>t)])(e)}function Ld(e){return L.sortWith([L.descend(({value:t})=>t??0),L.descend(({quantity:t})=>Number(t)),L.ascend(({chain:t})=>t.name)])(e)}function qd(e,t){return L.sortWith([L.descend(({chain:s})=>s.chainId===t),L.ascend(({chain:s})=>s.name),L.ascend(({denom:s})=>s)])(e)}function Rd(e,t){return L.sortWith([L.descend(({chainId:s})=>s===t),L.descend(L.prop("value"))])(e)}function Pd(e,t,s,o,a){const r=e.find(d=>d.metadata?.is_l1)?.chainId,i={};for(const d of e){const h=d.chainId,f=t[h]??[],g=s[h],p=o[h],y=[];for(const{amount:x,denom:b}of f){if(!q(x).gt(0))continue;const j=g?.find(T=>T.denom===b),v=p?.find(T=>T.id===b)?.price,w=j?.decimals??0,C=k.fromBaseUnit(x,{decimals:w}),I=v?q(C).times(v).toNumber():void 0;y.push({...$d(b,j),amount:x,denom:b,decimals:w,quantity:C,price:v,value:I,address:j?.address,unlisted:!j,chain:hr(d)})}i[h]=y}const c=new Map;for(const[d,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===d);if(!f)continue;const g=h.reduce((p,{value:y})=>p+(y??0),0);c.set(d,{...hr(f),value:g})}const l=new Map;for(const d of Object.values(i))for(const h of d)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const u=[];for(const[d,h]of l){const f=L.head(h);if(!f)continue;const g=Ld(h),p=g.reduce((x,{value:b})=>x+(b??0),0),y=g.reduce((x,{quantity:b})=>x.plus(b),q(0)).toNumber();u.push({symbol:d,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:y})}const m=[];for(const d of Object.values(i))for(const h of d)h.unlisted&&m.push(h);return{chainsByValue:Rd(Array.from(c.values()),a),assetGroups:Md(u),unlistedAssets:qd(m,r),totalValue:u.reduce((d,h)=>d+h.totalValue,0)}}function Ta(){const{defaultChainId:e}=se(),t=_e(),s=du(),o=os(),a=_a(),r=t.map(h=>h.chainId),i=L.zipObj(r,s.map(L.prop("data"))),c=L.zipObj(r,o.map(L.prop("data"))),l=L.zipObj(r,a.map(L.prop("data"))),u=Pd(t,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...u,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function ie(){const e=Bn();return e?k.InitiaAddress(e).bech32:""}function Bn(){const{address:e}=Qe.useAccount();return e?k.InitiaAddress(e).hex:""}function Yt(){const e=xn(),t=ie(),s=Bn();return e.metadata?.minitia?.type==="minievm"?s:t}function hc(e){const t=Yt(),s=e??t,o=vi();return E.useQuery({queryKey:Xs.username(o.restUrl,s).queryKey,queryFn:()=>o.getUsername(s),enabled:!!s,staleTime:V.MINUTE})}function tt(){const e=Yt(),t=ie(),s=Bn(),{data:o}=hc(),a=ls(),r=Fi(),i=Td(),{isDrawerOpen:c,openDrawer:l}=Dt(),{isModalOpen:u}=Dn(),m=()=>{l("/")},d=()=>{l("/connect")},h=b=>{l("/bridge",b)},f=Uu(),g=Ou(),p=io();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||u,openConnect:d,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const Dd="_status_tn9m1_1",Bd="_error_tn9m1_9",fr={status:Dd,error:Bd},je=({error:e,children:t})=>n.jsx("p",{className:B(fr.status,{[fr.error]:e}),role:e?"alert":"status",children:t}),xe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(je,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(je,{children:"Loading..."}),children:s})=>n.jsx(di.ErrorBoundary,{...e,children:n.jsx(_.Suspense,{fallback:t,children:s})}),gn=1n<<64n,Fd=1n<<63n,fc=(1n<<128n)-1n;function Gt(e){const t=BigInt(e);return t>=Fd?t-gn:t}const Ud=(1n<<256n)-1n,Wt=443636n,Od=4295048017n,Vd=18446744073709551616n,Kd=79226673515401279992447579062n,Wd=255738958999603826347141n;function zd(e,t,s){const o=Number(Gt(e)),a=Number(Gt(t)),r=Math.floor(-Number(Wt)/s)*s,i=Math.floor(Number(Wt)/s)*s;return o===r&&a===i}function pc(e){return e>>64n}function Hd(e){const t=e>>64n;return e%gn!==0n?t+1n:t}function Mn(e){if(e<0n||e>fc)throw new Error("INPUT_OUT_OF_RANGE");return e}function Qd(e,t){const s=e*t>>64n;if(s>fc)throw new Error("OVERFLOW");return s}function Ea(e,t){return e>t?[t,e]:[e,t]}function Gd(e,t,s,o){if(e===t)return 0n;const[a,r]=Ea(e,t);if(a===0n||r===0n)return 0n;const i=s*gn,c=r-a,l=i*c;if(l===0n)return 0n;const u=a*r;return o?(l-1n)/u+1n:l/u}function Yd(e,t,s,o){if(e===t)return 0n;const[a,r]=Ea(e,t),c=(r-a)*s;return o?Hd(Mn(c)):pc(Mn(c))}function pr(e,t,s){return Gd(e,t,s<0n?-s:s,s>=0n)}function gr(e,t,s){return Yd(e,t,s<0n?-s:s,s>=0n)}const To=1n<<64n,_r=1n<<65n,Zd=64n;function Jd(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<Zd-1n,r=0n,i=1;for(;t>=_r;)t>>=1n,s+=To;for(;t<To;)i=0,t<<=1n,o+=To;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=_r&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?Mn(s):Mn(o-s);return[i,c]}function zt(e){const t=e<0n?-e:e;if(t>Wt)throw new Error("MAX_TICK");let s=(t&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(t&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(t&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(t&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(t&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(t&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(t&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(t&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(t&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(t&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(t&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(t&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(t&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(t&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(t&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(t&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(t&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(t&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(t&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=Ud/s);const o=s/gn;return s%gn!==0n?o+1n:o}function Xd(e){if(e<Od||e>=Kd)throw new Error("INVALID_SQRT_PRICE");const[,t]=Jd(Mn(e)),s=Qd(t,Mn(Wd)),o=pc(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<Vd?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Wt&&(a=-Wt),i>Wt&&(i=Wt),zt(i)<=e){if(i>=Wt)throw new Error("GTE_MAX_TICK");if(zt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(zt(r)<=e)return r;if(zt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function em(e,t,s,o){const[a,r]=Ea(t,s);return e<a?[pr(a,r,o),0n]:e<r?[pr(e,r,o),gr(a,e,o)]:[0n,gr(a,r,o)]}function tm({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=zt(Gt(e)),r=zt(Gt(t));return em(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const Eo=gn*gn,nm=1e-300,sm=BigInt(Number.MAX_SAFE_INTEGER);function yr(e){const t=e*e,s=t/Eo,o=t%Eo;return s>sm?Number(s):Number(s)+Number(o)/Number(Eo)}function xr(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,nm)}function om({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=zt(Gt(e)),a=zt(Gt(t)),r=yr(o),i=yr(a);return s?{min:xr(i),max:xr(r)}:{min:r,max:i}}const wn=qe.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,s)=>[e,t,s],clammFees:(e,t,s)=>[e,t,s],clammIncentive:(e,t,s,o)=>[e,t,s,o]}),$a={lens:"lens",pool:"pool",farming:"farming"},Ma={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function am(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:k.InitiaAddress(e).hex}function Ks(e){return de.toBase64(k.InitiaAddress(am(e),32).bytes)}function gc(e,t){return`${e}:${t}`}function rm(e){return`clamm:${e}`}function im(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function cm(e){return e.map(t=>({tokenAddress:t.token_address,lpMetadata:t.lp_metadata,tickLower:t.tick_lower,tickUpper:t.tick_upper,liquidity:t.liquidity,incentives:t.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function lm(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await z.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...im(r.positions)),o=r.pagination.next_key||void 0}while(o);return cm(s)},staleTime:V.MINUTE})}function um(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:$a.lens,functionName:"get_pool_info",typeArgs:[],args:[Ks(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function dm(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:$a.pool,functionName:"fees_available",typeArgs:[],args:[Ks(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function mm(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:$a.farming,functionName:"pending_reward_info",typeArgs:[],args:[Ks(r.tokenAddress),Ks(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(gc(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function _c(e){const{dexUrl:t}=se(),o=E.useSuspenseQueries({queries:e.map(a=>({queryKey:wn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await z.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:V.MINUTE}))}).map(a=>a.data);return _.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function yc(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function hm(e){return _c(e)}function fm(e){const t=ce(),s=Qt(t),o=_.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=_.useMemo(()=>e.map(i=>k.denomToMetadata(i)),[e]),r=_c(a);return _.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const u=a[l];if(!u){i.set(c,null);return}const m=r.get(u);if(!m){i.set(c,null);return}if(c===Pu){i.set(c,{...m,symbol:Du});return}const d=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:d})}),i},[e,a,r,o])}const pm="lock_staking";function xc(e,t){const s=`${t}::lock_staking::StakingAccount`,o=k.createObjectAddress(e,s);return k.InitiaAddress(o).bech32}const ds=qe.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,t)=>[e,t],undelegations:(e,t,s)=>[e,t,s],lockStaking:(e,t,s)=>[e,t,s],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,s)=>[e,t,s]});function La(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.delegations(e,t||"").queryKey,queryFn:async()=>t?(await z.get(`${e}/initia/mstaking/v1/delegations/${t}`).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=k.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},u=o.get(c)??[];u.push(l),o.set(c,u)}}return o},staleTime:V.MINUTE})}function qa(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie(),o=s?xc(s,t):"";return E.useSuspenseQuery({queryKey:ds.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const u of l.balance){const m=k.denomToMetadata(u.denom),d={denom:u.denom,metadata:m,amount:u.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(d),r.set(m,h)}}return r},staleTime:V.MINUTE})}function Ra(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie();return E.useSuspenseQuery({queryKey:ds.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=k.createMoveClient(e);return await o({moduleAddress:t,moduleName:pm,functionName:"get_locked_delegations",typeArgs:[],args:[de.toBase64(k.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:V.MINUTE})}function bc(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=k.denomToMetadata(s.denom);let a=new q(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=t.get(o);if(r){const i=new q(r.amount);a=a.plus(i)}t.set(o,{denom:s.denom,amount:a.toString()})}return t}function wc(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await z.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:bc,staleTime:V.MINUTE})}function vc(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie(),o=s?xc(s,t):"";return E.useSuspenseQuery({queryKey:ds.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:bc,staleTime:V.MINUTE})}function Pa(){const e=ce(),t=Qt(e),{data:s,isLoading:o}=Pt(e),{data:a}=La(),{data:r}=qa(),{data:i}=Ra(),c=_.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Bs(c),u=_.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=_.useMemo(()=>{const f=new Map;for(const g of t)f.set(g.denom,g);return f},[t]),d=_.useMemo(()=>{const f=[],g=p=>{const y=m.get(p);return y?{symbol:y.symbol,decimals:y.decimals}:null};for(const[p,y]of a){const x=l.get(p)??y[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j};f.push({type:"staking",validator:v.validator,balance:T})}}for(const[p,y]of i){const x=l.get(p);if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j},A=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(A)?0:A,balance:T})}}for(const[p,y]of r){const x=l.get(p)??y[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j},A=new Date(v.completionTime).getTime(),$=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:$,balance:T})}}return f.filter(p=>p.type!=="fungible-position"&&p.balance.denom===Je)},[a,i,r,l,m,u]),h=_.useMemo(()=>d.reduce((f,g)=>g.type==="fungible-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[d]);return{positions:d,totalValue:h,isLoading:o}}function gm(e){const t=new Map;for(const s of e){const o=k.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function _m(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function ym(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:V.MINUTE})}function xm(){const e=ce(),t=as(e),s=_.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=ym(s);return _.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return gm(a)},[t,o])}function bm(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${t}/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:V.MINUTE})}function wm(e,t,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of t){const c=i[0]?.denom;c&&c!==Je&&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!==Je&&a.add(r)}return Array.from(a)}function vm(e){const t=[];for(const[,s]of e)s&&s!==Je&&t.push(s);return t}function jm(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=yc(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 $o(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(k.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function Cm(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(k.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function km(e,t,s,o){for(const[a,r]of e){const i=k.denomToMetadata(a),c=t?.get(i),l=c?k.fromBaseUnit(c.amount,{decimals:it}):"0",u=s?.get(i),m=u?k.fromBaseUnit(u.amount,{decimals:it}):"0",d=Number(l)+Number(m);d<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(d),totalValue:d*o})}}function Nm(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function co(){const e=ce(),t=Qt(e),s=ie(),o=xm(),{data:a}=La(),{data:r}=Ra(),{data:i}=qa(),{data:c}=wc(),{data:l}=vc(),{data:u}=Pt(e),{data:m}=lm(s),d=_.useMemo(()=>{const F=new Map;for(const D of m){const Z=F.get(D.lpMetadata)??[];Z.push(D),F.set(D.lpMetadata,Z)}return F},[m]),h=_.useMemo(()=>Array.from(d.keys()),[d]),f=hm(h),g=um(h),p=_.useMemo(()=>m.map(F=>F.tokenAddress),[m]),y=dm(p),x=_.useMemo(()=>{const F=[];for(const D of m)for(const Z of D.incentives)F.push({tokenAddress:D.tokenAddress,incentiveAddress:Z.incentiveAddress});return F},[m]),b=mm(x),j=_.useMemo(()=>{const F=new Set;for(const D of m)for(const Z of D.incentives)F.add(Z.rewardMetadata);return Array.from(F)},[m]),v=Bs(j,{failSoft:!0}),w=_.useMemo(()=>wm(o,a,r,i),[o,a,r,i]),C=Bs(w),I=_.useMemo(()=>vm(C),[C]),{data:T}=bm(I),A=fm(I),$=_.useMemo(()=>{const F=new Map;for(const D of t)F.set(D.denom,D);return F},[t]),N=_.useMemo(()=>{const F=new Map;for(const D of u??[])F.set(D.id,D.price);return F},[u]),{rows:S,totalValue:P}=_.useMemo(()=>{const F=u?.find(W=>W.id===Je)?.price??0,D=new Map;for(const W of I)D.set(W,jm(W,A,$));$o(o,C,T,D,"deposit"),$o(a,C,T,D,"staking"),Cm(r,C,T,D,"lockStaking"),$o(i,C,T,D,"unstaking"),km(D,c,l,F);for(const W of h){const O=d.get(W)??[];if(O.length===0)continue;const J=f.get(W),Q=g.get(W),ee=rm(W),ue=J?.coins.map(le=>le.denom)??[],ye=J?yc(J,$).filter(Boolean):[],me=ue.map(le=>$.get(le)?.symbol||le),Ce=J?.symbol||me.join("-")||ee,Se=_m(ue,$),ke=O.map(le=>{let G,$t,Xt,Mt=!1,bt=0,en=0;try{const dt=om({tickLower:le.tickLower,tickUpper:le.tickUpper});G=dt.min,$t=dt.max}catch{G=void 0,$t=void 0}if(Q){try{const dt=Xd(BigInt(Q.sqrtPrice)),Ue=Gt(le.tickLower),nt=Gt(le.tickUpper),X=Number(Q.tickSpacing);Mt=Number.isFinite(X)&&X>0?zd(le.tickLower,le.tickUpper,X):!1,Xt=Mt||dt>=Ue&&dt<nt}catch{Xt=void 0,Mt=!1}if(J&&ue.length>0)try{tm({sqrtPrice:Q.sqrtPrice,tickLower:le.tickLower,tickUpper:le.tickUpper,liquidity:le.liquidity}).forEach((Ue,nt)=>{const X=J.coins[nt];if(!X)return;const ve=$.get(X.denom)?.decimals??6,Oe=N.get(X.denom)??0,mt=Number(k.fromBaseUnit(String(Ue),{decimals:ve}));bt+=mt*Oe})}catch{bt=0}}return J&&((y.get(le.tokenAddress)??[]).forEach((Ue,nt)=>{const X=J.coins[nt];if(!X)return;const ve=$.get(X.denom)?.decimals??6,Oe=N.get(X.denom)??0,mt=Number(k.fromBaseUnit(Ue,{decimals:ve}));en+=mt*Oe}),le.incentives.forEach(Ue=>{const nt=b.get(gc(le.tokenAddress,Ue.incentiveAddress))??"0",X=v.get(Ue.rewardMetadata);if(!X)return;const ve=$.get(X)?.decimals??6,Oe=N.get(X)??0,mt=Number(k.fromBaseUnit(nt,{decimals:ve}));en+=mt*Oe})),{tokenAddress:le.tokenAddress,positionId:Nm(le.tokenAddress),inRange:Xt,isFullRange:Mt,minPrice:G,maxPrice:$t,pricePairLabel:Se,rewardValue:en,value:bt}}),Et=ke.reduce((le,G)=>le+G.value,0),ut=ke.reduce((le,G)=>le+G.rewardValue,0),Re=ye.length>0;D.set(ee,{denom:ee,symbol:Ce,totalAmount:0,totalValue:Et,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:Re?ye:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:W,totalRewardValue:ut,positions:ke}})}const Z=Array.from(D.values()).filter(W=>W.totalAmount>0||W.isClamm).sort((W,O)=>O.totalValue-W.totalValue),K=Z.reduce((W,O)=>W+O.totalValue,0);return{rows:Z,totalValue:K}},[u,I,A,$,o,a,r,i,C,T,c,l,h,d,f,g,y,b,v,N]);return{totalValue:P,rows:S}}const Im=qe.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function Am(e){return e.filter(t=>t.data.length>0).map(t=>{const s=t.data[0].bridge_id,o=t.data[0].version,a=t.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:t.total_claimable_reward,claimedReward:a,initialReward:t.total_vesting_reward,lockedReward:t.total_locked_reward,requiredScore:t.required_score,rollup:{bridgeId:s,version:o}}}).filter(t=>t.initialReward>0).sort((t,s)=>s.initialReward-t.initialReward)}function jc(){const{vipUrl:e}=se(),t=ie();return E.useQuery({queryKey:Im.allVestingPositions(e,t).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:V.MINUTE,enabled:!!t})}function Sm(){const e=_e();return _.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function lo(){const{data:e}=jc(),t=ce(),{data:s}=Pt(t),o=Sm(),a=_.useMemo(()=>s?.find(l=>l.id===Je)?.price??0,[s]),r=_.useMemo(()=>e?Am(e).map(l=>{const u=o(l.rollup.bridgeId),m=Number(k.fromBaseUnit(String(l.lockedReward),{decimals:it})),d=Number(k.fromBaseUnit(String(l.claimableReward),{decimals:it})),h=q(k.fromBaseUnit(String(l.lockedReward),{decimals:it})).times(a).toNumber(),f=q(k.fromBaseUnit(String(l.claimableReward),{decimals:it})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:u?.name??"",logoUrl:u?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:d,claimableRewardValue:f}}).filter(l=>l.lockedReward+l.claimableReward>0):[],[e,a,o]),i=_.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Cc(){const{totalValue:e}=co(),{data:t}=La(),{data:s}=Ra(),{data:o}=qa(),{data:a}=jc(),r=_.useMemo(()=>Array.from(s.keys()),[s]),i=Bs(r),c=ce(),{data:l}=Pt(c),u=_.useMemo(()=>l?.find(d=>d.id===Je)?.price??0,[l]);return _.useMemo(()=>{let m=0,d=0;const h=u??0;for(const[,g]of t)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(k.fromBaseUnit(y,{decimals:it}))*h);for(const[g,p]of s)if(i.get(g)===Je)for(const{amount:y}of p)d+=Number(k.fromBaseUnit(y,{decimals:it}))*h;for(const[,g]of o)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(k.fromBaseUnit(y,{decimals:it}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,y=g.total_claimable_reward??0;f+=Number(k.fromBaseUnit(String(p+y),{decimals:it}))*h}return m+d+e+f},[t,s,i,o,a,u,e])}function Tm(){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"],t={"initia-wallet-widget:ethereum-public-keys":{prefix:he.PUBLIC_KEY,getSuffix:s=>k.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(t)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const u=`${o}:${a(c)}`;localStorage.setItem(u,l)}localStorage.removeItem(s)}catch{}}}const Jo=qe.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,s)=>[e,t,s],initiaPositions:(e,t)=>[e,"initia",t],echelonPositions:(e,t)=>[e,"echelon",t],inertiaPositions:(e,t)=>[e,"inertia",t],ravePositions:(e,t,s)=>[e,"rave",t,s],yominetPositions:(e,t)=>[e,"yominet",t],chainPositions:(e,t,s)=>[e,t,s]});function Da(e,t){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=t[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const u=`${i.chainId}:${l.denom}`;s.has(u)||s.set(u,l.logoUrl);const m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Ln(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const t=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-t:t}function Em(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 $m(e,t=!1){switch(e){case"staking":return t?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Mm(e){const t=new Map;for(const u of e){const m=Em(u);if(!m)continue;const d=t.get(m)??[];d.push(u),t.set(m,d)}const s=new Map,o=new Map;for(const[u,m]of t){const d=m.reduce((f,g)=>f+Ln(g),0),h=m.reduce((f,g)=>f+Math.abs(Ln(g)),0);s.set(u,d),o.set(u,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((u,m)=>{const d=u==="lending"||u==="borrowing"?i:o.get(u)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(u==="lending"||u==="borrowing")&&(m==="lending"||m==="borrowing")?u==="lending"?-1:1:h-d}),l=new Map;for(const u of c)l.set(u,{positions:t.get(u),totalValue:s.get(u)??0});return l}function Lm(e){return e.type==="fungible-position"?e.title:e.balance.denom}function qm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Rm(e){return e.type==="fungible-position"?null:e.balance}function Pm(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 Dm(e){const t=new Map;for(const s of e){const o=t.get(s.type)??[];o.push(s),t.set(s.type,o)}return t}function Bm(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Fm(e){const t=new Map;for(const o of e){const a=Lm(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=Rm(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:qm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+Ln(l),0),totalAmount:i,balance:r}}).sort(Bm)}function kc(e,t){const s=new Map;return e.forEach((o,a)=>{const r=t[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 Um(e,t){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=t.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function Om(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Vm(e,t,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,u=t.get(l)??s.get(c)??"";return u!==i.logoUrl?{...i,logoUrl:u}: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 Km(e,t,s){const o=t?e.filter(i=>{const{symbol:c,assets:l}=i,u=t.toLowerCase();return c.toLowerCase().includes(u)||l.some(({denom:m})=>m.toLowerCase().includes(u))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,u)=>l+(u.value??0),0),totalAmount:c.reduce((l,u)=>l+Number(u.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,u)=>l+(u.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Wm(e,t,s){const o=t?e.filter(({denom:a,address:r})=>{const i=t.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function zm(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=Km(e,s,o),i=Wm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Hm(e,t,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:u,balances:m}=c;if(!Array.isArray(m))continue;const d=t.get(l.toLowerCase()),h=d?.chainId??u??l,f=d?.prettyName??l,g=d?.logoUrl??"",p=s.get(h);for(const y of m){if(y.type==="unknown"){if(!y.amount||y.amount==="0")continue;r.push({symbol:y.denom,logoUrl:"",denom:y.denom,amount:y.amount,decimals:0,quantity:y.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(y.type==="lp"||(y.value??0)<=0&&(y.formattedAmount??0)<=0)continue;let x=y.value;if((x==null||x<=0)&&p){const v=p.get(y.denom)??0;v>0&&(x=y.formattedAmount*v)}const b={symbol:y.symbol,logoUrl:"",denom:y.denom,amount:y.amount,decimals:y.decimals,quantity:String(y.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:g}},j=a.get(y.symbol);j?j.push(b):a.set(y.symbol,[b])}}r.sort((c,l)=>{const u=c.chain.chainId===o,m=l.chain.chainId===o;if(u&&!m)return-1;if(!u&&m)return 1;const d=c.chain.name.localeCompare(l.chain.name);if(d!==0)return d;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)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((d,h)=>(h.value??0)-(d.value??0));let u=0,m=0;for(const d of l)u+=d.value??0,m+=Number(d.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:u,totalAmount:m})}return i.sort(Om),{listedGroups:i,unlistedAssets:r}}function Ba(){return ce().network_type==="testnet"}function Zt(){return $e.useFormContext()}function Qm(){const e=et(),t=Ba(),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=L.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(he.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(he.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(he.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(he.BRIDGE_DST_DENOM),quantity:localStorage.getItem(he.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(he.BRIDGE_SLIPPAGE_PERCENT)});return{...t?o:a,...r,...e}}const Gm={balances:[],positions:[],isLoading:!0,isComplete:!1},Nc=H.atom(0),Ym=1e3;let br=0;function Zm(){const e=H.useSetAtom(Nc);_.useEffect(()=>{const t=Date.now();t-br>=Ym&&(br=t,e(s=>s+1))},[e])}function Jm(){const e=E.useQueryClient(),t=ie(),{minityUrl:s}=se(),o=Ba(),a=H.useAtomValue(Nc),r=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.balances)?l.balances:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.positions)?l.positions:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=_.useEffectEvent((l,u)=>{const m=Jo.ssePortfolio(t??"",s).queryKey,d=e.getQueryData(m)??Gm,h=l.size>0||u.size>0;e.setQueryData(m,{...d,balances:Array.from(l.values()),positions:Array.from(u.values()),isLoading:h?!1:d.isLoading,isComplete:!1})});_.useEffect(()=>{if(!t||o)return;const l=Jo.ssePortfolio(t,s).queryKey,u=e.getQueryData(l),m=new Map,d=new Map;for(const y of u?.balances??[])m.set(y.chainName,y);for(const y of u?.positions??[])d.set(y.chainName,y);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;let g=null,p=!1;return e.setQueryData(l,{balances:u?.balances??[],positions:u?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=y=>{if(!p)try{const x=JSON.parse(y.data);x.type==="balances"?r(x,m):x.type==="positions"&&i(x,d),c(m,d)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[t,o,a])}const wr={balances:[],positions:[],isLoading:!0,isComplete:!1};function ms(){const e=ie(),{minityUrl:t}=se(),s=Jo.ssePortfolio(e??"",t).queryKey,{data:o}=E.useQuery({queryKey:s,queryFn:()=>wr,enabled:!!e,staleTime:V.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??wr}function Xm(){const e=_e();return _.useMemo(()=>{const t=new Map;for(const s of e){const o=s.chain_name.toLowerCase();t.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return t},[e])}function eh(){const{balances:e,positions:t}=ms(),s=_e(),o=_.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return _.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((g,p)=>{if(p.type==="fungible-position")return g+(p.value??0);if(p.balance.type==="unknown")return g;const y=p.balance.value??0;return p.type==="lending"&&p.direction==="borrow"?g-y:g+y},0),c=new Map,l=Array.isArray(e)?e:[],u=Array.isArray(t)?t:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+r(x),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of u){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+i(x),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),d=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return L.sortWith([L.descend(h),L.descend(L.prop("totalBalance"))],d)},[e,t,o])}function th(){const{balances:e}=ms(),t=_e(),s=_a(),o=_.useMemo(()=>kc(t,s),[t,s]);return _.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Um(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const u of l)u.type!=="lp"&&(r+=a(u));return r},[e,o])}function nh(){const{positions:e}=ms();return _.useMemo(()=>{const t=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,u)=>l+t(u),0))}return o},[e])}const Ie=qe.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:q(e.quantity||0).toString()},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function Fe(){const{routerApiUrl:e}=se();return _.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.8.0"}}),[e])}function sh(){const e=Fe();E.usePrefetchQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:V.MINUTE}),E.usePrefetchQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}const oh=()=>(fu(),pu(),null),ah="_loader_1vxch_1",rh={loader:ah},It=({size:e=24,color:t="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${s}px`};return n.jsx("div",{className:rh.loader,style:o,role:"status","aria-label":"Loading"})},ih="_button_1q027_1",ch="_outline_1q027_28",lh="_sm_1q027_46",uh="_full_1q027_53",dh="_small_1q027_57",mh="_unpadded_1q027_88",un={button:ih,outline:ch,sm:lh,full:uh,small:dh,unpadded:mh},Ic=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:B(un.button,{[un.sm]:t,[un.full]:s},a),disabled:!!o||i,"aria-busy":!!o,children:o?n.jsxs(n.Fragment,{children:[n.jsx(It,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:un.loading,children:o})]}):r})},hh=({className:e,...t})=>n.jsx(Ic,{...t,className:B(un.outline,e)}),fh=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:B(un.small,{[un.unpadded]:t},e)}),fe={White:Ic,Outline:hh,Small:fh},ph="_footer_1vp4h_1",gh="_actions_1vp4h_10",vr={footer:ph,actions:gh},Ae=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:B(vr.footer,t),children:[e,n.jsx("div",{className:vr.actions,children:s})]}),_h="_scrollable_13su7_1",yh={scrollable:_h},yt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:B(yh.scrollable,e),children:t}),xh="interwovenkit:";function bh(e){const[t]=e;return typeof t=="string"&&t.startsWith(xh)}function wh(e){e.removeQueries({predicate:t=>bh(t.queryKey)})}function uo(){return Ge.useMediaQuery("(max-width: 576px)")}const Xo="interwoven-kit";function Ac(){const e=document.querySelector(Xo)||document.body.appendChild(document.createElement(Xo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Sc(){const{theme:e,container:t}=se();return _.useEffect(()=>{document.querySelector(Xo)?.setAttribute("data-theme",e)},[e]),t??Ac()}function vh(e){const t=Ac(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const mo=_.createContext(null);function _n(){const{container:e}=_.useContext(mo);return e}function Tc(e){const t=_n();return t?getComputedStyle(t).getPropertyValue(e):""}function jh(){return Ge.useScrollLock(),null}function Ch(e){return/^[A-F0-9]{64}$/i.test(e)}function kh(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return Ch(s)?L.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!k.InitiaAddress.validate(o))return;const i=L.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Nh(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const Ih="_link_j1lkz_1",jr={link:Ih},ho=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...u}=a,m=_t(e),d=kh(m,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?k.truncate(t):s?k.truncate(s):"",f=c??h;return d?n.jsxs("a",{...u,href:Ul(Nh(d)),className:B(jr.link,i),onClick:l,target:"_blank",rel:"noopener noreferrer",children:[f,r&&n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]}):n.jsx("span",{...u,className:B(jr.link,i),children:f})},Ec=_.createContext(null),hs=()=>_.useContext(Ec),Ah=()=>{const[e,t]=H.useAtom(ac),{showNotification:s,updateNotification:o,hideNotification:a}=hs();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,u=l?l.message:c?n.jsx(ho,{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:u}),t(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:u,autoHide:!0}),t(null);break}},[e,t,s,o,a]),null},Ws=({value:e,children:t})=>{const[s,o]=_.useState(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Sh="_placeholder_10r3x_1",Th="_logo_10r3x_5",Cr={placeholder:Sh,logo:Th},re=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=_.useState(void 0),{width:u,height:m}=i,d=s??n.jsx("div",{className:B(Cr.placeholder,o?.placeholder),style:{width:u,height:m,...a},"aria-hidden":"true"});return!e||c===e?d:n.jsx("img",{...i,className:B(i.className,{[Cr.logo]:r}),style:{width:u,height:m,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function $c(){const{connector:e}=Qe.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Eh="_header_1q8ju_1",$h="_account_1q8ju_17",Mh="_name_1q8ju_28",Lh="_address_1q8ju_32",qh="_icon_1q8ju_36",Rh="_copied_1q8ju_43",Ph="_button_1q8ju_58",Dh="_settings_1q8ju_69",Bh="_disconnect_1q8ju_73",Fh="_label_1q8ju_83",Uh="_expanded_1q8ju_91",st={header:Eh,account:$h,name:Mh,address:Lh,icon:qh,copied:Rh,button:Ph,settings:Dh,disconnect:Bh,label:Fh,expanded:Uh},Oh=()=>{const e=Fi(),{address:t,username:s}=tt(),o=$c(),a=s??t,[r,i]=_.useState(!1),c=_.useRef(null),l=Nt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},d=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return _.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:st.header,children:[n.jsx(Ws,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:B(st.account,{[st.copied]:f}),onClick:h,"aria-label":f?"Copied":"Copy address",children:[n.jsx(re,{src:o,width:18,height:18}),n.jsx("div",{className:st.address,children:k.truncate(t)}),n.jsx("div",{className:st.name,children:k.truncate(a)}),n.jsx(M.IconCopy,{className:st.icon,size:12,"aria-hidden":"true"}),f?"Copied!":""]})}),n.jsx(mn,{to:"/settings",className:B(st.button,st.settings),"aria-label":"Open settings",children:n.jsx(M.IconSettingFilled,{size:16,"aria-hidden":"true"})}),n.jsxs(Nt.animated.button,{className:B(st.button,st.disconnect,{[st.expanded]:r}),style:l,onClick:u,onMouseLeave:m,onMouseEnter:d,"aria-label":"Disconnect wallet",children:[n.jsx(M.IconSignOut,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:st.label,children:"Disconnect"})]})]}):null},Vh="_overlay_jij9g_1",Kh="_content_jij9g_28",Wh="_inner_jij9g_60",Mo={overlay:Vh,content:Kh,inner:Wh},zh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=Dt(),{setContainer:o}=_.useContext(mo),a=_.useCallback(p=>{p&&o(p)},[o]),r=uo(),i=Sc(),c=H.useAtomValue(ro),l=H.useAtomValue(rs),u=E.useIsMutating({mutationKey:[oc]}),m=()=>{const p=u?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),c?.reject(new Error(p)),l?.reject(new Error("User rejected"))},d=to(),h=Me(),f=E.useQueryClient(),g={fallbackRender:({error:p,resetErrorBoundary:y})=>{const x=()=>{d==="/bridge"&&(localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM)),h("/"),wh(f),y()};return n.jsxs(yt,{children:[n.jsx(je,{error:!0,children:p.message}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:x,children:"Retry"})})]})}};return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:p=>!p&&m(),modal:!1,children:n.jsxs(Be.Dialog.Portal,{container:i,children:[r&&n.jsx(Be.Dialog.Backdrop,{className:Mo.overlay,onClick:m,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[n.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"}),n.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"})]})}),n.jsx(Be.Dialog.Popup,{className:Mo.content,children:n.jsxs("div",{className:B(Mo.inner,"body"),ref:a,children:[r&&n.jsx(jh,{}),n.jsx(Ah,{}),n.jsx(Oh,{}),n.jsx(xe,{errorBoundaryProps:g,children:e})]})})]})})},Hh="_backdrop_1bqx9_1",Qh="_modal_1bqx9_12",Gh="_closeButton_1bqx9_44",Lo={backdrop:Hh,modal:Qh,closeButton:Gh},Yh=({children:e})=>{const{isModalOpen:t,closeModal:s}=Dn(),{setContainer:o}=_.useContext(mo),a=_.useCallback(i=>{i&&o(i)},[o]),r=Sc();return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:i=>!i&&s(),children:n.jsxs(Be.Dialog.Portal,{container:r,children:[n.jsx(Be.Dialog.Backdrop,{className:Lo.backdrop,onClick:s}),n.jsxs(Be.Dialog.Popup,{className:Lo.modal,ref:a,children:[n.jsx("button",{className:Lo.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20})}),n.jsx(xe,{children:e})]})]})})},Mc=_.createContext(!1),Zh="_overlay_1iyfl_1",Jh="_fullscreen_1iyfl_15",Xh="_content_1iyfl_19",ef="_header_1iyfl_56",tf="_title_1iyfl_65",nf="_close_1iyfl_70",tn={overlay:Zh,fullscreen:Jh,content:Xh,header:ef,title:tf,close:nf},Lc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=_n(),c=_.useContext(Mc);return i?n.jsxs(Be.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Be.Dialog.Trigger,{className:o,children:s}),n.jsxs(Be.Dialog.Portal,{container:i,children:[n.jsx(Be.Dialog.Backdrop,{className:B(tn.overlay,{[tn.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Be.Dialog.Popup,{className:B(tn.content,{[tn.fullscreen]:c}),children:[e&&n.jsxs("header",{className:tn.header,children:[n.jsx(Be.Dialog.Title,{className:tn.title,children:e}),n.jsx(Be.Dialog.Close,{className:tn.close,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20,"aria-hidden":"true"})})]}),t]})]})]}):null},ts=({children:e})=>{const t=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=Nt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const c=t.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const u=new ResizeObserver(l);return u.observe(c),()=>u.disconnect()},[e]),e?n.jsx(Nt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},sf="_help_qcmtq_1",of="_icon_qcmtq_10",af="_info_qcmtq_19",rf="_warning_qcmtq_23",cf="_error_qcmtq_27",lf="_success_qcmtq_33",qo={help:sf,icon:of,info:af,warning:rf,error:cf,success:lf},In=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(It,{size:12});case"info":return n.jsx(M.IconInfoFilled,{size:12});case"warning":case"error":return n.jsx(M.IconWarningFilled,{size:12});default:return n.jsx(M.IconCheckCircleFilled,{size:12})}};return n.jsxs("div",{className:B(qo.help,e&&qo[e],t),style:{marginTop:s},role:e==="error"?"alert":"status",children:[n.jsx("div",{className:qo.icon,"aria-hidden":"true",children:a()}),o]})},uf="_stack_a6m7u_1",df="_help_a6m7u_6",mf="_info_a6m7u_14",hf="_warning_a6m7u_19",ff="_error_a6m7u_24",pf="_success_a6m7u_29",ea={stack:uf,help:df,info:mf,warning:hf,error:ff,success:pf},gf=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(ts,{children:n.jsx("div",{className:ea.stack,children:e})}),we=({mt:e=0,...t})=>n.jsx(In,{...t,className:B(ea.help,ea[t.level]),mt:e});we.Stack=gf;const _f="_root_16p5j_1",yf="_item_16p5j_10",xf="_chevron_16p5j_14",bf="_trigger_16p5j_19",wf="_content_16p5j_39",On={root:_f,item:yf,chevron:xf,trigger:bf,content:wf};function vf(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(te.Accordion.Root,{className:On.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(te.Accordion.Item,{className:On.item,value:s?.(c)??String(l),children:[n.jsx(te.Accordion.Header,{children:n.jsxs(te.Accordion.Trigger,{className:On.trigger,children:[o(c),n.jsx(M.IconChevronDown,{className:On.chevron,size:16,"aria-hidden":"true"})]})}),n.jsx(te.Accordion.Content,{className:On.content,children:a(c)})]},s?.(c)??l)),r]})}const jf="_trigger_u613p_1",Cf="_icon_u613p_18",kf="_content_u613p_27",Nf="_item_u613p_36",If="_itemText_u613p_52",Af="_itemIndicator_u613p_57",Sf="_active_u613p_60",Ot={trigger:jf,icon:Cf,content:kf,item:Nf,itemText:If,itemIndicator:Af,active:Sf};function Fa({options:e,value:t,onChange:s,classNames:o}){const a=_n(),r=e.find(c=>c.value===t);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(u=>String(u.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return n.jsxs(Lt.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(Lt.Select.Trigger,{className:B(Ot.trigger,o?.trigger),children:[n.jsx(Lt.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(Lt.Select.Icon,{className:Ot.icon,children:n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})})]}),n.jsx(Lt.Select.Portal,{container:a,children:n.jsx(Lt.Select.Positioner,{className:Ot.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(Lt.Select.Popup,{className:Ot.popup,children:e.map(c=>n.jsxs(Lt.Select.Item,{className:B(Ot.item,o?.item),value:String(c.value),children:[n.jsx(Lt.Select.ItemText,{className:B(Ot.itemText,o?.itemText),children:c.label}),n.jsx(M.IconCheck,{size:12,className:B(Ot.itemIndicator,{[Ot.active]:c.value===t}),"aria-hidden":"true"})]},String(c.value)))})})})]})}const Tf="_root_1t37n_1",Ef="_trigger_1t37n_7",$f="_item_1t37n_11",Mf="_itemText_1t37n_17",kr={root:Tf,trigger:Ef,item:$f,itemText:Mf},Lf=({options:e,value:t,onChange:s})=>{const{txRequest:o}=ic(),a=_t(o.chainId),r=St(a),i=(g,p)=>{if(k.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(q(g).isZero())return"0";const{symbol:y,decimals:x}=r(p),b=i(g,x);return`${k.formatAmount(g,{decimals:x,dp:b})} ${y}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:y}=r(p);return{value:p,label:c(g),triggerLabel:y}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const u=e.find(g=>g.amount[0].denom===t);if(!u)throw new Error("Fee option not found");const[{amount:m,denom:d}]=u.amount,{decimals:h}=r(d),f=i(m,h);return n.jsxs("div",{className:kr.root,children:[n.jsx("span",{className:"monospace",children:k.formatAmount(m,{decimals:h,dp:f})}),n.jsx(Fa,{options:l,value:t,onChange:s,classNames:kr})]})},qf="_root_16nr2_1",Rf="_trigger_16nr2_5",Pf="_chevron_16nr2_13",Df="_panel_16nr2_27",Bf="_details_16nr2_39",Ff="_row_16nr2_48",Cn={root:qf,trigger:Rf,chevron:Pf,panel:Df,details:Bf,row:Ff},Uf=({spend:e,fee:t,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:t},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return n.jsxs(Io.Collapsible.Root,{className:Cn.root,children:[n.jsxs(Io.Collapsible.Trigger,{className:Cn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(M.IconChevronDown,{className:Cn.chevron,size:16})]}),n.jsx(Io.Collapsible.Panel,{className:Cn.panel,children:n.jsx("div",{className:Cn.details,children:i.map(({label:l,value:u})=>n.jsxs("div",{className:Cn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[k.formatAmount(u,{decimals:r,dp:c})," ",a]})]},l))})})]})};function zs(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?de.toBase64(e):Array.isArray(e)?`[${e.map(zs).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Of="_container_1xzyq_1",Vf="_toggle_1xzyq_5",Kf="_list_1xzyq_11",Wf="_arg_1xzyq_16",zf="_type_1xzyq_21",Vn={container:Of,toggle:Vf,list:Kf,arg:Wf,type:zf},Hf=qe.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),Qf=({type:e,arg:t})=>zs(k.resolveBcsType(e).parse(t)),Gf=({msg:e,chainId:t,fallback:s})=>{const[o,a]=Ge.useToggle(!1),{restUrl:r}=_t(t),{moduleAddress:i,moduleName:c,functionName:l,args:u}=e,{data:m}=E.useQuery({queryKey:Hf.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:V.INFINITY});if(!m)return s;const d=(h,f)=>{const g=m[f];return n.jsxs("div",{className:Vn.arg,children:[n.jsx("div",{className:Vn.type,children:g}),n.jsx(di.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(Qf,{type:g,arg:h})})]},f)};return n.jsxs("div",{className:Vn.container,children:[n.jsx(fe.Small,{className:Vn.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Vn.list,children:u.map(d)}):s]})},Yf="_list_oip9m_1",Zf="_key_oip9m_9",Jf="_value_oip9m_14",Ro={list:Yf,key:Zf,value:Jf},Xf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:Ro.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:Ro.key,children:a}),n.jsx("div",{className:Ro.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(Gf,{msg:o,chainId:t,fallback:zs(r)}):zs(r)})]},a))})},ep="_item_1n572_1",tp="_title_1n572_10",np="_content_1n572_14",Po={item:ep,title:tp,content:np},Do=({title:e,content:t})=>n.jsxs("div",{className:Po.item,children:[n.jsx("div",{className:Po.title,children:e}),n.jsx("div",{className:Po.content,children:t})]});function ae(e){const t=e?q(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return"< $0.01";const s=e&&q(e).lt(0),o=k.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ua(e,t){return t==null?"$-":ae(e??0)}function qc(e,t){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===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u-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===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function Rc(e,t){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,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&k.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(u)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&k.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(u)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Pc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=E.useSuspenseQuery({queryKey:$n.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:V.INFINITY});return s(a)},sp="_root_1p8a4_1",op="_title_1p8a4_8",ap="_changes_1p8a4_14",rp="_change_1p8a4_14",ip="_amount_1p8a4_35",cp="_text_1p8a4_42",lp="_value_1p8a4_49",dn={root:sp,title:op,changes:ap,change:rp,amount:ip,text:cp,value:lp},Dc=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=k.formatAmount(e,{decimals:r}),l=s&&q(k.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:dn.change,children:[n.jsxs("div",{className:dn.amount,children:[n.jsx(re,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:dn.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:dn.value,children:ae(l)})]})},up=({changes:e,chain:t})=>{const s=St(t),{data:o}=Pt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:u})=>u===r)?.price;return n.jsx(Dc,{amount:a,asset:c,price:l},i)})},dp=({changes:e,chain:t})=>{const s=St(t),{data:o}=Pt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(Pc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:u})=>u===c)?.price;return n.jsx(Dc,{amount:a,asset:s(c),price:l})}},i))};function mp(e,t){return typeof t=="bigint"?t.toString():t}const hp=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,mp)]}),fp=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=tt(),r=_t(s),{simulateTx:i}=io(),{data:c}=E.useSuspenseQuery({queryKey:hp.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:V.SECOND}),l=h=>n.jsxs("div",{className:dn.root,children:[n.jsx("h2",{className:dn.title,children:"Estimated changes"}),n.jsx("div",{className:dn.changes,children:h})]});if(!c)return null;const u=c.result?.events??[];if(u.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=Rc(u,a),[f]=Nr(h);return f.length===0?null:l(n.jsx(dp,{changes:f,chain:r}))}const m=qc(u,o),[d]=Nr(m);return d.length===0?null:l(n.jsx(up,{changes:d,chain:r}))};function Nr(e){return L.partition(t=>new q(t.amount).isNegative(),e)}const pp="_title_1d032_1",gp="_meta_1d032_7",_p="_footer_1d032_14",yp="_rejectButton_1d032_19",Ns={title:pp,meta:gp,footer:_p,rejectButton:yp},Bc=()=>{const{txRequest:e,resolve:t,reject:s}=ic(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,u=_t(r),m=as(u),d=Ia(u),h=Aa(u),f=St(u),g=rc(),p=(e.gasPrices??d).map(({amount:A,denom:$})=>Le.calculateFee(Math.ceil(i*c),Le.GasPrice.fromString(A+$))),y=p.map(A=>A.amount[0]),x=A=>{const $=m.find(K=>K.denom===A)?.amount??"0",N=y.find(K=>K.denom===A)?.amount??"0",S=l.filter(K=>K.denom===A).reduce((K,W)=>q(K).plus(W.amount),q("0")),P=q(N).plus(S),F=q($).gte(P),{symbol:D,decimals:Z}=f(A);return{symbol:D,decimals:Z,spend:S.gt(0)?S.toFixed():null,fee:N,total:P.toFixed(),balance:$,isSufficient:F}},b=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of y)if(x(A).isSufficient)return A;return y[0]?.denom},[j,v]=_.useState(b),{mutate:w,isPending:C}=E.useMutation({mutationKey:[oc],mutationFn:async()=>{const A=p.find(N=>N.amount[0].denom===j);if(!A)throw new Error("Fee not found");const $=await g({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:j,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t($)},onError:async A=>{s(A)}}),I=x(j),T=!I.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(yt,{children:[n.jsx("h1",{className:Ns.title,children:"Confirm tx"}),n.jsxs("section",{className:Ns.meta,"aria-label":"Transaction metadata",children:[n.jsx(Do,{title:"Chain",content:r}),n.jsx(Do,{title:"Tx fee",content:n.jsx(Lf,{options:p,value:j,onChange:v})}),a&&n.jsx(Do,{title:"Memo",content:a}),T&&n.jsx(we,{level:"error",children:n.jsx(Uf,{...I})})]}),n.jsx(fp,{messages:o,memo:a,chainId:r}),n.jsx(vf,{list:o,renderHeader:({typeUrl:A})=>Ys.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(Xf,{message:A,chainId:r})})]}),n.jsxs(Ae,{className:Ns.footer,children:[n.jsx(fe.Outline,{onClick:()=>s(new Error("User rejected")),disabled:C,className:Ns.rejectButton,"aria-label":"Reject",children:n.jsx(M.IconClose,{size:16})}),n.jsx(fe.White,{onClick:()=>w(),disabled:T,loading:C,children:"Approve"})]})]})},xp=({children:e})=>{const[{title:t,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),c=H.useAtomValue(ro),l=_.useCallback(d=>{a(d),i(!0)},[]),u=_.useCallback(()=>{a({}),i(!1)},[]),m=_.useCallback(d=>{d||(c?.reject(new Error("User rejected")),a({})),i(d)},[c]);return n.jsxs(tc.Provider,{value:{openModal:l,closeModal:u},children:[e,n.jsx(Lc,{title:t,open:r,onOpenChange:m,children:n.jsx(xe,{children:o==="/tx"?n.jsx(Bc,{}):s})})]})},bp="_container_1w1hx_1",wp="_toast_1w1hx_11",vp="_info_1w1hx_24",jp="_success_1w1hx_28",Cp="_error_1w1hx_32",kp="_icon_1w1hx_37",Np="_content_1w1hx_45",Ip="_title_1w1hx_48",Ap="_description_1w1hx_53",Sp="_close_1w1hx_75",Vt={container:bp,toast:wp,info:vp,success:jp,error:Cp,icon:kp,content:Np,title:Ip,description:Ap,close:Sp},Tp=({notification:e,onClose:t,...s})=>{const o=Nt.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 n.jsx(It,{size:16});case"info":case"success":return n.jsx(M.IconCheckCircleFilled,{size:16});case"error":return n.jsx(M.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:u}=i,m=a(c);return n.jsx(Nt.animated.div,{style:r,className:Vt.container,children:n.jsxs("div",{className:B(Vt.toast,c&&Vt[c]),role:"alert",...s,children:[m&&n.jsx("div",{className:Vt.icon,"aria-hidden":"true",children:m}),n.jsxs("div",{className:Vt.content,children:[n.jsx("p",{className:Vt.title,children:l}),u&&n.jsx("div",{className:Vt.description,children:u})]}),n.jsx("button",{className:Vt.close,onClick:t,"aria-label":"Dismiss notification",children:n.jsx(M.IconClose,{size:14,"aria-hidden":"true"})})]})})})},Bo=5e3,Ep=({children:e})=>{const t=_n(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=_.useCallback(()=>{i(),o(null)},[]),l=_.useCallback(h=>{i(),o({...h,id:ir.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Bo))},[c]),u=_.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ir.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Bo))},[c]),m=()=>{i(),r.current=!0},d=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Bo))};return _.useEffect(()=>()=>i(),[]),n.jsxs(Ec.Provider,{value:{showNotification:l,updateNotification:u,hideNotification:c},children:[e,t&&Ol.createPortal(n.jsx(Tp,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:d}),t)]})},$p=({children:e})=>{const[t,s]=_.useState(null);return n.jsx(mo.Provider,{value:{container:t,setContainer:s},children:e})};function Mp(e){const t=e.split(".");return t.length!==4?!1:t.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function Fc(e){return Mp(e)||e.includes(":")}function ta(e){const t=Vl.parse(e);return"error"in t?null:t.domain}function Lp(e,t){return e===t||e===`www.${t}`}function qp(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||Fc(t)?!1:ta(t)!==null}function Rp(e,t){try{const s=new URL(e);if(!qp(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||Fc(a)||a==="localhost")return!1;const r=ta(o);if(!r)return!1;const i=ta(a);return!i||i!==r?!1:Lp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const Pp="_container_1422v_1",Dp="_title_1422v_7",Bp="_description_1422v_14",Fp="_sectionTitle_1422v_20",Up="_websiteInfo_1422v_27",Op="_favicon_1422v_37",Vp="_websiteTitle_1422v_42",Kp="_websiteHost_1422v_48",Wp="_warningContent_1422v_54",zp="_ignoreButton_1422v_61",Hp="_infoList_1422v_65",Qp="_infoItem_1422v_75",Gp="_label_1422v_84",Yp="_infoValue_1422v_94",Zp="_durationTrigger_1422v_100",Jp="_durationItem_1422v_101",Xp="_featureList_1422v_105",eg="_featureItem_1422v_113",tg="_checkIcon_1422v_123",ng="_learnMoreLink_1422v_127",sg="_feedbackContainer_1422v_140",og="_footer_1422v_146",pe={container:Pp,title:Dp,description:Bp,sectionTitle:Fp,websiteInfo:Up,favicon:Op,websiteTitle:Vp,websiteHost:Kp,warningContent:Wp,ignoreButton:zp,infoList:Hp,infoItem:Qp,label:Gp,infoValue:Yp,durationTrigger:Zp,durationItem:Jp,featureList:Xp,featureItem:eg,checkIcon:tg,learnMoreLink:ng,feedbackContainer:sg,footer:og};function ag(e){return e instanceof z.HTTPError&&e.response.status===404}const rg=qe.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(ag(a))return!1;throw a}}})}),ig=()=>{const[e,t]=H.useAtom(rs),[s,o]=_.useState(()=>e?.defaultDuration??Zo),[a,r]=_.useState(!1),i=lt(),c=_e(),{address:l,initiaAddress:u,username:m}=tt(),{mutate:d,isPending:h}=Ad(),{closeDrawer:f}=Dt();if(!e)throw new Error("Pending request not found");const{logoUrl:g,name:p,restUrl:y}=i(e.chainId),{data:x,isLoading:b,isError:j}=E.useQuery(rg.info(y,u)),v={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(P=>P.chainId===e.chainId),C=w?.website?Rp(w.website,window.location.hostname):!1,I=()=>{d(s)},T=()=>{e?.reject(new Error("User cancelled")),t(null),f()},A=!C&&!a,$=!b&&!j&&x===!1,N=!b&&j,S=A||b||j||x===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(yt,{className:pe.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:pe.title,children:"Enable auto-signing"}),n.jsx("p",{className:pe.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:pe.websiteInfo,children:[n.jsx("img",{src:v.favicon,alt:"",className:pe.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:pe.websiteTitle,children:v.title}),n.jsx("div",{className:pe.websiteHost,children:v.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:pe.infoList,children:[n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Address"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(M.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:k.truncate(m??l)})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Chain"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(re,{src:g,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Duration"}),n.jsx(Fa,{options:Sa,value:s,onChange:o,classNames:{trigger:pe.durationTrigger,item:pe.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:pe.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(P=>n.jsxs("li",{className:pe.featureItem,children:[n.jsx(M.IconCheckCircle,{size:12,className:pe.checkIcon}),n.jsx("span",{children:P})]},P))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:pe.learnMoreLink,children:["Learn more ",n.jsx(M.IconExternalLink,{size:12})]})]})]}),n.jsxs(Ae,{className:pe.footer,extra:n.jsxs("div",{className:pe.feedbackContainer,children:[$&&n.jsx(we,{level:"error",children:"Insufficient balance for fee"}),N&&n.jsx(we,{level:"warning",children:"Unable to verify account status. Try again."}),!C&&!a&&n.jsx(we,{level:"warning",children:n.jsxs("div",{className:pe.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:pe.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(fe.Outline,{onClick:T,children:"Cancel"}),n.jsx(fe.White,{onClick:I,disabled:S,loading:h,children:"Enable"})]})]})},cg=()=>{const e=H.useAtomValue(rs);return e?n.jsx(ig,{},`${e.chainId}:${e.defaultDuration}`):null},lg="_container_mqvhs_1",ug="_badge_mqvhs_5",Ir={container:lg,badge:ug},Uc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:B(Ir.container,a),children:[o,!s&&n.jsx("div",{className:Ir.badge,style:{right:t,top:t},"aria-hidden":"true"})]})},dg="_header_s7mee_1",mg="_back_s7mee_12",hg="_title_s7mee_24",Fo={header:dg,back:mg,title:hg},Tt=({title:e,backButton:t,extra:s,children:o})=>{const a=Ni();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Fo.header,children:[n.jsx(mn,{to:t??(a.length>1?-1:"/"),className:Fo.back,shouldReset:!!t,"aria-label":"Go back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsx("h1",{className:Fo.title,children:e}),s]}),n.jsx(yt,{children:o})]})};function Oa(){const e=_e();return t=>e.some(s=>s.chain_id===t)}function fg(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function fs(){const e=Oa();return t=>e(t.chain_id)?"initia":t.chain_type}function yn(e){return fs()(e)}function fo(){const e=Fe(),{data:t}=E.useSuspenseQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>L.sortWith([L.descend(({chain_name:o})=>o==="initia"),L.ascend(({pretty_name:o})=>o)],s),staleTime:V.MINUTE});return t}function Bt(){const e=fo(),t=_i();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=t.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 Ye(e){return Bt()(e)}function pg(e,t){try{return de.fromBech32(e).prefix===t}catch{return!1}}function Oc(){const{initiaAddress:e,hexAddress:t}=tt(),s=Bt(),o=fs();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Va(){const e=Bt(),t=fs();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return k.InitiaAddress.validate(s);case"evm":return kt.isAddress(s);case"cosmos":return a.bech32_prefix?pg(s,a.bech32_prefix):!1;default:return!1}}}function gg(){const e=Bt(),t=fs();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=t(i),l=e(a),u=t(l);if(c==="evm"&&u==="initia")return k.InitiaAddress(s).bech32;if(c==="initia"&&u==="evm")return k.InitiaAddress(s).hex;if(c===u)return s;if(r){if(u==="initia")return k.InitiaAddress(r).bech32;if(u==="evm")return k.InitiaAddress(r).hex}return""}}function _g(){const e=Fe();return E.useSuspenseQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}function ps(){const{data:{chain_to_assets_map:e}}=_g(),t=fo(),s=E.useQueryClient();return _.useMemo(()=>{const o=[];for(const a in e){if(!t.some(i=>i.chain_id===a))continue;const{assets:r}=e[a]??{assets:[]};s.setQueryData(Ie.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(Ie.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Hs(e){const t=Fe(),s=E.useQueryClient(),{data:o}=E.useSuspenseQuery({queryKey:Ie.assets(e).queryKey,queryFn:()=>t.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(Ie.asset(e,i.denom).queryKey,i);return r.slice().sort(L.descend(i=>i.symbol==="INIT"))},staleTime:V.MINUTE});return o}function Vc(e){const t=Hs(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function At(e,t){return Vc(t)(e)}const yg="_root_ekn9t_1",xg="_header_ekn9t_6",bg="_title_ekn9t_12",wg="_warning_ekn9t_18",vg="_content_ekn9t_22",jg="_footer_ekn9t_26",Cg="_secondary_ekn9t_36",nn={root:yg,header:xg,title:bg,warning:wg,content:vg,footer:jg,secondary:Cg},Kc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(yt,{className:nn.root,children:[n.jsxs("header",{className:B(nn.header,t&&nn[t]),children:[s,n.jsx("h1",{className:nn.title,children:o})]}),n.jsx("div",{className:nn.content,children:a}),n.jsxs("footer",{className:nn.footer,children:[n.jsx(fe.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:nn.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})]})]})},kg="_list_k4n3k_1",Ng="_row_k4n3k_9",Ig="_dt_k4n3k_20",Ag="_asset_k4n3k_26",Is={list:kg,row:Ng,dt:Ig,asset:Ag},Sg=({list:e,onNavigate:t,onDismiss:s})=>{const o=ce(),a=lt(),r=St(o);return n.jsx(Kc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:Is.list,children:e.slice().sort((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:u})=>{const m=a(c),{decimals:d,symbol:h}=r(u),f=k.formatAmount(l,{decimals:d});return n.jsxs("div",{className:Is.row,children:[n.jsxs("div",{className:Is.dt,children:[n.jsx(re,{src:m.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:m.name})]}),n.jsxs("span",{className:Is.asset,children:[f," ",h]})]},i)})})})};function Uo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const As=({chainId:e,txHash:t})=>`${he.OP_REMINDER}:${e}:${t}`,Tg=Kl.atomWithStorage(he.OP_REMINDER,[]);function Fn(){const e=ie(),[t=[],s]=H.useAtom(Tg),o=_.useMemo(()=>t.map(l=>{const u=localStorage.getItem(As(l));return u?JSON.parse(u):null}).filter(l=>{if(!l)return!1;const{recipient:u,claimableAt:m}=l;return u!==e?!1:Xe.isPast(m)}),[e,t]),a=_.useCallback((l,u)=>{t.some(m=>Uo(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(As(l),JSON.stringify(u)))},[t,s]),r=_.useCallback(l=>{s((u=[])=>u.filter(m=>!Uo(m,l))),localStorage.removeItem(As(l))},[s]),i=_.useCallback(l=>{const u=l.filter(m=>!t.some(d=>Uo(d,m)));u.length!==0&&s((m=[])=>[...m,...u])},[t,s]),c=_.useCallback((l,u)=>{localStorage.setItem(As(l),JSON.stringify(u)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Wc(){const e=Me(),{openModal:t,closeModal:s}=ao(),{reminders:o,setReminder:a}=Fn();_.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(u=>u.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})};t({content:_.createElement(Sg,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const Eg="_wrapper_5ssm8_1",$g="_balance_5ssm8_11",Mg="_button_5ssm8_15",Oo={wrapper:Eg,balance:$g,button:Mg},zc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:Oo.wrapper,children:[n.jsx(M.IconWallet,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:Oo.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:Oo.button,onClick:()=>e(),disabled:s,"aria-label":"Use maximum balance",children:"MAX"})]}),Lg="_fieldset_up6fh_1",qg="_upper_up6fh_9",Rg="_select_up6fh_14",Pg="_account_up6fh_20",Dg="_lower_up6fh_25",Bg="_wrapper_up6fh_26",Fg="_balance_up6fh_33",Ug="_value_up6fh_37",Og="_error_up6fh_50",qt={fieldset:Lg,upper:qg,select:Rg,account:Pg,lower:Dg,wrapper:Bg,balance:Fg,value:Ug,error:Og},na=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:qt.fieldset,children:[n.jsxs("div",{className:qt.upper,children:[n.jsx("div",{className:qt.select,children:t}),n.jsx("div",{className:qt.account,children:s})]}),!c&&n.jsxs("div",{className:qt.lower,children:[o,n.jsxs("div",{className:qt.wrapper,children:[n.jsx("div",{className:qt.balance,children:a}),r&&n.jsx("div",{className:qt.value,children:r})]}),i&&n.jsxs("footer",{className:qt.error,children:[n.jsx(M.IconWarningFilled,{size:12,"aria-hidden":"true"}),n.jsx("p",{role:"alert",children:i})]})]})]})},Hc=({quantity:e,balance:t,decimals:s})=>!e||t===void 0||s===void 0||q(e).isZero()?!1:q(k.toBaseUnit(e,{decimals:s})).gt(t);function gs(){const e=_.useRef(null),t=uo();return _.useEffect(()=>{t||e.current?.focus()},[t]),e}const Vg="_input_h8073_1",Kg={input:Vg};function Qc(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=gs();return n.jsx($e.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(Wl.NumericFormat,{value:l.value,getInputRef:mi.mergeRefs([l.ref,c]),className:B(Kg.input,a),onValueChange:u=>{l.onChange(u.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Wg="_input_19r9r_1",zg="_placeholder_19r9r_18",sa={input:Wg,placeholder:zg},Hg=({children:e})=>n.jsx("p",{className:B(sa.input,{[sa.placeholder]:q(e).isZero()}),children:e}),ns=({balance:e,decimals:t,className:s})=>{const{control:o}=$e.useFormContext(),a={required:"Enter amount",validate:r=>q(r).isZero()?"Enter amount":Hc({quantity:r,balance:e,decimals:t})?"Insufficient balance":!0};return n.jsx(Qc,{name:"quantity",control:o,className:B(sa.input,s),rules:a})};ns.ReadOnly=Hg;const qn=({title:e,content:t,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return n.jsx(Lc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},Qg="_tooltip_19kvs_1",Gg="_arrow_19kvs_44",Ar={tooltip:Qg,arrow:Gg},_s=({label:e,children:t,small:s,...o})=>n.jsxs(te.Tooltip.Root,{...o,children:[n.jsx(te.Tooltip.Trigger,{asChild:!0,children:t}),n.jsx(te.Tooltip.Portal,{container:_n(),children:n.jsxs(te.Tooltip.Content,{className:B(Ar.tooltip,{small:s}),collisionBoundary:_n(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(te.Tooltip.Arrow,{className:Ar.arrow})]})})]});function po(e,t){const s=Fe(),o=Va(),a=!!t&&!!e&&o(e,t);return E.useQuery({queryKey:Ie.balances(t,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>a?r?r[t]?.denoms??{}:{}:{},enabled:a,staleTime:V.SECOND})}function Yg(e,t,s){const{data:o={}}=po(e,t);return L.path([s],o)}function Zg({sourceDenom:e,sourceBalance:t,amountIn:s,feeTokenDenoms:o,balancesByDenom:a,additionalFees:r=[]}){if(!o.includes(e)||t===void 0||s===void 0||a===void 0)return!1;const c=r.reduce((m,d)=>{if(d.amount===void 0)return m;const h=d.origin_asset.denom,f=m.get(h)??q(0);return m.set(h,f.plus(d.amount)),m},new Map);if(o.some(m=>{if(m===e)return!1;const d=q(a[m]?.amount??"0"),h=c.get(m);return h?d.gte(h):d.gt(0)}))return!1;const u=c.get(e)??q(0);return u.isZero()?!1:q(t).lt(q(s).plus(u))}const Jg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ss(e){if(!e)return;const{formattedParts:t}=Jg.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 t.join(" ")}function Gc(e,t){return q(e).times(q(100).minus(t)).div(100).integerValue(q.ROUND_FLOOR).toFixed(0)}function Ka(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${k.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Yc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,u=t.getQueryData(Ie.asset(a,r).queryKey);if(!u||u.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const m=u.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:k.toBaseUnit(i,{decimals:m}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function oa(e,t){const{watch:s}=Zt(),o=s(),a=Fe(),r={srcChainId:o.srcChainId,srcDenom:o.srcDenom,dstChainId:o.dstChainId,dstDenom:o.dstDenom,quantity:e},i=!r.srcChainId||!r.srcDenom||!r.dstChainId||!r.dstDenom,c=q(r.quantity||0),l=c.isFinite()&&c.gt(0),u=t?.refreshMs??1e4,m=l&&!t?.disabled&&!i,d=E.useQueryClient();return E.useQuery({queryKey:Ie.route(r,t?.isOpWithdraw).queryKey,queryFn:async({signal:h})=>Yc(a,d,r,{isOpWithdraw:t?.isOpWithdraw,signal:h}),enabled:m,staleTime:u,refetchInterval:m?u:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function Xg(e){return E.useQuery({queryKey:Ie.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function e_(){const{watch:e}=Zt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=Ye(t),i=yn(r),c=At(s,t),l=At(a,o),u=ce(),m=_e();return i==="initia"&&o===u.chainId&&c.symbol===l.symbol&&m.find(d=>d.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const t_="_label_t93ix_1",n_="_wrapper_t93ix_7",s_="_input_t93ix_10",o_="_clear_t93ix_18",Ss={label:t_,wrapper:n_,input:s_,clear:o_},Wa=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=k.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=gs(),{control:l,getValues:u,setValue:m,formState:d}=$e.useFormContext(),h=u("recipient"),[f,g]=_.useState(h),p=vi(),{data:y,isLoading:x,error:b}=E.useQuery({queryKey:Xs.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:V.MINUTE,enabled:p.validateUsername(f)}),j=y??(o(f)?f:""),v=t&&k.InitiaAddress.equals(j,t),w=async()=>{try{const T=await navigator.clipboard.readText();g(T.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!d.dirtyFields.recipient||m("recipient",y??f,{shouldValidate:!0,shouldDirty:!0}))},[d.dirtyFields.recipient,f,e,m,y]);const C=()=>{x||b||(m("recipient",j,{shouldValidate:!0,shouldDirty:!0}),r?.())},I=()=>{if(x)return n.jsx(In,{level:"loading",children:"Resolving username..."});if(b)return n.jsx(In,{level:"error",children:b.message});if(y)return n.jsx(In,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&f&&!j)return n.jsx(In,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:Ss.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(fe.Small,{type:"button",tabIndex:-1,onClick:w,children:"Paste"})]}),n.jsxs("div",{className:Ss.wrapper,children:[n.jsx($e.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:T=>o(T)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:B(Ss.input,"monospace"),value:f,onChange:T=>g(T.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?mi.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:Ss.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:n.jsx(M.IconCloseCircleFilled,{size:16})})]}),I(),v&&n.jsx(In,{children:"This is my address"}),e==="onSubmit"&&n.jsx(Ae,{extra:(!t||!!j&&!v)&&n.jsx(we,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(fe.White,{type:"button",onClick:C,disabled:x||!!b||!j,children:"Apply"})})]})},a_="_scrollable_vgj3r_1",r_="_list_vgj3r_5",i_="_item_vgj3r_9",c_="_name_vgj3r_22",Ts={scrollable:a_,list:r_,item:i_,name:c_};function Zc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(yt,{className:Ts.scrollable,children:n.jsx("div",{className:Ts.list,children:t.map(l=>n.jsxs("button",{className:Ts.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),"aria-busy":!!i?.(l),children:[n.jsx(re,{src:o(l),width:28,height:28}),n.jsx("span",{className:Ts.name,children:a(l)}),i?.(l)&&n.jsx(It,{size:16})]},r(l)))})})}function go(){const{cosmosWallets:e=[]}=se(),t=_.useMemo(()=>{const a=[{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"}].filter(r=>!e.some(i=>i.name===r.name));return[...e,...a]},[e]);return{list:t,find:o=>t.find(a=>a.name===o)}}const l_="_account_h04x1_8",u_="_clear_h04x1_28",d_="_white_h04x1_39",Kn={account:l_,clear:u_,white:d_},Sr=({type:e})=>{const{watch:t,setValue:s}=Zt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=yn(Ye(a)),{showNotification:u}=hs(),{list:m,find:d}=go(),h=d(r),f=Oc(),g=Va(),p=f(a),y=k.InitiaAddress.equals(c,p),x=()=>n.jsx(qn,{title:"Connect wallet",content:v=>n.jsx(Zc,{onSelect:async w=>{const C=w.getProvider();if(!C){w.fallbackUrl?window.open(w.fallbackUrl,"_blank"):u({type:"error",title:`${w.name} not available`,description:"Please install the wallet extension and try again."});return}try{const T=await C.getOfflineSigner(o).getAccounts();if(T.length===0)throw new Error("No accounts found");s("sender",T[0].address),s("cosmosWalletName",w.name),v()}catch(I){const T=I instanceof Error?I.message:"Unknown error";u({type:"error",title:`Failed to connect ${w.name}`,description:T})}},list:m,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:B(Kn.account,{[Kn.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[h&&n.jsx(re,{src:h.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:k.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})}),b=v=>n.jsx(qn,{title:"Recipient",content:w=>n.jsx(yt,{children:n.jsx(Wa,{mode:"onSubmit",myAddress:p,chainType:l,validate:C=>g(C,a),onApply:w})}),className:Kn.account,children:v}),j=()=>{switch(l){case"initia":case"evm":return y?b(n.jsx(M.IconWallet,{size:14})):n.jsxs("div",{className:Kn.account,children:[n.jsx("span",{className:"monospace",children:k.truncate(c)}),n.jsx("button",{type:"button",className:Kn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(M.IconCloseCircleFilled,{size:14})})]});case"cosmos":return b(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:k.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(M.IconEdit,{size:14,"aria-hidden":"true"})]}))}};switch(e){case"src":return x();case"dst":return j()}},m_="_images_cj4xz_1",Vo={images:m_},_o=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:B(Vo.images,r),style:{position:"relative"},"aria-hidden":"true",children:[n.jsx(re,{src:e,width:t,height:t,className:Vo.asset,logo:!0}),n.jsx(re,{src:s,width:o,height:o,className:Vo.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),h_="_root_6187w_1",f_="_content_6187w_10",p_="_details_6187w_20",g_="_symbol_6187w_26",__="_chain_6187w_34",y_="_chevron_6187w_43",sn={root:h_,content:f_,details:p_,symbol:g_,chain:__,chevron:y_},Jc=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:sn.content,children:[n.jsx(_o,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:sn.details,children:[n.jsx("div",{className:sn.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:sn.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:sn.root,children:o}):n.jsxs("div",{className:sn.root,children:[o,n.jsx(M.IconChevronDown,{size:16,className:sn.chevron,"aria-hidden":"true"})]})};function x_(e,t,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return L.any(L.includes(t.toLowerCase()),a)})}const b_="_root_1sh27_1",w_="_label_1sh27_8",v_="_input_1sh27_21",j_="_hasValue_1sh27_31",C_="_clear_1sh27_35",Wn={root:b_,label:w_,input:v_,hasValue:j_,clear:C_},ys=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:B(Wn.root,t,{[Wn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Wn.label,children:n.jsx(M.IconSearch,{size:o})}),n.jsx("input",{className:Wn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Wn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(M.IconCloseCircleFilled,{size:o})})]})},k_="_container_5tajg_1",N_="_search_5tajg_7",I_="_list_5tajg_11",A_="_item_5tajg_15",S_="_logo_5tajg_37",T_="_info_5tajg_41",E_="_symbol_5tajg_47",$_="_name_5tajg_56",M_="_balance_5tajg_62",L_="_value_5tajg_69",rt={container:k_,search:N_,list:I_,item:A_,logo:S_,info:T_,symbol:E_,name:$_,balance:M_,value:L_},xs=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=_.useState(""),i=x_(["symbol"],a,t);return n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:rt.search,padding:20,ref:gs()}),i.length===0?n.jsx(je,{children:"No assets"}):n.jsx("div",{className:rt.list,children:i.map(c=>n.jsx("button",{type:"button",className:rt.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:u,logoUrl:m,symbol:d,name:h,balance:f,decimals:g,value:p=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(re,{src:m,width:32,height:32,className:rt.logo,logo:!0}),n.jsxs("div",{className:rt.info,children:[n.jsx("div",{className:rt.symbol,children:d||u}),n.jsx("div",{className:rt.name,children:h})]}),n.jsxs("div",{className:rt.balance,children:[f&&n.jsx("div",{children:k.formatAmount(f,{decimals:g})}),p>0&&n.jsx("div",{className:rt.value,children:ae(p)})]})]})})},c.denom))})]})},q_=()=>n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{rootClassName:rt.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(je,{children:"Loading..."})]});xs.Placeholder=q_;const R_="_stack_16oqn_1",P_="_title_16oqn_9",D_="_grid_16oqn_16",B_="_item_16oqn_22",F_="_button_16oqn_26",U_="_active_16oqn_44",An={stack:R_,title:P_,grid:D_,item:B_,button:F_,active:U_},fn=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:An.title,children:e}),n.jsx("div",{className:An.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(Uc,{offset:-2,disabled:!a?.(r),className:An.item,children:n.jsx(_s,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button","aria-label":i,className:B(An.button,{[An.active]:r===s}),onClick:()=>o(r),children:n.jsx(re,{src:c,width:28,height:28,logo:!0})})})},r))})]}),O_=({children:e})=>n.jsx("div",{className:An.stack,children:e});fn.Stack=O_;const V_=({address:e,chain:t,onSelect:s})=>{const o=Hs(t.chain_id),{data:a={}}=po(e,t.chain_id);return n.jsx(xs,{assets:L.sortWith([L.descend(r=>r.symbol==="INIT"),L.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>q(i).comparedTo(r)??0,L.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=k.truncate(i),logo_uri:l}=r,u=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:u.amount,value:Number(u.value_usd??0)}})),onSelect:s})},K_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Yt(),i=fo(),{watch:c,setValue:l}=Zt(),u=c(a),m=c(s),d=c(o),[h,f]=_.useState(m),g=Ye(h),p=gg(),y=Oa(),[x,b]=L.partition(v=>y(v.chain_id),i.filter(v=>!v.hidden)),j=v=>{if(m===h&&d===v){t();return}l(s,h),l(o,v),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(fn.Stack,{children:[n.jsx(fn,{label:"Interwoven Economy",chains:x.map(({chain_id:v,chain_name:w,pretty_name:C,logo_uri:I})=>({chainId:v,name:C||w,logoUrl:I??""})),value:h,onSelect:f}),n.jsx(fn,{label:"Chains",chains:b.map(({chain_id:v,chain_name:w,pretty_name:C,logo_uri:I})=>({chainId:v,name:C||w,logoUrl:I??""})),value:h,onSelect:f})]}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(V_,{address:p({initialAddress:u,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:j})},h)]})},Tr=({type:e})=>{const t=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Zt(),r=a(t),i=a(s),c=Ye(r),l=At(i,r);return n.jsx(qn,{title:o,content:u=>n.jsx(K_,{type:e,afterSelect:u}),children:n.jsx(Jc,{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??""}})})},W_="_skeleton_1l4jn_1",z_={skeleton:W_},pn=({width:e="100%",height:t})=>n.jsx("div",{className:z_.skeleton,style:{width:e,height:t},"aria-hidden":"true"}),H_="_stack_oq1ir_1",Q_="_button_oq1ir_6",G_="_isLoading_oq1ir_19",Y_="_disabled_oq1ir_19",Z_="_checked_oq1ir_23",J_="_header_oq1ir_37",X_="_title_oq1ir_43",ey="_duration_oq1ir_52",ty="_warning_oq1ir_62",ny="_amount_oq1ir_66",sy="_value_oq1ir_67",at={stack:H_,button:Q_,isLoading:G_,disabled:Y_,checked:Z_,header:J_,title:X_,duration:ey,warning:ty,amount:ny,value:sy},oy=({children:e})=>n.jsx("div",{className:at.stack,role:"radiogroup","aria-label":"Route options",children:e}),Ps=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Zt(),{dstChainId:l,dstDenom:u}=c(),m=At(u,l),d=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:B(at.button,{[at.isLoading]:i,[at.disabled]:h,[at.checked]:d}),onClick:()=>{i||h||o(s)},role:"radio","aria-checked":d,"aria-disabled":h,children:[n.jsxs("div",{className:at.header,children:[n.jsxs("div",{className:at.title,children:[n.jsx("span",{children:e}),d&&n.jsx(M.IconCheck,{size:14,"aria-hidden":"true"})]}),i?n.jsx(pn,{width:80,height:16}):r?n.jsxs("div",{className:B(at.duration,{[at.warning]:s==="op"}),children:[n.jsx(M.IconClockFilled,{size:12,"aria-hidden":"true"}),n.jsx("span",{children:ss(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:at.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:at.amount,children:i?n.jsx(pn,{width:260,height:40}):r?k.formatAmount(r.amount_out,{decimals:m.decimals}):null}),n.jsx("div",{className:at.value,children:i?n.jsx(pn,{width:120,height:16}):r?r.usd_amount_out?ae(r.usd_amount_out):"$-":null})]})]})};Ps.Stack=oy;const ay="_description_nuyvt_1",ry="_presets_nuyvt_8",iy="_preset_nuyvt_8",cy="_active_nuyvt_29",ly="_custom_nuyvt_40",uy="_wrapper_nuyvt_47",dy="_percent_nuyvt_58",vt={description:ay,presets:ry,preset:iy,active:cy,custom:ly,wrapper:uy,percent:dy},Er=["0.1","0.5","1.0"],my=({afterConfirm:e})=>{const t=Zt(),s=t.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:c,setValue:l}=$e.useForm({defaultValues:{value:s}}),u=i("value");_.useEffect(()=>{const p=Er.findIndex(y=>y===s);a(p>=0?p:null)},[s]);const m=(p,y)=>{l("value",p),a(y)},d=()=>{a(null)},h=_.useMemo(()=>Number(u)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(u)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(u)<.1?{type:"warning",text:"Your transaction may fail"}:null,[u]),f=h?.type==="error",g=({value:p})=>{t.setValue("slippagePercent",p),e()};return n.jsxs(yt,{children:[n.jsx("p",{className:vt.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."}),n.jsxs("div",{className:vt.presets,role:"radiogroup","aria-label":"Slippage presets",children:[Er.map((p,y)=>n.jsxs("button",{type:"button",className:B(vt.preset,{[vt.active]:o===y}),onClick:()=>m(p,y),role:"radio","aria-checked":o===y,children:[p,"%"]},p)),o!==null?n.jsx("button",{type:"button",className:B(vt.preset,vt.custom),onClick:()=>a(null),role:"radio","aria-checked":o===null,children:"Custom"}):n.jsxs("div",{className:vt.wrapper,children:[n.jsx(Qc,{name:"value",control:r,dp:2,onFocus:d,placeholder:"",className:B(vt.preset,vt.active)}),n.jsx("span",{className:vt.percent,children:"%"})]})]}),h&&n.jsx(we,{level:h.type,children:h.text}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},hy="_form_1owk5_1",fy="_arrow_1owk5_5",py="_divider_1owk5_14",gy="_flip_1owk5_23",_y="_meta_1owk5_41",yy="_row_1owk5_54",xy="_title_1owk5_60",by="_description_1owk5_64",wy="_icon_1owk5_71",vy="_edit_1owk5_76",jy="_link_1owk5_94",Cy="_warning_1owk5_99",Ve={form:hy,arrow:fy,divider:py,flip:gy,meta:_y,row:yy,title:xy,description:by,icon:wy,edit:vy,link:jy,warning:Cy};function ky({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}function Ny({srcChainType:e,chainFeeAssets:t,srcDenom:s}){switch(e){case"initia":case"cosmos":return t.map(({denom:o})=>o);case"evm":return kt.isAddress(s)?[]:[s];default:return[]}}const Iy=q(1),Ay=()=>{const e=Me(),t=uo(),s=Pn(),[o,a]=_.useState(void 0),[r,i]=_.useState(!1),[c,l]=Ge.useLocalStorage(he.BRIDGE_ROUTE_TYPE,"default"),{watch:u,setValue:m,handleSubmit:d,formState:h}=Zt(),f=u(),{srcChainId:g,srcDenom:p,dstChainId:y,dstDenom:x,quantity:b,sender:j,slippagePercent:v}=f,w=ce(),C=Ye(g),I=yn(C),T=Ye(y),A=yn(T),$=At(p,g),N=At(x,y),{data:S,isError:P}=po(j,g),F=Yg(j,g,p),D=S!==void 0,Z=F?.amount??(S?"0":void 0),K=!Z||q(Z).isZero(),[W]=Ge.useDebounceValue(b,300),O=Hc({quantity:W,balance:Z,decimals:$?.decimals}),J=g===y,Q=J&&g===w.chainId,ue=ky({isLayer1Swap:Q,isL2Swap:J&&I==="initia"&&!Q}),ye=I!=="initia"&&A!=="initia",me=e_(),Ce=oa(W,{disabled:ye,refreshMs:ue}),Se=oa(W,{isOpWithdraw:!0,disabled:!me,refreshMs:ue}),ke=me&&c==="op",Et=ke?Se:Ce,ut=ke?Ce:Se,Re=ke?!ye:me,le=Et.error&&Re?ut:Et,{data:G,isLoading:$t,error:Xt}=le,{data:Mt}=Xg(Xt),bt=W&&$t&&!r,en=()=>{m("srcChainId",y),m("srcDenom",x),m("dstChainId",g),m("dstDenom",p),m("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:dt,closeModal:Ue}=ao(),nt=d(async oe=>{a(void 0),i(!0);try{const Ne=await le.refetch();if(Ne.error||!Ne.data||!Ne.dataUpdatedAt){a(Ne.error instanceof Error?Ne.error.message:"Failed to refresh route. Please try again.");return}const Ft=Ne.data,Un=Ne.dataUpdatedAt;if(s("Bridge Simulation Success",{quantity:oe.quantity,srcChainId:oe.srcChainId,srcDenom:oe.srcDenom,dstChainId:oe.dstChainId,dstDenom:oe.dstDenom}),Ft.warning){const{type:Rl="",message:Pl}=Ft.warning??{};dt({content:n.jsx(Kc,{type:"warning",icon:n.jsx(M.IconWarningFilled,{size:40}),title:Ys.sentenceCase(Rl),primaryButton:{label:"Cancel",onClick:Ue},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:Ft,values:oe,quoteVerifiedAt:Un}),Ue()}},children:n.jsx("p",{className:Ve.warning,children:Pl})})});return}e("/bridge/preview",{route:Ft,values:oe,quoteVerifiedAt:Un})}finally{i(!1)}}),X=_.useMemo(()=>G?.estimated_fees?.filter(({fee_behavior:oe})=>oe==="FEE_BEHAVIOR_DEDUCTED")??[],[G]),ve=_.useMemo(()=>G?.estimated_fees?.filter(({fee_behavior:oe})=>oe==="FEE_BEHAVIOR_ADDITIONAL")??[],[G]),Oe=_.useMemo(()=>{if(D)for(const oe of ve){const Ne=S?.[oe.origin_asset.denom]?.amount??"0",Ft=G?.source_asset_denom===oe.origin_asset.denom?G.amount_in:"0";if(q(Ne).lt(q(Ft).plus(oe.amount??"0")))return`Insufficient ${oe.origin_asset.symbol} for fees`}},[ve,S,D,G]),mt=!!G&&ve.length>0&&!D,jo=G?k.formatAmount(G.amount_out,{decimals:N.decimals}):"0",ws=_.useMemo(()=>C.fee_assets??[],[C.fee_assets]),Co=_.useCallback((oe,Ne)=>{const Ft=q(S?.[oe]?.amount??"0"),Un=oe===(Ne?.sourceDenom??p)?q(Ne?.amountIn??G?.amount_in??"0"):q(0);return Ft.minus(Un)},[S,G?.amount_in,p]),ko=_.useMemo(()=>Ny({srcChainType:I,chainFeeAssets:ws,srcDenom:p}),[ws,I,p]),$l=Zg({sourceDenom:p,sourceBalance:Z,amountIn:G?.amount_in,feeTokenDenoms:ko,balancesByDenom:S,additionalFees:ve}),Ml=ko.some(oe=>Co(oe).gt(Iy)),er=D&&!!G&&ko.length>0&&!Ml||$l?"Insufficient balance for fees":void 0,Ll=!!o,tr=_.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!W)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(P)return"Failed to load balance";if(O)return"Insufficient balance";if(!G)return"Route not found";if(mt)return"Loading balances...";if(Oe)return Oe},[W,Oe,h,mt,P,O,G,f]),ql=_.useMemo(()=>r?"Refreshing route...":bt?"Simulating...":!1,[bt,r]),No=_.useCallback((oe,Ne)=>oe.length?n.jsxs("div",{className:Ve.description,children:[Ka(oe),!t&&n.jsx(_s,{label:Ne,children:n.jsx("span",{className:Ve.icon,children:n.jsx(M.IconInfoFilled,{size:12,"aria-hidden":"true"})})})]}):null,[t]),vs=q(b).gt(0)&&me&&Ce.data&&Se.data&&Se.data.estimated_route_duration_seconds>Ce.data.estimated_route_duration_seconds,nr=_.useMemo(()=>{if(!G)return[];const oe=Gc(G.amount_out,v);return[{condition:!!G.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[No(X,"Fee deducted from the amount you receive"),No(ve,"Fee charged in addition to the amount you enter")]})},{condition:!vs&&!!ss(G.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Ve.description,children:ss(G.estimated_route_duration_seconds)})},{condition:G.does_swap,title:"Slippage",content:n.jsxs("span",{className:Ve.description,children:[n.jsxs("span",{children:[v,"%"]}),n.jsx(qn,{title:"Slippage tolerance",content:Ne=>n.jsx(my,{afterConfirm:Ne}),className:Ve.edit,children:n.jsx(M.IconSettingFilled,{size:12,"aria-hidden":"true"})})]})},{condition:G.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Ve.description,children:[n.jsx("img",{src:N.logo_uri,alt:N.symbol,width:12,height:12}),k.formatAmount(oe,{decimals:N.decimals})," ",N.symbol]})}].filter(Ne=>Ne.condition)},[ve,X,N,No,G,vs,v]);return n.jsxs("form",{className:Ve.form,onSubmit:nt,"aria-label":"Bridge and swap form",children:[n.jsx(na,{selectButton:n.jsx(Tr,{type:"src"}),accountButton:I==="cosmos"&&n.jsx(Sr,{type:"src"}),quantityInput:n.jsx(ns,{balance:Z,decimals:$?.decimals}),balanceButton:n.jsx(zc,{onClick:()=>m("quantity",k.fromBaseUnit(F?.amount,{decimals:$?.decimals??0}),{shouldValidate:!0}),disabled:K,children:k.formatAmount(Z??"0",{decimals:$.decimals})}),value:G?.usd_amount_in?ae(G.usd_amount_in):"$-"}),n.jsxs("div",{className:Ve.arrow,children:[n.jsx("div",{className:Ve.divider}),n.jsx("button",{type:"button",className:Ve.flip,onClick:()=>en(),"aria-label":"Swap source and destination",children:n.jsx(M.IconChevronDown,{size:16,"aria-hidden":"true"})})]}),n.jsx(na,{selectButton:n.jsx(Tr,{type:"dst"}),accountButton:n.jsx(Sr,{type:"dst"}),quantityInput:n.jsx(ns.ReadOnly,{children:jo}),value:G?.usd_amount_out?ae(G.usd_amount_out):"$-",hideNumbers:vs}),n.jsx(ts,{children:vs?n.jsxs(Ps.Stack,{children:[n.jsx(Ps,{label:"Fast",query:Ce,value:"default",onSelect:l,checked:c==="default"}),n.jsx(Ps,{label:"Lossless",query:Se,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(Ae,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(we.Stack,{children:[P&&n.jsx(we,{level:"error",children:"Failed to load balance"}),Ll&&n.jsx(we,{level:"error",children:o}),G?.extra_infos?.map(oe=>n.jsx(we,{level:"info",children:oe},oe)),Mt&&n.jsx(we,{level:"info",children:Mt}),er&&n.jsx(we,{level:"warning",children:er}),G?.warning&&n.jsx(we,{level:"warning",children:G.warning.message}),G?.extra_warnings?.map(oe=>n.jsx(we,{level:"warning",children:oe},oe))]}),n.jsx(ts,{children:nr.length>0&&n.jsx("section",{className:Ve.meta,"aria-label":"Route details",children:nr.map((oe,Ne)=>n.jsxs("div",{className:Ve.row,children:[n.jsx("span",{className:Ve.title,children:oe.title}),oe.content]},Ne))})})]}),children:n.jsx(fe.White,{loading:ql,disabled:!!tr||r,children:tr??"Preview route"})})]})},Sy=()=>{Wc();const e=Ni(),t=Me(),s=Yt(),o=Qm(),a=$e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:u,dstDenom:m,quantity:d,slippagePercent:h,recipient:f}=r();r((S,{name:P})=>{(P==="srcChainId"||P==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Oc(),p=g(c),y=g(l),b=Va()(f,l);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),_.useEffect(()=>{b||i("recipient",y)},[y,b,i]);const{showNotification:j}=hs(),v=Ye(c),w=Ye(l),C=Hs(c),I=Hs(l),T=C.some(S=>S.denom===u),A=I.some(S=>S.denom===m);_.useEffect(()=>{C.length>0&&!T&&(i("srcDenom",C[0].denom),j({type:"info",title:`Switched to ${C[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[C,T,i,j,v.pretty_name]),_.useEffect(()=>{I.length>0&&!A&&(i("dstDenom",I[0].denom),j({type:"info",title:`Switched to ${I[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[I,A,i,j,w.pretty_name]),_.useEffect(()=>{!T||!A||(localStorage.setItem(he.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(he.BRIDGE_SRC_DENOM,u),localStorage.setItem(he.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(he.BRIDGE_DST_DENOM,m),localStorage.setItem(he.BRIDGE_QUANTITY,d),localStorage.setItem(he.BRIDGE_SLIPPAGE_PERCENT,h))},[c,u,l,m,d,h,T,A]);const $=e[0].path==="/bridge",{reminders:N}=Fn();return n.jsx(Tt,{title:"Bridge/Swap",backButton:$?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(fe.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,"aria-label":"Bridge/Swap history",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:[n.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"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(Uc,{offset:0,disabled:N.length===0,children:n.jsx(fe.Small,{onClick:()=>t("/op/withdrawals"),disabled:!s,children:n.jsx("span",{children:"Withdrawal status"})})})]}),children:T&&A&&n.jsx($e.FormProvider,{...a,children:n.jsx(xe,{children:n.jsx(Ay,{})})})})},Ty="_button_1crvp_1",Ey="_checkbox_1crvp_11",$y="_checked_1crvp_25",Es={button:Ty,checkbox:Ey,checked:$y},My=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:B(Es.button,o),onClick:t,role:"checkbox","aria-checked":e,children:[n.jsx("div",{className:B(Es.checkbox,{[Es.checked]:e}),children:e&&n.jsx(M.IconCheck,{size:12,"aria-hidden":"true"})}),n.jsx("span",{className:Es.label,children:s})]}),Ly="_button_aoxv2_1",qy={button:Ly},Xc=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=zl.useInView();return _.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:qy.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})]})};function el(e,t){return e.reduce((s,o)=>{const a=t(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 Ds=({chainId:e,txHash:t})=>`${he.BRIDGE_HISTORY}:${e}:${t}`,Qs=100,$r=10;function tl(){const[e,t]=Ge.useLocalStorage(he.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(Ds(a),JSON.stringify(r));for(const i of e.slice(Qs-1))localStorage.removeItem(Ds(i));t((i=[])=>[a,...i.slice(0,Qs-1)])},[e,t]),o=_.useCallback(a=>{const r=localStorage.getItem(Ds(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function nl(e){return Ge.useLocalStorage(Ds(e),null)}const vn=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function yo(){const{restUrl:e}=ce();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function Ry(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:vn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:V.INFINITY});return s}const Mr=20;function Py(e){const t=ie();return E.useSuspenseInfiniteQuery({queryKey:vn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:Mr,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=L.last(s)?.sequence;return s.length<Mr||!o||o<=1?null:o-1},initialPageParam:0,staleTime:V.SECOND})}function Dy(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:vn.latestOutput(e).queryKey,queryFn:()=>t.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:V.SECOND});return s}function By({bridge_id:e,output_index:t}){const s=yo(),{data:o}=E.useSuspenseQuery({queryKey:vn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:V.SECOND});return o}function Fy({bridge_id:e,sequence:t}){const o=_e().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=lt()(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}=E.useSuspenseQuery({queryKey:vn.outputResponse(i,t).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:V.SECOND});return c}function sl(e,t){const{bridge_id:s}=e,o=yo(),{data:a}=E.useSuspenseQuery({queryKey:vn.withdrawalClaimed(s,t).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:V.SECOND});return a}function zn(e){return Hl.sha3_256.create().update(e).digest()}function Ko(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function ol(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Ko(t.toString(),8),c=Ko(s.toString(),8),l=Ko(o.amount,8),u=ln.concatBytes(i,c,zn(ln.utf8ToBytes(a)),zn(ln.utf8ToBytes(r)),zn(ln.utf8ToBytes(o.denom)),l);return zn(zn(u))}async function Uy(e,t,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function Oy(e,t){const s=z.create({prefixUrl:t}),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`)}function Vy({addressList:e,route:t,slippagePercent:s,signedOpHook:o}){return{address_list:e,amount_in:t.amount_in,amount_out:t.amount_out,source_asset_chain_id:t.source_asset_chain_id,source_asset_denom:t.source_asset_denom,dest_asset_chain_id:t.dest_asset_chain_id,dest_asset_denom:t.dest_asset_denom,slippage_tolerance_percent:s,operations:t.operations,signed_op_hook:o}}async function Ky(e,t){const s=Vy(t),{txs:o}=await e.post("v2/fungible/msgs",{json:s}).json();if(!o||o.length===0)throw new Error("No transaction data found");return o}function xo(e,t){if(!e?.length)throw new Error("Invalid transaction data");return e.map(({msg_type_url:s,msg:o})=>{if(!(s&&o))throw new Error("Invalid transaction data");const a=t.converters[s];if(!a)throw new Error(`Unsupported message type: ${s}`);return t.fromAmino({type:a.aminoType,value:JSON.parse(o)})})}function Wy({gas:e,gasPrices:t,gasAdjustment:s=Ht}){return t.reduce((o,{amount:a,denom:r})=>(o[r]=q(e).times(s).times(a).integerValue(q.ROUND_CEIL).toFixed(0),o),{})}function zy({balances:e,requiredFeeByDenom:t,sourceDenom:s,amountIn:o}){const a=Object.keys(t);return a.length===0?!0:a.some(r=>{const i=q(e[r]?.amount??"0"),c=q(r===s?o:0),l=q(t[r]??"0");return i.minus(c).gte(l)})}async function aa(e,t){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=t;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(L.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 xt(){return et()}function Hy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Me(),{showNotification:r,updateNotification:i,hideNotification:c}=hs(),{addHistoryItem:l}=tl(),u=Pn(),{route:m,values:d}=xt(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=d,y=Qi(),{requestTxSync:x,submitTxSync:b,waitForTxConfirmation:j}=tt(),{find:v}=go(),w=is(),C=cs(),I=bn(),T=Ye(h),A=yn(T),$=Vc(h),N=E.useQueryClient(),{registryUrl:S}=se(),P=lt(),F=ce(),{addReminder:D}=Fn(),Z=Fe();return E.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const K=xo(e.cosmos_tx.msgs,{converters:C,fromAmino:I.fromAmino.bind(I)});if(A==="initia"){const{srcDenom:ut,quantity:Re}=d,{decimals:le}=$(ut),G=s?await b({messages:K,chainId:h,fee:s}):await x({messages:K,chainId:h,internal:1,spendCoins:[{denom:ut,amount:k.toBaseUnit(Re,{decimals:le})}]}),$t=j({txHash:G,chainId:h});return{txHash:G,wait:$t}}const W=v(p)?.getProvider();if(!W)throw new Error("Wallet not connected");const O=W.getOfflineSignerOnlyAmino(h),J=await Le.SigningStargateClient.connectWithSigner(T.rpc,O,{registry:w,aminoTypes:I}),Q=await J.getAllBalances(f),ee=T.fee_assets.find(ut=>Q.some(Re=>Re.denom===ut.denom&&q(Re.amount).gt(0)));if(!ee){const Re=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(le=>$(le.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:ue,gas_price:ye}=ee;if(!ye)throw new Error(`Gas price not found for ${ue}`);const me=await J.simulate(f,K,""),Ce=Le.GasPrice.fromString(ye.average+ue),Se=Le.calculateFee(Math.ceil(me*Ht),Ce),ke=await J.signAndBroadcastSync(f,K,Se),Et=cc({txHash:ke,client:J});return{txHash:ke,wait:Et}}if("evm_tx"in e){const{chain_id:K,to:W,value:O,data:J}=e.evm_tx,Q=await y(),ee=await Q.getSigner();await aa(Q,T);const ue=await ee.sendTransaction({chainId:K,to:W,value:O,data:`0x${J}`}),ye=Gi(ue.wait(),3e4,"Transaction was not confirmed in time. It may still be processing.");return{txHash:ue.hash,wait:ye}}throw new Error("Unlisted chain type")}catch(K){throw K instanceof hn?K:await ct(K)}},onSuccess:async({txHash:K,wait:W})=>{localStorage.removeItem(he.BRIDGE_QUANTITY),N.removeQueries({queryKey:Ie.route._def}),N.removeQueries({queryKey:Ie.routeErrorInfo._def}),o?o({txhash:K,chainId:h,timestamp:Date.now(),success:!0,route:m,values:d}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await W;const O=bo(m)==="OP Bridge withdrawal",J=O?{success:!0,error:null}:await Jy(Z,K,h);if(!o&&!J.success&&J.error){const me=J.error instanceof Error?J.error.message:String(J.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${me}. The transaction may still be processing.`,autoHide:!0})}const Q=J.success,ue=Lr({txHash:K,srcChainId:h,route:m,values:d,recipient:g},Q);l(ue.tx,ue.details),o||i(Gy(c));const ye=Wo(d,K);if(u("Bridge Transaction Success",ye),O){const me=P(h).metadata?.op_bridge_id;if(me&&!await Uy(F.restUrl,Number(me),m.dest_asset_denom)){const Se=Zy(ue.tx,m,g);D(ue.tx,Se)}}}catch(O){const J=O instanceof Error?O.message:String(O);if(O instanceof hn){const ee=Lr({txHash:K,srcChainId:h,route:m,values:d},!1);l(ee.tx,ee.details),o||i(Yy(c))}else o?o({success:!1,error:J,route:m,values:d}):i({type:"error",title:"Transaction not confirmed",description:J});u("Bridge Confirmation Failed",{...Wo(d,K),error:J,type:O instanceof hn?"timeout":"error"})}finally{N.invalidateQueries({queryKey:Ie.balances(h,f).queryKey})}},onError:async K=>{const W=A==="initia"?await Nn(K,P(h),S):K;o?o({success:!1,error:W.message,route:m,values:d}):r({type:"error",title:"Transaction failed",description:W.message});const O=Wo(d);u("Bridge Transaction Failed",{...O,error:W.message})}})}function Qy(){const e=Fe(),t=ie(),s=zi(),{route:o,values:a}=xt(),r=Bt(),i=cs(),c=bn();return E.useMutation({mutationFn:async()=>{try{const{chain_id:l,hook:u}=await e.post("op-hook",{json:{source_address:t,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:k.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Oy(t,r(o.dest_asset_chain_id).rest);const m=xo(u,{converters:i,fromAmino:c.fromAmino.bind(c)}),d=await s(l,t,m,{amount:[],gas:"1"},"",{incrementSequence:l===a.srcChainId?2:0}),h=Ze.Tx.fromPartial({body:Ze.TxBody.decode(d.bodyBytes),authInfo:Ze.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:de.toBase64(Ze.Tx.encode(h).finish())}}catch(l){throw await ct(l)}}})}function Gy(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(mn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Yy(e){return{type:"info",title:"Transaction pending",description:_.createElement(_.Fragment,null,"Confirmation is taking longer than expected. Check ",_.createElement(mn,{to:"/bridge/history",onClick:e},"the activity page")," for updates"),autoHide:!0}}function Wo(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function Lr(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=bo(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:t},isOpWithdraw:c}}function Zy(e,t,s){return{...e,recipient:k.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function Jy(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function al(e){const{chainId:t,txHash:s,tracked:o}=e,a=Fe();return E.useQuery({queryKey:Ie.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:V.INFINITY,enabled:!o})}function rl(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=Fe();return E.useQuery({queryKey:Ie.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 u=t+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),d=Math.floor((u-m)/1e3);return d<=0?1e3:d<=300?5e3:60*1e3},staleTime:V.INFINITY})}var Yn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Yn||{});function bo(e){const{operations:t,dest_asset_denom:s}=e;return L.has("op_init_transfer",L.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Xy="_success_t4dfk_1",ex="_error_t4dfk_5",qr={success:Xy,error:ex},tx=({tx:e})=>{const[t,s]=nl(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=rl(t),a=t.state??nx(o);switch(_.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return n.jsx("div",{className:qr.error,children:n.jsx(M.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:qr.success,children:n.jsx(M.IconCheckCircleFilled,{size:14})});default:return n.jsx(It,{size:14})}};function nx(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 sx="_link_104m3_1",ox="_header_104m3_23",ax="_title_104m3_31",rx="_date_104m3_37",ix="_explorer_104m3_41",cx="_fees_104m3_57",lx="_label_104m3_65",ux="_content_104m3_69",dx="_route_104m3_75",mx="_row_104m3_80",hx="_asset_104m3_86",fx="_amount_104m3_94",px="_chain_104m3_99",gx="_account_104m3_108",_x="_arrow_104m3_115",Pe={link:sx,header:ox,title:ax,date:rx,explorer:ix,fees:cx,label:lx,content:ux,route:dx,row:mx,asset:hx,amount:fx,chain:px,account:gx,arrow:_x},yx=({tx:e})=>{const[t,s]=nl(e);if(!t)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=t,{data:u}=al(t),{address:m="",connector:d}=Qe.useAccount(),{find:h}=go();_.useEffect(()=>{u&&s(D=>{if(!D)throw new Error("Bridge history details not found");return{...D,tracked:!0}})},[s,u]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:y,dest_asset_chain_id:x,dest_asset_denom:b,estimated_fees:j=[]}=r,v=Ye(p),w=Ye(x),C=At(y,p),I=At(b,x),T=(D,Z)=>Z?n.jsx(re,{src:Z,width:12,height:12}):k.InitiaAddress.equals(D,m)?n.jsx(re,{src:d?.icon,width:12,height:12}):n.jsx(M.IconWallet,{size:12}),A=(D,{symbol:Z,decimals:K,logo_uri:W},{chain_name:O,pretty_name:J,...Q},ee,ue)=>n.jsxs("div",{className:Pe.row,children:[n.jsx(_o,{assetLogoUrl:W,chainLogoUrl:Q.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:Pe.asset,children:[n.jsx("span",{className:Pe.amount,children:k.formatAmount(D,{decimals:K})}),n.jsx("span",{children:Z})]}),n.jsxs("div",{className:Pe.chain,children:[n.jsxs("span",{children:["on ",J||O]}),n.jsxs("div",{className:Pe.account,children:[ue,n.jsx("span",{className:"monospace",children:k.truncate(ee)})]})]})]})]}),$=bo(r),N=_.useMemo(()=>{switch($){case Yn.SKIP:return"Skip Explorer";case Yn.OP_WITHDRAW:return"Initia Scan"}},[$]),S=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Pe.header,children:[n.jsxs("div",{className:Pe.title,children:[l?n.jsx(tx,{tx:e}):n.jsx(It,{size:14}),n.jsx("div",{className:Pe.date,children:Xe.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:Pe.explorer,children:[n.jsx("span",{children:N}),n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]})]}),n.jsxs("div",{className:Pe.route,children:[A(f,C,v,i.sender,T(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:Pe.arrow,children:n.jsx(M.IconArrowDown,{size:12,"aria-hidden":"true"})}),A(g,I,w,i.recipient,T(i.recipient))]}),j.length>0&&n.jsxs("div",{className:Pe.fees,children:[n.jsx("span",{className:Pe.label,children:"Fees"}),n.jsx("span",{className:Pe.content,children:Ka(j)})]})]});if($===Yn.OP_WITHDRAW)return n.jsx(ho,{chainId:o,txHash:a,className:Pe.link,children:S});const P=new URLSearchParams({tx_hash:a,chain_id:o}),F=new URL(`?${P.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:F.toString(),className:Pe.link,target:"_blank",rel:"noopener noreferrer",children:S})},xx="_history_13u9z_1",bx="_header_13u9z_5",wx="_checkbox_13u9z_9",vx="_groups_13u9z_13",jx="_dateGroup_13u9z_21",Cx="_dateHeader_13u9z_26",kx="_list_13u9z_32",on={history:xx,header:bx,checkbox:wx,groups:vx,dateGroup:jx,dateHeader:Cx,list:kx},Nx=()=>{const{initiaAddress:e,hexAddress:t}=tt(),{history:s,getHistoryDetails:o}=tl(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:y,recipient:x}=p;return[y,x].some(b=>[e,t].includes(b))}),[i,c]=_.useState(1),[l,u]=Ge.useToggle(!r.length),m=l?a:r,d=m.slice(0,i*$r),h=_.useMemo(()=>el(d,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[d,o]);return n.jsx(Tt,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:on.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:on.header,children:n.jsx(My,{checked:l,onClick:u,label:"Show all transactions stored in this browser",className:on.checkbox})}),m.length===0?n.jsx(je,{children:"No bridge/swap activity"}):n.jsx("div",{className:on.groups,children:Object.entries(h).map(([f,g])=>n.jsxs("div",{className:on.dateGroup,children:[n.jsx("div",{className:on.dateHeader,children:f}),n.jsx("div",{className:on.list,children:g.map(p=>n.jsx(xe,{children:n.jsx(yx,{tx:p})},p.txHash))})]},f))}),m.length>i*$r?n.jsx(Xc,{onClick:()=>c(f=>f+1)}):s.length>=Qs&&n.jsxs(je,{children:["Only the latest ",Qs," items are stored. Older entries will be removed automatically."]})]})})};function il({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Ix({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return il({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function Ax({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return il({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const Sx=1e4;function ra(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(ra).join(",")}]`:`{${Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${ra(s)}`).join(",")}}`}function Rr(e){return ra({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Tx(e,t,s){const o=Me(),a=et(),r=E.useQueryClient(),i=Fe(),[c,l]=_.useState(!1),[u,m]=_.useState(void 0),[d,h]=_.useState(s??0),f=_.useRef(null);return _.useEffect(()=>{h(s??0)},[s]),_.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const p=Math.max(s??0,d);if(Date.now()-p<=Sx)return!1;l(!0),m(void 0);const y=new AbortController;f.current=y;try{const x=await Yc(i,r,t,{isOpWithdraw:bo(e)===Yn.OP_WITHDRAW,signal:y.signal});if(y.signal.aborted)return!0;const b=Rr(x)!==Rr(e),j=Date.now();return b?(o(0,Ix({currentState:a,route:x,values:t,quoteVerifiedAt:j})),!0):(h(j),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||y.signal.aborted||m((await ct(x)).message),!0}finally{f.current===y&&(f.current=null),y.signal.aborted||l(!1)}},isRefreshing:c,refreshError:u,clearRefreshError:()=>m(void 0)}}function Ex(e,t){return t?"Confirm updated route":e||"Confirm"}function $x({error:e,warning:t,messageRefreshError:s,refreshError:o,requiresReconfirm:a}){if(e)return{level:"error",text:e};if(s)return{level:"error",text:s};if(o)return{level:"error",text:o};if(t)return{level:"warning",text:t};if(a)return{level:"info",text:"Route updated. Please review and confirm again."}}function Mx({isCheckingApprovals:e,isCheckingFeeBalance:t,isFetchingMessages:s,isEstimatingGas:o,isRouteTransitioning:a}){return a?"Refreshing route...":s?"Fetching messages...":t?"Checking fee balance...":e?"Checking approvals...":o?"Estimating gas...":!1}function Lx({isRefreshing:e,isPending:t,backgroundLoadingText:s}){return e?"Refreshing route...":t?"Signing transaction...":s}const za=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a,warning:r,isCheckingApprovals:i,isCheckingFeeBalance:c,messageRefreshError:l,isRouteTransitioning:u,isFetchingMessages:m,isEstimatingGas:d})=>{const h=Me(),f=et(),{route:g,values:p,quoteVerifiedAt:y,requiresReconfirm:x}=xt(),{mutate:b,isPending:j}=Hy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:v,isRefreshing:w,refreshError:C,clearRefreshError:I}=Tx(g,p,y),T=Mx({isCheckingApprovals:i,isCheckingFeeBalance:c,isFetchingMessages:m,isEstimatingGas:d,isRouteTransitioning:u}),A=async()=>{if(!(j||w||T||l)){if(x){h(0,Ax({currentState:f,route:g,values:p,quoteVerifiedAt:y??Date.now()}));return}await v()||(I(),b())}},$=$x({error:a,warning:r,messageRefreshError:l,refreshError:C,requiresReconfirm:x}),N=Lx({isRefreshing:w,isPending:j,backgroundLoadingText:T}),S=j||w||!!T||!!l;return n.jsx(Ae,{extra:$&&n.jsx(we,{level:$.level,children:$.text}),children:n.jsx(fe.White,{onClick:A,loading:N,disabled:!!a||!!r||S,children:Ex(o,!!x)})})};function qx({approvalError:e,approveTokens:t,exactFeeCheckError:s,isApproving:o,isCheckingApprovals:a,isCheckingFeeBalance:r,isFetchingMessages:i,messageRefreshError:c,requiresApproval:l}){return i||c?{kind:"preview",isFetchingMessages:i,messageRefreshError:c}:r?{kind:"preview",isCheckingFeeBalance:!0}:s?{kind:"preview",error:s}:a?{kind:"preview",isCheckingApprovals:!0}:l&&t?{kind:"approval",approvalError:e,approveTokens:t,isApproving:!!o}:{kind:"preview"}}const Rx="_content_1hzj2_1",Px="_info_1hzj2_6",Dx="_arrow_1hzj2_11",Bx="_divider_1hzj2_19",Fx="_type_1hzj2_27",Ux="_asset_1hzj2_47",Ox="_amount_1hzj2_55",Vx="_lower_1hzj2_60",Kx="_chain_1hzj2_66",Wx="_address_1hzj2_72",ot={content:Rx,info:Px,arrow:Dx,divider:Bx,type:Fx,asset:Ux,amount:Ox,lower:Vx,chain:Kx,address:Wx},cl=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=k.truncate(a),decimals:u=0,logo_uri:m=ya}=e,{chain_name:d,pretty_name:h,...f}=Ye(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:ot.arrow,children:[n.jsx("div",{className:ot.divider}),s?n.jsx(_s,{label:s,children:n.jsx("button",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})})}):n.jsx("span",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})}),n.jsx("div",{className:ot.divider})]}),n.jsxs("div",{className:ot.content,children:[n.jsx(_o,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:ot.info,children:[n.jsxs("div",{className:ot.asset,children:[n.jsx("span",{className:ot.amount,children:k.formatAmount(o,{decimals:u})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:ot.lower,children:[n.jsxs("div",{className:ot.chain,children:["on ",h||d]}),i&&n.jsx(Ws,{value:i,children:({copy:g,copied:p})=>n.jsxs("button",{className:ot.address,onClick:g,children:[c,p?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:k.truncate(i)})]})})]})]})]})]})},Sn=e=>{const t=At(e.denom,e.chainId);return n.jsx(cl,{...e,...t})};Sn.Placeholder=cl;const zx="_root_1hbar_1",Hx="_flexEnd_1hbar_6",Qx="_toggle_1hbar_11",Gx="_route_1hbar_36",Yx="_content_1hbar_43",Hn={root:zx,flexEnd:Hx,toggle:Qx,route:Gx,content:Yx};function Zx(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":Ys.capitalCase(L.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(t).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(t).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 Jx=({addressList:e})=>{const{values:t,route:s}=xt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=L.zipObj(s.required_chain_addresses,e),{find:l}=go(),{connector:u,address:m=""}=Qe.useAccount(),[d,h]=Ge.useToggle(!1),f=i.length>1,g=n.jsx(re,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:u?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:g},y=w=>k.InitiaAddress.equals(w,m)?g:n.jsx(M.IconWallet,{size:11}),x=w=>{const{label:C,amount_out:I,denom:T,denom_out:A=T,chain_id:$,from_chain_id:N,to_chain_id:S=$??N}=w,P=c[S];return{label:f&&!d?void 0:C,amount:I,denom:A,chainId:S,address:P,walletIcon:y(P)}},b=i.map(Zx).map(x),j=b.slice(0,-1),v=b[b.length-1];return n.jsxs(te.Collapsible.Root,{className:Hn.root,open:d,onOpenChange:h,children:[f&&n.jsx("div",{className:Hn.flexEnd,children:n.jsx(te.Collapsible.Trigger,{className:Hn.toggle,children:d?n.jsxs(n.Fragment,{children:[n.jsx(M.IconMinus,{size:12}),n.jsx("span",{children:"Hide details"})]}):n.jsxs(n.Fragment,{children:[n.jsx(M.IconList,{size:12}),n.jsx("span",{children:"Show details"})]})})}),n.jsxs("div",{className:Hn.route,children:[n.jsx(Sn,{...p,source:!0}),n.jsx(te.Collapsible.Content,{className:Hn.content,children:j.map((w,C)=>n.jsx(xe,{suspenseFallback:n.jsx(Sn.Placeholder,{...w}),errorBoundaryProps:{fallback:n.jsx(Sn.Placeholder,{...w})},children:n.jsx(Sn,{...w})},C))}),n.jsx(Sn,{...v})]})]})},ll=({error:e})=>{const t=Me();return n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:e.message}),children:n.jsx(fe.White,{onClick:()=>t("/bridge"),children:"Home"})})},ul=({children:e})=>{const t=xt(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:u,hexAddress:m}=tt(),d=ls(),h=Bt(),f=fs(),g=h(r),p=f(g),y=a.slice(0,-1).some(I=>{const T=h(I);return f(T)==="cosmos"})&&p!=="cosmos",[x,b]=_.useState(void 0),[j,v]=_.useState(!1),[w,C]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!y)return;if(!d)throw new Error("Wallet not connected");v(!0),C(null);const[{pubkey:T}]=await d.getAccounts();b(T)}catch(T){C(await ct(T))}finally{v(!1)}})()},[y,d]),w)return n.jsx(ll,{error:w});if(j)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:j&&"Generating intermediary addresses..."})});if(!y||x){const I=a.map((T,A)=>{if(A===a.length-1){const F=h(i);return f(F)==="initia"?k.InitiaAddress(l).bech32:l}const $=h(T),N=f($),S=h(r),P=f(S);switch(N){case"initia":return u;case"evm":return m;case"cosmos":{if(P==="cosmos")return de.toBech32($.bech32_prefix,de.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return En.pubkeyToAddress(En.encodeSecp256k1Pubkey(x),$.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(I)}return null};function Xx(e){return"evm_tx"in e?JSON.stringify({approvals:e.evm_tx.required_erc20_approvals??[],chainId:e.evm_tx.chain_id,signerAddress:e.evm_tx.signer_address}):"non-evm"}function e1({currentKey:e,isPending:t,nextKey:s}){return!t&&e!==s}function t1(e,t){return typeof e=="function"?e(t):t.isCheckingApprovals?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Checking approvals..."})}):t.requiresApproval&&t.approveTokens?n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:t.approvalError}),children:n.jsx(fe.White,{onClick:t.approveTokens,loading:t.isApproving&&"Approving tokens...",children:"Approve tokens"})}):e}const dl=({tx:e,children:t})=>{const s=Qi(),o=Bt(),a=E.useQueryClient(),r=Xx(e),i=_.useRef(r),{data:c,isLoading:l}=E.useQuery({queryKey:["interwovenkit:erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:g,signer_address:p}=e.evm_tx,y=await s();await aa(y,o(g));const x=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async j=>{const{token_contract:v,spender:w}=j,I=await new kt.ethers.Contract(v,x,y).allowance(p,w);return{approval:j,currentAllowance:BigInt(I.toString())}}))).filter(({approval:j,currentAllowance:v})=>v<BigInt(j.amount)).map(({approval:j})=>j)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:u,data:m,isPending:d,error:h,reset:f}=E.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!c||c.length===0)throw new Error("No approvals needed");const{chain_id:g}=e.evm_tx,p=await s(),y=await p.getSigner();await aa(p,o(g));for(const x of c){const{token_contract:b,spender:j,amount:v}=x,w=["function approve(address spender, uint256 amount) external returns (bool)"],I=await new kt.ethers.Contract(b,w,y).approve(j,v);await Gi(I.wait(),3e4,"Approval was not confirmed in time. It may still be processing.")}return!0}catch(g){throw g instanceof hn?(a.invalidateQueries({queryKey:["interwovenkit:erc20-approvals-needed",e]}),g):await ct(g)}}});return _.useEffect(()=>{const g=i.current;e1({currentKey:g,isPending:d,nextKey:r})&&(i.current=r,f())},[r,d,f]),t1(t,{approvalError:h?.message,approveTokens:c&&c.length>0&&!m?()=>u():void 0,isApproving:d,isCheckingApprovals:l,requiresApproval:!!c&&c.length>0&&!m})};function n1({route:e,tx:t,isSrcInitia:s,isDstInitia:o,sender:a,recipient:r}){return!!e&&"cosmos_tx"in t&&!!t.cosmos_tx.msgs?.length&&!e.required_op_hook&&s&&o&&!!a&&!!r}function s1({hasBalances:e,hasChain:t,requiresExactFeeCheck:s}){return s&&e&&t}function o1({balances:e,feeDenoms:t}){return e?t.toSorted().map(s=>`${s}:${e[s]?.amount??"0"}`).join("|"):""}function a1({tx:e,children:t}){const{route:s,values:o}=xt(),{sender:a,recipient:r,srcChainId:i,srcDenom:c,dstChainId:l}=o,u=Ye(i),m=Ye(l),d=yn(u),h=yn(m),{data:f,isLoading:g,error:p}=po(a,i),y=cs(),x=bn(),b=us(),j=n1({route:s,tx:e,isSrcInitia:d==="initia",isDstInitia:h==="initia",sender:a,recipient:r}),{chain:v,error:w,isLoading:C}=au(i,j),I=v?Array.from(new Set([c,...v.fees.fee_tokens.map(({denom:P})=>P)])):[],T=o1({balances:f,feeDenoms:I}),A=s1({hasBalances:f!==void 0,hasChain:!!v,requiresExactFeeCheck:j}),{data:$,error:N,isLoading:S}=E.useQuery({queryKey:["interwovenkit:bridge-preview-fee-check",e,a,i,c,s.amount_in,T],queryFn:async()=>{try{if(!(j&&v&&"cosmos_tx"in e&&e.cosmos_tx.msgs?.length&&f))throw new Error("Invalid transaction data");const P=xo(e.cosmos_tx.msgs,{converters:y,fromAmino:x.fromAmino.bind(x)}),D=await(await b(i)).simulate(a,P,""),Z=await Na(v),K=Wy({gas:D,gasPrices:Z});return zy({balances:f,requiredFeeByDenom:K,sourceDenom:c,amountIn:s.amount_in})}catch(P){throw await ct(P)}},enabled:A,retry:!1});return t(j?w?{exactFeeCheckError:w.message,isCheckingFeeBalance:!1}:p?{exactFeeCheckError:p instanceof Error?p.message:"Failed to load balances",isCheckingFeeBalance:!1}:C||g||f===void 0||S?{isCheckingFeeBalance:!0}:N?{exactFeeCheckError:N.message,isCheckingFeeBalance:!1}:$?{isCheckingFeeBalance:!1}:{exactFeeCheckError:"Insufficient balance for fees",isCheckingFeeBalance:!1}:{isCheckingFeeBalance:!1})}function r1({addressList:e,operations:t,signedOpHook:s}){return JSON.stringify({addressList:e,operations:t,signedOpHook:s??null})}function i1({previousQuoteVerifiedAt:e,quoteVerifiedAt:t,hasValue:s,hasMessageRefreshError:o}){return s&&o&&e!==void 0&&t!==void 0&&t!==e}function c1({error:e,loading:t,value:s}){const o=s!==void 0;return{isFetchingMessages:t,messageRefreshError:!t&&o&&e?e.message:void 0,shouldRenderError:!!e&&!o,shouldRenderLoading:!o}}const ml=({addressList:e,signedOpHook:t,children:s})=>{const o=Fe(),{route:a,values:r,quoteVerifiedAt:i}=xt(),[c,l]=_.useState(void 0),[u,m]=_.useState(!1),[d,h]=_.useState(null),[f,g]=_.useState(0),p=_.useRef(i),y=r1({addressList:e,operations:a.operations,signedOpHook:t});_.useEffect(()=>{const b=p.current;i1({previousQuoteVerifiedAt:b,quoteVerifiedAt:i,hasValue:c!==void 0,hasMessageRefreshError:d!==null})&&g(j=>j+1),p.current=i},[i,c,d]),_.useEffect(()=>{let b=!1;return(async()=>{try{if(m(!0),h(null),a.required_op_hook&&!t)throw new Error("Op hook is required");const v=await Ky(o,{addressList:e,route:{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,operations:a.operations},slippagePercent:String(r.slippagePercent),signedOpHook:t});if(b)return;const[w]=v;l(w)}catch(v){if(b)return;h(await ct(v))}finally{b||m(!1)}})(),()=>{b=!0}},[y,f,a.amount_in,a.amount_out,a.source_asset_chain_id,a.source_asset_denom,a.dest_asset_chain_id,a.dest_asset_denom,a.required_op_hook,r.slippagePercent,o]);const x=c1({error:d,loading:u,value:c});return x.shouldRenderError&&d?n.jsx(ll,{error:d}):x.shouldRenderLoading?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Fetching messages..."})}):s(c,{isFetchingMessages:x.isFetchingMessages,messageRefreshError:x.messageRefreshError})},hl=({children:e})=>{const{route:t}=xt(),s=Qy();return t.required_op_hook&&!s.data?n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:s.error?.message}),children:n.jsx(fe.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)};function l1({approvalError:e,approveTokens:t,isApproving:s}){return n.jsx(Ae,{extra:e&&n.jsx(we,{level:"error",children:e}),children:n.jsx(fe.White,{onClick:t,loading:s&&"Approving tokens...",children:"Approve tokens"})})}const u1=()=>n.jsx(Tt,{title:"Route preview",children:n.jsx(ul,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(Jx,{addressList:e}),n.jsx(hl,{children:t=>n.jsx(ml,{addressList:e,signedOpHook:t,children:(s,{isFetchingMessages:o,messageRefreshError:a})=>n.jsx(a1,{tx:s,children:({exactFeeCheckError:r,isCheckingFeeBalance:i})=>n.jsx(dl,{tx:s,children:({approvalError:c,approveTokens:l,isApproving:u,isCheckingApprovals:m,requiresApproval:d})=>{const h=qx({approvalError:c,approveTokens:l,exactFeeCheckError:r,isApproving:u,isCheckingApprovals:m,isCheckingFeeBalance:i,isFetchingMessages:o,messageRefreshError:a,requiresApproval:d});return h.kind==="approval"?l1({approvalError:h.approvalError,approveTokens:h.approveTokens,isApproving:h.isApproving}):n.jsx(za,{tx:s,error:h.error,isCheckingApprovals:h.isCheckingApprovals,isCheckingFeeBalance:h.isCheckingFeeBalance,isFetchingMessages:h.isFetchingMessages,messageRefreshError:h.messageRefreshError})}})})})})]})})}),fl=_.createContext(null);function wo(){return _.useContext(fl)}const d1="_button_17r1o_1",m1="_claimed_17r1o_24",Pr={button:d1,claimed:m1},h1=()=>{const{withdrawalTx:e}=wo(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:u}=e,m=ce(),d=ie(),{requestTxSync:h,waitForTxConfirmation:f}=tt(),g=Fy(e),p=de.toBase64(ol(e)),y=sl(e,p),x=E.useQueryClient(),{mutate:b,isPending:j}=E.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:v}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:d,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(de.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:de.fromBase64(u),storageRoot:de.fromBase64(i),lastBlockHash:de.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:m.chain_id,txHash:v}),x.invalidateQueries({queryKey:vn.withdrawalClaimed(t,p).queryKey})}});return y?n.jsxs("div",{className:Pr.claimed,children:[n.jsx(M.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:Pr.button,onClick:()=>b(),disabled:j,children:"Claim"})},f1=({children:e})=>{const{withdrawalTx:t}=wo(),s=Ry(t.bridge_id),o=By(t),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Xe.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},pl=1e3,p1=60,g1=60,_1=24,ia=pl*p1,ca=ia*g1,Dr=ca*_1,y1=({date:e})=>{const t=_.useCallback(()=>{const u=new Date().getTime(),d=e.getTime()-u;if(d<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(d/Dr),f=Math.floor(d%Dr/ca),g=Math.floor(d%ca/ia),p=Math.floor(d%ia/pl);return{days:h,hours:f,minutes:g,seconds:p}},[e]),[s,o]=_.useState(t());_.useEffect(()=>{const u=window.setInterval(()=>{o(t())},1e3);return()=>window.clearInterval(u)},[t,e]);const a=u=>u.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return n.jsx(_s,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},x1="_container_1lz3w_1",b1="_title_1lz3w_5",Br={container:x1,title:b1},w1=({date:e})=>n.jsxs("div",{className:Br.container,children:[n.jsx("div",{className:Br.title,children:"Claimable in"}),n.jsx(y1,{date:e})]}),v1="_container_1oldz_1",j1="_icon_1oldz_7",Fr={container:v1,icon:j1},C1="Withdrawal will begin within an hour",Ur=()=>{const e=uo();return n.jsxs("div",{className:Fr.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(_s,{label:C1,children:n.jsx("span",{className:Fr.icon,children:n.jsx(M.IconInfoFilled,{size:12})})})]})},k1=({children:e})=>{const{withdrawalTx:t}=wo(),s=Dy(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},N1=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=wo(),a=de.toBase64(ol(o)),r=sl(o,a),{setReminder:i,removeReminder:c}=Fn();return _.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:Xe.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},I1=()=>n.jsx(k1,{children:e=>e?n.jsx(Ur,{}):n.jsx(f1,{children:t=>t?n.jsx(N1,{date:t,children:Xe.isFuture(t)?n.jsx(w1,{date:t}):n.jsx(h1,{})}):n.jsx(Ur,{})})}),A1="_asset_6h8u2_1",S1="_info_6h8u2_7",T1="_symbol_6h8u2_11",zo={asset:A1,info:S1,symbol:T1},E1=({amount:e,denom:t})=>{const s=ce(),o=bi(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:zo.asset,children:[n.jsx(re,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:zo.info,children:[n.jsx("span",{className:"monospace",children:k.formatAmount(e,{decimals:i})}),n.jsx("span",{className:zo.symbol,children:a})]})]})},$1="_item_km5w2_1",M1={item:$1},L1=({chain:e})=>{const t=e.metadata?.executor_uri;if(!t)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=Py(t),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Fn();return _.useEffect(()=>{const l=i.map(u=>({chainId:e.chainId,txHash:u.tx_hash}));c(l)},[e.chainId,i,c]),i.length?n.jsxs(n.Fragment,{children:[i.map(l=>{const{amount:u}=l;return n.jsxs("div",{className:M1.item,children:[n.jsx(E1,{...u}),n.jsx(xe,{suspenseFallback:null,children:n.jsx(fl.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(I1,{})})})]},l.sequence)}),a&&n.jsx(Xc,{onClick:()=>o(),disabled:r})]}):n.jsx(je,{children:"No withdrawals"})},q1="_content_dj1qm_1",R1="_title_dj1qm_5",Or={content:q1,title:R1},P1=()=>{const{chainId:e}=et(),t=_e(),s=xn(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=lt(),{reminders:i}=Fn(),c=o?r(o):void 0;return n.jsxs(Tt,{title:"OP Bridge withdrawals",children:[n.jsx(fn,{chains:t.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(u=>u.chainId===l)}),n.jsx("div",{className:Or.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Or.title,children:c.name}),n.jsx(xe,{children:n.jsx(L1,{chain:c})},o)]}):n.jsx(we,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Rn=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),D1="5722e7dffb709492cf5312446ceeff73",B1=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${D1}`,gl=["interwovenkit:walletconnect-wallets"],F1=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",_l=async e=>{const t=await z.get(B1,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(F1)},U1=()=>E.useQuery({queryKey:gl,queryFn:({signal:e})=>_l(e),staleTime:V.INFINITY,gcTime:V.INFINITY,retry:2}),O1="_page_13y8q_1",V1="_pageTop_13y8q_19",K1="_backButtonFixed_13y8q_63",W1="_listItem_13y8q_64",z1="_socialButton_13y8q_65",H1="_arrowIcon_13y8q_66",Q1="_searchInputUnderline_13y8q_67",G1="_header_13y8q_72",Y1="_title_13y8q_81",Z1="_headerSpacer_13y8q_116",J1="_icon_13y8q_120",X1="_installedText_13y8q_124",e0="_divider_13y8q_131",t0="_dividerText_13y8q_152",n0="_loading_13y8q_193",s0="_socialIcons_13y8q_198",o0="_socialText_13y8q_204",a0="_searchWrapper_13y8q_214",r0="_scrollable_13y8q_248",i0="_list_13y8q_64",c0="_listIconWrapper_13y8q_332",l0="_moreIconSmall_13y8q_342",u0="_externalLinkIcon_13y8q_364",d0="_listName_13y8q_368",m0="_listNameMuted_13y8q_381",h0="_recentBadge_13y8q_394",f0="_learnMoreLink_13y8q_408",U={page:O1,pageTop:V1,backButtonFixed:K1,listItem:W1,socialButton:z1,arrowIcon:H1,searchInputUnderline:Q1,header:G1,title:Y1,headerSpacer:Z1,icon:J1,installedText:X1,divider:e0,dividerText:t0,loading:n0,socialIcons:s0,socialText:o0,searchWrapper:a0,scrollable:r0,list:i0,listIconWrapper:c0,moreIconSmall:l0,externalLinkIcon:u0,listName:d0,listNameMuted:m0,recentBadge:h0,learnMoreLink:f0},p0=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},g0=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=_.useState(""),{data:l=[],isError:u,isLoading:m,isFetching:d}=U1(),h=m||d&&l.length===0,f=_.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(y=>y.name.toLowerCase().includes(p))},[e,i]),g=_.useMemo(()=>{const p=new Set(e.map(x=>Rn(x.name))),y=i.toLowerCase();return l.filter(x=>!p.has(Rn(x.name))).filter(x=>!i||x.name.toLowerCase().includes(y)).sort((x,b)=>x.name.localeCompare(b.name))},[l,e,i]);return n.jsxs("div",{className:U.pageTop,children:[n.jsx("button",{type:"button",className:U.backButtonFixed,onClick:r,"aria-label":"Back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"All Wallets"}),n.jsx("div",{className:U.headerSpacer})]}),n.jsx("div",{className:U.searchWrapper,children:n.jsx(ys,{rootClassName:U.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),n.jsx(yt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[f.map(p=>{const{name:y,icon:x,id:b}=p,j=o===b,v=s===b,w="ready"in p?!!p.ready:!0;return n.jsxs("button",{type:"button",className:B(U.listItem,{[U.loading]:v}),onClick:()=>a(p),disabled:t||!w,"aria-busy":v,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:y}),v?n.jsx(It,{size:16}):j?n.jsx("span",{className:U.recentBadge,children:"Recent"}):w?n.jsx("span",{className:U.installedText,children:"Installed"}):null]},`connector:${b}`)}),h&&n.jsxs("div",{className:B(U.listItem,U.loading),role:"status","aria-live":"polite",children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(It,{size:16})}),n.jsx("span",{className:U.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const y=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,x=y&&p0(y)?y:void 0;return n.jsxs("button",{type:"button",className:U.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[n.jsx("div",{className:U.listIconWrapper,children:x&&n.jsx(re,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:p.name})]},`wc:${p.id}`)}),u&&n.jsx(we,{level:"error",children:"Couldn't load additional wallets."})]})})]})},_0=(e,t,s,o)=>{if(e.length<=s)return[...e];const a=o?e.findIndex(d=>d.id===o):-1,r=a>=0?e[a]:void 0,i=a>=0?e.filter((d,h)=>h!==a):e,c=new Set(t.map(d=>d.id)),l=new Set(t.map(d=>Rn(d.name))),u=[],m=[];for(const d of i)c.has(d.id)||l.has(Rn(d.name))?u.push(d):m.push(d);return r?[r,...u,...m].slice(0,s):u.concat(m).slice(0,s)},y0=()=>n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),x0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[n.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),n.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),n.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),n.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),b0=()=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),w0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Vr=[{id:"io.rabby",name:"Rabby",icon:"https://assets.initia.xyz/images/wallets/Rabby.webp",url:"https://rabby.io"},{id:"app.phantom",name:"Phantom",icon:"https://assets.initia.xyz/images/wallets/Phantom.webp",url:"https://phantom.com"},{id:"app.keplr",name:"Keplr",icon:"https://assets.initia.xyz/images/wallets/Keplr.webp",url:"https://keplr.app"},{id:"io.leapwallet",name:"Leap",icon:"https://assets.initia.xyz/images/wallets/Leap.webp",url:"https://leapwallet.io"},{id:"io.metamask",name:"MetaMask",icon:"https://assets.initia.xyz/images/wallets/MetaMask.webp",url:"https://metamask.io"}],Kr=5,v0=({walletConnectors:e,privyConnector:t,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),u=_0(l,Vr,Kr,a),m=new Set(l.map(g=>g.id)),d=new Set(l.map(g=>Rn(g.name))),h=Math.max(0,Kr-u.length),f=Vr.filter(g=>!m.has(g.id)&&!d.has(Rn(g.name))).slice(0,h);return n.jsxs("div",{className:U.page,children:[n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"Sign In"}),n.jsx("div",{className:U.headerSpacer})]}),t&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:B(U.socialButton,{[U.loading]:o===t.id}),onClick:()=>r(t),disabled:s,"aria-busy":o===t.id,children:[n.jsx("span",{className:U.socialText,children:"Email / Socials"}),o===t.id?n.jsx(It,{size:16}):n.jsxs("div",{className:U.socialIcons,children:[n.jsx(x0,{}),n.jsx(w0,{}),n.jsx(b0,{})]})]}),n.jsx("div",{className:U.divider,children:n.jsx("span",{className:U.dividerText,children:"or"})})]}),n.jsx(yt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[u.map(g=>{const{icon:p,id:y,name:x,uid:b}=g,j=o===y,v=a===y;return n.jsxs("button",{type:"button",className:B(U.listItem,{[U.loading]:j}),onClick:()=>r(g),disabled:s,"aria-busy":j,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:p,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:x}),j?n.jsx(It,{size:16}):v?n.jsx("span",{className:U.recentBadge,children:"Recent"}):n.jsx("span",{className:U.installedText,children:"Installed"})]},b)}),f.map(g=>n.jsxs("a",{className:U.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:g.icon,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:g.name}),n.jsx(M.IconExternalLink,{size:10,className:U.externalLinkIcon,"aria-hidden":"true"})]},g.id)),n.jsxs("button",{type:"button",className:U.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx("div",{className:U.moreIconSmall,children:n.jsx(y0,{})})}),n.jsx("span",{className:U.listNameMuted,children:"More wallets"}),n.jsx("span",{className:U.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),n.jsxs("a",{className:U.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Wr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=Qe.useConnect(),o=Ge.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,c]=_.useState("signin"),l=E.useQueryClient(),u=()=>l.prefetchQuery({queryKey:gl,queryFn:({signal:p})=>_l(p),staleTime:V.INFINITY,gcTime:V.INFINITY}),{mutate:m,isPending:d}=E.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(y){throw await ct(y)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=_.useMemo(()=>[...t].sort((p,y)=>p.id===o?-1:y.id===o?1:p.name.localeCompare(y.name)),[t,o]),f=_.useMemo(()=>h.find(p=>p.id===Jn.id),[h]),g=_.useMemo(()=>h.filter(p=>p.id!==Jn.id),[h]);return i==="all"?n.jsx(g0,{walletConnectors:g,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):n.jsx(v0,{walletConnectors:g,privyConnector:f,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:u})},j0="iUSD",zr="1",C0="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",k0="0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",N0={[j0]:{externalSourceSymbols:["USDC","AUSD"],extraExternalOptions:[{chainId:zr,denom:C0},{chainId:zr,denom:k0}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Hr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function I0(e){return N0[e]}function Qr(e){return e.pretty_name||e.chain_name}function Gr(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const A0={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:""};function S0({chainIds:e,chains:t}){return Object.fromEntries(e.map(s=>[s,t?.[s]?.denoms??{}]))}const T0={deposit:{mode:"deposit",label:"Deposit",local:{denomKey:"dstDenom",chainIdKey:"dstChainId"},external:{denomKey:"srcDenom",chainIdKey:"srcChainId"}},withdraw:{mode:"withdraw",label:"Withdraw",local:{denomKey:"srcDenom",chainIdKey:"srcChainId"},external:{denomKey:"dstDenom",chainIdKey:"dstChainId"}}};function bs(e){return T0[e]}function E0(){const e=Fe(),{data:t,error:s}=E.useQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:o})=>o.filter(({chain_type:a,bech32_prefix:r})=>a==="evm"||a==="cosmos"&&r==="init"),staleTime:V.MINUTE});return{chains:t??[],error:s}}function Ha(){const e=Fe(),t=Bn(),s=ie(),{chains:o,error:a}=E0(),r=_.useMemo(()=>o.map(({chain_id:u})=>u),[o]),{data:i,error:c,isLoading:l}=E.useQuery({queryKey:Ie.allBalances(r,[t,s]).queryKey,queryFn:()=>{const u=Object.fromEntries(o.map(m=>[m.chain_id,{address:m.chain_type==="evm"?t:s,denoms:[]}]));return e.post("v2/info/balances",{json:{chains:u}}).json()},select:({chains:u})=>S0({chainIds:r,chains:u}),enabled:!!s&&r.length>0,staleTime:V.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Qa(){const{localOptions:e=[]}=et(),t=E.useQueryClient(),s=Fe(),{data:o,isLoading:a}=E.useQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:V.MINUTE});return{data:_.useMemo(()=>{if(o){const i=Object.values(o.chain_to_assets_map).flatMap(l=>l?.assets??[]),c=new Map(i.map(l=>[`${l.chain_id}:${l.denom}`,l]));return e.map(({denom:l,chainId:u})=>{const m=c.get(`${u}:${l}`);return{denom:l,chain_id:u,symbol:m?.symbol??"",logo_uri:m?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData($n.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Ga(e){const{local:t}=bs(e),s=ps(),{watch:o}=Jt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function $0(e){const{external:t}=bs(e),s=ps(),{watch:o}=Jt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function yl(e){const t=ps(),s=fo(),o=Bt(),a=Oa(),{data:r,isLoading:i}=Ha(),{remoteOptions:c=[]}=et(),l=Ga(e);if(!l)return{...A0,isLoading:i};const u=I0(l.symbol),m=u?.externalSourceSymbols??[l.symbol],d=c.length>0,h=u?.extraExternalOptions??[],f=u?.extraInitiaSourceSymbols??[],g=u?.externalChainListSource??"supported-assets",p=new Map(s.map(w=>[w.chain_id,w])),y=t.filter(({symbol:w,denom:C,chain_id:I})=>{if(d)return c.some(P=>Hr(P,I,C));const T=h.some(P=>Hr(P,I,C)),A=p.get(I),$=!!A&&a(A.chain_id)&&f.includes(w),N=T||$;return w===l.symbol||N}).map(w=>{if(w.hidden||w.chain_id===l.chain_id)return null;const C=o(w.chain_id);if(!C||!Gr(C))return null;const I=r?.[C.chain_id]?.[w.denom];return{asset:w,chain:C,balance:I}}).filter(w=>w!==null),x=y.filter(({balance:w})=>e!=="deposit"||!!w&&Number(w.amount)>0),b=new Map;if(g==="extra-options")for(const{chainId:w}of h){const C=p.get(w);C&&Gr(C)&&(a(C.chain_id)||b.set(C.chain_id,C))}else for(const{chain:w}of x)a(w.chain_id)||b.set(w.chain_id,w);const j=Array.from(b.values()).sort((w,C)=>Qr(w).localeCompare(Qr(C))),v=[...new Set(y.filter(({chain:w})=>fg(w,a)).map(({asset:w})=>w.symbol))];return{data:x,isLoading:i,supportedExternalChains:j,appchainSourceSymbols:v,externalSourceSymbols:m,localSymbol:l.symbol}}function Jt(){return $e.useFormContext()}const M0="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",L0="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e";function la(e){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(", ")}, or ${e[e.length-1]}`}function q0(e,t,s){const o=[...new Set(e)],a=[],r=[...s,t];for(const c of r)o.includes(c)&&!a.includes(c)&&a.push(c);const i=o.filter(c=>!a.includes(c)).sort((c,l)=>c.localeCompare(l));return[...a,...i]}function R0(e,t,s){if(!e.length)return"";const o=q0(e,t,s);return o.length===1&&o[0]===t?"from any app":`using ${la(o)} from any app`}function P0({localSymbol:e,externalSourceSymbols:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=la(s),c=[...new Set(t)],l=la(c),u=R0(o,e,c),m=!!u,d=c.length!==1||c[0]!==e;if(r&&m){const h=d?`using ${l} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${h}, or ${u}.`}}return r?d?{title:a,description:`You can deposit ${e} using ${l} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:m?{title:a,description:`You can deposit ${e} ${u}.`}:{title:a,description:"No deposit sources are currently available."}}const D0="_container_pjkfr_1",B0="_title_pjkfr_5",F0="_close_pjkfr_12",U0="_emptyIcon_pjkfr_24",O0="_empty_pjkfr_24",V0="_emptyDescription_pjkfr_39",K0="_list_pjkfr_60",W0="_asset_pjkfr_75",z0="_placeholder_pjkfr_91",H0="_activeAsset_pjkfr_104",Q0="_iconContainer_pjkfr_108",G0="_assetIcon_pjkfr_118",Y0="_chainIcon_pjkfr_128",Z0="_assetPlaceholder_pjkfr_142",J0="_assetName_pjkfr_163",X0="_assetChain_pjkfr_178",e2="_balance_pjkfr_186",t2="_value_pjkfr_195",be={container:D0,title:B0,close:F0,emptyIcon:U0,empty:O0,emptyDescription:V0,list:K0,asset:W0,placeholder:z0,activeAsset:H0,iconContainer:Q0,assetIcon:G0,chainIcon:Y0,assetPlaceholder:Z0,assetName:J0,assetChain:X0,balance:e2,value:t2},n2=({mode:e})=>{const{external:t}=bs(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbols:i,localSymbol:c}=yl(e),{setValue:l,watch:u}=Jt(),m=Ga(e),{data:d}=Qa(),{theme:h}=se(),f=u(),g=f[t.denomKey],p=f[t.chainIdKey],x=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"";function b(w,C){l(t.denomKey,w),l(t.chainIdKey,C),e==="deposit"&&l("quantity",""),l("page","fields")}const j=_.useEffectEvent(()=>{if(!x)return;const[{asset:w,chain:C}]=s;if(g===w.denom&&p===C.chain_id){l("page","fields");return}b(w.denom,C.chain_id)});_.useEffect(()=>{j()},[x]);function v(){const w=g&&p;return!w&&d.length<=1&&e==="deposit"?null:n.jsx("button",{className:be.close,onClick:()=>{e==="withdraw"||w?l("page","fields"):l("page","select-local")},children:n.jsx(M.IconBack,{size:20})})}if(!m)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const w=a.map(T=>T.pretty_name||T.chain_name).filter(T=>!!T),C=P0({localSymbol:c,externalSourceSymbols:i,externalChainNames:w,appchainSourceSymbols:r}),I=e==="withdraw"?`No supported destinations to withdraw ${m.symbol}.`:C.title;return n.jsxs("div",{className:be.container,children:[v(),n.jsx("h4",{className:be.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?M0:L0,alt:"No assets",className:be.emptyIcon}),n.jsx("p",{className:be.empty,children:I}),e==="deposit"&&n.jsx("p",{className:be.emptyDescription,children:C.description})]})}return n.jsxs("div",{className:be.container,children:[v(),n.jsxs("h4",{className:be.title,children:[e==="withdraw"?"Select destination":`Deposit ${m.symbol}`," "]}),n.jsxs("div",{className:be.list,children:[o&&Array.from({length:5}).map((w,C)=>n.jsxs("div",{className:B(be.asset,be.placeholder),children:[n.jsxs("div",{className:be.iconContainer,children:[n.jsx("div",{className:be.assetIcon}),n.jsx("div",{className:be.chainIcon})]}),n.jsx("div",{className:be.assetPlaceholder})]},C)),!o&&s.sort(({balance:w},{balance:C})=>Number(C?.value_usd??0)-Number(w?.value_usd??0)).map(({asset:w,chain:C,balance:I})=>{const T=g===w.denom&&p===C.chain_id,A=Ua(I?.value_usd,I?.price);return n.jsxs("button",{className:B(be.asset,T&&be.activeAsset),onClick:()=>b(w.denom,C.chain_id),children:[n.jsxs("div",{className:be.iconContainer,children:[n.jsx("img",{src:w.logo_uri,alt:w.symbol,className:be.assetIcon}),n.jsx("img",{src:C.logo_uri||"",alt:C.chain_name,className:be.chainIcon})]}),n.jsxs("p",{className:be.assetName,children:[w.symbol," ",T&&n.jsx("span",{children:n.jsx(M.IconCheck,{size:16})})]}),n.jsxs("p",{className:be.assetChain,children:["on ",C.pretty_name]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:be.balance,children:k.formatAmount(I.amount,{decimals:I.decimals||6})}),n.jsx("p",{className:be.value,children:A})]})]},`${w.chain_id}-${w.denom}`)})]})]})},s2="_title_iequo_1",o2="_list_iequo_7",a2="_asset_iequo_15",r2="_imgPlaceholder_iequo_40",$s={title:s2,list:o2,asset:a2,imgPlaceholder:r2},i2=({mode:e})=>{const{local:t,external:s}=bs(e),{setValue:o}=Jt(),{data:a,isLoading:r}=Qa(),[i,c]=_.useTransition(),l=(m,d)=>{o(t.denomKey,m),o(t.chainIdKey,d),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},u=_.useEffectEvent(()=>{const{denom:m,chain_id:d}=a[0];l(m,d)});return _.useEffect(()=>{!r&&a.length===1&&u()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:$s.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:$s.list,"aria-busy":i,children:a.map(({denom:m,chain_id:d,symbol:h,logo_uri:f})=>n.jsxs("button",{className:$s.asset,onClick:()=>l(m,d),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:$s.imgPlaceholder,"aria-hidden":"true"}),h]},`${m}-${d}`))})]}):n.jsx("div",{children:"No assets found"})},c2="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",l2="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",u2="_container_9k4hs_1",d2="_title_9k4hs_8",m2="_subtitle_9k4hs_14",h2="_linkContainer_9k4hs_30",f2="_link_9k4hs_30",p2="_separator_9k4hs_51",g2="_errorIcon_9k4hs_62",_2="_error_9k4hs_62",De={container:u2,title:d2,subtitle:m2,linkContainer:h2,link:f2,separator:p2,errorIcon:g2,error:_2};function y2(e){if(!e)return"pending";const t=e.state;return t==="STATE_COMPLETED_SUCCESS"?"success":t==="STATE_ABANDONED"||t==="STATE_COMPLETED_ERROR"||t==="STATE_PENDING_ERROR"?"failed":"pending"}function ua({type:e}){const{closeModal:t}=Dn(),{theme:s}=se(),{watch:o}=Jt(),{result:a}=o(),{openDrawer:r}=Dt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,u=i?0:a.timestamp??0,{route:m,values:d}=a,{srcDenom:h,srcChainId:f,quantity:g}=d,p=At(h,f),y=e==="deposit"?"Deposit":"Withdraw",{data:x}=al({chainId:l,txHash:c,tracked:!1}),{data:b}=rl({chainId:l,txHash:c,tracked:!!x,timestamp:u,route:m}),j=y2(b),v=s==="dark"?c2:l2,w=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,C=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return n.jsxs("div",{className:De.container,children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:v,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:a?.error}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]});const I=ss(m.estimated_route_duration_seconds),T=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${T.toString()}`,"https://explorer.skip.build"),$=()=>n.jsxs("div",{className:De.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:De.link,children:"View transaction"}),n.jsx("div",{className:De.separator}),n.jsx("button",{className:De.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:De.container,children:[j==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),n.jsx("video",{src:w,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:De.subtitle,children:["Estimated time: ",n.jsx("span",{children:I})]}),$(),n.jsx("p",{className:De.subtitle,children:"Your transaction will continue even if you close this"})]}),j==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," complete"]}),n.jsx("video",{src:C,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const S=N.currentTarget;S.duration-S.currentTime<.1&&S.pause()}}),$(),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]}),j==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:v,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:"Your transaction could not be completed"}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const x2=qe.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),b2=({tx:e,children:t})=>{const{values:s}=xt(),{srcChainId:o}=s,a=ie(),r=cs(),i=bn(),c=us(),{data:l,isLoading:u,isFetching:m}=E.useQuery({queryKey:x2.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const f=xo(e.cosmos_tx.msgs,{converters:r,fromAmino:i.fromAmino.bind(i)});return{estimatedGas:await(await c(o)).simulate(a,f,""),messages:f}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if("cosmos_tx"in e&&!l&&u)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})});const d=l?.estimatedGas??null,h="cosmos_tx"in e&&(u||m);return n.jsx(n.Fragment,{children:t(d,{isEstimatingGas:h})})};function w2(e,t){return e?k.InitiaAddress(e).hex:t}function v2({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:w2(e.recipientAddress,o),slippagePercent:"0.1",...a}}}function j2({hasBalancesSnapshot:e,hasBalanceQueryError:t,isBalancesLoading:s}){if(!e){if(s)return"loading";if(t)return"error"}}function C2({hasBalancesSnapshot:e,balance:t}){if(e)return t??"0"}function Yr(e){if(!e)return null;const t=q(e);return!t.isFinite()||t.lt(0)?null:t}function k2({balance:e,requiredAmount:t}){if(t==="0")return!0;const s=Yr(e??"0"),o=Yr(t);return!s||!o?!1:s.gte(o)}function N2({sourceDenom:e,feeDetailsByDenom:t}){const s=t.get(e);if(!s||s.isSufficient)return;for(const[a,r]of t)if(a!==e&&r.isSufficient)return;if(q(s.balance).gte(s.fee))return"Make sure to leave enough for transaction fee"}function I2({feeDenom:e,sourceDenom:t,feeWarning:s,hasSourceBalance:o,isFeeBalanceSufficient:a}){if(!o)return{error:"Insufficient balance"};const r=e===t?s:void 0;return r?{warning:r}:a?{}:{error:"Insufficient balance"}}const A2="_container_11kmm_1",S2="_back_11kmm_6",T2="_title_11kmm_18",E2="_divider_11kmm_26",$2="_label_11kmm_30",M2="_asset_11kmm_37",L2="_assetIcon_11kmm_55",q2="_chainIcon_11kmm_67",R2="_assetName_11kmm_80",P2="_chevron_11kmm_92",D2="_input_11kmm_96",B2="_balanceContainer_11kmm_108",F2="_value_11kmm_116",U2="_maxButton_11kmm_126",O2="_detail_11kmm_142",V2="_detailsContainer_11kmm_153",K2="_detailsButton_11kmm_163",W2="_expandableDetails_11kmm_184",z2="_detailValue_11kmm_192",H2="_detailToken_11kmm_202",Q2="_receiveSummary_11kmm_210",Y={container:A2,back:S2,title:T2,divider:E2,label:$2,asset:M2,assetIcon:L2,chainIcon:q2,assetName:R2,chevron:P2,input:D2,balanceContainer:B2,value:F2,maxButton:U2,detail:O2,detailsContainer:V2,detailsButton:K2,expandableDetails:W2,detailValue:z2,detailToken:H2,receiveSummary:Q2},xl=({renderFee:e})=>{const{route:t}=et(),{values:s}=xt(),{dstDenom:o,dstChainId:a}=s,i=ps().find(({denom:g,chain_id:p})=>g===o&&p===a),c=ie(),l=$c(),[u,m]=Ge.useToggle(!1),d=_.useId(),h=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const f=Gc(t.amount_out,s.slippagePercent);return n.jsxs("div",{className:Y.detailsContainer,children:[n.jsxs("div",{children:[n.jsxs("button",{type:"button",className:Y.detailsButton,onClick:m,"aria-expanded":u,"aria-controls":d,children:["Transaction details"," ",n.jsx(M.IconChevronDown,{size:12,style:{transform:u?"rotate(180deg)":"rotate(0deg)"},"aria-hidden":"true"})]}),n.jsx(ts,{children:n.jsx("div",{id:d,children:u&&n.jsxs("div",{className:Y.expandableDetails,children:[t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Slippage"}),n.jsxs("p",{className:Y.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:Y.detailValue,children:Ka(t.estimated_fees)})]}),e&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Tx fee"}),n.jsx("div",{className:Y.detailValue,children:e()})]}),c&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",k.truncate(c)]})]}),t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",k.formatAmount(f,{decimals:i.decimals})," ",i.symbol]})]})]})})})]}),n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated time"}),n.jsx("p",{className:Y.detailValue,style:h?{color:"var(--warning)"}:void 0,children:ss(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:B(Y.detail,Y.receiveSummary),children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",k.formatAmount(t.amount_out,{decimals:i.decimals})," ",i.symbol]})]})]})},G2="_trigger_1c7d7_1",Y2="_item_1c7d7_5",Z2="_itemText_1c7d7_13",J2={trigger:G2,item:Y2,itemText:Z2};function X2(e){return!e.isFetchingMessages&&!e.messageRefreshError}function bl(e,t,s){return X2(s)?n.jsx(dl,{tx:e,children:t}):t}function eb({feeDetailsByDenom:e,feeOptions:t,lastUsedFeeDenom:s,preferredFeeDenom:o}){if(o&&e.get(o)?.isSufficient)return o;if(s&&e.get(s)?.isSufficient)return s;for(const a of t){const[{denom:r}]=a.amount;if(e.get(r)?.isSufficient)return r}return t[0]?.amount[0].denom}const tb=({tx:e,gas:t,confirmMessage:s,onCompleted:o,messageRefreshError:a,isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c})=>{const{values:l}=xt(),{srcChainId:u,srcDenom:m,quantity:d}=l,f=ps().find(({denom:Q,chain_id:ee})=>Q===m&&ee===u),g=_t(u),p=as(g),y=Ia(g),x=Aa(g),b=St(g),j=t==null?[]:y.map(({amount:Q,denom:ee})=>Le.calculateFee(Math.ceil(t*Ht),Le.GasPrice.fromString(Q+ee))),v=new Map(j.map(Q=>{const[{denom:ee}]=Q.amount;return[ee,Q]})),w=new Map(p.map(({denom:Q,amount:ee})=>[Q,ee])),C=f?q(d||"0").times(q(10).pow(f.decimals)).toFixed(0):"0",I=new Map(j.map(Q=>{const[{amount:ee,denom:ue}]=Q.amount,ye=w.get(ue)??"0",me=f&&m===ue?C:"0",Ce=q(ee).plus(me),{symbol:Se,decimals:ke}=b(ue);return[ue,{symbol:Se,decimals:ke,spend:q(me).gt(0)?me:null,fee:ee,total:Ce.toFixed(),balance:ye,isSufficient:q(ye).gte(Ce)}]})),[T,A]=_.useState(null),$={isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c,messageRefreshError:a},N=eb({feeDetailsByDenom:I,feeOptions:j,lastUsedFeeDenom:x,preferredFeeDenom:T}),S=N?v.get(N):void 0,P=N?I.get(N):null,F=N2({sourceDenom:m,feeDetailsByDenom:I}),D=k2({balance:w.get(m)??"0",requiredAmount:C}),Z=I2({feeDenom:N,sourceDenom:m,feeWarning:F,hasSourceBalance:D,isFeeBalanceSufficient:P?.isSufficient??!0}),K=n.jsx(za,{tx:e,fee:S,onCompleted:o,confirmMessage:s,error:Z.error,warning:Z.warning,...$}),W=(Q,ee)=>{if(k.formatAmount(Q,{decimals:ee})==="0.000000")return 8},O=Q=>{const[{amount:ee,denom:ue}]=Q.amount;if(q(ee).isZero())return"0";const{symbol:ye,decimals:me}=b(ue),Ce=W(ee,me);return`${k.formatAmount(ee,{decimals:me,dp:Ce})} ${ye}`},J=()=>{if(j.length===0)return null;if(j.length===1)return n.jsx("span",{className:"monospace",children:O(j[0])});if(!S||!N)return null;const Q=j.map(Ce=>{const[{denom:Se}]=Ce.amount,{symbol:ke}=b(Se);return{value:Se,label:O(Ce),triggerLabel:ke}}),[{amount:ee,denom:ue}]=S.amount,{decimals:ye}=b(ue),me=W(ee,ye);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:k.formatAmount(ee,{decimals:ye,dp:me})}),n.jsx(Fa,{options:Q,value:N,onChange:A,classNames:J2})]})};return n.jsxs(n.Fragment,{children:[n.jsx(xl,{renderFee:j.length>0?J:void 0}),bl(e,K,$)]})},nb=({tx:e,gas:t,mode:s,messageRefreshError:o,isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i})=>{const{setValue:c}=Jt(),l={isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i,messageRefreshError:o},u=h=>{c("page","completed"),c("result",h)},m=s==="withdraw"?"Withdraw":"Deposit",d=n.jsx(za,{tx:e,fee:void 0,onCompleted:u,confirmMessage:m,...l});return"cosmos_tx"in e?n.jsx(tb,{tx:e,gas:t,onCompleted:u,confirmMessage:m,...l}):n.jsxs(n.Fragment,{children:[n.jsx(xl,{}),bl(e,d,l)]})};function Zr(e){const t=e.values;return{recipient:t?.recipient,sender:t?.sender}}function sb({currentState:e,nextState:t}){if(e.route!==t.route||e.quoteVerifiedAt!==t.quoteVerifiedAt)return!0;const s=Zr(e),o=Zr(t);return s.sender!==o.sender||s.recipient!==o.recipient}function ob({disabledMessage:e,routeForState:t,routeError:s,isNoRouteError:o,isServerError:a}){return e?"disabled":t?"ready":s?o?"no-route":a?"server-error":"refresh-failed":"loading"}function ab({hasRouteState:e,routeStatus:t}){return e&&(t==="ready"||t==="loading")}function rb({routeStatus:e,disabledMessage:t,isRouteSynced:s}){if(e==="disabled")return t;if(e==="loading"||e==="ready"&&!s)return"Fetching route...";if(e==="no-route")return"No route found";if(e==="server-error")return"Server error";if(e==="refresh-failed")return"Failed to refresh route"}const ib=typeof window>"u"?_.useEffect:_.useLayoutEffect,cb=({mode:e})=>{const t=bs(e),s=Me(),o=et(),{data:a}=Qa(),r=Bt(),{data:i,error:c,chainsError:l,isLoading:u}=Ha(),m=Bn(),{watch:d,setValue:h,getValues:f}=Jt(),g=d(),{srcChainId:p,srcDenom:y,quantity:x=""}=g,{recipientAddress:b,route:j}=o,v=g[t.external.denomKey],w=g[t.external.chainIdKey],C=Ga(e),I=$0(e),{data:T,isLoading:A}=yl(e),$=!A&&T.length===1,N=e==="withdraw"&&!A&&T.length>0&&new Set(T.map(({chain:X})=>X.chain_id)).size===1,S=_.useMemo(()=>A||!T.length?null:$?T[0]:N?T.reduce((X,ve)=>{const Oe=Number(X.balance?.value_usd??0);return Number(ve.balance?.value_usd??0)>Oe?ve:X},T[0]):null,[T,$,N,A]),P=S?`${S.chain.chain_id}:${S.asset.denom}`:"",F=w?r(w):null,D=i?.[p]?.[y]?.amount,Z=i?.[p]?.[y]?.price,K=q(Z??0).times(x||0),[W]=Ge.useDebounceValue(x,300),O=e==="withdraw"?C:I,J=j2({hasBalancesSnapshot:i!==void 0,hasBalanceQueryError:!!(c||l),isBalancesLoading:u}),Q=C2({hasBalancesSnapshot:i!==void 0,balance:D}),ee=_.useMemo(()=>{if(e==="deposit"&&!I)return"Select asset";const X=q(x||0);if(!X.isFinite()||X.lte(0))return"Enter amount";if(e==="withdraw"&&!I)return"Select destination";if(J==="loading")return"Loading balances...";if(J==="error")return"Failed to load balances";if(Q!==void 0){const ve=k.fromBaseUnit(Q,{decimals:O?.decimals||6});if(X.gt(ve))return"Insufficient balance"}},[O,Q,J,I,e,x]),ue=_.useMemo(()=>{if(e==="deposit"&&!I)return!0;const X=q(x||0);if(!X.isFinite()||X.lte(0)||e==="withdraw"&&!I||J==="error")return!0;if(Q!==void 0){const ve=k.fromBaseUnit(Q,{decimals:O?.decimals||6});if(X.gt(ve))return!0}return!1},[O,Q,J,I,e,x]),{data:ye,error:me,dataUpdatedAt:Ce}=oa(W,{disabled:ue}),Se=me instanceof z.HTTPError&&me.response.status===400,ke=!ee&&!Se?ye:void 0,Et=ke&&Ce>0?Ce:void 0,ut=me instanceof z.HTTPError&&me.response.status===500,Re=ob({disabledMessage:ee,routeForState:ke,routeError:me,isNoRouteError:Se,isServerError:ut}),le=Re==="ready"&&o.route===ke,G=Re==="loading"||Re==="ready"&&!le,$t=ab({hasRouteState:!!o.route,routeStatus:Re}),Xt=rb({routeStatus:Re,disabledMessage:ee,isRouteSynced:le});ib(()=>{const X=v2({currentState:o,route:ke,quoteVerifiedAt:Et,hexAddress:m,values:f()});sb({currentState:o,nextState:X})&&s(0,X)},[j,f,m,s,Et,b,ke]);const Mt=_.useEffectEvent(()=>{if(!S||v&&w)return;const{asset:X,chain:ve}=S;h(t.external.denomKey,X.denom),h(t.external.chainIdKey,ve.chain_id),e==="deposit"&&h("quantity","")});if(_.useEffect(()=>{Mt()},[P]),!C||e==="deposit"&&!I)return null;const bt=O?.decimals||6,en=e==="withdraw"?"Select chain":"Select asset",dt=()=>{h("quantity",""),h(t.external.denomKey,""),h(t.external.chainIdKey,""),(e==="withdraw"||$)&&(h(t.local.denomKey,""),h(t.local.chainIdKey,"")),h("page",e==="withdraw"||$?"select-local":"select-external")},Ue=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:Y.asset,disabled:$,onClick:()=>h("page","select-external"),children:[n.jsx("div",{className:Y.assetIcon,children:I?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol}),n.jsx("img",{src:F?.logo_uri||"",alt:F?.pretty_name,className:Y.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:Y.chainIcon})}),n.jsx("p",{className:Y.assetName,children:I?n.jsxs(n.Fragment,{children:[I.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",F?.pretty_name]})]}):en}),!$&&n.jsx(M.IconChevronDown,{className:Y.chevron,size:16})]})]}),nt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:"Amount"}),n.jsx(ns,{balance:Q,decimals:bt,className:Y.input}),Q!==void 0&&n.jsxs("div",{className:Y.balanceContainer,children:[n.jsx("p",{className:Y.value,children:x?Ua(K.toString(),Z):"$-"}),n.jsxs("button",{className:Y.maxButton,onClick:()=>{const X=k.fromBaseUnit(Q,{decimals:bt});q(x||0).eq(X)||h("quantity",X)},children:[n.jsx(M.IconWallet,{size:16})," ",k.formatAmount(Q,{decimals:bt})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("section",{className:Y.container,"aria-label":"Transfer form",children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:Y.back,onClick:dt,children:n.jsx(M.IconBack,{size:20})}),n.jsxs("h3",{className:Y.title,children:[t.label," ",C.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[nt,n.jsx("div",{className:Y.divider}),Ue]}):n.jsxs(n.Fragment,{children:[Ue,n.jsx("div",{className:Y.divider}),nt]}),(l||c)&&n.jsx(je,{error:!0,children:"Failed to load balances"}),$t?n.jsx(ul,{children:X=>n.jsx(hl,{children:ve=>n.jsx(ml,{addressList:X,signedOpHook:ve,children:(Oe,{isFetchingMessages:mt,messageRefreshError:jo})=>n.jsx(b2,{tx:Oe,children:(ws,{isEstimatingGas:Co})=>n.jsx(xe,{suspenseFallback:n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})}),children:n.jsx(nb,{tx:Oe,gas:ws,mode:e,isRouteTransitioning:G,isFetchingMessages:mt,isEstimatingGas:Co,messageRefreshError:jo})})})})})}):n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:G&&"Fetching route...",disabled:!0,fullWidth:!0,children:Xt})})]})},lb="_container_7nl9j_1",ub="_page_7nl9j_5",Jr={container:lb,page:ub},wl=({mode:e})=>{const t=$e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Ha(),n.jsx($e.FormProvider,{...t,children:n.jsx(db,{mode:e})})},db=({mode:e})=>{const{watch:t}=Jt(),s=t("page"),o=Nt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return n.jsx(i2,{mode:e});case"select-external":return n.jsx(n2,{mode:e});case"fields":return n.jsx(cb,{mode:e});case"completed":return n.jsx(ua,{type:e})}};return n.jsx(ts,{children:n.jsx("div",{className:Jr.container,children:o((r,i)=>n.jsx(Nt.animated.div,{style:r,className:Jr.page,children:a(i)}))})})},mb=()=>n.jsx(wl,{mode:"deposit"}),hb=()=>n.jsx(wl,{mode:"withdraw"}),fb="_root_1lo0i_1",pb="_address_1lo0i_9",gb="_copy_1lo0i_19",_b="_labelWrapper_1lo0i_33",yb="_labelCopy_1lo0i_43",xb="_labelCopied_1lo0i_47",bb="_copied_1lo0i_55",wb="_derived_1lo0i_65",vb="_derivedLabel_1lo0i_79",jb="_derivedAddress_1lo0i_83",Cb="_hexAddress_1lo0i_89",kb="_derivedCopy_1lo0i_94",Ke={root:fb,address:pb,copy:gb,labelWrapper:_b,labelCopy:yb,labelCopied:xb,copied:bb,derived:wb,derivedLabel:vb,derivedAddress:jb,hexAddress:Cb,derivedCopy:kb},Nb=()=>{const e=_.useRef(null),t=_.useRef(null),{initiaAddress:s,hexAddress:o}=tt(),a=Tc("--gray-0");return _.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new Ql({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"}}),t.current.append(e.current)))},[s,a]),n.jsx(Tt,{title:"Receive",children:n.jsxs("div",{className:Ke.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Ke.address,children:s}),n.jsx(Ws,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:B(Ke.copy,{[Ke.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy address",children:[n.jsx(M.IconCopy,{size:12,"aria-hidden":"true"}),n.jsxs("div",{className:Ke.labelWrapper,children:[n.jsx("span",{className:Ke.labelCopy,children:"Copy address"}),n.jsx("span",{className:Ke.labelCopied,children:"Copied!"})]})]})}),n.jsx(Ws,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:B(Ke.derived,{[Ke.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy derived address",children:[n.jsx("span",{className:Ke.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Ke.derivedAddress,children:[n.jsx("span",{className:Ke.hexAddress,children:k.truncate(o)}),n.jsx(M.IconCopy,{size:12,className:Ke.derivedCopy,"aria-hidden":"true"}),i&&n.jsx("span",{className:Ke.copiedText,children:"Copied!"})]})]})})]})})};function Ib(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function Ab(){const e=ie(),t=_e();return E.useQueries({queries:t.map(s=>({queryKey:Vs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Js(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Yi(o),r=e?wa(e,s.chainId):null,i=Ib(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:V.SECOND,retry:!1}))})}const Sb="_countdown_vfms8_1",Tb={countdown:Sb},Eb=({expiration:e})=>{const t=()=>{const a=new Date,r=Xe.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),u=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${u}s`),m.join(" ")},[s,o]=_.useState(t());return Ge.useInterval(()=>{o(t())},1e3),Xe.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:Tb.countdown,children:s})]})},$b="_container_1l528_1",Mb="_info_1l528_11",Lb="_header_1l528_17",qb="_chainName_1l528_23",Rb="_expiration_1l528_29",Pb="_revokeButton_1l528_35",kn={container:$b,info:Mb,header:Lb,chainName:qb,expiration:Rb,revokeButton:Pb},Db=({chainId:e,grantee:t,expiration:s})=>{const o=_t(e),{mutate:a,isPending:r}=dc({grantee:t,internal:!0});return n.jsxs("div",{className:kn.container,children:[n.jsxs("div",{className:kn.info,children:[n.jsxs("div",{className:kn.header,children:[n.jsx(re,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:kn.chainName,children:o.name})]}),n.jsx("div",{className:kn.expiration,children:s?n.jsx(Eb,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:kn.revokeButton,onClick:()=>a(e),disabled:r,"aria-busy":r,children:r?"Revoking...":"Revoke"})]})},Bb=({chainId:e,grants:t})=>{const s=new Map;for(const a of t){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=ka([r.expiration,i])}return[...s.values()].map(a=>_.createElement(Db,{...a,chainId:e,key:a.grantee}))},Fb="_content_q36qs_1",Ub={content:Fb},Ob=()=>{const e=Ab(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(je,{children:"No permissions found"}):n.jsx("div",{className:Ub.content,children:s.map(({chainId:o,grants:a})=>n.jsx(Bb,{chainId:o,grants:a},o))})};return n.jsx(Tt,{title:"Manage auto-signing",backButton:"/settings",children:t()})},Vb="_version_1sf5y_1",Kb={version:Vb},Wb=()=>n.jsxs("aside",{className:Kb.version,children:["v","2.8.0"]}),zb="_link_se23z_1",Hb="_title_se23z_17",Qb="_subtitle_se23z_23",Gb="_icon_se23z_30",Ms={link:zb,title:Hb,subtitle:Qb,icon:Gb},vl=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:Ms.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:Ms.title,children:e}),t&&n.jsx("p",{className:Ms.subtitle,children:t})]}),n.jsx("div",{className:Ms.icon,children:s??n.jsx(M.IconChevronRight,{size:16,"aria-hidden":"true"})})]}),Yb="https://export.initia.xyz/",Zb=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(vl,{title:"Export private key",rightSection:n.jsx(M.IconExternalLink,{size:16}),onClick:()=>window.open(Yb,"_blank",e)})},Jb="_container_1vxr7_1",Xb="_separator_1vxr7_7",Xr={container:Jb,separator:Xb},ew=()=>{const e=Me(),{connector:t}=Qe.useAccount();return n.jsx(Tt,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Xr.container,children:[n.jsx(vl,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ga&&n.jsx(Zb,{}),n.jsx(Rt.Separator,{className:Xr.separator}),n.jsx(Wb,{})]})})},tw="_trigger_1yjkd_1",nw="_icon_1yjkd_23",sw="_full_1yjkd_27",ow="_triggerContent_1yjkd_32",aw="_triggerText_1yjkd_40",rw="_popoverBackdrop_1yjkd_51",iw="_popoverPositioner_1yjkd_70",cw="_popoverPopup_1yjkd_74",lw="_search_1yjkd_99",uw="_viewport_1yjkd_105",dw="_item_1yjkd_111",mw="_highlighted_1yjkd_127",hw="_active_1yjkd_131",fw="_itemContent_1yjkd_136",pw="_extra_1yjkd_142",gw="_connectedTag_1yjkd_149",Ee={trigger:tw,icon:nw,full:sw,triggerContent:ow,triggerText:aw,popoverBackdrop:rw,popoverPositioner:iw,popoverPopup:cw,search:lw,viewport:uw,item:dw,highlighted:mw,active:hw,itemContent:fw,extra:pw,connectedTag:gw},vo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=se(),[i,c]=_.useState(""),[l,u]=_.useState(!1),[m,d]=_.useState(0),[h,f]=_.useState(),g=_.useRef([]),p=_.useRef(null),y=_e(),x=s.map(N=>y.find(S=>S.chainId===N)).filter(Boolean),b=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.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"}),n.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"})]}),j=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const N=[j,...x];if(!i)return N;const S=i.toLowerCase();return N.filter(P=>P.name.toLowerCase().includes(S)||P.chainId.toLowerCase().includes(S))},[x,i,j]),w=x.find(N=>N.chainId===e)||j,C=parseInt(Tc("--drawer-offset")),I=6,T=()=>{if(c(""),d(-1),p.current){const S=p.current.getBoundingClientRect().bottom+I,P=window.innerHeight-S-2*C;f(P)}u(!0)};_.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=_.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),d(S=>(S+1)%v.length);break;case"ArrowUp":N.preventDefault(),d(S=>(S-1+v.length)%v.length);break;case"Enter":N.preventDefault(),v[m]&&(t(v[m].chainId),u(!1));break;case"Escape":N.preventDefault(),u(!1);break}},[v,m,t,u]),$=N=>{t(N),u(!1)};return n.jsxs(jn.Popover.Root,{open:l,onOpenChange:T,modal:"trap-focus",children:[n.jsx(jn.Popover.Trigger,{render:n.jsxs("button",{className:B(Ee.trigger,{[Ee.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[n.jsxs("div",{className:Ee.triggerContent,children:[typeof w.logoUrl=="string"?n.jsx(re,{src:w.logoUrl,width:14,height:14,logo:!0}):w.logoUrl(14),n.jsx("span",{className:Ee.triggerText,children:w.name})]}),n.jsx(M.IconChevronDown,{size:16,className:Ee.icon})]})}),n.jsxs(jn.Popover.Portal,{container:_n(),children:[n.jsx(jn.Popover.Backdrop,{className:Ee.popoverBackdrop,onClick:()=>u(!1)}),n.jsx(jn.Popover.Positioner,{className:Ee.popoverPositioner,align:"end",side:"bottom",sideOffset:I,collisionAvoidance:{side:"none"},children:n.jsxs(jn.Popover.Popup,{className:B(Ee.popoverPopup,{[Ee.full]:a}),style:{maxHeight:h},children:[n.jsx(ys,{value:i,onChange:N=>{c(N.target.value),d(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search apps",rootClassName:Ee.search,ref:gs()}),n.jsx("div",{className:Ee.viewport,role:"listbox",children:v.length===0?n.jsx(je,{children:"No apps found"}):v.map(({chainId:N,name:S,logoUrl:P},F)=>n.jsxs("div",{className:B(Ee.item,{[Ee.highlighted]:F===m,[Ee.active]:e===N}),onClick:()=>$(N),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),$(N))},onMouseEnter:()=>d(F),role:"option","aria-selected":e===N,tabIndex:-1,ref:D=>{D&&(g.current[F]=D)},children:[n.jsxs("div",{className:Ee.itemContent,children:[typeof P=="string"?n.jsx(re,{src:P,width:16,height:16,logo:!0}):P(16),n.jsx("span",{className:Ee.name,children:S}),N===r&&n.jsx("span",{className:Ee.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:Ee.extra,children:o(N)})]},N))})]})})]})]})},_w="_container_1nap1_1",yw="_controls_1nap1_7",xw="_search_1nap1_13",Ya={container:_w,controls:yw,search:xw},bw=({children:e})=>n.jsx("div",{className:Ya.container,children:e}),ww=({children:e})=>n.jsx("div",{className:Ya.controls,children:e}),vw=e=>n.jsx(ys,{...e,rootClassName:Ya.search}),gt={Root:bw,Controls:ww,SearchInput:vw},jl=H.atom(""),Cl=H.atom(""),jw=H.atom(""),Cw=H.atom(""),kw=H.atom(""),Nw="_change_1nm9m_1",Iw="_positive_1nm9m_8",Aw="_negative_1nm9m_12",Ho={change:Nw,positive:Iw,negative:Aw},kl=({amount:e,asset:t})=>{const{denom:s,symbol:o,decimals:a}=t,r=new q(e).isPositive(),i=new q(e).abs().toString();return n.jsxs("div",{className:B(Ho.change,r?Ho.positive:Ho.negative),children:[r?"+":"-",k.formatAmount(i,{decimals:a})," ",o||s]})},Sw=({changes:e,chain:t})=>{const s=St(t);return e.map(({amount:o,denom:a},r)=>n.jsx(kl,{amount:o,asset:s(a)},r))},Tw=({changes:e,chain:t})=>{const s=St(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(Pc,{metadata:a,chain:t,children:i=>n.jsx(kl,{amount:o,asset:s(i)})},r))},Ew=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=tt();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(Tw,{changes:Rc(e,o),chain:t}):n.jsx(Sw,{changes:qc(e,s),chain:t})},$w="_message_1qc8m_1",Mw="_more_1qc8m_9",ei={message:$w,more:Mw},Lw=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:ei.message,children:Ys.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:ei.more,children:`+${e.length-3} more`})]}),qw="_link_1vbb0_1",Rw="_inner_1vbb0_16",Pw="_header_1vbb0_21",Dw="_time_1vbb0_30",Bw="_error_1vbb0_36",Fw="_timestamp_1vbb0_40",Uw="_chainInfo_1vbb0_45",Ow="_content_1vbb0_53",Vw="_messages_1vbb0_61",Kw="_changes_1vbb0_67",jt={link:qw,inner:Rw,header:Pw,time:Dw,error:Bw,timestamp:Fw,chainInfo:Uw,content:Ow,messages:Vw,changes:Kw},Ww=({txItem:e,chain:t})=>n.jsx(ho,{txHash:e.txhash,chainId:t.chainId,className:jt.link,children:n.jsxs("div",{className:jt.inner,children:[n.jsxs("div",{className:jt.header,children:[n.jsxs("div",{className:jt.time,children:[e.code!==0&&n.jsx(M.IconWarningFilled,{size:14,className:jt.error}),n.jsx("span",{className:jt.timestamp,children:Xe.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:jt.chainInfo,children:[n.jsx(re,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:jt.content,children:[n.jsx("div",{className:jt.messages,children:n.jsx(Lw,{messages:e.tx.body.messages})}),n.jsx("div",{className:jt.changes,children:n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(Ew,{...e,chain:t})})})]})]})}),zw="_list_1mv55_1",Hw="_dateGroup_1mv55_7",Qw="_dateHeader_1mv55_12",Gw="_more_1mv55_18",Ls={list:zw,dateGroup:Hw,dateHeader:Qw,more:Gw},Yw=({list:e,chainId:t})=>{const s=ie(),o=_.useMemo(()=>el(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(je,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Ls.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Ls.dateGroup,children:[n.jsx("div",{className:Ls.dateHeader,children:a}),r.map(i=>n.jsx(xe,{errorBoundaryProps:{fallback:null},children:n.jsx(Ww,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(ho,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},Zw=()=>{const{activities:e,isLoading:t}=hd(),[s,o]=H.useAtom(kw),a=ce(),r=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return t&&e.length===0?n.jsx(je,{children:"Loading activities..."}):!e.length&&!t?n.jsx(je,{children:"No activity yet"}):n.jsxs(gt.Root,{children:[n.jsx(gt.Controls,{children:n.jsx(vo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Yw,{list:i,chainId:s||a.chainId})]})},Jw="_thumbnail_1xyqw_1",Xw="_placeholder_1xyqw_18",ev="_clickable_1xyqw_24",Qn={thumbnail:Jw,placeholder:Xw,clickable:ev},tv=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=se(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:B(Qn.thumbnail,Qn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(re,{src:l,classNames:{placeholder:Qn.placeholder}})}):n.jsx("div",{className:Qn.thumbnail,style:{width:t,height:t},children:n.jsx(re,{src:l,classNames:{placeholder:Qn.placeholder}})})},nv="_collectionName_qs5tw_1",sv="_nftName_qs5tw_6",ov="_chainInfo_qs5tw_10",Qo={collectionName:nv,nftName:sv,chainInfo:ov},Za=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return n.jsxs("div",{className:a?.root,children:[n.jsx(tv,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:B(Qo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:B(Qo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:B(Qo.chainInfo,a?.chainInfo),children:[n.jsx(re,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ja=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function av(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function rv(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const iv=()=>{const e=ie(),t=_e(),s=E.useQueries({queries:t.map(l=>({queryKey:Ja.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Js(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:V.SECOND}))}),o=s.map(L.prop("data")),a=rv(t,o),r=a.reduce((l,{chain:u})=>({...l,[u.chainId]:(l[u.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,u)=>l+u,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function cv(e){const t=ti(e);return E.useQuery({queryKey:Ja.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await z.get(t).json();return{...s,image:ti(s.image)}}catch{return{}}},staleTime:V.INFINITY})}function ti(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const lv=({nftInfo:e,children:t})=>{const{data:s={}}=cv(e.nft.uri),o=av(e,s);return t(o)},uv="_grid_1wwdn_1",dv="_root_1wwdn_7",mv="_collectionName_1wwdn_15",hv="_nftName_1wwdn_23",fv="_chainInfo_1wwdn_32",ni={grid:uv,root:dv,collectionName:mv,nftName:hv,chainInfo:fv},pv=()=>{const[e,t]=H.useAtom(jw),[s,o]=H.useAtom(Cw),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=iv(),l=Me(),u=_.useMemo(()=>a.filter(({collection_addr:d,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const y=e.trim().toLowerCase();return d.toLowerCase().includes(y)||h.toLowerCase().includes(y)||f.token_id.toLowerCase().includes(y)||g.toLowerCase().includes(y)}return!0}),[a,s,e]),m=_.useMemo(()=>Array.from(new Set(a.map(({chain:d})=>d.chainId))),[a]);return c&&a.length===0?n.jsx(je,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(je,{children:"No NFTs"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(vo,{value:s,onChange:o,chainIds:m,renderExtra:d=>d?r[d]||0:i})]}),u.length===0?n.jsx(je,{children:"No NFTs found"}):n.jsx("div",{className:ni.grid,children:u.map(d=>{const{collection_addr:h,nft:f}=d;return n.jsx(lv,{nftInfo:d,children:g=>n.jsx(Za,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:ni})},h+f.token_id)})})]})},Nl=_.createContext(null);function Il(){return _.useContext(Nl)}const gv="_popup_nbecp_1",_v="_item_nbecp_19",qs={popup:gv,item:_v},Al=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:u}=l,[m,d]=_.useState(!1),h=Me(),f=Il(),{showNotification:g}=hs(),{defaultChainId:p}=se(),{evm_chain_id:y}=xn(),x=Qe.useChainId(),{switchChainAsync:b}=Qe.useSwitchChain(),{watchAssetAsync:j}=Qe.useWatchAsset(),v=()=>{d(!1),h("/send",{denom:s,chain:l})},w=()=>{d(!1),h("/bridge",{srcChainId:u,srcDenom:s,quantity:""})},C=E.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const I=r;return await b({chainId:Number(y)}),j({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:I}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:I=>{g({type:"error",title:"Asset addition failed",description:I.message})}});return n.jsxs(Rt.Menu.Root,{open:m,onOpenChange:d,modal:!1,children:[n.jsx(Rt.Menu.Trigger,{render:t}),n.jsx(Rt.Menu.Portal,{container:f,children:n.jsx(Rt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(Rt.Menu.Popup,{className:qs.popup,children:[n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:v,children:[n.jsx(M.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:w,disabled:i,children:[n.jsx(M.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),u===p&&y===x&&!!c&&n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:()=>C.mutate(),disabled:C.isPending||C.data,children:[C.data?n.jsx(M.IconCheck,{size:16}):n.jsx(M.IconPlus,{size:16}),n.jsx("span",{children:"Add to Wallet"})]})]})})})]})},yv="_item_38qhm_1",xv="_info_38qhm_23",bv="_images_38qhm_29",wv="_name_38qhm_33",vv="_value_38qhm_39",jv="_amount_38qhm_47",Cv="_usd_38qhm_53",an={item:yv,info:xv,images:bv,name:wv,value:vv,amount:jv,usd:Cv},kv=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=k.formatAmount(t,{decimals:e.decimals});return n.jsx(Al,{asset:e,children:n.jsxs("button",{className:an.item,children:[n.jsxs("div",{className:an.info,children:[n.jsx(_o,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:an.images}),n.jsx("span",{className:an.name,children:a.name})]}),n.jsxs("div",{className:an.value,children:[n.jsx("span",{className:an.amount,children:r}),Number(s)>0&&n.jsx("span",{className:an.usd,children:ae(s)})]})]})})},Nv="_container_ytg3p_1",Iv="_assetItem_ytg3p_6",Av="_expandIcon_ytg3p_22",Sv="_assetInfo_ytg3p_27",Tv="_logo_ytg3p_33",Ev="_details_ytg3p_37",$v="_symbol_ytg3p_42",Mv="_chainName_ytg3p_53",Lv="_chainInfos_ytg3p_59",qv="_chainLogos_ytg3p_65",Rv="_chainLogo_ytg3p_65",Pv="_moreChains_ytg3p_76",Dv="_expanded_ytg3p_93",Bv="_valueColumn_ytg3p_98",Fv="_amount_ytg3p_108",Uv="_value_ytg3p_98",Ov="_collapsibleContent_ytg3p_121",Vv="_chainsList_ytg3p_151",Te={container:Nv,assetItem:Iv,expandIcon:Av,assetInfo:Sv,logo:Tv,details:Ev,symbol:$v,chainName:Mv,chainInfos:Lv,chainLogos:qv,chainLogo:Rv,moreChains:Pv,expanded:Dv,valueColumn:Bv,amount:Fv,value:Uv,collapsibleContent:Ov,chainsList:Vv},Kv=H.atom([]),Xa=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(Kv),c=_.useMemo(()=>Ed(e),[e]),l=_.useMemo(()=>mc(e),[e]),u=r.includes(t),m=()=>{i(h=>u?h.filter(f=>f!==t):[...new Set([...h,t])])},d=()=>n.jsxs("button",{className:Te.assetItem,children:[n.jsxs("div",{className:Te.assetInfo,children:[s&&n.jsx(re,{src:s,width:32,height:32,className:Te.logo,logo:!0}),n.jsxs("div",{className:Te.details,children:[n.jsx("div",{className:Te.symbol,children:t}),a?n.jsx("div",{className:Te.chainName,children:o[0].chain.name}):n.jsxs("div",{className:Te.chainInfos,children:[n.jsx("div",{className:Te.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(re,{src:h.logoUrl,width:16,height:16,className:Te.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:Te.moreChains,children:["+",o.length-5]}),n.jsx(M.IconChevronDown,{size:16,className:B(Te.expandIcon,{[Te.expanded]:u})})]})]})]}),n.jsxs("div",{className:Te.valueColumn,children:[n.jsx("div",{className:Te.amount,children:k.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:Te.value,children:ae(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:Te.container,children:n.jsx(Al,{asset:h,children:d()})})}return n.jsx("div",{className:Te.container,children:n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:d()}),n.jsx(te.Collapsible.Content,{className:Te.collapsibleContent,children:n.jsx("div",{className:Te.chainsList,children:o.map(h=>n.jsx(kv,{asset:h},h.chain.chainId))})})]})})},Wv="_collapsible_1g7rh_1",zv="_trigger_1g7rh_5",Hv="_divider_1g7rh_20",Qv="_label_1g7rh_28",Gv="_chevron_1g7rh_33",Yv="_content_1g7rh_41",Zv="_list_1g7rh_45",Kt={collapsible:Wv,trigger:zv,divider:Hv,label:Qv,chevron:Gv,content:Yv,list:Zv},Sl=({unlistedAssets:e})=>{const[t,s]=_.useState(!1),o=Il(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const d=a.current.scrollHeight;i(d)}},[e]);const c=_.useRef(null),l=d=>{s(d),d&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const x=g.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},u=Nt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),m=_.useMemo(()=>e.map(d=>({...d,assets:[d],totalValue:d.value??0,totalAmount:Number(d.quantity)})),[e]);return e.length===0?null:n.jsxs(te.Collapsible.Root,{open:t,onOpenChange:l,className:Kt.collapsible,children:[n.jsxs(te.Collapsible.Trigger,{ref:c,className:Kt.trigger,children:[n.jsx("div",{className:Kt.divider}),n.jsxs("span",{className:Kt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(M.IconChevronDown,{className:Kt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Kt.divider})]}),n.jsx(te.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(Nt.animated.div,{className:Kt.content,style:u,children:n.jsx("div",{className:Kt.list,ref:a,children:m.map(d=>n.jsx(Xa,{assetGroup:d},d.assets[0].denom))})})})]})},Jv="_container_15xfg_1",Xv="_header_15xfg_7",ej="_title_15xfg_13",tj="_totalValue_15xfg_19",nj="_list_15xfg_26",Tn={container:Jv,header:Xv,title:ej,totalValue:tj,list:nj},sj=()=>{const[e,t]=H.useAtom(jl),[s,o]=H.useAtom(Cl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=Ta(),u=i.map(({chainId:h})=>h),m=_.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:y}=g;return p.toLowerCase().includes(e.toLowerCase())||y.some(({denom:x,address:b})=>x.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),d=_.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?n.jsx(je,{children:"Loading assets..."}):!m.length&&!d.length&&!e&&!s&&!l?n.jsx(je,{children:"No assets"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(vo,{value:s,onChange:o,chainIds:u,renderExtra:h=>{if(!h)return ae(c);const f=i.find(g=>g.chainId===h);return f?ae(f.value):null}})]}),n.jsx("div",{children:m.length===0&&d.length===0?n.jsx(je,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Tn.list,children:m.map(h=>n.jsx(Xa,{assetGroup:h},h.symbol))}),n.jsx(Sl,{unlistedAssets:d})]})})]})},oj="_container_11k2x_1",aj={container:oj},Ct=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(pn,{height:e,width:s}):n.jsx("div",{className:aj.container,"aria-hidden":"true",children:o.map(a=>n.jsx(pn,{height:e,width:s},a))})},rj=_.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ms(),l=ce(),{listedGroups:u,unlistedAssets:m}=_.useMemo(()=>Hm(i,a,r,l.chainId),[i,a,r,l.chainId]),d=_.useMemo(()=>Vm(u,s,o),[u,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=_.useMemo(()=>zm(d,m,e,t),[d,m,e,t]);return n.jsxs("div",{className:Tn.container,children:[n.jsxs("div",{className:Tn.header,children:[n.jsx("span",{className:Tn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Tn.totalValue,children:ae(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Tn.list,children:h.map(p=>n.jsx(Xa,{assetGroup:p},p.symbol))}),n.jsx(Sl,{unlistedAssets:g})]}):d.length===0&&c?n.jsx(Ct,{height:56,length:3}):n.jsx(je,{children:"No liquid assets"})]})}),ij="_container_1n61l_1",cj="_section_1n61l_7",lj="_sectionHeader_1n61l_19",uj="_sectionTitle_1n61l_25",dj="_sectionLabel_1n61l_31",mj="_externalLink_1n61l_37",hj="_sectionValue_1n61l_49",fj="_tokenList_1n61l_56",pj="_stakingTokenList_1n61l_62",gj="_tokenRow_1n61l_72",_j="_tokenMain_1n61l_78",yj="_tokenTrigger_1n61l_84",xj="_tokenChevron_1n61l_100",bj="_expanded_1n61l_111",wj="_triggerValue_1n61l_115",vj="_tokenInfo_1n61l_122",jj="_tokenInfoLabel_1n61l_128",Cj="_tokenLogo_1n61l_134",kj="_tokenSymbol_1n61l_138",Nj="_tokenValues_1n61l_144",Ij="_tokenAmount_1n61l_150",Aj="_tokenValue_1n61l_144",Sj="_typeBreakdown_1n61l_164",Tj="_typeRow_1n61l_172",Ej="_typeLabel_1n61l_180",$j="_typeValues_1n61l_186",Mj="_typeAmount_1n61l_192",Lj="_typeValue_1n61l_186",qj="_collapsibleContent_1n61l_206",ne={container:ij,section:cj,sectionHeader:lj,sectionTitle:uj,sectionLabel:dj,externalLink:mj,sectionValue:hj,tokenList:fj,stakingTokenList:pj,tokenRow:gj,tokenMain:_j,tokenTrigger:yj,tokenChevron:xj,expanded:bj,triggerValue:wj,tokenInfo:vj,tokenInfoLabel:jj,tokenLogo:Cj,tokenSymbol:kj,tokenValues:Nj,tokenAmount:Ij,tokenValue:Aj,typeBreakdown:Sj,typeRow:Tj,typeLabel:Ej,typeValues:$j,typeAmount:Mj,typeValue:Lj,collapsibleContent:qj},Tl=({protocols:e,denomLogoMap:t,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const c=e.flatMap(l=>l.positions);return Mm(c)},[e]);return i.size===0?null:n.jsx("div",{className:ne.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(Rj,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Rj=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,u=$m(e,o),m=_.useMemo(()=>Fm(c),[c]),d=e==="staking";return n.jsxs("section",{className:ne.section,"aria-label":u,children:[n.jsxs("div",{className:ne.sectionHeader,children:[n.jsxs("div",{className:ne.sectionTitle,children:[n.jsx("span",{className:ne.sectionLabel,children:u}),d&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:ne.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:ne.sectionValue,children:ae(l)})]}),n.jsx("div",{className:B(ne.tokenList,{[ne.stakingTokenList]:d}),children:m.map(h=>n.jsx(Pj,{group:h,showTypeBreakdown:d,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},Pj=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:u}=e,m=s.get(r),[d,h]=_.useState(!1),f=_.useMemo(()=>{if(!t)return null;const g=Dm(u);return g.size>0?g:null},[u,t]);return f?n.jsxs(te.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ne.tokenTrigger,children:[n.jsxs("div",{className:ne.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(ne.tokenChevron,{[ne.expanded]:d}),"aria-hidden":"true"}),n.jsxs("div",{className:ne.tokenInfoLabel,children:[m?.assetLogo&&n.jsx(re,{src:m.assetLogo,width:20,height:20,className:ne.tokenLogo}),n.jsx("span",{className:ne.tokenSymbol,children:i})]})]}),n.jsx("span",{className:ne.triggerValue,children:ae(l)})]})}),n.jsx(te.Collapsible.Content,{className:ne.collapsibleContent,children:n.jsx(Dj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:ne.tokenRow,children:n.jsxs("div",{className:ne.tokenMain,children:[n.jsxs("div",{className:ne.tokenInfo,children:[m?.assetLogo&&n.jsx(re,{src:m.assetLogo,width:20,height:20,className:ne.tokenLogo}),n.jsx("span",{className:ne.tokenSymbol,children:i})]}),n.jsxs("div",{className:ne.tokenValues,children:[n.jsx("span",{className:ne.tokenAmount,children:k.formatNumber(c,{dp:6})}),n.jsx("span",{className:ne.tokenValue,children:ae(l)})]})]})})},Dj=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([l,u])=>{const m=u.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),d=u.reduce((h,f)=>h+Ln(f),0);return{type:l,typeAmount:m,typeValue:d}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:u}of r){const m=o(s,u);l+=Number(m)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:ne.typeBreakdown,children:[r.map(({type:l,typeAmount:u,typeValue:m})=>n.jsxs("div",{className:ne.typeRow,children:[n.jsx("span",{className:ne.typeLabel,children:Pm(l)}),n.jsxs("div",{className:ne.typeValues,children:[n.jsxs("span",{className:ne.typeAmount,children:[k.formatNumber(u,{dp:6})," ",t]}),n.jsx("span",{className:ne.typeValue,children:ae(m)})]})]},l)),c&&n.jsxs("div",{className:ne.typeRow,children:[n.jsx("span",{className:ne.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ne.typeValues,children:[n.jsxs("span",{className:ne.typeAmount,children:[k.formatNumber(i,{dp:6})," ",pt]}),n.jsx("span",{className:ne.typeValue,children:ae(i*(a??0))})]})]})]})},Bj="_container_ymkoc_1",Fj="_trigger_ymkoc_6",Uj="_expandIcon_ymkoc_22",Oj="_chainInfo_ymkoc_27",Vj="_logo_ymkoc_33",Kj="_chainNameContainer_ymkoc_37",Wj="_chainName_ymkoc_37",zj="_externalLink_ymkoc_49",Hj="_externalIcon_ymkoc_53",Qj="_valueColumn_ymkoc_63",Gj="_value_ymkoc_63",Yj="_expanded_ymkoc_80",Zj="_collapsibleContent_ymkoc_85",Jj="_content_ymkoc_97",We={container:Bj,trigger:Fj,expandIcon:Uj,chainInfo:Oj,logo:Vj,chainNameContainer:Kj,chainName:Wj,externalLink:zj,externalIcon:Hj,valueColumn:Qj,value:Gj,expanded:Yj,collapsibleContent:Zj,content:Jj},Xj=H.atom([]),eC=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Da(r,a),[r,a]),l=_.useMemo(()=>{const u=new Map;for(const m of o)for(const d of m.positions){if(d.type==="fungible-position"||d.balance.type==="unknown")continue;const{denom:h,symbol:f}=d.balance,g=f.toUpperCase(),p=`${t}:${h}`,y=i.get(p)??c.get(g);y&&u.set(h,{assetLogo:y,chainLogo:s??""})}return u},[o,i,c,t,s]);return n.jsx(Tl,{protocols:o,denomLogoMap:l})},tC=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(Xj),c=_.useMemo(()=>o.reduce((f,g)=>f+g.positions.reduce((p,y)=>p+Ln(y),0),0),[o]),l=["civitia","yominet"],u=r.includes(t),m=t?.toLowerCase(),d=l.includes(m),h=()=>{i(f=>u?f.filter(g=>g!==t):[...new Set([...f,t])])};return n.jsx("div",{className:We.container,children:n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:h,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:We.trigger,children:[n.jsxs("div",{className:We.chainInfo,children:[s&&n.jsx(re,{src:s,width:32,height:32,className:We.logo,logo:!0}),n.jsxs("div",{className:We.chainNameContainer,children:[n.jsx("span",{className:We.chainName,children:t}),a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:We.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,className:We.externalIcon})})]})]}),n.jsxs("div",{className:We.valueColumn,children:[!d&&n.jsx("span",{className:We.value,children:ae(c)}),n.jsx(M.IconChevronDown,{size:16,className:B(We.expandIcon,{[We.expanded]:u})})]})]})}),n.jsx(te.Collapsible.Content,{className:We.collapsibleContent,children:n.jsx("div",{className:We.content,children:n.jsx(eC,{chainGroup:e})})})]})})},nC="_container_g7q2b_1",sC="_section_g7q2b_6",oC="_sectionHeader_g7q2b_14",aC="_sectionTitle_g7q2b_20",rC="_sectionLabel_g7q2b_26",iC="_externalLink_g7q2b_32",cC="_sectionValue_g7q2b_44",lC="_tokenList_g7q2b_51",uC="_tokenTrigger_g7q2b_63",dC="_tokenChevron_g7q2b_79",mC="_expanded_g7q2b_90",hC="_tokenInfo_g7q2b_94",fC="_tokenInfoLabel_g7q2b_100",pC="_tokenLogo_g7q2b_106",gC="_pairedLogos_g7q2b_110",_C="_coinLogo_g7q2b_115",yC="_tokenSymbol_g7q2b_133",xC="_triggerValue_g7q2b_139",bC="_clammBreakdownContent_g7q2b_146",wC="_clammPositionRow_g7q2b_154",vC="_statusDot_g7q2b_163",jC="_inRange_g7q2b_170",CC="_outRange_g7q2b_174",kC="_unknown_g7q2b_178",NC="_clammStatusValue_g7q2b_182",IC="_breakdownContent_g7q2b_192",AC="_breakdownRow_g7q2b_200",SC="_breakdownLabel_g7q2b_208",TC="_breakdownValues_g7q2b_214",EC="_breakdownAmount_g7q2b_220",$C="_breakdownValue_g7q2b_214",MC="_collapsibleContent_g7q2b_241",R={container:nC,section:sC,sectionHeader:oC,sectionTitle:aC,sectionLabel:rC,externalLink:iC,sectionValue:cC,tokenList:lC,tokenTrigger:uC,tokenChevron:dC,expanded:mC,tokenInfo:hC,tokenInfoLabel:fC,tokenLogo:pC,pairedLogos:gC,coinLogo:_C,tokenSymbol:yC,triggerValue:xC,clammBreakdownContent:bC,clammPositionRow:wC,statusDot:vC,inRange:jC,outRange:CC,unknown:kC,clammStatusValue:NC,breakdownContent:IC,breakdownRow:AC,breakdownLabel:SC,breakdownValues:TC,breakdownAmount:EC,breakdownValue:$C,collapsibleContent:MC},LC=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("section",{className:R.section,"aria-label":"Liquidity positions",children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:va,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:R.sectionValue,children:ae(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(UC,{row:a,denomLogoMap:t},a.denom))})]})})},qC={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function RC(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function PC(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function si(e,t){return e===void 0?"-":`${k.formatNumber(e,{dp:6})} ${t}`}function El({isOpen:e,symbol:t,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return n.jsxs("button",{className:R.tokenTrigger,children:[n.jsxs("div",{className:R.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(R.tokenChevron,{[R.expanded]:e}),"aria-hidden":"true"}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(re,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(re,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const DC=({position:e})=>{const t=RC(e.inRange),s=PC(e.inRange);return n.jsxs("div",{className:R.clammPositionRow,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Position ID"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:e.positionId})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Deposit"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(e.value)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Status"}),n.jsxs("div",{className:R.clammStatusValue,children:[n.jsx("span",{className:B(R.statusDot,t)}),n.jsx("span",{children:s})]})]}),e.isFullRange?n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Range Bounds"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:"Full range"})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Min"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:si(e.minPrice,e.pricePairLabel)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Max"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:si(e.maxPrice,e.pricePairLabel)})})]})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(e.rewardValue)})})]})]})},BC=({row:e,denomLogoMap:t})=>{const[s,o]=_.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:u}=e,m=t.get(a);if(!u)return null;const d=l||m?.assetLogo;return n.jsxs(te.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:El({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:d,rightContent:n.jsx("span",{className:R.triggerValue,children:ae(i)})})}),n.jsx(te.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.clammBreakdownContent,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(u.totalRewardValue)})})]}),u.positions.map(h=>n.jsx(DC,{position:h},h.tokenAddress))]})})]})},FC=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[u,m]=_.useState(!1),d=t.get(s),h=i||d?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),p=l&&Number(l.total)>0;return n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:El({isOpen:u,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:ae(a)})})}),n.jsx(te.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[g.map(([y,x])=>{const b=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:qC[y]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[k.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:ae(b)})]})]},y)}),p&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[k.formatNumber(Number(l.total),{dp:6})," ",pt]}),n.jsx("span",{className:R.breakdownValue,children:ae(l.totalValue)})]})]})]})})]})},UC=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(BC,{row:e,denomLogoMap:t}):n.jsx(FC,{row:e,denomLogoMap:t}),OC="_container_1nijk_1",VC="_section_1nijk_6",KC="_sectionHeader_1nijk_14",WC="_sectionTitle_1nijk_20",zC="_sectionLabel_1nijk_26",HC="_externalLink_1nijk_32",QC="_sectionValue_1nijk_44",GC="_tokenList_1nijk_51",YC="_tokenTrigger_1nijk_63",ZC="_tokenChevron_1nijk_79",JC="_expanded_1nijk_90",XC="_tokenInfo_1nijk_94",ek="_tokenInfoLabel_1nijk_100",tk="_tokenLogo_1nijk_106",nk="_tokenName_1nijk_110",sk="_triggerValue_1nijk_116",ok="_breakdownContent_1nijk_123",ak="_breakdownRow_1nijk_131",rk="_breakdownLabel_1nijk_139",ik="_breakdownValues_1nijk_145",ck="_breakdownAmount_1nijk_151",lk="_breakdownValue_1nijk_145",uk="_collapsibleContent_1nijk_165",ge={container:OC,section:VC,sectionHeader:KC,sectionTitle:WC,sectionLabel:zC,externalLink:HC,sectionValue:QC,tokenList:GC,tokenTrigger:YC,tokenChevron:ZC,expanded:JC,tokenInfo:XC,tokenInfoLabel:ek,tokenLogo:tk,tokenName:nk,triggerValue:sk,breakdownContent:ok,breakdownRow:ak,breakdownLabel:rk,breakdownValues:ik,breakdownAmount:ck,breakdownValue:lk,collapsibleContent:uk},dk=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:ge.container,children:n.jsxs("section",{className:ge.section,"aria-label":"VIP rewards",children:[n.jsxs("div",{className:ge.sectionHeader,children:[n.jsxs("div",{className:ge.sectionTitle,children:[n.jsx("span",{className:ge.sectionLabel,children:"VIP"}),n.jsx("a",{href:Bu,target:"_blank",rel:"noopener noreferrer",className:ge.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:ge.sectionValue,children:ae(t)})]}),n.jsx("div",{className:ge.tokenList,children:s.map(o=>n.jsx(mk,{row:o},`${o.bridgeId}-${o.version}`))})]})})},mk=({row:e})=>{const{name:t,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=_.useState(!1),u=a+i;return n.jsxs(te.Collapsible.Root,{open:c,onOpenChange:l,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ge.tokenTrigger,children:[n.jsxs("div",{className:ge.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(ge.tokenChevron,{[ge.expanded]:c}),"aria-hidden":"true"}),n.jsxs("div",{className:ge.tokenInfoLabel,children:[s&&n.jsx(re,{src:s,width:20,height:20,className:ge.tokenLogo,logo:!0}),n.jsx("span",{className:ge.tokenName,children:t})]})]}),n.jsx("span",{className:ge.triggerValue,children:ae(u)})]})}),n.jsx(te.Collapsible.Content,{className:ge.collapsibleContent,children:n.jsxs("div",{className:ge.breakdownContent,children:[o>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Locked"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[k.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:ae(a)})]})]}),r>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[k.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:ae(i)})]})]})]})})]})},hk="_container_ymkoc_1",fk="_trigger_ymkoc_6",pk="_expandIcon_ymkoc_22",gk="_chainInfo_ymkoc_27",_k="_logo_ymkoc_33",yk="_chainNameContainer_ymkoc_37",xk="_chainName_ymkoc_37",bk="_externalLink_ymkoc_49",wk="_externalIcon_ymkoc_53",vk="_valueColumn_ymkoc_63",jk="_value_ymkoc_63",Ck="_expanded_ymkoc_80",kk="_collapsibleContent_ymkoc_85",Nk="_content_ymkoc_97",ze={container:hk,trigger:fk,expandIcon:pk,chainInfo:gk,logo:_k,chainNameContainer:yk,chainName:xk,externalLink:bk,externalIcon:wk,valueColumn:vk,value:jk,expanded:Ck,collapsibleContent:kk,content:Nk},Ik=H.atom(!1),Ak=()=>{const{totalValue:e}=Pa(),{totalValue:t}=co(),{totalValue:s}=lo(),o=e+t+s;return n.jsx("span",{className:ze.value,children:ae(o)})},Sk=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Pa(),{data:i}=wc(),{data:c}=vc(),l=_.useMemo(()=>{const d=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),y=`${e}:${f}`,x=s.get(y)??o.get(p);x&&d.set(f,{assetLogo:x,chainLogo:t})}return d},[r,s,o,e,t]),u=_.useMemo(()=>(d,h)=>{const f=k.denomToMetadata(d);if(h==="staking"){const g=i?.get(f);return g?k.fromBaseUnit(g.amount,{decimals:it}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?k.fromBaseUnit(g.amount,{decimals:it}):"0"}return"0"},[i,c]),m=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:va,positions:r}],[r]);return m.length===0?null:n.jsx(Tl,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:u,initPrice:a})},Tk=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=co(),r=_.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:u}=c,m=u.toUpperCase(),d=`${e}:${l}`,h=s.get(d)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx(LC,{data:a,denomLogoMap:r})},Ek=()=>{const e=lo();return e.rows.length===0?null:n.jsx(dk,{data:e})},$k=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=H.useAtom(Ik),i=_e(),c=os(),{denomLogos:l,symbolLogos:u}=_.useMemo(()=>Da(c,i),[c,i]),m=ce(),{data:d}=Pt(m),h=_.useMemo(()=>d?.find(g=>g.id===Je)?.price??0,[d]);return n.jsx("div",{className:ze.container,children:n.jsxs(te.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ze.trigger,children:[n.jsxs("div",{className:ze.chainInfo,children:[o&&n.jsx(re,{src:o,width:32,height:32,className:ze.logo,logo:!0}),n.jsxs("div",{className:ze.chainNameContainer,children:[n.jsx("span",{className:ze.chainName,children:s}),n.jsx("a",{href:va,target:"_blank",rel:"noopener noreferrer",className:ze.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,className:ze.externalIcon})})]})]}),n.jsxs("div",{className:ze.valueColumn,children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:16,width:60,length:1}),children:n.jsx(Ak,{})}),n.jsx(M.IconChevronDown,{size:16,className:B(ze.expandIcon,{[ze.expanded]:a})})]})]})}),n.jsx(te.Collapsible.Content,{className:ze.collapsibleContent,children:n.jsxs("div",{className:ze.content,children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:2}),children:n.jsx(Sk,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u,initPrice:h})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:2}),children:n.jsx(Tk,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:1}),children:n.jsx(Ek,{})})]})})]})})},Mk="_totalValue_1v2ca_1",Lk={totalValue:Mk},qk=({filteredChainGroups:e})=>{const{totalValue:t}=Pa(),{totalValue:s}=co(),{totalValue:o}=lo(),a=t+s+o,r=_.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,u)=>u.isInitia?l:l+u.totalValue,0)+(i?a:0)},[e,a]);return n.jsx("span",{className:Lk.totalValue,children:ae(r)})},Rk="_container_1eubu_1",Pk="_header_1eubu_7",Dk="_title_1eubu_13",Bk="_list_1eubu_19",Fk="_skeletonWrapper_1eubu_24",Gn={container:Rk,header:Pk,title:Dk,list:Bk,skeletonWrapper:Fk},Uk=_.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ms(),r=ce(),i=_.useMemo(()=>{const l=[];for(const m of o){if(!Array.isArray(m.positions))continue;const d=s.get(m.chainName.toLowerCase()),h=m.chainName.toLowerCase();if(t&&d?.chainId!==t||!m.positions.some(x=>x.positions.some(b=>b.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const g=m.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),p=r.chainId===d?.chainId,y=g.reduce((x,b)=>x+b.positions.reduce((j,v)=>j+Ln(v),0),0);l.push({chainId:d?.chainId??"",chainName:d?.prettyName??m.chainName,chainLogo:d?.logoUrl??"",protocols:g,isInitia:p,totalValue:y})}const u=["civitia","yominet"];return L.sortWith([L.descend(m=>m.isInitia??!1),L.ascend(m=>u.includes(m.chainName.toLowerCase())),L.descend(m=>m.totalValue??0),L.ascend(m=>m.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Gn.container,children:[n.jsxs("div",{className:Gn.header,children:[n.jsx("span",{className:Gn.title,children:"Positions"}),c&&n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:16,width:60,length:1}),children:n.jsx(qk,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Gn.list,children:i.map(l=>l.isInitia?n.jsx(xe,{suspenseFallback:n.jsx("div",{className:Gn.skeletonWrapper,children:n.jsx(Ct,{height:56,length:1})}),children:n.jsx($k,{chainGroup:l})},l.chainName):n.jsx(tC,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(Ct,{height:56,length:3}):n.jsx(je,{children:"No positions"})]})}),Ok="_content_1w1ad_1",Vk={content:Ok},Kk=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=se(),o=ce(),a=eh(),{totalValue:r}=lo(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=_.useMemo(()=>{const u=new Map;let m=0;for(const h of a)u.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(u.set(o.chainId,(u.get(o.chainId)??0)+r),m+=r),{chainIds:L.sortWith([L.descend(h=>h===s),L.descend(h=>h===o.chainId),L.descend(h=>u.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:u,totalBalance:m}},[a,s,o,r]);return n.jsx(vo,{value:e,onChange:t,chainIds:i,renderExtra:u=>ae(u?c.get(u)??0:l)})},Wk=()=>{const[e,t]=H.useAtom(jl),[s,o]=H.useAtom(Cl),a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Da(r,a),[r,a]),l=_a(),u=_.useMemo(()=>kc(a,l),[a,l]),m=Xm();return n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(xe,{suspenseFallback:n.jsx(pn,{height:44,width:132}),children:n.jsx(Kk,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("section",{className:Vk.content,"aria-label":"Assets and positions",children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:48,length:5}),children:n.jsx(rj,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:56,length:3}),children:n.jsx(Uk,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},zk="_totalValue_5pf7e_1",Hk="_totalLabel_5pf7e_7",Qk="_totalAmount_5pf7e_13",Gk="_loading_5pf7e_18",Yk="_skeletonWrapper_5pf7e_23",Zk="_nav_5pf7e_28",Jk="_item_5pf7e_34",Xk="_tabs_5pf7e_59",eN="_tab_5pf7e_59",He={totalValue:zk,totalLabel:Hk,totalAmount:Qk,loading:Gk,skeletonWrapper:Yk,nav:Zk,item:Jk,tabs:Xk,tab:eN},tN=()=>{const{totalValue:e,isLoading:t}=Ta();return n.jsx("div",{className:B(He.totalAmount,{[He.loading]:t}),children:ae(e)})},nN=()=>{const e=th(),t=nh(),s=Cc(),o=e+s+t;return n.jsx("div",{className:He.totalAmount,children:ae(o)})},sN=()=>{Wc(),Zm();const e=Ba(),t=Me(),s=to(),o=_.useRef(null);return n.jsx(Nl.Provider,{value:o,children:n.jsxs(yt,{ref:o,children:[n.jsxs("div",{className:He.totalValue,children:[n.jsx("div",{className:He.totalLabel,children:"Total value"}),n.jsx(xe,{suspenseFallback:n.jsx("div",{className:He.skeletonWrapper,children:n.jsx(pn,{height:48,width:120})}),children:e?n.jsx(tN,{}):n.jsx(nN,{})})]}),n.jsxs("nav",{className:He.nav,"aria-label":"Quick actions",children:[n.jsxs(mn,{to:"/send",className:He.item,children:[n.jsx(M.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(mn,{to:"/bridge",className:He.item,children:[n.jsx(M.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(mn,{to:"/receive",className:He.item,children:[n.jsx(M.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Ut.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Ut.Tabs.List,{className:He.tabs,children:[n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/nfts",children:"NFTs"}),n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/activity",children:"Activity"})]}),n.jsx(Ut.Tabs.Panel,{value:"/",children:e?n.jsx(sj,{}):n.jsx(Wk,{})}),n.jsx(Ut.Tabs.Panel,{value:"/nfts",children:n.jsx(pv,{})}),n.jsx(Ut.Tabs.Panel,{value:"/activity",children:n.jsx(Zw,{})})]})]})})},oN="_root_th990_1",aN="_collectionName_th990_9",rN="_nftName_th990_13",iN="_chainInfo_th990_17",cN="_attributes_th990_21",lN="_title_th990_24",uN="_count_th990_29",dN="_item_th990_33",mN="_type_th990_39",hN="_value_th990_45",rn={root:oN,collectionName:aN,nftName:rN,chainInfo:iN,attributes:cN,title:lN,count:uN,item:dN,type:mN,value:hN},fN=()=>{const e=Me(),t=et(),{attributes:s}=t;return n.jsxs(Tt,{title:"NFT details",children:[n.jsx(Za,{normalizedNft:t,chainIconSize:14,classNames:rn}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:rn.attributes,children:[n.jsxs("header",{className:rn.title,children:["Traits ",n.jsxs("span",{className:rn.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:rn.item,children:[n.jsx("div",{className:rn.type,children:o}),n.jsx("div",{className:rn.value,children:a})]},o))})]})]})};function pN({balances:e,gasPrices:t,gas:s}){return t.map(({denom:o,amount:a})=>{const r=q(a).times(s).toFixed(0,q.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>q(a).gte(o))}function gN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(u=>u.denom===e)?.amount??"0",i=pN({balances:t,gasPrices:s,gas:a}),c=i.find(u=>u.denom===o);if(i.length===0)return r;if(e===o&&c){const u=q(r).minus(c.amount);return q.max(u,0).toString()}const l=i.find(u=>u.denom!==e)||i[0];if(!c&&e===l.denom){const u=q(r).minus(l.amount);return q.max(u,0).toString()}return q(r).toString()}const _N=({chain:e,onSelect:t})=>{const s=mu(e);return n.jsx(xs,{assets:s,onSelect:t})},yN=({afterSelect:e})=>{const{watch:t,setValue:s}=$e.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=_.useState(r),l=_t(i),u=_e(),m=d=>{if(o===i&&a===d){e();return}s("chainId",i),s("denom",d),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(fn.Stack,{children:n.jsx(fn,{chains:u,value:i,onSelect:c})}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(_N,{chain:l,onSelect:m})},i)]})},xN="_fields_brpej_1",bN="_divider_brpej_11",oi={fields:xN,divider:bN},wN=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),vN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=tt(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=$e.useFormContext(),{errors:u}=l,{chainId:m,denom:d,recipient:h,quantity:f,memo:g}=r(),p=_t(m),y=as(p),x=Ia(p),b=Aa(p),j=bi(d,p),{data:v}=Pt(p),{decimals:w}=j,C=y.find(O=>O.denom===d)?.amount??"0",I=v?.find(({id:O})=>O===d)?.price,{data:T=0,isLoading:A}=E.useQuery({queryKey:wN.gas({chainId:m,denom:d,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:cr.MsgSend.fromPartial({fromAddress:t,toAddress:k.InitiaAddress(h).bech32,amount:[{denom:d,amount:"1"}]})}];return s({messages:O,chainId:m})},enabled:k.InitiaAddress.validate(h),staleTime:V.INFINITY}),$=Math.ceil(T*Ht),N=gN({denom:d,balances:y,gasPrices:x,lastFeeDenom:b,gas:$}),S=q(C).isZero(),F=x.some(({denom:O})=>O===d)&&A,D=S||F,{mutate:Z,isPending:K}=E.useMutation({mutationFn:({chainId:O,denom:J,quantity:Q,recipient:ee,memo:ue})=>{const ye=k.toBaseUnit(Q,{decimals:w}),me=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:cr.MsgSend.fromPartial({fromAddress:t,toAddress:k.InitiaAddress(ee).bech32,amount:[{denom:J,amount:ye}]})}];return o({messages:me,memo:ue,chainId:O,gas:T,gasAdjustment:Ht,gasPrices:x,spendCoins:[{denom:J,amount:ye}],internal:"/"})}}),W=_.useMemo(()=>{if(!f)return"Enter amount";if(u.quantity)return u.quantity.message;if(!h)return"Enter recipient address";if(u.recipient)return u.recipient.message;if(u.memo)return u.memo.message},[f,h,u.quantity,u.recipient,u.memo]);return n.jsx(Tt,{title:"Send",children:n.jsxs("form",{onSubmit:c(O=>Z(O)),"aria-label":"Send token form",children:[n.jsxs("div",{className:oi.fields,children:[n.jsx(na,{selectButton:n.jsx(qn,{title:"Select chain and asset",content:O=>n.jsx(yN,{afterSelect:O}),children:n.jsx(Jc,{asset:j,chain:p})}),quantityInput:n.jsx(ns,{balance:C,decimals:w}),balanceButton:n.jsx(zc,{onClick:()=>i("quantity",k.fromBaseUnit(N,{decimals:w}),{shouldValidate:!0}),disabled:D,children:k.formatAmount(C??"0",{decimals:w})}),value:f?Ua(q(f).times(I??0),I):"$0"}),n.jsx("div",{className:oi.divider}),n.jsx(Wa,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(we.Stack,{children:!g&&n.jsx(we,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:(A?"Estimating gas...":!1)||K,disabled:!!W,children:W??"Confirm"})})]})})},jN=()=>{const e=et(),t=xn(),s=Qt(t),{chain:o=t}=e,a=L.head(s);if(!e.denom&&!a)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const r=e.denom??a?.denom,i=$e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return n.jsx($e.FormProvider,{...i,children:n.jsx(vN,{})})};async function da(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function CN(e,t){const s=new kt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:t}).post("minievm/evm/v1/call",{json:{sender:k.InitiaAddress("0x1").bech32,contract_addr:k.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function kN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function NN({collection_addr:e},{restUrl:t}){const s=await CN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${k.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await da(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${k.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function IN(e,t){const{data:s}=await z.create({prefixUrl:t}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function AN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await IN(t,s);return o.startsWith("ibc/")?k.InitiaAddress.equals(k.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await da(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await da(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function SN(e,t){const s=de.toBase64(ln.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function TN(e,t){const{collection:s}=await z.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function EN(e,t){const s=de.toBase64(ln.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function ai(e){const t=/^(.*channel-\d+)\/(.*)$/,s=e.match(t);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function $N({collection_addr:e},t,s){const o=k.InitiaAddress(e).bech32,a=await SN(o,t.restUrl),r=t.metadata?.ibc_channels?.find(({chain_id:p,version:y})=>p===s.chain_id&&y.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=de.toBase64(ln.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:u}=await z.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=u??o,d=await EN(c,t.restUrl),h=await TN(o,t.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:d};if(u&&h!==i.replace("wasm.","")){const[p,y]=ai(u);return{class_id:o,class_trace:{path:p,base_class_id:y},outgoing_proxy:d}}const[f,g]=ai(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:d}}const MN={minimove:AN,minievm:NN,miniwasm:$N};async function LN({nft:e,srcChain:t,intermediaryChain:s}){const o=t.metadata?.is_l1?"minimove":t.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await MN[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await kN([e.token_id],a.class_id,t.restUrl)})}const qN="_root_1tyvn_1",RN="_collectionName_1tyvn_10",PN="_nftName_1tyvn_15",DN="_chainInfo_1tyvn_19",BN="_fields_1tyvn_24",FN="_chain_1tyvn_19",Go={root:qN,collectionName:RN,nftName:PN,chainInfo:DN,fields:BN,chain:FN},UN=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),ON=()=>{const e=_e(),t=et(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=se(),r=bn(),i=ce(),{address:c,initiaAddress:l,requestTxSync:u}=tt(),{watch:m,setValue:d,handleSubmit:h,formState:f}=$e.useFormContext(),{errors:g}=f,p=m(),{recipient:y,dstChainId:x}=p,b=_t(x),j=E.useQuery({queryKey:UN.simulation({collection_addr:o,nft:t,sender:l,recipient:y,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:k.InitiaAddress(y).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==b.chainId&&await LN({nft:t,srcChain:s,intermediaryChain:i})),{msgs:S}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return S.map(P=>r.fromAmino(P))},enabled:k.InitiaAddress.validate(y)}),{data:v,isLoading:w,error:C}=j,I=E.useQueryClient(),{mutate:T,isPending:A}=E.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await u({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{I.invalidateQueries({queryKey:Ja.nfts._def})}}),$=_.useMemo(()=>{if(!y)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(C)return"Route not found"},[y,g.recipient,C]);return n.jsxs("form",{onSubmit:h(()=>T()),children:[n.jsx(Za,{normalizedNft:t,thumbnailSize:80,classNames:Go}),n.jsxs("div",{className:Go.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination app"}),n.jsxs(qn,{title:"Destination app",content:N=>n.jsx(Zc,{onSelect:({chainId:S})=>{d("dstChainId",S),N()},list:e,getImage:S=>S.logoUrl,getName:S=>S.name,getKey:S=>S.chainId}),className:B("input",Go.chain),children:[n.jsx(re,{src:b.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:b.name})]})]}),n.jsx(Wa,{myAddress:c,ref:gs()})]}),n.jsx(Ae,{children:n.jsx(fe.White,{loading:(w?"Finding route...":!1)||A,disabled:!!$,children:$??"Confirm"})})]})},VN=()=>{const{chain:e}=et(),t=$e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(Tt,{title:"Send NFT",children:n.jsx($e.FormProvider,{...t,children:n.jsx(ON,{})})})},ma=()=>{const e=Me(),t=to(),s=Yt(),{closeDrawer:o}=Dt(),{closeModal:a}=ao();_.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=Pn();if(_.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(Wr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(Wr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(sN,{});case"/send":return n.jsx(jN,{},s);case"/receive":return n.jsx(Nb,{});case"/nft":return n.jsx(fN,{});case"/nft/send":return n.jsx(VN,{},s);case"/bridge":return n.jsx(Sy,{},s);case"/bridge/preview":return n.jsx(u1,{});case"/bridge/history":return n.jsx(Nx,{});case"/op/withdrawals":return n.jsx(P1,{});case"/tx":return n.jsx(Bc,{});case"/autosign/enable":return n.jsx(cg,{});case"/settings":return n.jsx(ew,{});case"/settings/autosign":return n.jsx(Ob,{});case"/deposit":return n.jsx(mb,{});case"/deposit/completed":return n.jsx(ua,{type:"deposit"});case"/withdraw":return n.jsx(hb,{});case"/withdraw/completed":return n.jsx(ua,{type:"withdraw"})}},KN="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",WN=()=>n.jsxs(n.Fragment,{children:[n.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),n.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),n.jsx("link",{rel:"stylesheet",href:KN}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),zN=()=>(sh(),Lu(),ad(),_e(),Jm(),Cc(),os(),null),HN=({children:e,...t})=>(_.useEffect(()=>{Tm()},[]),Ge.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(WN,{}),n.jsx(pi.Provider,{value:{...fi,...t},children:n.jsx(Ii,{children:n.jsx($p,{children:n.jsx(te.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(Ep,{children:n.jsxs(xp,{children:[e,n.jsx(oh,{}),n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(zN,{})}),n.jsx(Yh,{children:n.jsx(ma,{})}),n.jsx(zh,{children:n.jsx(ma,{})})]})})})})})})]}):null),QN=({bridge:e})=>n.jsx(Ii,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(Mc.Provider,{value:!!e,children:n.jsx(xe,{children:n.jsx(ma,{})})})})}),GN={1:"https://ethereum-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com"};function YN(e){const{id:t="testWallet",name:s="Test Wallet",rpcUrls:o,debug:a=!1,sendTransactionOverrides:r}=e;if("mnemonic"in e&&e.mnemonic==="")throw new Error("mnemonic must not be empty");if(!("mnemonic"in e&&e.mnemonic)&&!("privateKey"in e&&e.privateKey))throw new Error("Either mnemonic or privateKey is required");let i;try{i=e.mnemonic?lr.mnemonicToAccount(e.mnemonic):lr.privateKeyToAccount(e.privateKey)}catch(p){throw new Error(`[${t}] Failed to create account from ${e.mnemonic?"mnemonic":"privateKey"}`,{cause:p})}let c=1;const l={};function u(p,...y){l[p]?.forEach(x=>{x(...y)})}const m={...GN,...o},d={1:Gl.mainnet};function h(p){if(m[p])return m[p];const y=d[p];if(y)return y.rpcUrls.default.http[0];throw new Error(`[${t}] No RPC configured for chain ${p}`)}async function f(p,y){const x=h(c),b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p,params:y??[]})});if(!b.ok)throw new Error(`[${t}] RPC "${p}" failed: HTTP ${b.status} ${b.statusText} (${x})`);let j;try{j=await b.json()}catch(v){throw new Error(`[${t}] RPC "${p}" returned non-JSON response (${x})`,{cause:v})}if(j.error)throw new ft.EIP1193ProviderRpcError(j.error.code,j.error.message);return j.result}const g={request:async({method:p,params:y})=>{switch(a&&console.log(`[${t}] ${p}`,y),p){case"eth_requestAccounts":case"eth_accounts":return[i.address];case"eth_chainId":return`0x${c.toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:x}]=y,b=Number(x);if(!d[b]&&!m[b])throw new ft.EIP1193ProviderRpcError(4902,"Unrecognized chain ID");return!d[b]&&m[b]&&(d[b]={id:b,name:`Chain ${b}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[m[b]]}}}),c=b,u("chainChanged",x),null}case"wallet_addEthereumChain":{const[x]=y,b=x.rpcUrls?.[0];if(!b)throw new Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);const j=Number(x.chainId);return d[j]?a&&console.log(`[${t}] Chain ${j} already registered, skipping`):d[j]={id:j,name:x.chainName??`Chain ${j}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[b]}}},null}case"personal_sign":{const[x]=y;return i.signMessage({message:{raw:x}})}case"eth_signTypedData":case"eth_signTypedData_v4":{const[,x]=y;return i.signMessage({message:{raw:x}})}case"wallet_getPermissions":case"wallet_requestPermissions":return[{parentCapability:"eth_accounts"}];case"eth_sendTransaction":{const[x]=y,b=d[c];if(!b)throw new Error(`[${t}] No chain registered for chain ${c}. Call wallet_switchEthereumChain first.`);return ft.createWalletClient({account:i,chain:b,transport:ft.http(h(c))}).sendTransaction({to:x.to,value:x.value?BigInt(x.value):void 0,data:x.data,chainId:c,...r})}default:return f(p,y)}},on:(p,y)=>{(l[p]??=new Set).add(y)},removeListener:(p,y)=>{l[p]?.delete(y)},removeAllListeners:()=>{for(const p of Object.keys(l))delete l[p]}};return Yl.injected({target:()=>({id:t,name:s,provider:g})})}const ri={"noble-1":"noble",celestia:"celestia","neutron-1":"neutron","osmosis-1":"osmo"};function ZN(e){const{mnemonic:t,name:s="Test Cosmos Wallet",image:o,chains:a,debug:r=!1}=e;if(!t)throw new Error("mnemonic is required");const i=new Map;function c(d){return a?.[d]?a[d].prefix:ri[d]?ri[d]:d.replace(/-\d+$/,"")}function l(d){const h=c(d),f=i.get(h);if(f)return f;r&&console.log(`[${s}] Creating wallet for chain ${d} (prefix: ${h})`);const g=En.Secp256k1HdWallet.fromMnemonic(t,{prefix:h});return g.catch(p=>{i.delete(h),console.error(`[${s}] Failed to create wallet for prefix "${h}":`,p)}),i.set(h,g),g}function u(d){return{async getAccounts(){return(await l(d)).getAccounts()},async signAmino(h,f){return(await l(d)).signAmino(h,f)}}}const m={getOfflineSigner(d){return u(d)},getOfflineSignerOnlyAmino(d){return u(d)}};return{name:s,image:o,getProvider:()=>m}}exports.DEFAULT_GAS_ADJUSTMENT=Ht;exports.DEFAULT_GAS_PRICE_MULTIPLIER=hi;exports.InterwovenKit=QN;exports.InterwovenKitProvider=HN;exports.MAINNET=fi;exports.MoveError=nc;exports.PRIVY_APP_ID=ga;exports.TESTNET=Jl;exports.createTestCosmosWallet=ZN;exports.createTestWalletConnector=YN;exports.initiaPrivyWallet=eu;exports.initiaPrivyWalletConnector=Xl;exports.initiaPrivyWalletOptions=Jn;exports.injectStyles=vh;exports.useAddress=Yt;exports.useHexAddress=Bn;exports.useInitiaAddress=ie;exports.useInterwovenKit=tt;exports.usePortfolio=Ta;exports.useUsernameQuery=hc;
8
+ Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function Cu(e,t){const s=ft.hexToBytes(e);if(s.length!==65)throw new Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${s.length}`);const o=s.slice(0,64),a=ft.hexToBytes(ft.keccak256(ft.bytesToHex(o))),r=ht.Bip39.encode(a),i=await ht.Bip39.mnemonicToSeed(r),c=ht.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=ht.Slip10.derivePath(ht.Slip10Curve.Secp256k1,i,c),u=await ht.Secp256k1.makeKeypair(l),m=ht.Secp256k1.compressPubkey(u.pubkey),h=u.pubkey.slice(1),f=ft.bytesToHex(h),g=ft.keccak256(f),p=ft.hexToBytes(g).slice(-20),y=de.toBech32(t,p);return{privateKey:l,publicKey:m,address:y}}function Cs(e,t){return`${e}:${t}`}const rs=Q.atom(null),Xn=Q.atom({}),es=Q.atom({}),no=Q.atom({}),mr=Q.atom(0),Nu="autosign:";function ku(e,t){const s=e.get(mr)+1;return e.set(mr,s),`${t}:${s}`}function Bs(e,t){return e.get(no)[t]}function Iu(e,t,s){e.set(no,o=>({...o,[t]:s}))}function Mi(e,t){e.set(no,s=>{const o={...s};return delete o[t],o})}function Au(e,t,s){const o=Bs(e,t);!o||o.token!==s||Mi(e,t)}function Su(e,t,s){const o=Bs(e,t);return!!o&&o.token===s}function Ns(e,t){return e.get(es)[t]}function Tu(e,t,s){e.set(es,o=>({...o,[t]:s}))}function Eu(e,t){e.set(es,s=>{const o={...s};return delete o[t],o})}function $u(e,t,s){e.set(Xn,o=>({...o,[t]:s}))}function Mu(e,t){e.set(Xn,s=>{const o={...s};return delete o[t],o})}function Li(e,t){return`${Nu}${e}:${t}`}function Lu(e,t,s){try{return e.getItem(Li(t,s))}catch{return null}}function qu(e,t,s,o){try{e.setItem(Li(t,s),o)}catch{}}function qi(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ba(e,t){const s=qi();if(s)return Lu(s,e,t)}function Pu(e,t,s){const o=qi();o&&qu(o,e,t,s)}function Ru(e){return{publicKey:e.publicKey,address:e.address}}function Us(e){e&&e.fill(0)}function Pi(e){e.set(no,{});const t=e.get(es);for(const s of Object.values(t))Us(s);e.set(es,{}),e.set(Xn,{})}function Du(e,t){return e!==""&&e!==t}function Fu(){const e=ie(),t=Q.useStore(),s=_.useRef(e);_.useEffect(()=>{const o=s.current;Du(o,e)&&Pi(t),s.current=e},[t,e])}class Bu{constructor(t,s){this.wallet=t,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(t,s){if(this.wallet.address!==t)throw new Error("Signer address does not match the derived wallet address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=kt.ethers.hashMessage(o),r=de.fromHex(a.replace("0x","")),i=await ht.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=$i(this.wallet.publicKey,c);return{signed:s,signature:l}}}function so(){const e=Q.useStore(),{signMessageAsync:t}=He.useSignMessage(),s=lt(),o=ie();return{deriveWallet:async u=>{if(!o)throw new Error("User address not available");const m=s(u),d=Cs(o,m.bech32_prefix),h=e.get(Xn)[d];if(h&&Ns(e,d))return h;const f=Bs(e,d);if(f)return f.promise;const g=ku(e,d),p=(async()=>{try{const y=window.location.origin,x=ju(y),w=await t({message:x}),C=await Cu(w,m.bech32_prefix),j=Ru(C);if(Su(e,d,g))return Tu(e,d,C.privateKey),$u(e,d,j),j;throw Us(C.privateKey),new Error("Wallet derivation was cancelled")}finally{Au(e,d,g)}})();return Iu(e,d,{promise:p,token:g}),p},getWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);if(Ns(e,d))return e.get(Xn)[d]},getWalletPrivateKey:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);return Ns(e,d)},clearWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix),h=Ns(e,d);Bs(e,d)&&Mi(e,d),Us(h),Eu(e,d),Mu(e,d)},clearAllWallets:()=>{Pi(e)}}}function Ri({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:ha.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function Uu({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const u=Ri({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:t},d=new Uint8Array(i),h=new Bu(r,d);try{return await l(e,r.address,u,m,a,{customSigner:h})}finally{Us(d)}}const vt="interwovenkit",Je="uinit",pt="INIT",it=6,Ou="uoinit",Vu="omniINIT",Di="strat",Fi="https://app.initia.xyz",va=`${Fi}/liquidity/my`,Ku=`${Fi}/vip/my`,Wu=1e3,Bi=60*Wu,Ui=60*Bi,hr=24*Ui,he={PUBLIC_KEY:`${vt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${vt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${vt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${vt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${vt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${vt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${vt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${vt}:bridge:route-type`,BRIDGE_HISTORY:`${vt}:bridge:history`,OP_REMINDER:`${vt}:op:reminder`},Oi=Q.atom(!1),Vi=Q.atom(!1);function Ft(){const e=xa(),[t,s]=Q.useAtom(Oi),o=Q.useSetAtom(Vi),a=Rn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function Dn(){const e=xa(),[t,s]=Q.useAtom(Vi),o=Q.useSetAtom(Oi),a=Rn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ki(){const e=Me(),{closeDrawer:t}=Ft(),{closeModal:s}=Dn(),{disconnect:o}=He.useDisconnect(),{clearAllWallets:a}=so();return()=>{e("/blank"),t(),s(),o(),a(),localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM),localStorage.removeItem(he.BRIDGE_QUANTITY),localStorage.removeItem(he.BRIDGE_SLIPPAGE_PERCENT)}}function zu(){const e=Zt(),t=wn(),{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??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Hu(){const e=Zt(),t=wn(),{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??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Qu(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Yo.PubKey.decode(e.value);return $n.encodeSecp256k1Pubkey(t)}return Gs.decodeOptionalPubkey(e)}function Gu({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Wl.BaseAccount.decode(t),i=Qu(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Le.accountFromAny({typeUrl:e,value:t})}const Wi="/cosmos.feegrant.v1beta1.MsgGrantAllowance",zi="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Hi="cosmos-sdk/AllowedMsgAllowance";function Yu(){const e=fa.aminoConverters[Wi];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Os=Yu();function Qi(e){if(e.typeUrl===zi){const t=ln.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Hi,value:{allowance:Qi(t.allowance),allowed_messages:t.allowedMessages}}}return Os.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Gi(e){if(e.type===Hi){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Gi(t.allowance);return{typeUrl:zi,value:ln.AllowedMsgAllowance.encode(ln.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Os.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Zu={...fa.aminoConverters,[Wi]:{...Os,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Qi(e.allowance)}:Os.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Gi(e.allowance)})}},is=()=>{const e=ae();return new Gs.Registry([...fa.protoRegistry,...e.protoTypes??[]])},cs=()=>{const e=ae();return{...Zu,...e.aminoConverters}},bn=()=>{const e=cs();return new Le.AminoTypes(e)};class Ju{constructor(t,s,o){this.address=t,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const t=`${he.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(t);if(s)return this.cachedPublicKey=de.fromHex(s),de.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,de.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,de.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await H.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?de.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=kt.ethers.hashMessage(t),a=kt.ethers.SigningKey.recoverPublicKey(o,s);return ht.Secp256k1.compressPubkey(de.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(t,s){if(this.address!==t)throw new Error("Signer address does not match the provided address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=await this.signMessage(o),r=de.fromHex(a.replace("0x","")).subarray(0,-1),c=ht.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=$i(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Yi(){const e=is(),t=bn(),s=ls(),o=us();return async function(a,r,i,c,l,u){const m=u?.customSigner??s;if(!m)throw new Error("Signer not initialized");const d=await o(a),{accountNumber:h,sequence:f}=await Zi({getSequence:k=>d.getSequence(k),signerAddress:r,incrementSequence:u?.incrementSequence??0,allowMissingAccount:!!u?.customSigner}),[g]=await m.getAccounts(),p=Ei(wa(g.pubkey)),y=mi.SignMode.SIGN_MODE_EIP_191,x=i.map(k=>t.toAmino(k)),w=Zn.makeSignDoc(x,c,a,l,h,f),{signature:C,signed:j}=await m.signAmino(r,w),v={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:j.msgs.map(k=>t.fromAmino(k)),memo:l}},I=e.encode(v),S=or.Int53.fromString(j.fee.gas).toNumber(),A=or.Int53.fromString(j.sequence).toNumber(),$=Gs.makeAuthInfoBytes([{pubkey:p,sequence:A}],j.fee.amount,S,j.fee.granter,j.fee.payer,y);return Ze.TxRaw.fromPartial({bodyBytes:I,authInfoBytes:$,signatures:[de.fromBase64(C.signature)]})}}function Xu(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Zi({getSequence:e,signerAddress:t,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(t);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Xu(a,t))return{accountNumber:0,sequence:s};throw a}}function ls(){const e=ie(),{signMessageAsync:t}=He.useSignMessage(),s=ce();return _.useMemo(()=>new Ju(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const Ao=new Map,Ps=new Map;function ed(e,t){const s=`${e}:${t}`;Ps.delete(s)}function ja(){const e=lt();return async t=>{if(Ao.has(t))return Ao.get(t);const{rpcUrl:s}=e(t),o=await ar.Comet38Client.create(new ar.HttpClient(s));return Ao.set(t,o),o}}function us(){const e=is(),t=bn(),s=ls(),o=ie(),a=ja();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 Le.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:Gu,broadcastPollIntervalMs:500});return Ps.set(i,l),l}}function Ji(){const{connector:e}=He.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new kt.BrowserProvider(await e.getProvider())}}class fn extends Error{constructor(t){super(t),this.name="TimeoutError"}}function Xi(e,t,s){let o;const a=new Promise((r,i)=>{o=setTimeout(()=>i(new fn(s)),t)});return Promise.race([e,a]).finally(()=>{clearTimeout(o)})}function ec(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function tc(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function td(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function nc(){const e=ie(),t=lt();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=H.create({prefixUrl:c.restUrl});try{const{allowance:u}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return u}catch(u){if(u instanceof H.HTTPError&&[404,500].includes(u.response.status))return null;throw u}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=H.create({prefixUrl:c.restUrl}),{grants:u}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return u},fetchAllGrants:async r=>{const i=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,u=await Js(l,{prefixUrl:i.restUrl},"grants");return ec(u)}}}const Vs=qe.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),nd=4,sc=4;function sd(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function Ca(){const e=ae(),t=wn(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(t.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 od(){const{data:e}=oo(),t=Ca();return(s,o)=>{const a=o.every(i=>{const c=t[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function oo(){const e=ie(),t=Ca(),s=sd(t),{fetchFeegrant:o,fetchAllGrants:a}=nc();return E.useQuery({queryKey:Vs.expirations(e,s,t).queryKey,queryFn:()=>ad({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:V.MINUTE,retry:1})}async function ad(e){const{initiaAddress:t,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},u=[];for(const[d,h]of Object.entries(s))r[d]=null,i[d]=void 0,c[d]=!1,h.length>0&&u.push([d,h]);if(u.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await oc(u,nd,async([d,h])=>{const f=ba(t,d);try{const g=await o(d),p=f===void 0?g:f===null?[]:g.filter(v=>v.grantee===f),y=cd(p,h);if(y.length===0)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const x=await id({chainId:d,candidates:y,fetchFeegrant:a,concurrency:sc});if(!x)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const w=x.grantee.grants.filter(v=>h.includes(v.authorization.msg)).map(v=>v.expiration),C=tc(x.feegrant.allowance),j=[...w,C],b=Na(j);return{chainId:d,expectedAddress:f,expiration:b?new Date(b):void 0,grantee:x.grantee.grantee}}catch{return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0}}});for(const d of m)l[d.chainId]=d.expectedAddress,r[d.chainId]=d.expiration,i[d.chainId]=d.grantee;for(const[d]of u)c[d]=ld({expiration:r[d],grantee:i[d],expectedAddress:l[d]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function oc(e,t,s){const o=new Array(e.length),a=Math.max(1,t);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function rd(e){const t=td(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=tc(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Xe.isFuture(a)}async function id(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=sc}=e,r=await oc(s,a,async i=>{const c=await o(t,i.grantee);return c&&rd(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function cd(e,t){if(t.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(u=>!u.expiration||Xe.isFuture(new Date(u.expiration))),c=i.map(u=>u.authorization.msg);t.every(u=>c.includes(u))&&o.push({grantee:a,grants:i})}return o}function ld(e){const{expiration:t,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(t){case null:return!1;case void 0:return a;default:return a&&Xe.isFuture(t)}}function ud(){const{data:e,refetch:t}=oo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Xe.isFuture(c));if(o.length===0)return;const a=Na(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{t()},r+100);return()=>clearTimeout(i)},[e,t])}function Na(e){const t=e.filter(s=>s!==void 0);if(t.length!==0)return[...t].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const ac=_.createContext(null),ao=()=>_.useContext(ac);class rc extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(t,s,o,a,r,i,c){super(t),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const dd=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,So=new Map;function md(e){const t=e.match(dd);if(!t)return null;const[,s,o,a]=t;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function hd(e,t,s){const o=`${e}:${t}`;if(So.has(o))return So.get(o);try{const a=t==="0x1"?"0x1.json":`${e}/${t}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await H.get(r).json();return So.set(o,i),i}catch{return null}}function fd(e,t,s,o,a,r,i){return new rc(e,t,s,o,a,r,i)}async function In(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await ct(e);const o=md(e.message);if(!o)return await ct(e);const a=await hd(t.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,u=!!c;return fd(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,u)}const pd=10;function ic(){const e=ie();return(t,s)=>E.queryOptions({queryKey:Xs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":pd},{txs:a}=await H.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:V.SECOND})}function gd(e,t){const s=ic();return E.useSuspenseQuery(s(e,t))}function _d(e,t){const s=e.flatMap((o,a)=>(t[a]??[]).map(i=>({...i,chain:o})));return L.sortWith([L.descend(o=>new Date(o.timestamp).getTime())])(s)}const yd=()=>{const e=_e(),t=ic(),s=E.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map(L.prop("data")),a=_d(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function ka(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await H.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return[...s].sort(L.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:gi;return{amount:q(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:t,fixed_min_gas_price:s})=>{if(L.isNil(s))throw new Error(`${t} has no price`);return{amount:String(s),denom:t}})}function Ia(e){const{data:t}=E.useSuspenseQuery({queryKey:Zs.gasPrices(e).queryKey,queryFn:()=>ka(e),staleTime:V.SECOND});return t}function Aa(e){const t=ie(),{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=>N.InitiaAddress.equals(t,kt.computeAddress(`0x${de.toHex(ht.Secp256k1.uncompressPubkey(de.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const cc="approve",ro=Q.atom(),lc=Q.atom(null),xd=Qt,wd=1.5;function bd({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(t)??r(s)??a[0]}function vd({simulatedGas:e,gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),u=bd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Le.calculateFee(l,Le.GasPrice.fromString(`${u.amount}${u.denom}`))}function jd({derivedAddress:e,messages:t,encoder:s}){return{messages:Ri({granteeAddress:e,messages:t,encoder:s})}}function Cd(e){if(!(e instanceof Error))return!1;const t=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=t.includes("user rejected")||t.includes("rejected the request")||t.includes("user denied")||t.includes("denied by user")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("cancelled by user")||t.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function Nd({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Le.createProtobufRpcClient(e),i=new rr.ServiceClientImpl(r),c=Ze.Tx.fromPartial({authInfo:Ze.AuthInfo.fromPartial({fee:Ze.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:mi.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ze.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(rr.SimulateRequest.fromPartial({txBytes:Ze.Tx.encode(c).finish()}))}function kd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function Id({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},u){const m=async()=>u.signWithEthSecp256k1(t,e,s,a,o),d=(y,x)=>{u.onAutoSignFallback?.({chainId:t,reason:y,errorMessage:kd(x)})};if(!c)return m();if(!u.validateAutoSign(t,s))return d("validation_failed"),m();let f=u.getWallet(t),g=!1;if(!f&&l)try{f=await u.deriveWallet(t)}catch(y){if(Cd(y))throw y;d("derive_wallet_failed",y),g=!0,f=void 0}if(!f)return g||d("missing_derived_wallet"),m();let p;try{const y=i??await u.getSigningClient(t);p=await u.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:y})}catch(y){return d("fee_computation_failed",y),m()}try{return await u.signWithDerivedWallet(t,e,s,p,o,f)}catch(y){return d("derived_wallet_sign_failed",y),m()}}function uc(){const e=ie(),{autoSignFeePolicy:t}=ae(),s=lt(),o=ja(),a=us(),r=is(),i=od(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:u}=so(),m=Yi(),d=Rn(),h=p=>{const y=t?.[p];return{gasMultiplier:y?.gasMultiplier??xd,maxGasMultiplierFromSim:y?.maxGasMultiplierFromSim??wd,allowedFeeDenoms:y?.allowedFeeDenoms}},f=async({chainId:p,messages:y,memo:x,derivedWallet:w,preferredFeeDenom:C,fallbackFeeDenom:j,client:b})=>{const v=s(p),I=await ka(v),A=jd({derivedAddress:w.address,messages:y,encoder:r}).messages.map(K=>r.encodeAsAny(K)),$=Ei(wa(w.publicKey)),{sequence:k}=await Zi({getSequence:K=>b.getSequence(K),signerAddress:w.address,incrementSequence:0,allowMissingAccount:!0}),T=await o(p),R=Le.QueryClient.withExtensions(T,Le.setupTxExtension),{gasInfo:B}=await Nd({queryClient:R,messages:A,memo:x,pubkey:$,sequence:k}),D=B?Number(B.gasUsed.toString()):0,J=h(p);return vd({simulatedGas:D,gasPrices:I,preferredFeeDenom:C,fallbackFeeDenom:j,policy:J})},g=async(p,y,x,w,C,j)=>{let b=j??c(p);b||(b=await l(p));const v=u(p);if(!v)throw new Error("Derived wallet key not initialized");return await Uu({chainId:p,granterAddress:y,messages:x,fee:w,memo:C,derivedWallet:b,privateKey:v,encoder:r,signWithEthSecp256k1:m})};return p=>Id({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:y,reason:x,errorMessage:w})=>{d("AutoSign Fallback",{chainId:y,reason:x,errorMessage:w})}})}function dc(){const e=Q.useAtomValue(ro);if(!e)throw new Error("Tx request not found");return e}function io(){const e=Me(),t=ie(),{defaultChainId:s,registryUrl:o}=ae(),a=lt(),{openDrawer:r,closeDrawer:i}=Ft(),{openModal:c,closeModal:l}=ao(),u=Q.useSetAtom(ro),m=Q.useSetAtom(lc),d=ja(),h=us(),f=ls(),g=is(),p=uc(),y=async({messages:A,memo:$,chainId:k=s})=>{try{return await(await h(k)).simulate(t,A,$)}catch(T){throw await In(T,a(k),o)}},x=async({messages:A,memo:$,chainId:k=s})=>{const T=await d(k),R=Le.QueryClient.withExtensions(T,Le.setupTxExtension),B=A.map(O=>g.encodeAsAny(O)),[D]=await f.getAccounts(),J=$n.encodeSecp256k1Pubkey(D.pubkey),K=await h(k),{sequence:z}=await K.getSequence(t);return R.tx.simulate(B,$,J,z)},w=async({txRequest:A,broadcaster:$})=>{const T={...{memo:"",chainId:s,gas:A.gas||await y(A),gasAdjustment:Qt,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((R,B)=>{u({txRequest:T,resolve:async J=>{try{const K=await h(T.chainId),z=await $(K,Ze.TxRaw.encode(J).finish());R(z),typeof T.internal=="string"&&e(T.internal)}catch(K){B(await In(K,a(T.chainId),o))}finally{D()}},reject:J=>{B(J),D()}}),T.internal?c({path:"/tx"}):r("/tx");const D=()=>{if(!T.internal){e("/blank"),i();return}l()}})},C=async A=>{const $=A.chainId??s;try{const k=await w({txRequest:A,broadcaster:async(T,R)=>await T.broadcastTxSync(R)});return A.internal&&typeof A.internal!="number"&&(m({txHash:k,chainId:$,status:"loading"}),S({txHash:k,chainId:A.chainId}).then(T=>{m({status:T.code===0?"success":"error",chainId:$,txHash:k})}).catch(()=>{m({status:"error",chainId:$,txHash:k})})),k}catch(k){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:$,error:k}),k}},j=(A,$=30*1e3,k=.5*1e3)=>w({txRequest:A,broadcaster:async(T,R)=>{const B=await T.broadcastTx(R,$,k);if(B.code!==0)throw new Error(B.rawLog);return B}}),b=async({chainId:A,messages:$,memo:k="",fee:T,preferredFeeDenom:R})=>{const B=await h(A),D=await p({chainId:A,messages:$,memo:k,fee:T,preferredFeeDenom:R,client:B,allowWalletDerivation:!0});return{client:B,signedTx:D}},v=async A=>{const $=A.chainId??s;try{const{client:k,signedTx:T}=await b({...A,chainId:$});return await k.broadcastTxSync(Ze.TxRaw.encode(T).finish())}catch(k){throw await In(k,a($),o)}},I=async(A,$=30*1e3,k=.5*1e3)=>{const T=A.chainId??s;try{const{client:R,signedTx:B}=await b({...A,chainId:T}),D=await R.broadcastTx(Ze.TxRaw.encode(B).finish(),$,k);if(D.code!==0)throw new Error(D.rawLog);return D}catch(R){throw await In(R,a(T),o)}},S=async({chainId:A=s,...$})=>{try{const k=await h(A);return await mc({...$,client:k})}catch(k){throw k instanceof fn?k:await In(k,a(A),o)}};return{estimateGas:y,simulateTx:x,requestTxSync:C,requestTxBlock:j,submitTxSync:v,submitTxBlock:I,waitForTxConfirmation:S}}async function mc({txHash:e,client:t,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await t.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new fn(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Ad="/cosmos.authz.v1beta1.MsgExec";function Sd(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function Td(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function Ed(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function $d(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function hc(e){const t=[Vs.expirations._def,Vs.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function fc(){const e=ie(),{fetchFeegrant:t,fetchGrants:s}=nc();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await t(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:hi.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=$d(c).map(d=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:ha.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:d})}));return[...l,...m]}}function Md(){const e=ie(),t=Ca(),{requestTxBlock:s}=io(),o=E.useQueryClient(),[a,r]=Q.useAtom(rs),{closeDrawer:i}=Ft(),c=fc(),{deriveWallet:l}=so();return E.useMutation({mutationFn:async u=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const d=t[m];if(!d||d.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);ed(e,m);const f=ba(e,m),g=Td({currentGrantee:h.address,expectedGrantee:f}),y=(await Promise.all(g.map(v=>c({chainId:m,grantee:v})))).flat(),x=u===0?void 0:Xe.addMilliseconds(new Date,u),w={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:ln.BasicAllowance.encode(ln.BasicAllowance.fromPartial({expiration:x})).finish()},C={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:hi.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:ln.AllowedMsgAllowance.encode(ln.AllowedMsgAllowance.fromPartial({allowance:w,allowedMessages:[Ad]})).finish()}})},j=d.map(v=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:ha.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:ir.GenericAuthorization.encode(ir.GenericAuthorization.fromPartial({msg:v})).finish()},expiration:x}})})),b=[...y,C,...j];return await s({messages:b,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:u,derivedWallet:m})=>{e&&Pu(e,u,m.address),await hc(o),a?.resolve()},onError:u=>{a?.reject(u)},onSettled:()=>{r(null),i()}})}function pc(e){const t=ae(),s=_e(),o=lt(),{getWallet:a,clearWallet:r}=so(),{requestTxBlock:i}=io(),c=E.useQueryClient(),l=fc(),{data:u,refetch:m}=oo();return E.useMutation({mutationFn:async(d=t.defaultChainId)=>{const h=a(d),f=u?.granteeByChain[d];let g;e?.grantee||(g=(await m()).data?.granteeByChain[d]);const p=Sd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const x=(await Promise.all(p.map(w=>l({chainId:d,grantee:w})))).flat();return x.length===0?{chainId:d,didBroadcast:!1}:(await i({messages:x,chainId:d,internal:e?.internal}),{chainId:d,didBroadcast:!0})},onSuccess:async({chainId:d,didBroadcast:h})=>{await hc(c);const f=o(d),g=s.filter(j=>j.bech32_prefix===f.bech32_prefix).map(j=>j.chain_id).filter(j=>j!==d);let p;try{p=(await m()).data}catch{p=void 0}const y=p??u;let x=!1;g.length>0&&y&&(x=g.some(j=>y?.isEnabledByChain[j]));const w=h?p?.isEnabledByChain[d]:(p??u)?.isEnabledByChain[d];Ed({isEnabledOnTargetChain:w,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(d)}})}const Sa=[{value:10*Bi,label:"for 10 minutes"},{value:Ui,label:"for 1 hour"},{value:hr,label:"for 1 day"},{value:7*hr,label:"for 7 days"},{value:0,label:"until revoked"}],Zo=Sa[0].value;function Ld(e){return e===void 0?Zo:Sa.some(t=>t.value===e)?e:Zo}function qd(){const{defaultChainId:e}=ae(),{openDrawer:t}=Ft(),s=Q.useSetAtom(rs),o=pc(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=oo();return{...a,isLoading:r,enable:async(l=e,u)=>new Promise((m,d)=>{s({chainId:l,defaultDuration:Ld(u?.defaultDuration),resolve:m,reject:d}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function gc(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function Pd(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),q(0)).toString()}function Rd(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??ya}}function fr(e){return L.pick(["chainId","name","logoUrl"],e)}function Dd(e){return L.sortWith([L.descend(({symbol:t})=>t===pt),L.descend(gc),L.descend(({assets:t})=>t.length),L.ascend(({symbol:t})=>t)])(e)}function Fd(e){return L.sortWith([L.descend(({value:t})=>t??0),L.descend(({quantity:t})=>Number(t)),L.ascend(({chain:t})=>t.name)])(e)}function Bd(e,t){return L.sortWith([L.descend(({chain:s})=>s.chainId===t),L.ascend(({chain:s})=>s.name),L.ascend(({denom:s})=>s)])(e)}function Ud(e,t){return L.sortWith([L.descend(({chainId:s})=>s===t),L.descend(L.prop("value"))])(e)}function Od(e,t,s,o,a){const r=e.find(d=>d.metadata?.is_l1)?.chainId,i={};for(const d of e){const h=d.chainId,f=t[h]??[],g=s[h],p=o[h],y=[];for(const{amount:x,denom:w}of f){if(!q(x).gt(0))continue;const C=g?.find(S=>S.denom===w),j=p?.find(S=>S.id===w)?.price,b=C?.decimals??0,v=N.fromBaseUnit(x,{decimals:b}),I=j?q(v).times(j).toNumber():void 0;y.push({...Rd(w,C),amount:x,denom:w,decimals:b,quantity:v,price:j,value:I,address:C?.address,unlisted:!C,chain:fr(d)})}i[h]=y}const c=new Map;for(const[d,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===d);if(!f)continue;const g=h.reduce((p,{value:y})=>p+(y??0),0);c.set(d,{...fr(f),value:g})}const l=new Map;for(const d of Object.values(i))for(const h of d)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const u=[];for(const[d,h]of l){const f=L.head(h);if(!f)continue;const g=Fd(h),p=g.reduce((x,{value:w})=>x+(w??0),0),y=g.reduce((x,{quantity:w})=>x.plus(w),q(0)).toNumber();u.push({symbol:d,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:y})}const m=[];for(const d of Object.values(i))for(const h of d)h.unlisted&&m.push(h);return{chainsByValue:Ud(Array.from(c.values()),a),assetGroups:Dd(u),unlistedAssets:Bd(m,r),totalValue:u.reduce((d,h)=>d+h.totalValue,0)}}function Ta(){const{defaultChainId:e}=ae(),t=_e(),s=gu(),o=os(),a=_a(),r=t.map(h=>h.chainId),i=L.zipObj(r,s.map(L.prop("data"))),c=L.zipObj(r,o.map(L.prop("data"))),l=L.zipObj(r,a.map(L.prop("data"))),u=Od(t,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...u,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function ie(){const e=Fn();return e?N.InitiaAddress(e).bech32:""}function Fn(){const{address:e}=He.useAccount();return e?N.InitiaAddress(e).hex:""}function Zt(){const e=wn(),t=ie(),s=Fn();return e.metadata?.minitia?.type==="minievm"?s:t}function _c(e){const t=Zt(),s=e??t,o=Ni();return E.useQuery({queryKey:Xs.username(o.restUrl,s).queryKey,queryFn:()=>o.getUsername(s),enabled:!!s,staleTime:V.MINUTE})}function tt(){const e=Zt(),t=ie(),s=Fn(),{data:o}=_c(),a=ls(),r=Ki(),i=qd(),{isDrawerOpen:c,openDrawer:l}=Ft(),{isModalOpen:u}=Dn(),m=()=>{l("/")},d=()=>{l("/connect")},h=w=>{l("/bridge",w)},f=zu(),g=Hu(),p=io();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||u,openConnect:d,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const Vd="_status_tn9m1_1",Kd="_error_tn9m1_9",pr={status:Vd,error:Kd},je=({error:e,children:t})=>n.jsx("p",{className:P(pr.status,{[pr.error]:e}),role:e?"alert":"status",children:t}),xe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(je,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(je,{children:"Loading..."}),children:s})=>n.jsx(fi.ErrorBoundary,{...e,children:n.jsx(_.Suspense,{fallback:t,children:s})}),_n=1n<<64n,Wd=1n<<63n,yc=(1n<<128n)-1n;function Yt(e){const t=BigInt(e);return t>=Wd?t-_n:t}const zd=(1n<<256n)-1n,zt=443636n,Hd=4295048017n,Qd=18446744073709551616n,Gd=79226673515401279992447579062n,Yd=255738958999603826347141n;function Zd(e,t,s){const o=Number(Yt(e)),a=Number(Yt(t)),r=Math.floor(-Number(zt)/s)*s,i=Math.floor(Number(zt)/s)*s;return o===r&&a===i}function xc(e){return e>>64n}function Jd(e){const t=e>>64n;return e%_n!==0n?t+1n:t}function Ln(e){if(e<0n||e>yc)throw new Error("INPUT_OUT_OF_RANGE");return e}function Xd(e,t){const s=e*t>>64n;if(s>yc)throw new Error("OVERFLOW");return s}function Ea(e,t){return e>t?[t,e]:[e,t]}function em(e,t,s,o){if(e===t)return 0n;const[a,r]=Ea(e,t);if(a===0n||r===0n)return 0n;const i=s*_n,c=r-a,l=i*c;if(l===0n)return 0n;const u=a*r;return o?(l-1n)/u+1n:l/u}function tm(e,t,s,o){if(e===t)return 0n;const[a,r]=Ea(e,t),c=(r-a)*s;return o?Jd(Ln(c)):xc(Ln(c))}function gr(e,t,s){return em(e,t,s<0n?-s:s,s>=0n)}function _r(e,t,s){return tm(e,t,s<0n?-s:s,s>=0n)}const To=1n<<64n,yr=1n<<65n,nm=64n;function sm(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<nm-1n,r=0n,i=1;for(;t>=yr;)t>>=1n,s+=To;for(;t<To;)i=0,t<<=1n,o+=To;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=yr&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?Ln(s):Ln(o-s);return[i,c]}function Ht(e){const t=e<0n?-e:e;if(t>zt)throw new Error("MAX_TICK");let s=(t&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(t&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(t&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(t&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(t&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(t&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(t&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(t&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(t&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(t&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(t&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(t&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(t&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(t&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(t&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(t&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(t&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(t&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(t&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=zd/s);const o=s/_n;return s%_n!==0n?o+1n:o}function om(e){if(e<Hd||e>=Gd)throw new Error("INVALID_SQRT_PRICE");const[,t]=sm(Ln(e)),s=Xd(t,Ln(Yd)),o=xc(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<Qd?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-zt&&(a=-zt),i>zt&&(i=zt),Ht(i)<=e){if(i>=zt)throw new Error("GTE_MAX_TICK");if(Ht(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(Ht(r)<=e)return r;if(Ht(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function am(e,t,s,o){const[a,r]=Ea(t,s);return e<a?[gr(a,r,o),0n]:e<r?[gr(e,r,o),_r(a,e,o)]:[0n,_r(a,r,o)]}function rm({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=Ht(Yt(e)),r=Ht(Yt(t));return am(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const Eo=_n*_n,im=1e-300,cm=BigInt(Number.MAX_SAFE_INTEGER);function xr(e){const t=e*e,s=t/Eo,o=t%Eo;return s>cm?Number(s):Number(s)+Number(o)/Number(Eo)}function wr(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,im)}function lm({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=Ht(Yt(e)),a=Ht(Yt(t)),r=xr(o),i=xr(a);return s?{min:wr(i),max:wr(r)}:{min:r,max:i}}const vn=qe.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,s)=>[e,t,s],clammFees:(e,t,s)=>[e,t,s],clammIncentive:(e,t,s,o)=>[e,t,s,o]}),$a={lens:"lens",pool:"pool",farming:"farming"},Ma={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function um(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:N.InitiaAddress(e).hex}function Ks(e){return de.toBase64(N.InitiaAddress(um(e),32).bytes)}function wc(e,t){return`${e}:${t}`}function dm(e){return`clamm:${e}`}function mm(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function hm(e){return e.map(t=>({tokenAddress:t.token_address,lpMetadata:t.lp_metadata,tickLower:t.tick_lower,tickUpper:t.tick_upper,liquidity:t.liquidity,incentives:t.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function fm(e){const{dexUrl:t}=ae();return E.useSuspenseQuery({queryKey:vn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await H.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...mm(r.positions)),o=r.pagination.next_key||void 0}while(o);return hm(s)},staleTime:V.MINUTE})}function pm(e){const t=ce(),{viewFunction:s}=N.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:vn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:$a.lens,functionName:"get_pool_info",typeArgs:[],args:[Ks(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function gm(e){const t=ce(),{viewFunction:s}=N.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:vn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:$a.pool,functionName:"fees_available",typeArgs:[],args:[Ks(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function _m(e){const t=ce(),{viewFunction:s}=N.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:vn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:$a.farming,functionName:"pending_reward_info",typeArgs:[],args:[Ks(r.tokenAddress),Ks(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(wc(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function bc(e){const{dexUrl:t}=ae(),o=E.useSuspenseQueries({queries:e.map(a=>({queryKey:vn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await H.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:V.MINUTE}))}).map(a=>a.data);return _.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function vc(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function ym(e){return bc(e)}function xm(e){const t=ce(),s=Gt(t),o=_.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=_.useMemo(()=>e.map(i=>N.denomToMetadata(i)),[e]),r=bc(a);return _.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const u=a[l];if(!u){i.set(c,null);return}const m=r.get(u);if(!m){i.set(c,null);return}if(c===Ou){i.set(c,{...m,symbol:Vu});return}const d=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:d})}),i},[e,a,r,o])}const wm="lock_staking";function jc(e,t){const s=`${t}::lock_staking::StakingAccount`,o=N.createObjectAddress(e,s);return N.InitiaAddress(o).bech32}const ds=qe.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,t)=>[e,t],undelegations:(e,t,s)=>[e,t,s],lockStaking:(e,t,s)=>[e,t,s],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,s)=>[e,t,s]});function La(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.delegations(e,t||"").queryKey,queryFn:async()=>t?(await H.get(`${e}/initia/mstaking/v1/delegations/${t}`).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=N.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},u=o.get(c)??[];u.push(l),o.set(c,u)}}return o},staleTime:V.MINUTE})}function qa(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=ae(),s=ie(),o=s?jc(s,t):"";return E.useSuspenseQuery({queryKey:ds.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await H.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await H.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 u of l.balance){const m=N.denomToMetadata(u.denom),d={denom:u.denom,metadata:m,amount:u.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(d),r.set(m,h)}}return r},staleTime:V.MINUTE})}function Pa(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=ae(),s=ie();return E.useSuspenseQuery({queryKey:ds.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=N.createMoveClient(e);return await o({moduleAddress:t,moduleName:wm,functionName:"get_locked_delegations",typeArgs:[],args:[de.toBase64(N.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:V.MINUTE})}function Cc(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=N.denomToMetadata(s.denom);let a=new q(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=t.get(o);if(r){const i=new q(r.amount);a=a.plus(i)}t.set(o,{denom:s.denom,amount:a.toString()})}return t}function Nc(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await H.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:Cc,staleTime:V.MINUTE})}function kc(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=ae(),s=ie(),o=s?jc(s,t):"";return E.useSuspenseQuery({queryKey:ds.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await H.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Cc,staleTime:V.MINUTE})}function Ra(){const e=ce(),t=Gt(e),{data:s,isLoading:o}=Dt(e),{data:a}=La(),{data:r}=qa(),{data:i}=Pa(),c=_.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Fs(c),u=_.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=_.useMemo(()=>{const f=new Map;for(const g of t)f.set(g.denom,g);return f},[t]),d=_.useMemo(()=>{const f=[],g=p=>{const y=m.get(p);return y?{symbol:y.symbol,decimals:y.decimals}:null};for(const[p,y]of a){const x=l.get(p)??y[0]?.denom;if(!x)continue;const w=g(x);if(!w)continue;const C=u.get(x)??0;for(const j of y){const{symbol:b,decimals:v}=w,I=Number(N.fromBaseUnit(j.amount,{decimals:v})),S={type:"asset",denom:x,symbol:b,amount:j.amount,formattedAmount:I,decimals:v,value:I*C};f.push({type:"staking",validator:j.validator,balance:S})}}for(const[p,y]of i){const x=l.get(p);if(!x)continue;const w=g(x);if(!w)continue;const C=u.get(x)??0;for(const j of y){const{symbol:b,decimals:v}=w,I=Number(N.fromBaseUnit(j.amount,{decimals:v})),S={type:"asset",denom:x,symbol:b,amount:j.amount,formattedAmount:I,decimals:v,value:I*C},A=Number(j.releaseTime);f.push({type:"lockstaking",validator:j.validator,releaseTime:Number.isNaN(A)?0:A,balance:S})}}for(const[p,y]of r){const x=l.get(p)??y[0]?.denom;if(!x)continue;const w=g(x);if(!w)continue;const C=u.get(x)??0;for(const j of y){const{symbol:b,decimals:v}=w,I=Number(N.fromBaseUnit(j.amount,{decimals:v})),S={type:"asset",denom:x,symbol:b,amount:j.amount,formattedAmount:I,decimals:v,value:I*C},A=new Date(j.completionTime).getTime(),$=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:j.validator,completionTime:$,balance:S})}}return f.filter(p=>p.type!=="fungible-position"&&p.type!=="perp-position"&&p.balance.denom===Je)},[a,i,r,l,m,u]),h=_.useMemo(()=>d.reduce((f,g)=>g.type==="fungible-position"||g.type==="perp-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[d]);return{positions:d,totalValue:h,isLoading:o}}function bm(e){const t=new Map;for(const s of e){const o=N.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function vm(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function jm(e){const{dexUrl:t}=ae();return E.useSuspenseQuery({queryKey:vn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await H.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:V.MINUTE})}function Cm(){const e=ce(),t=as(e),s=_.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=jm(s);return _.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return bm(a)},[t,o])}function Nm(e){const{dexUrl:t}=ae();return E.useSuspenseQuery({queryKey:vn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await H.get(`${t}/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:V.MINUTE})}function km(e,t,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of t){const c=i[0]?.denom;c&&c!==Je&&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!==Je&&a.add(r)}return Array.from(a)}function Im(e){const t=[];for(const[,s]of e)s&&s!==Je&&t.push(s);return t}function Am(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=vc(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 $o(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(N.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function Sm(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(N.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function Tm(e,t,s,o){for(const[a,r]of e){const i=N.denomToMetadata(a),c=t?.get(i),l=c?N.fromBaseUnit(c.amount,{decimals:it}):"0",u=s?.get(i),m=u?N.fromBaseUnit(u.amount,{decimals:it}):"0",d=Number(l)+Number(m);d<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(d),totalValue:d*o})}}function Em(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function co(){const e=ce(),t=Gt(e),s=ie(),o=Cm(),{data:a}=La(),{data:r}=Pa(),{data:i}=qa(),{data:c}=Nc(),{data:l}=kc(),{data:u}=Dt(e),{data:m}=fm(s),d=_.useMemo(()=>{const B=new Map;for(const D of m){const J=B.get(D.lpMetadata)??[];J.push(D),B.set(D.lpMetadata,J)}return B},[m]),h=_.useMemo(()=>Array.from(d.keys()),[d]),f=ym(h),g=pm(h),p=_.useMemo(()=>m.map(B=>B.tokenAddress),[m]),y=gm(p),x=_.useMemo(()=>{const B=[];for(const D of m)for(const J of D.incentives)B.push({tokenAddress:D.tokenAddress,incentiveAddress:J.incentiveAddress});return B},[m]),w=_m(x),C=_.useMemo(()=>{const B=new Set;for(const D of m)for(const J of D.incentives)B.add(J.rewardMetadata);return Array.from(B)},[m]),j=Fs(C,{failSoft:!0}),b=_.useMemo(()=>km(o,a,r,i),[o,a,r,i]),v=Fs(b),I=_.useMemo(()=>Im(v),[v]),{data:S}=Nm(I),A=xm(I),$=_.useMemo(()=>{const B=new Map;for(const D of t)B.set(D.denom,D);return B},[t]),k=_.useMemo(()=>{const B=new Map;for(const D of u??[])B.set(D.id,D.price);return B},[u]),{rows:T,totalValue:R}=_.useMemo(()=>{const B=u?.find(z=>z.id===Je)?.price??0,D=new Map;for(const z of I)D.set(z,Am(z,A,$));$o(o,v,S,D,"deposit"),$o(a,v,S,D,"staking"),Sm(r,v,S,D,"lockStaking"),$o(i,v,S,D,"unstaking"),Tm(D,c,l,B);for(const z of h){const O=d.get(z)??[];if(O.length===0)continue;const X=f.get(z),G=g.get(z),te=dm(z),ue=X?.coins.map(le=>le.denom)??[],ye=X?vc(X,$).filter(Boolean):[],me=ue.map(le=>$.get(le)?.symbol||le),Ce=X?.symbol||me.join("-")||te,Se=vm(ue,$),Ne=O.map(le=>{let Y,Mt,en,Lt=!1,bt=0,tn=0;try{const dt=lm({tickLower:le.tickLower,tickUpper:le.tickUpper});Y=dt.min,Mt=dt.max}catch{Y=void 0,Mt=void 0}if(G){try{const dt=om(BigInt(G.sqrtPrice)),Oe=Yt(le.tickLower),nt=Yt(le.tickUpper),ee=Number(G.tickSpacing);Lt=Number.isFinite(ee)&&ee>0?Zd(le.tickLower,le.tickUpper,ee):!1,en=Lt||dt>=Oe&&dt<nt}catch{en=void 0,Lt=!1}if(X&&ue.length>0)try{rm({sqrtPrice:G.sqrtPrice,tickLower:le.tickLower,tickUpper:le.tickUpper,liquidity:le.liquidity}).forEach((Oe,nt)=>{const ee=X.coins[nt];if(!ee)return;const ve=$.get(ee.denom)?.decimals??6,Ve=k.get(ee.denom)??0,mt=Number(N.fromBaseUnit(String(Oe),{decimals:ve}));bt+=mt*Ve})}catch{bt=0}}return X&&((y.get(le.tokenAddress)??[]).forEach((Oe,nt)=>{const ee=X.coins[nt];if(!ee)return;const ve=$.get(ee.denom)?.decimals??6,Ve=k.get(ee.denom)??0,mt=Number(N.fromBaseUnit(Oe,{decimals:ve}));tn+=mt*Ve}),le.incentives.forEach(Oe=>{const nt=w.get(wc(le.tokenAddress,Oe.incentiveAddress))??"0",ee=j.get(Oe.rewardMetadata);if(!ee)return;const ve=$.get(ee)?.decimals??6,Ve=k.get(ee)??0,mt=Number(N.fromBaseUnit(nt,{decimals:ve}));tn+=mt*Ve})),{tokenAddress:le.tokenAddress,positionId:Em(le.tokenAddress),inRange:en,isFullRange:Lt,minPrice:Y,maxPrice:Mt,pricePairLabel:Se,rewardValue:tn,value:bt}}),$t=Ne.reduce((le,Y)=>le+Y.value,0),ut=Ne.reduce((le,Y)=>le+Y.rewardValue,0),Pe=ye.length>0;D.set(te,{denom:te,symbol:Ce,totalAmount:0,totalValue:$t,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:Pe?ye:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:z,totalRewardValue:ut,positions:Ne}})}const J=Array.from(D.values()).filter(z=>z.totalAmount>0||z.isClamm).sort((z,O)=>O.totalValue-z.totalValue),K=J.reduce((z,O)=>z+O.totalValue,0);return{rows:J,totalValue:K}},[u,I,A,$,o,a,r,i,v,S,c,l,h,d,f,g,y,w,j,k]);return{totalValue:R,rows:T}}const $m=qe.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function Mm(e){return e.filter(t=>t.data.length>0).map(t=>{const s=t.data[0].bridge_id,o=t.data[0].version,a=t.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:t.total_claimable_reward,claimedReward:a,initialReward:t.total_vesting_reward,lockedReward:t.total_locked_reward,requiredScore:t.required_score,rollup:{bridgeId:s,version:o}}}).filter(t=>t.initialReward>0).sort((t,s)=>s.initialReward-t.initialReward)}function Ic(){const{vipUrl:e}=ae(),t=ie();return E.useQuery({queryKey:$m.allVestingPositions(e,t).queryKey,queryFn:async()=>(await H.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:V.MINUTE,enabled:!!t})}function Lm(){const e=_e();return _.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function lo(){const{data:e}=Ic(),t=ce(),{data:s}=Dt(t),o=Lm(),a=_.useMemo(()=>s?.find(l=>l.id===Je)?.price??0,[s]),r=_.useMemo(()=>e?Mm(e).map(l=>{const u=o(l.rollup.bridgeId),m=Number(N.fromBaseUnit(String(l.lockedReward),{decimals:it})),d=Number(N.fromBaseUnit(String(l.claimableReward),{decimals:it})),h=q(N.fromBaseUnit(String(l.lockedReward),{decimals:it})).times(a).toNumber(),f=q(N.fromBaseUnit(String(l.claimableReward),{decimals:it})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:u?.name??"",logoUrl:u?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:d,claimableRewardValue:f}}).filter(l=>l.lockedReward+l.claimableReward>0):[],[e,a,o]),i=_.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Ac(){const{totalValue:e}=co(),{data:t}=La(),{data:s}=Pa(),{data:o}=qa(),{data:a}=Ic(),r=_.useMemo(()=>Array.from(s.keys()),[s]),i=Fs(r),c=ce(),{data:l}=Dt(c),u=_.useMemo(()=>l?.find(d=>d.id===Je)?.price??0,[l]);return _.useMemo(()=>{let m=0,d=0;const h=u??0;for(const[,g]of t)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(N.fromBaseUnit(y,{decimals:it}))*h);for(const[g,p]of s)if(i.get(g)===Je)for(const{amount:y}of p)d+=Number(N.fromBaseUnit(y,{decimals:it}))*h;for(const[,g]of o)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(N.fromBaseUnit(y,{decimals:it}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,y=g.total_claimable_reward??0;f+=Number(N.fromBaseUnit(String(p+y),{decimals:it}))*h}return m+d+e+f},[t,s,i,o,a,u,e])}function qm(){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"],t={"initia-wallet-widget:ethereum-public-keys":{prefix:he.PUBLIC_KEY,getSuffix:s=>N.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(t)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const u=`${o}:${a(c)}`;localStorage.setItem(u,l)}localStorage.removeItem(s)}catch{}}}const Jo=qe.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,s)=>[e,t,s],initiaPositions:(e,t)=>[e,"initia",t],echelonPositions:(e,t)=>[e,"echelon",t],inertiaPositions:(e,t)=>[e,"inertia",t],ravePositions:(e,t,s)=>[e,"rave",t,s],yominetPositions:(e,t)=>[e,"yominet",t],chainPositions:(e,t,s)=>[e,t,s]});function Da(e,t){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=t[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const u=`${i.chainId}:${l.denom}`;s.has(u)||s.set(u,l.logoUrl);const m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Sc(e){return e.pnl??null}function Fa(e){return e.balance.type==="unknown"?null:e.balance.value??null}function Pm(e){return Fa(e)==null}function br(e){if(e==null||!Number.isFinite(e))return"—";const t=q(e).decimalPlaces(2,q.ROUND_HALF_UP);return t.isZero()?"$0.00":`${t.gt(0)?"+":"-"}$${N.formatNumber(t.abs().toNumber(),{dp:2})}`}function Rm(e,t){if(e==null||t==null||!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return"";const s=q(e).div(t).times(100).decimalPlaces(2,q.ROUND_HALF_UP);return s.isZero()?"(0.00%)":`(${s.gt(0)?"+":"-"}${s.abs().toFixed(2)}%)`}function Dm(e){return!Number.isFinite(e)||e<1?"":q(e).decimalPlaces(0,q.ROUND_DOWN).toString()}function _t(e){if(e.type==="fungible-position")return e.value??0;if(e.type==="perp-position"){const s=Fa(e);if(s==null)return 0;const o=Sc(e);return q(s).plus(o??0).toNumber()}if(e.balance.type==="unknown")return 0;const t=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-t:t}function Fm(e){switch(e.type){case"fungible-position":return null;case"perp-position":return"perp";case"staking":case"unstaking":case"lockstaking":return"staking";case"lending":return e.direction==="supply"?"lending":"borrowing";default:return e}}function Bm(e,t={}){const{isInitia:s=!1,chainName:o}=t,a=o?.toLowerCase()===Di;switch(e){case"staking":return a?"Vault":s?"INIT staking":"Staking";case"perp":return"Perpetuals";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Um(e){const t=new Map;for(const u of e){const m=Fm(u);if(!m)continue;const d=t.get(m)??[];d.push(u),t.set(m,d)}const s=new Map,o=new Map;for(const[u,m]of t){const d=m.reduce((f,g)=>f+_t(g),0),h=m.reduce((f,g)=>f+Math.abs(_t(g)),0);s.set(u,d),o.set(u,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((u,m)=>{const d=u==="lending"||u==="borrowing"?i:o.get(u)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(u==="lending"||u==="borrowing")&&(m==="lending"||m==="borrowing")?u==="lending"?-1:1:h-d}),l=new Map;for(const u of c)l.set(u,{positions:t.get(u),totalValue:s.get(u)??0});return l}function Om(e){return e.type==="fungible-position"?e.title:e.type==="perp-position"?e.pair:e.balance.denom}function Vm(e){return e.type==="fungible-position"?e.title:e.type==="perp-position"?e.pair:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Km(e){return e.type==="fungible-position"||e.type==="perp-position"?null:e.balance}function Wm(e){switch(e){case"staking":return"Staking";case"unstaking":return"Unstaking";case"lockstaking":return"Lock staking";case"lending":return"Lending";case"fungible-position":return"Position";case"perp-position":return"Perpetuals";default:return""}}function zm(e){const t=new Map;for(const s of e){const o=t.get(s.type)??[];o.push(s),t.set(s.type,o)}return t}function Hm(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Qm(e){const t=new Map;for(const o of e){const a=Om(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=Km(a[0]);let i=0;for(const c of a)c.type==="fungible-position"||c.type==="perp-position"||c.balance.type!=="unknown"&&(i+=c.balance.formattedAmount);return{denom:o,symbol:Vm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+_t(l),0),totalAmount:i,balance:r}}).sort(Hm)}function Tc(e,t){const s=new Map;return e.forEach((o,a)=>{const r=t[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 Gm(e,t){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=t.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function Ym(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Zm(e,t,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,u=t.get(l)??s.get(c)??"";return u!==i.logoUrl?{...i,logoUrl:u}: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 Jm(e,t,s){const o=t?e.filter(i=>{const{symbol:c,assets:l}=i,u=t.toLowerCase();return c.toLowerCase().includes(u)||l.some(({denom:m})=>m.toLowerCase().includes(u))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,u)=>l+(u.value??0),0),totalAmount:c.reduce((l,u)=>l+Number(u.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,u)=>l+(u.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Xm(e,t,s){const o=t?e.filter(({denom:a,address:r})=>{const i=t.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function eh(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=Jm(e,s,o),i=Xm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function th(e,t,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:u,balances:m}=c;if(!Array.isArray(m))continue;const d=t.get(l.toLowerCase()),h=d?.chainId??u??l,f=d?.prettyName??l,g=d?.logoUrl??"",p=s.get(h);for(const y of m){if(y.type==="unknown"){if(!y.amount||y.amount==="0")continue;r.push({symbol:y.denom,logoUrl:"",denom:y.denom,amount:y.amount,decimals:0,quantity:y.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(y.type==="lp"||(y.value??0)<=0&&(y.formattedAmount??0)<=0)continue;let x=y.value;if((x==null||x<=0)&&p){const j=p.get(y.denom)??0;j>0&&(x=y.formattedAmount*j)}const w={symbol:y.symbol,logoUrl:"",denom:y.denom,amount:y.amount,decimals:y.decimals,quantity:String(y.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:g}},C=a.get(y.symbol);C?C.push(w):a.set(y.symbol,[w])}}r.sort((c,l)=>{const u=c.chain.chainId===o,m=l.chain.chainId===o;if(u&&!m)return-1;if(!u&&m)return 1;const d=c.chain.name.localeCompare(l.chain.name);if(d!==0)return d;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)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((d,h)=>(h.value??0)-(d.value??0));let u=0,m=0;for(const d of l)u+=d.value??0,m+=Number(d.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:u,totalAmount:m})}return i.sort(Ym),{listedGroups:i,unlistedAssets:r}}function Ba(){return ce().network_type==="testnet"}function Jt(){return $e.useFormContext()}function nh(){const e=et(),t=Ba(),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=L.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(he.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(he.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(he.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(he.BRIDGE_DST_DENOM),quantity:localStorage.getItem(he.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(he.BRIDGE_SLIPPAGE_PERCENT)});return{...t?o:a,...r,...e}}const sh={balances:[],positions:[],isLoading:!0,isComplete:!1},Ec=Q.atom(0),oh=1e3;let vr=0;function ah(){const e=Q.useSetAtom(Ec);_.useEffect(()=>{const t=Date.now();t-vr>=oh&&(vr=t,e(s=>s+1))},[e])}function rh(){const e=E.useQueryClient(),t=ie(),{minityUrl:s}=ae(),o=Ba(),a=Q.useAtomValue(Ec),r=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.balances)?l.balances:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.positions)?l.positions:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=_.useEffectEvent((l,u)=>{const m=Jo.ssePortfolio(t??"",s).queryKey,d=e.getQueryData(m)??sh,h=l.size>0||u.size>0;e.setQueryData(m,{...d,balances:Array.from(l.values()),positions:Array.from(u.values()),isLoading:h?!1:d.isLoading,isComplete:!1})});_.useEffect(()=>{if(!t||o)return;const l=Jo.ssePortfolio(t,s).queryKey,u=e.getQueryData(l),m=new Map,d=new Map;for(const y of u?.balances??[])m.set(y.chainName,y);for(const y of u?.positions??[])d.set(y.chainName,y);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;let g=null,p=!1;return e.setQueryData(l,{balances:u?.balances??[],positions:u?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=y=>{if(!p)try{const x=JSON.parse(y.data);x.type==="balances"?r(x,m):x.type==="positions"&&i(x,d),c(m,d)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[t,o,a])}const jr={balances:[],positions:[],isLoading:!0,isComplete:!1};function ms(){const e=ie(),{minityUrl:t}=ae(),s=Jo.ssePortfolio(e??"",t).queryKey,{data:o}=E.useQuery({queryKey:s,queryFn:()=>jr,enabled:!!e,staleTime:V.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??jr}function ih(){const e=_e();return _.useMemo(()=>{const t=new Map;for(const s of e){const o=s.chain_name.toLowerCase();t.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return t},[e])}function ch(){const{balances:e,positions:t}=ms(),s=_e(),o=_.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return _.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((g,p)=>g+_t(p),0),c=new Map,l=Array.isArray(e)?e:[],u=Array.isArray(t)?t:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+r(x),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of u){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+i(x),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),d=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return L.sortWith([L.descend(h),L.descend(L.prop("totalBalance"))],d)},[e,t,o])}function lh(){const{balances:e}=ms(),t=_e(),s=_a(),o=_.useMemo(()=>Tc(t,s),[t,s]);return _.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Gm(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const u of l)u.type!=="lp"&&(r+=a(u));return r},[e,o])}function uh(){const{positions:e}=ms();return _.useMemo(()=>{const t=r=>r.positions.reduce((i,c)=>i+_t(c),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,u)=>l+t(u),0))}return o},[e])}const Ie=qe.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:q(e.quantity||0).toString()},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function Ue(){const{routerApiUrl:e}=ae();return _.useMemo(()=>H.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.9.0"}}),[e])}function dh(){const e=Ue();E.usePrefetchQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:V.MINUTE}),E.usePrefetchQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}const mh=()=>(xu(),wu(),null),hh="_loader_1vxch_1",fh={loader:hh},At=({size:e=24,color:t="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${s}px`};return n.jsx("div",{className:fh.loader,style:o,role:"status","aria-label":"Loading"})},ph="_button_1q027_1",gh="_outline_1q027_28",_h="_sm_1q027_46",yh="_full_1q027_53",xh="_small_1q027_57",wh="_unpadded_1q027_88",dn={button:ph,outline:gh,sm:_h,full:yh,small:xh,unpadded:wh},$c=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:P(dn.button,{[dn.sm]:t,[dn.full]:s},a),disabled:!!o||i,"aria-busy":!!o,children:o?n.jsxs(n.Fragment,{children:[n.jsx(At,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:dn.loading,children:o})]}):r})},bh=({className:e,...t})=>n.jsx($c,{...t,className:P(dn.outline,e)}),vh=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:P(dn.small,{[dn.unpadded]:t},e)}),fe={White:$c,Outline:bh,Small:vh},jh="_footer_1vp4h_1",Ch="_actions_1vp4h_10",Cr={footer:jh,actions:Ch},Ae=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:P(Cr.footer,t),children:[e,n.jsx("div",{className:Cr.actions,children:s})]}),Nh="_scrollable_13su7_1",kh={scrollable:Nh},xt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:P(kh.scrollable,e),children:t}),Ih="interwovenkit:";function Ah(e){const[t]=e;return typeof t=="string"&&t.startsWith(Ih)}function Sh(e){e.removeQueries({predicate:t=>Ah(t.queryKey)})}function uo(){return Qe.useMediaQuery("(max-width: 576px)")}const Xo="interwoven-kit";function Mc(){const e=document.querySelector(Xo)||document.body.appendChild(document.createElement(Xo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Lc(){const{theme:e,container:t}=ae();return _.useEffect(()=>{document.querySelector(Xo)?.setAttribute("data-theme",e)},[e]),t??Mc()}function Th(e){const t=Mc(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const mo=_.createContext(null);function yn(){const{container:e}=_.useContext(mo);return e}function qc(e){const t=yn();return t?getComputedStyle(t).getPropertyValue(e):""}function Eh(){return Qe.useScrollLock(),null}function $h(e){return/^[A-F0-9]{64}$/i.test(e)}function Mh(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return $h(s)?L.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!N.InitiaAddress.validate(o))return;const i=L.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Lh(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const qh="_link_j1lkz_1",Nr={link:qh},ho=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...u}=a,m=yt(e),d=Mh(m,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?N.truncate(t):s?N.truncate(s):"",f=c??h;return d?n.jsxs("a",{...u,href:zl(Lh(d)),className:P(Nr.link,i),onClick:l,target:"_blank",rel:"noopener noreferrer",children:[f,r&&n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]}):n.jsx("span",{...u,className:P(Nr.link,i),children:f})},Pc=_.createContext(null),hs=()=>_.useContext(Pc),Ph=()=>{const[e,t]=Q.useAtom(lc),{showNotification:s,updateNotification:o,hideNotification:a}=hs();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,u=l?l.message:c?n.jsx(ho,{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:u}),t(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:u,autoHide:!0}),t(null);break}},[e,t,s,o,a]),null},Ws=({value:e,children:t})=>{const[s,o]=_.useState(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Rh="_placeholder_10r3x_1",Dh="_logo_10r3x_5",kr={placeholder:Rh,logo:Dh},oe=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=_.useState(void 0),{width:u,height:m}=i,d=s??n.jsx("div",{className:P(kr.placeholder,o?.placeholder),style:{width:u,height:m,...a},"aria-hidden":"true"});return!e||c===e?d:n.jsx("img",{...i,className:P(i.className,{[kr.logo]:r}),style:{width:u,height:m,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function Rc(){const{connector:e}=He.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Fh="_header_1q8ju_1",Bh="_account_1q8ju_17",Uh="_name_1q8ju_28",Oh="_address_1q8ju_32",Vh="_icon_1q8ju_36",Kh="_copied_1q8ju_43",Wh="_button_1q8ju_58",zh="_settings_1q8ju_69",Hh="_disconnect_1q8ju_73",Qh="_label_1q8ju_83",Gh="_expanded_1q8ju_91",st={header:Fh,account:Bh,name:Uh,address:Oh,icon:Vh,copied:Kh,button:Wh,settings:zh,disconnect:Hh,label:Qh,expanded:Gh},Yh=()=>{const e=Ki(),{address:t,username:s}=tt(),o=Rc(),a=s??t,[r,i]=_.useState(!1),c=_.useRef(null),l=It.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},d=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return _.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:st.header,children:[n.jsx(Ws,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:P(st.account,{[st.copied]:f}),onClick:h,"aria-label":f?"Copied":"Copy address",children:[n.jsx(oe,{src:o,width:18,height:18}),n.jsx("div",{className:st.address,children:N.truncate(t)}),n.jsx("div",{className:st.name,children:N.truncate(a)}),n.jsx(M.IconCopy,{className:st.icon,size:12,"aria-hidden":"true"}),f?"Copied!":""]})}),n.jsx(hn,{to:"/settings",className:P(st.button,st.settings),"aria-label":"Open settings",children:n.jsx(M.IconSettingFilled,{size:16,"aria-hidden":"true"})}),n.jsxs(It.animated.button,{className:P(st.button,st.disconnect,{[st.expanded]:r}),style:l,onClick:u,onMouseLeave:m,onMouseEnter:d,"aria-label":"Disconnect wallet",children:[n.jsx(M.IconSignOut,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:st.label,children:"Disconnect"})]})]}):null},Zh="_overlay_jij9g_1",Jh="_content_jij9g_28",Xh="_inner_jij9g_60",Mo={overlay:Zh,content:Jh,inner:Xh},ef=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=Ft(),{setContainer:o}=_.useContext(mo),a=_.useCallback(p=>{p&&o(p)},[o]),r=uo(),i=Lc(),c=Q.useAtomValue(ro),l=Q.useAtomValue(rs),u=E.useIsMutating({mutationKey:[cc]}),m=()=>{const p=u?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),c?.reject(new Error(p)),l?.reject(new Error("User rejected"))},d=to(),h=Me(),f=E.useQueryClient(),g={fallbackRender:({error:p,resetErrorBoundary:y})=>{const x=()=>{d==="/bridge"&&(localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM)),h("/"),Sh(f),y()};return n.jsxs(xt,{children:[n.jsx(je,{error:!0,children:p.message}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:x,children:"Retry"})})]})}};return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:p=>!p&&m(),modal:!1,children:n.jsxs(Be.Dialog.Portal,{container:i,children:[r&&n.jsx(Be.Dialog.Backdrop,{className:Mo.overlay,onClick:m,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[n.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"}),n.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"})]})}),n.jsx(Be.Dialog.Popup,{className:Mo.content,children:n.jsxs("div",{className:P(Mo.inner,"body"),ref:a,children:[r&&n.jsx(Eh,{}),n.jsx(Ph,{}),n.jsx(Yh,{}),n.jsx(xe,{errorBoundaryProps:g,children:e})]})})]})})},tf="_backdrop_1bqx9_1",nf="_modal_1bqx9_12",sf="_closeButton_1bqx9_44",Lo={backdrop:tf,modal:nf,closeButton:sf},of=({children:e})=>{const{isModalOpen:t,closeModal:s}=Dn(),{setContainer:o}=_.useContext(mo),a=_.useCallback(i=>{i&&o(i)},[o]),r=Lc();return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:i=>!i&&s(),children:n.jsxs(Be.Dialog.Portal,{container:r,children:[n.jsx(Be.Dialog.Backdrop,{className:Lo.backdrop,onClick:s}),n.jsxs(Be.Dialog.Popup,{className:Lo.modal,ref:a,children:[n.jsx("button",{className:Lo.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20})}),n.jsx(xe,{children:e})]})]})})},Dc=_.createContext(!1),af="_overlay_1iyfl_1",rf="_fullscreen_1iyfl_15",cf="_content_1iyfl_19",lf="_header_1iyfl_56",uf="_title_1iyfl_65",df="_close_1iyfl_70",nn={overlay:af,fullscreen:rf,content:cf,header:lf,title:uf,close:df},Fc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=yn(),c=_.useContext(Dc);return i?n.jsxs(Be.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Be.Dialog.Trigger,{className:o,children:s}),n.jsxs(Be.Dialog.Portal,{container:i,children:[n.jsx(Be.Dialog.Backdrop,{className:P(nn.overlay,{[nn.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Be.Dialog.Popup,{className:P(nn.content,{[nn.fullscreen]:c}),children:[e&&n.jsxs("header",{className:nn.header,children:[n.jsx(Be.Dialog.Title,{className:nn.title,children:e}),n.jsx(Be.Dialog.Close,{className:nn.close,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20,"aria-hidden":"true"})})]}),t]})]})]}):null},ts=({children:e})=>{const t=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=It.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const c=t.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const u=new ResizeObserver(l);return u.observe(c),()=>u.disconnect()},[e]),e?n.jsx(It.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},mf="_help_qcmtq_1",hf="_icon_qcmtq_10",ff="_info_qcmtq_19",pf="_warning_qcmtq_23",gf="_error_qcmtq_27",_f="_success_qcmtq_33",qo={help:mf,icon:hf,info:ff,warning:pf,error:gf,success:_f},An=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(At,{size:12});case"info":return n.jsx(M.IconInfoFilled,{size:12});case"warning":case"error":return n.jsx(M.IconWarningFilled,{size:12});default:return n.jsx(M.IconCheckCircleFilled,{size:12})}};return n.jsxs("div",{className:P(qo.help,e&&qo[e],t),style:{marginTop:s},role:e==="error"?"alert":"status",children:[n.jsx("div",{className:qo.icon,"aria-hidden":"true",children:a()}),o]})},yf="_stack_a6m7u_1",xf="_help_a6m7u_6",wf="_info_a6m7u_14",bf="_warning_a6m7u_19",vf="_error_a6m7u_24",jf="_success_a6m7u_29",ea={stack:yf,help:xf,info:wf,warning:bf,error:vf,success:jf},Cf=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(ts,{children:n.jsx("div",{className:ea.stack,children:e})}),be=({mt:e=0,...t})=>n.jsx(An,{...t,className:P(ea.help,ea[t.level]),mt:e});be.Stack=Cf;const Nf="_root_16p5j_1",kf="_item_16p5j_10",If="_chevron_16p5j_14",Af="_trigger_16p5j_19",Sf="_content_16p5j_39",On={root:Nf,item:kf,chevron:If,trigger:Af,content:Sf};function Tf(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(ne.Accordion.Root,{className:On.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(ne.Accordion.Item,{className:On.item,value:s?.(c)??String(l),children:[n.jsx(ne.Accordion.Header,{children:n.jsxs(ne.Accordion.Trigger,{className:On.trigger,children:[o(c),n.jsx(M.IconChevronDown,{className:On.chevron,size:16,"aria-hidden":"true"})]})}),n.jsx(ne.Accordion.Content,{className:On.content,children:a(c)})]},s?.(c)??l)),r]})}const Ef="_trigger_u613p_1",$f="_icon_u613p_18",Mf="_content_u613p_27",Lf="_item_u613p_36",qf="_itemText_u613p_52",Pf="_itemIndicator_u613p_57",Rf="_active_u613p_60",Vt={trigger:Ef,icon:$f,content:Mf,item:Lf,itemText:qf,itemIndicator:Pf,active:Rf};function Ua({options:e,value:t,onChange:s,classNames:o}){const a=yn(),r=e.find(c=>c.value===t);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(u=>String(u.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return n.jsxs(qt.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(qt.Select.Trigger,{className:P(Vt.trigger,o?.trigger),children:[n.jsx(qt.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(qt.Select.Icon,{className:Vt.icon,children:n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})})]}),n.jsx(qt.Select.Portal,{container:a,children:n.jsx(qt.Select.Positioner,{className:Vt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(qt.Select.Popup,{className:Vt.popup,children:e.map(c=>n.jsxs(qt.Select.Item,{className:P(Vt.item,o?.item),value:String(c.value),children:[n.jsx(qt.Select.ItemText,{className:P(Vt.itemText,o?.itemText),children:c.label}),n.jsx(M.IconCheck,{size:12,className:P(Vt.itemIndicator,{[Vt.active]:c.value===t}),"aria-hidden":"true"})]},String(c.value)))})})})]})}const Df="_root_1t37n_1",Ff="_trigger_1t37n_7",Bf="_item_1t37n_11",Uf="_itemText_1t37n_17",Ir={root:Df,trigger:Ff,item:Bf,itemText:Uf},Of=({options:e,value:t,onChange:s})=>{const{txRequest:o}=dc(),a=yt(o.chainId),r=Tt(a),i=(g,p)=>{if(N.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(q(g).isZero())return"0";const{symbol:y,decimals:x}=r(p),w=i(g,x);return`${N.formatAmount(g,{decimals:x,dp:w})} ${y}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:y}=r(p);return{value:p,label:c(g),triggerLabel:y}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const u=e.find(g=>g.amount[0].denom===t);if(!u)throw new Error("Fee option not found");const[{amount:m,denom:d}]=u.amount,{decimals:h}=r(d),f=i(m,h);return n.jsxs("div",{className:Ir.root,children:[n.jsx("span",{className:"monospace",children:N.formatAmount(m,{decimals:h,dp:f})}),n.jsx(Ua,{options:l,value:t,onChange:s,classNames:Ir})]})},Vf="_root_16nr2_1",Kf="_trigger_16nr2_5",Wf="_chevron_16nr2_13",zf="_panel_16nr2_27",Hf="_details_16nr2_39",Qf="_row_16nr2_48",Nn={root:Vf,trigger:Kf,chevron:Wf,panel:zf,details:Hf,row:Qf},Gf=({spend:e,fee:t,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:t},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return n.jsxs(Io.Collapsible.Root,{className:Nn.root,children:[n.jsxs(Io.Collapsible.Trigger,{className:Nn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(M.IconChevronDown,{className:Nn.chevron,size:16})]}),n.jsx(Io.Collapsible.Panel,{className:Nn.panel,children:n.jsx("div",{className:Nn.details,children:i.map(({label:l,value:u})=>n.jsxs("div",{className:Nn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[N.formatAmount(u,{decimals:r,dp:c})," ",a]})]},l))})})]})};function zs(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?de.toBase64(e):Array.isArray(e)?`[${e.map(zs).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Yf="_container_1xzyq_1",Zf="_toggle_1xzyq_5",Jf="_list_1xzyq_11",Xf="_arg_1xzyq_16",ep="_type_1xzyq_21",Vn={container:Yf,toggle:Zf,list:Jf,arg:Xf,type:ep},tp=qe.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),np=({type:e,arg:t})=>zs(N.resolveBcsType(e).parse(t)),sp=({msg:e,chainId:t,fallback:s})=>{const[o,a]=Qe.useToggle(!1),{restUrl:r}=yt(t),{moduleAddress:i,moduleName:c,functionName:l,args:u}=e,{data:m}=E.useQuery({queryKey:tp.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await H.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:V.INFINITY});if(!m)return s;const d=(h,f)=>{const g=m[f];return n.jsxs("div",{className:Vn.arg,children:[n.jsx("div",{className:Vn.type,children:g}),n.jsx(fi.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(np,{type:g,arg:h})})]},f)};return n.jsxs("div",{className:Vn.container,children:[n.jsx(fe.Small,{className:Vn.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Vn.list,children:u.map(d)}):s]})},op="_list_oip9m_1",ap="_key_oip9m_9",rp="_value_oip9m_14",Po={list:op,key:ap,value:rp},ip=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:Po.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:Po.key,children:a}),n.jsx("div",{className:Po.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(sp,{msg:o,chainId:t,fallback:zs(r)}):zs(r)})]},a))})},cp="_item_1n572_1",lp="_title_1n572_10",up="_content_1n572_14",Ro={item:cp,title:lp,content:up},Do=({title:e,content:t})=>n.jsxs("div",{className:Ro.item,children:[n.jsx("div",{className:Ro.title,children:e}),n.jsx("div",{className:Ro.content,children:t})]});function se(e){const t=e?q(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return"< $0.01";const s=e&&q(e).lt(0),o=N.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Oa(e,t){return t==null?"$-":se(e??0)}function Bc(e,t){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===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u-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===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function Uc(e,t){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,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&N.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(u)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&N.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(u)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Oc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=E.useSuspenseQuery({queryKey:Mn.denom(o,e).queryKey,queryFn:()=>H.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:V.INFINITY});return s(a)},dp="_root_1p8a4_1",mp="_title_1p8a4_8",hp="_changes_1p8a4_14",fp="_change_1p8a4_14",pp="_amount_1p8a4_35",gp="_text_1p8a4_42",_p="_value_1p8a4_49",mn={root:dp,title:mp,changes:hp,change:fp,amount:pp,text:gp,value:_p},Vc=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=N.formatAmount(e,{decimals:r}),l=s&&q(N.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:mn.change,children:[n.jsxs("div",{className:mn.amount,children:[n.jsx(oe,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:mn.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:mn.value,children:se(l)})]})},yp=({changes:e,chain:t})=>{const s=Tt(t),{data:o}=Dt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:u})=>u===r)?.price;return n.jsx(Vc,{amount:a,asset:c,price:l},i)})},xp=({changes:e,chain:t})=>{const s=Tt(t),{data:o}=Dt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(Oc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:u})=>u===c)?.price;return n.jsx(Vc,{amount:a,asset:s(c),price:l})}},i))};function wp(e,t){return typeof t=="bigint"?t.toString():t}const bp=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,wp)]}),vp=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=tt(),r=yt(s),{simulateTx:i}=io(),{data:c}=E.useSuspenseQuery({queryKey:bp.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:V.SECOND}),l=h=>n.jsxs("div",{className:mn.root,children:[n.jsx("h2",{className:mn.title,children:"Estimated changes"}),n.jsx("div",{className:mn.changes,children:h})]});if(!c)return null;const u=c.result?.events??[];if(u.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=Uc(u,a),[f]=Ar(h);return f.length===0?null:l(n.jsx(xp,{changes:f,chain:r}))}const m=Bc(u,o),[d]=Ar(m);return d.length===0?null:l(n.jsx(yp,{changes:d,chain:r}))};function Ar(e){return L.partition(t=>new q(t.amount).isNegative(),e)}const jp="_title_1d032_1",Cp="_meta_1d032_7",Np="_footer_1d032_14",kp="_rejectButton_1d032_19",ks={title:jp,meta:Cp,footer:Np,rejectButton:kp},Kc=()=>{const{txRequest:e,resolve:t,reject:s}=dc(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,u=yt(r),m=as(u),d=Ia(u),h=Aa(u),f=Tt(u),g=uc(),p=(e.gasPrices??d).map(({amount:A,denom:$})=>Le.calculateFee(Math.ceil(i*c),Le.GasPrice.fromString(A+$))),y=p.map(A=>A.amount[0]),x=A=>{const $=m.find(K=>K.denom===A)?.amount??"0",k=y.find(K=>K.denom===A)?.amount??"0",T=l.filter(K=>K.denom===A).reduce((K,z)=>q(K).plus(z.amount),q("0")),R=q(k).plus(T),B=q($).gte(R),{symbol:D,decimals:J}=f(A);return{symbol:D,decimals:J,spend:T.gt(0)?T.toFixed():null,fee:k,total:R.toFixed(),balance:$,isSufficient:B}},w=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of y)if(x(A).isSufficient)return A;return y[0]?.denom},[C,j]=_.useState(w),{mutate:b,isPending:v}=E.useMutation({mutationKey:[cc],mutationFn:async()=>{const A=p.find(k=>k.amount[0].denom===C);if(!A)throw new Error("Fee not found");const $=await g({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:C,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t($)},onError:async A=>{s(A)}}),I=x(C),S=!I.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(xt,{children:[n.jsx("h1",{className:ks.title,children:"Confirm tx"}),n.jsxs("section",{className:ks.meta,"aria-label":"Transaction metadata",children:[n.jsx(Do,{title:"Chain",content:r}),n.jsx(Do,{title:"Tx fee",content:n.jsx(Of,{options:p,value:C,onChange:j})}),a&&n.jsx(Do,{title:"Memo",content:a}),S&&n.jsx(be,{level:"error",children:n.jsx(Gf,{...I})})]}),n.jsx(vp,{messages:o,memo:a,chainId:r}),n.jsx(Tf,{list:o,renderHeader:({typeUrl:A})=>Ys.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(ip,{message:A,chainId:r})})]}),n.jsxs(Ae,{className:ks.footer,children:[n.jsx(fe.Outline,{onClick:()=>s(new Error("User rejected")),disabled:v,className:ks.rejectButton,"aria-label":"Reject",children:n.jsx(M.IconClose,{size:16})}),n.jsx(fe.White,{onClick:()=>b(),disabled:S,loading:v,children:"Approve"})]})]})},Ip=({children:e})=>{const[{title:t,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),c=Q.useAtomValue(ro),l=_.useCallback(d=>{a(d),i(!0)},[]),u=_.useCallback(()=>{a({}),i(!1)},[]),m=_.useCallback(d=>{d||(c?.reject(new Error("User rejected")),a({})),i(d)},[c]);return n.jsxs(ac.Provider,{value:{openModal:l,closeModal:u},children:[e,n.jsx(Fc,{title:t,open:r,onOpenChange:m,children:n.jsx(xe,{children:o==="/tx"?n.jsx(Kc,{}):s})})]})},Ap="_container_1w1hx_1",Sp="_toast_1w1hx_11",Tp="_info_1w1hx_24",Ep="_success_1w1hx_28",$p="_error_1w1hx_32",Mp="_icon_1w1hx_37",Lp="_content_1w1hx_45",qp="_title_1w1hx_48",Pp="_description_1w1hx_53",Rp="_close_1w1hx_75",Kt={container:Ap,toast:Sp,info:Tp,success:Ep,error:$p,icon:Mp,content:Lp,title:qp,description:Pp,close:Rp},Dp=({notification:e,onClose:t,...s})=>{const o=It.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 n.jsx(At,{size:16});case"info":case"success":return n.jsx(M.IconCheckCircleFilled,{size:16});case"error":return n.jsx(M.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:u}=i,m=a(c);return n.jsx(It.animated.div,{style:r,className:Kt.container,children:n.jsxs("div",{className:P(Kt.toast,c&&Kt[c]),role:"alert",...s,children:[m&&n.jsx("div",{className:Kt.icon,"aria-hidden":"true",children:m}),n.jsxs("div",{className:Kt.content,children:[n.jsx("p",{className:Kt.title,children:l}),u&&n.jsx("div",{className:Kt.description,children:u})]}),n.jsx("button",{className:Kt.close,onClick:t,"aria-label":"Dismiss notification",children:n.jsx(M.IconClose,{size:14,"aria-hidden":"true"})})]})})})},Fo=5e3,Fp=({children:e})=>{const t=yn(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=_.useCallback(()=>{i(),o(null)},[]),l=_.useCallback(h=>{i(),o({...h,id:cr.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Fo))},[c]),u=_.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:cr.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Fo))},[c]),m=()=>{i(),r.current=!0},d=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Fo))};return _.useEffect(()=>()=>i(),[]),n.jsxs(Pc.Provider,{value:{showNotification:l,updateNotification:u,hideNotification:c},children:[e,t&&Hl.createPortal(n.jsx(Dp,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:d}),t)]})},Bp=({children:e})=>{const[t,s]=_.useState(null);return n.jsx(mo.Provider,{value:{container:t,setContainer:s},children:e})};function Up(e){const t=e.split(".");return t.length!==4?!1:t.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function Wc(e){return Up(e)||e.includes(":")}function ta(e){const t=Ql.parse(e);return"error"in t?null:t.domain}function Op(e,t){return e===t||e===`www.${t}`}function Vp(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||Wc(t)?!1:ta(t)!==null}function Kp(e,t){try{const s=new URL(e);if(!Vp(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||Wc(a)||a==="localhost")return!1;const r=ta(o);if(!r)return!1;const i=ta(a);return!i||i!==r?!1:Op(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const Wp="_container_1422v_1",zp="_title_1422v_7",Hp="_description_1422v_14",Qp="_sectionTitle_1422v_20",Gp="_websiteInfo_1422v_27",Yp="_favicon_1422v_37",Zp="_websiteTitle_1422v_42",Jp="_websiteHost_1422v_48",Xp="_warningContent_1422v_54",eg="_ignoreButton_1422v_61",tg="_infoList_1422v_65",ng="_infoItem_1422v_75",sg="_label_1422v_84",og="_infoValue_1422v_94",ag="_durationTrigger_1422v_100",rg="_durationItem_1422v_101",ig="_featureList_1422v_105",cg="_featureItem_1422v_113",lg="_checkIcon_1422v_123",ug="_learnMoreLink_1422v_127",dg="_feedbackContainer_1422v_140",mg="_footer_1422v_146",pe={container:Wp,title:zp,description:Hp,sectionTitle:Qp,websiteInfo:Gp,favicon:Yp,websiteTitle:Zp,websiteHost:Jp,warningContent:Xp,ignoreButton:eg,infoList:tg,infoItem:ng,label:sg,infoValue:og,durationTrigger:ag,durationItem:rg,featureList:ig,featureItem:cg,checkIcon:lg,learnMoreLink:ug,feedbackContainer:dg,footer:mg};function hg(e){return e instanceof H.HTTPError&&e.response.status===404}const fg=qe.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=H.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(hg(a))return!1;throw a}}})}),pg=()=>{const[e,t]=Q.useAtom(rs),[s,o]=_.useState(()=>e?.defaultDuration??Zo),[a,r]=_.useState(!1),i=lt(),c=_e(),{address:l,initiaAddress:u,username:m}=tt(),{mutate:d,isPending:h}=Md(),{closeDrawer:f}=Ft();if(!e)throw new Error("Pending request not found");const{logoUrl:g,name:p,restUrl:y}=i(e.chainId),{data:x,isLoading:w,isError:C}=E.useQuery(fg.info(y,u)),j={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},b=c.find(R=>R.chainId===e.chainId),v=b?.website?Kp(b.website,window.location.hostname):!1,I=()=>{d(s)},S=()=>{e?.reject(new Error("User cancelled")),t(null),f()},A=!v&&!a,$=!w&&!C&&x===!1,k=!w&&C,T=A||w||C||x===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(xt,{className:pe.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:pe.title,children:"Enable auto-signing"}),n.jsx("p",{className:pe.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:pe.websiteInfo,children:[n.jsx("img",{src:j.favicon,alt:"",className:pe.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:pe.websiteTitle,children:j.title}),n.jsx("div",{className:pe.websiteHost,children:j.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:pe.infoList,children:[n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Address"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(M.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:N.truncate(m??l)})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Chain"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(oe,{src:g,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Duration"}),n.jsx(Ua,{options:Sa,value:s,onChange:o,classNames:{trigger:pe.durationTrigger,item:pe.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:pe.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(R=>n.jsxs("li",{className:pe.featureItem,children:[n.jsx(M.IconCheckCircle,{size:12,className:pe.checkIcon}),n.jsx("span",{children:R})]},R))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:pe.learnMoreLink,children:["Learn more ",n.jsx(M.IconExternalLink,{size:12})]})]})]}),n.jsxs(Ae,{className:pe.footer,extra:n.jsxs("div",{className:pe.feedbackContainer,children:[$&&n.jsx(be,{level:"error",children:"Insufficient balance for fee"}),k&&n.jsx(be,{level:"warning",children:"Unable to verify account status. Try again."}),!v&&!a&&n.jsx(be,{level:"warning",children:n.jsxs("div",{className:pe.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:pe.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(fe.Outline,{onClick:S,children:"Cancel"}),n.jsx(fe.White,{onClick:I,disabled:T,loading:h,children:"Enable"})]})]})},gg=()=>{const e=Q.useAtomValue(rs);return e?n.jsx(pg,{},`${e.chainId}:${e.defaultDuration}`):null},_g="_container_mqvhs_1",yg="_badge_mqvhs_5",Sr={container:_g,badge:yg},zc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:P(Sr.container,a),children:[o,!s&&n.jsx("div",{className:Sr.badge,style:{right:t,top:t},"aria-hidden":"true"})]})},xg="_header_s7mee_1",wg="_back_s7mee_12",bg="_title_s7mee_24",Bo={header:xg,back:wg,title:bg},Et=({title:e,backButton:t,extra:s,children:o})=>{const a=Si();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Bo.header,children:[n.jsx(hn,{to:t??(a.length>1?-1:"/"),className:Bo.back,shouldReset:!!t,"aria-label":"Go back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsx("h1",{className:Bo.title,children:e}),s]}),n.jsx(xt,{children:o})]})};function Va(){const e=_e();return t=>e.some(s=>s.chain_id===t)}function vg(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function fs(){const e=Va();return t=>e(t.chain_id)?"initia":t.chain_type}function xn(e){return fs()(e)}function fo(){const e=Ue(),{data:t}=E.useSuspenseQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>L.sortWith([L.descend(({chain_name:o})=>o==="initia"),L.ascend(({pretty_name:o})=>o)],s),staleTime:V.MINUTE});return t}function Bt(){const e=fo(),t=wi();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=t.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 Ge(e){return Bt()(e)}function jg(e,t){try{return de.fromBech32(e).prefix===t}catch{return!1}}function Hc(){const{initiaAddress:e,hexAddress:t}=tt(),s=Bt(),o=fs();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Ka(){const e=Bt(),t=fs();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return N.InitiaAddress.validate(s);case"evm":return kt.isAddress(s);case"cosmos":return a.bech32_prefix?jg(s,a.bech32_prefix):!1;default:return!1}}}function Cg(){const e=Bt(),t=fs();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=t(i),l=e(a),u=t(l);if(c==="evm"&&u==="initia")return N.InitiaAddress(s).bech32;if(c==="initia"&&u==="evm")return N.InitiaAddress(s).hex;if(c===u)return s;if(r){if(u==="initia")return N.InitiaAddress(r).bech32;if(u==="evm")return N.InitiaAddress(r).hex}return""}}function Ng(){const e=Ue();return E.useSuspenseQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}function ps(){const{data:{chain_to_assets_map:e}}=Ng(),t=fo(),s=E.useQueryClient();return _.useMemo(()=>{const o=[];for(const a in e){if(!t.some(i=>i.chain_id===a))continue;const{assets:r}=e[a]??{assets:[]};s.setQueryData(Ie.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(Ie.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Hs(e){const t=Ue(),s=E.useQueryClient(),{data:o}=E.useSuspenseQuery({queryKey:Ie.assets(e).queryKey,queryFn:()=>t.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(Ie.asset(e,i.denom).queryKey,i);return[...r].sort(L.descend(i=>i.symbol==="INIT"))},staleTime:V.MINUTE});return o}function Qc(e){const t=Hs(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function St(e,t){return Qc(t)(e)}const kg="_root_ekn9t_1",Ig="_header_ekn9t_6",Ag="_title_ekn9t_12",Sg="_warning_ekn9t_18",Tg="_content_ekn9t_22",Eg="_footer_ekn9t_26",$g="_secondary_ekn9t_36",sn={root:kg,header:Ig,title:Ag,warning:Sg,content:Tg,footer:Eg,secondary:$g},Gc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(xt,{className:sn.root,children:[n.jsxs("header",{className:P(sn.header,t&&sn[t]),children:[s,n.jsx("h1",{className:sn.title,children:o})]}),n.jsx("div",{className:sn.content,children:a}),n.jsxs("footer",{className:sn.footer,children:[n.jsx(fe.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:sn.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})]})]})},Mg="_list_k4n3k_1",Lg="_row_k4n3k_9",qg="_dt_k4n3k_20",Pg="_asset_k4n3k_26",Is={list:Mg,row:Lg,dt:qg,asset:Pg},Rg=({list:e,onNavigate:t,onDismiss:s})=>{const o=ce(),a=lt(),r=Tt(o);return n.jsx(Gc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:Is.list,children:[...e].sort((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:u})=>{const m=a(c),{decimals:d,symbol:h}=r(u),f=N.formatAmount(l,{decimals:d});return n.jsxs("div",{className:Is.row,children:[n.jsxs("div",{className:Is.dt,children:[n.jsx(oe,{src:m.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:m.name})]}),n.jsxs("span",{className:Is.asset,children:[f," ",h]})]},i)})})})};function Uo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const As=({chainId:e,txHash:t})=>`${he.OP_REMINDER}:${e}:${t}`,Dg=Gl.atomWithStorage(he.OP_REMINDER,[]);function Bn(){const e=ie(),[t=[],s]=Q.useAtom(Dg),o=_.useMemo(()=>t.map(l=>{const u=localStorage.getItem(As(l));return u?JSON.parse(u):null}).filter(l=>{if(!l)return!1;const{recipient:u,claimableAt:m}=l;return u!==e?!1:Xe.isPast(m)}),[e,t]),a=_.useCallback((l,u)=>{t.some(m=>Uo(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(As(l),JSON.stringify(u)))},[t,s]),r=_.useCallback(l=>{s((u=[])=>u.filter(m=>!Uo(m,l))),localStorage.removeItem(As(l))},[s]),i=_.useCallback(l=>{const u=l.filter(m=>!t.some(d=>Uo(d,m)));u.length!==0&&s((m=[])=>[...m,...u])},[t,s]),c=_.useCallback((l,u)=>{localStorage.setItem(As(l),JSON.stringify(u)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Yc(){const e=Me(),{openModal:t,closeModal:s}=ao(),{reminders:o,setReminder:a}=Bn();_.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(u=>u.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})};t({content:_.createElement(Rg,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const Fg="_wrapper_5ssm8_1",Bg="_balance_5ssm8_11",Ug="_button_5ssm8_15",Oo={wrapper:Fg,balance:Bg,button:Ug},Zc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:Oo.wrapper,children:[n.jsx(M.IconWallet,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:Oo.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:Oo.button,onClick:()=>e(),disabled:s,"aria-label":"Use maximum balance",children:"MAX"})]}),Og="_fieldset_up6fh_1",Vg="_upper_up6fh_9",Kg="_select_up6fh_14",Wg="_account_up6fh_20",zg="_lower_up6fh_25",Hg="_wrapper_up6fh_26",Qg="_balance_up6fh_33",Gg="_value_up6fh_37",Yg="_error_up6fh_50",Pt={fieldset:Og,upper:Vg,select:Kg,account:Wg,lower:zg,wrapper:Hg,balance:Qg,value:Gg,error:Yg},na=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:Pt.fieldset,children:[n.jsxs("div",{className:Pt.upper,children:[n.jsx("div",{className:Pt.select,children:t}),n.jsx("div",{className:Pt.account,children:s})]}),!c&&n.jsxs("div",{className:Pt.lower,children:[o,n.jsxs("div",{className:Pt.wrapper,children:[n.jsx("div",{className:Pt.balance,children:a}),r&&n.jsx("div",{className:Pt.value,children:r})]}),i&&n.jsxs("footer",{className:Pt.error,children:[n.jsx(M.IconWarningFilled,{size:12,"aria-hidden":"true"}),n.jsx("p",{role:"alert",children:i})]})]})]})},Jc=({quantity:e,balance:t,decimals:s})=>!e||t===void 0||s===void 0||q(e).isZero()?!1:q(N.toBaseUnit(e,{decimals:s})).gt(t);function gs(){const e=_.useRef(null),t=uo();return _.useEffect(()=>{t||e.current?.focus()},[t]),e}const Zg="_input_h8073_1",Jg={input:Zg};function Xc(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=gs();return n.jsx($e.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(Yl.NumericFormat,{value:l.value,getInputRef:pi.mergeRefs([l.ref,c]),className:P(Jg.input,a),onValueChange:u=>{l.onChange(u.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Xg="_input_19r9r_1",e_="_placeholder_19r9r_18",sa={input:Xg,placeholder:e_},t_=({children:e})=>n.jsx("p",{className:P(sa.input,{[sa.placeholder]:q(e).isZero()}),children:e}),ns=({balance:e,decimals:t,className:s})=>{const{control:o}=$e.useFormContext(),a={required:"Enter amount",validate:r=>q(r).isZero()?"Enter amount":Jc({quantity:r,balance:e,decimals:t})?"Insufficient balance":!0};return n.jsx(Xc,{name:"quantity",control:o,className:P(sa.input,s),rules:a})};ns.ReadOnly=t_;const qn=({title:e,content:t,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return n.jsx(Fc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},n_="_tooltip_19kvs_1",s_="_arrow_19kvs_44",Tr={tooltip:n_,arrow:s_},_s=({label:e,children:t,small:s,...o})=>n.jsxs(ne.Tooltip.Root,{...o,children:[n.jsx(ne.Tooltip.Trigger,{asChild:!0,children:t}),n.jsx(ne.Tooltip.Portal,{container:yn(),children:n.jsxs(ne.Tooltip.Content,{className:P(Tr.tooltip,{small:s}),collisionBoundary:yn(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(ne.Tooltip.Arrow,{className:Tr.arrow})]})})]});function po(e,t){const s=Ue(),o=Ka(),a=!!t&&!!e&&o(e,t);return E.useQuery({queryKey:Ie.balances(t,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>a?r?r[t]?.denoms??{}:{}:{},enabled:a,staleTime:V.SECOND})}function o_(e,t,s){const{data:o={}}=po(e,t);return L.path([s],o)}function a_({sourceDenom:e,sourceBalance:t,amountIn:s,feeTokenDenoms:o,balancesByDenom:a,additionalFees:r=[]}){if(!o.includes(e)||t===void 0||s===void 0||a===void 0)return!1;const c=r.reduce((m,d)=>{if(d.amount===void 0)return m;const h=d.origin_asset.denom,f=m.get(h)??q(0);return m.set(h,f.plus(d.amount)),m},new Map);if(o.some(m=>{if(m===e)return!1;const d=q(a[m]?.amount??"0"),h=c.get(m);return h?d.gte(h):d.gt(0)}))return!1;const u=c.get(e)??q(0);return u.isZero()?!1:q(t).lt(q(s).plus(u))}const r_=[["d",1440*60],["h",3600],["m",60],["s",1]];function ss(e){if(!e)return;const{formattedParts:t}=r_.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 t.join(" ")}function el(e,t){return q(e).times(q(100).minus(t)).div(100).integerValue(q.ROUND_FLOOR).toFixed(0)}function Wa(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${N.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function tl(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,u=t.getQueryData(Ie.asset(a,r).queryKey);if(!u||u.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const m=u.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:N.toBaseUnit(i,{decimals:m}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function oa(e,t){const{watch:s}=Jt(),o=s(),a=Ue(),r={srcChainId:o.srcChainId,srcDenom:o.srcDenom,dstChainId:o.dstChainId,dstDenom:o.dstDenom,quantity:e},i=!r.srcChainId||!r.srcDenom||!r.dstChainId||!r.dstDenom,c=q(r.quantity||0),l=c.isFinite()&&c.gt(0),u=t?.refreshMs??1e4,m=l&&!t?.disabled&&!i,d=E.useQueryClient();return E.useQuery({queryKey:Ie.route(r,t?.isOpWithdraw).queryKey,queryFn:async({signal:h})=>tl(a,d,r,{isOpWithdraw:t?.isOpWithdraw,signal:h}),enabled:m,staleTime:u,refetchInterval:m?u:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function i_(e){return E.useQuery({queryKey:Ie.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof H.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function c_(){const{watch:e}=Jt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=Ge(t),i=xn(r),c=St(s,t),l=St(a,o),u=ce(),m=_e();return i==="initia"&&o===u.chainId&&c.symbol===l.symbol&&m.find(d=>d.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const l_="_label_t93ix_1",u_="_wrapper_t93ix_7",d_="_input_t93ix_10",m_="_clear_t93ix_18",Ss={label:l_,wrapper:u_,input:d_,clear:m_},za=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=N.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=gs(),{control:l,getValues:u,setValue:m,formState:d}=$e.useFormContext(),h=u("recipient"),[f,g]=_.useState(h),p=Ni(),{data:y,isLoading:x,error:w}=E.useQuery({queryKey:Xs.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:V.MINUTE,enabled:p.validateUsername(f)}),C=y??(o(f)?f:""),j=t&&N.InitiaAddress.equals(C,t),b=async()=>{try{const S=await navigator.clipboard.readText();g(S.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!d.dirtyFields.recipient||m("recipient",y??f,{shouldValidate:!0,shouldDirty:!0}))},[d.dirtyFields.recipient,f,e,m,y]);const v=()=>{x||w||(m("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},I=()=>{if(x)return n.jsx(An,{level:"loading",children:"Resolving username..."});if(w)return n.jsx(An,{level:"error",children:w.message});if(y)return n.jsx(An,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&f&&!C)return n.jsx(An,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:Ss.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(fe.Small,{type:"button",tabIndex:-1,onClick:b,children:"Paste"})]}),n.jsxs("div",{className:Ss.wrapper,children:[n.jsx($e.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:S=>o(S)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:P(Ss.input,"monospace"),value:f,onChange:S=>g(S.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?pi.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:Ss.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:n.jsx(M.IconCloseCircleFilled,{size:16})})]}),I(),j&&n.jsx(An,{children:"This is my address"}),e==="onSubmit"&&n.jsx(Ae,{extra:(!t||!!C&&!j)&&n.jsx(be,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(fe.White,{type:"button",onClick:v,disabled:x||!!w||!C,children:"Apply"})})]})},h_="_scrollable_vgj3r_1",f_="_list_vgj3r_5",p_="_item_vgj3r_9",g_="_name_vgj3r_22",Ts={scrollable:h_,list:f_,item:p_,name:g_};function nl({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(xt,{className:Ts.scrollable,children:n.jsx("div",{className:Ts.list,children:t.map(l=>n.jsxs("button",{className:Ts.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),"aria-busy":!!i?.(l),children:[n.jsx(oe,{src:o(l),width:28,height:28}),n.jsx("span",{className:Ts.name,children:a(l)}),i?.(l)&&n.jsx(At,{size:16})]},r(l)))})})}function go(){const{cosmosWallets:e=[]}=ae(),t=_.useMemo(()=>{const a=[{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"}].filter(r=>!e.some(i=>i.name===r.name));return[...e,...a]},[e]);return{list:t,find:o=>t.find(a=>a.name===o)}}const __="_account_h04x1_8",y_="_clear_h04x1_28",x_="_white_h04x1_39",Kn={account:__,clear:y_,white:x_},Er=({type:e})=>{const{watch:t,setValue:s}=Jt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=xn(Ge(a)),{showNotification:u}=hs(),{list:m,find:d}=go(),h=d(r),f=Hc(),g=Ka(),p=f(a),y=N.InitiaAddress.equals(c,p),x=()=>n.jsx(qn,{title:"Connect wallet",content:j=>n.jsx(nl,{onSelect:async b=>{const v=b.getProvider();if(!v){b.fallbackUrl?window.open(b.fallbackUrl,"_blank"):u({type:"error",title:`${b.name} not available`,description:"Please install the wallet extension and try again."});return}try{const S=await v.getOfflineSigner(o).getAccounts();if(S.length===0)throw new Error("No accounts found");s("sender",S[0].address),s("cosmosWalletName",b.name),j()}catch(I){const S=I instanceof Error?I.message:"Unknown error";u({type:"error",title:`Failed to connect ${b.name}`,description:S})}},list:m,getImage:b=>b.image,getName:b=>b.name,getKey:b=>b.name}),className:P(Kn.account,{[Kn.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[h&&n.jsx(oe,{src:h.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:N.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})}),w=j=>n.jsx(qn,{title:"Recipient",content:b=>n.jsx(xt,{children:n.jsx(za,{mode:"onSubmit",myAddress:p,chainType:l,validate:v=>g(v,a),onApply:b})}),className:Kn.account,children:j}),C=()=>{switch(l){case"initia":case"evm":return y?w(n.jsx(M.IconWallet,{size:14})):n.jsxs("div",{className:Kn.account,children:[n.jsx("span",{className:"monospace",children:N.truncate(c)}),n.jsx("button",{type:"button",className:Kn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(M.IconCloseCircleFilled,{size:14})})]});case"cosmos":return w(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:N.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(M.IconEdit,{size:14,"aria-hidden":"true"})]}))}};switch(e){case"src":return x();case"dst":return C()}},w_="_images_cj4xz_1",Vo={images:w_},_o=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:P(Vo.images,r),style:{position:"relative"},"aria-hidden":"true",children:[n.jsx(oe,{src:e,width:t,height:t,className:Vo.asset,logo:!0}),n.jsx(oe,{src:s,width:o,height:o,className:Vo.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),b_="_root_6187w_1",v_="_content_6187w_10",j_="_details_6187w_20",C_="_symbol_6187w_26",N_="_chain_6187w_34",k_="_chevron_6187w_43",on={root:b_,content:v_,details:j_,symbol:C_,chain:N_,chevron:k_},sl=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:on.content,children:[n.jsx(_o,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:on.details,children:[n.jsx("div",{className:on.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:on.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:on.root,children:o}):n.jsxs("div",{className:on.root,children:[o,n.jsx(M.IconChevronDown,{size:16,className:on.chevron,"aria-hidden":"true"})]})};function I_(e,t,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return L.any(L.includes(t.toLowerCase()),a)})}const A_="_root_1sh27_1",S_="_label_1sh27_8",T_="_input_1sh27_21",E_="_hasValue_1sh27_31",$_="_clear_1sh27_35",Wn={root:A_,label:S_,input:T_,hasValue:E_,clear:$_},ys=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:P(Wn.root,t,{[Wn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Wn.label,children:n.jsx(M.IconSearch,{size:o})}),n.jsx("input",{className:Wn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Wn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(M.IconCloseCircleFilled,{size:o})})]})},M_="_container_5tajg_1",L_="_search_5tajg_7",q_="_list_5tajg_11",P_="_item_5tajg_15",R_="_logo_5tajg_37",D_="_info_5tajg_41",F_="_symbol_5tajg_47",B_="_name_5tajg_56",U_="_balance_5tajg_62",O_="_value_5tajg_69",rt={container:M_,search:L_,list:q_,item:P_,logo:R_,info:D_,symbol:F_,name:B_,balance:U_,value:O_},xs=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=_.useState(""),i=I_(["symbol"],a,t);return n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:rt.search,padding:20,ref:gs()}),i.length===0?n.jsx(je,{children:"No assets"}):n.jsx("div",{className:rt.list,children:i.map(c=>n.jsx("button",{type:"button",className:rt.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:u,logoUrl:m,symbol:d,name:h,balance:f,decimals:g,value:p=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(oe,{src:m,width:32,height:32,className:rt.logo,logo:!0}),n.jsxs("div",{className:rt.info,children:[n.jsx("div",{className:rt.symbol,children:d||u}),n.jsx("div",{className:rt.name,children:h})]}),n.jsxs("div",{className:rt.balance,children:[f&&n.jsx("div",{children:N.formatAmount(f,{decimals:g})}),p>0&&n.jsx("div",{className:rt.value,children:se(p)})]})]})})},c.denom))})]})},V_=()=>n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{rootClassName:rt.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(je,{children:"Loading..."})]});xs.Placeholder=V_;const K_="_stack_16oqn_1",W_="_title_16oqn_9",z_="_grid_16oqn_16",H_="_item_16oqn_22",Q_="_button_16oqn_26",G_="_active_16oqn_44",Sn={stack:K_,title:W_,grid:z_,item:H_,button:Q_,active:G_},pn=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:Sn.title,children:e}),n.jsx("div",{className:Sn.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(zc,{offset:-2,disabled:!a?.(r),className:Sn.item,children:n.jsx(_s,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button","aria-label":i,className:P(Sn.button,{[Sn.active]:r===s}),onClick:()=>o(r),children:n.jsx(oe,{src:c,width:28,height:28,logo:!0})})})},r))})]}),Y_=({children:e})=>n.jsx("div",{className:Sn.stack,children:e});pn.Stack=Y_;const Z_=({address:e,chain:t,onSelect:s})=>{const o=Hs(t.chain_id),{data:a={}}=po(e,t.chain_id);return n.jsx(xs,{assets:L.sortWith([L.descend(r=>r.symbol==="INIT"),L.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>q(i).comparedTo(r)??0,L.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=N.truncate(i),logo_uri:l}=r,u=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:u.amount,value:Number(u.value_usd??0)}})),onSelect:s})},J_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Zt(),i=fo(),{watch:c,setValue:l}=Jt(),u=c(a),m=c(s),d=c(o),[h,f]=_.useState(m),g=Ge(h),p=Cg(),y=Va(),[x,w]=L.partition(j=>y(j.chain_id),i.filter(j=>!j.hidden)),C=j=>{if(m===h&&d===j){t();return}l(s,h),l(o,j),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(pn.Stack,{children:[n.jsx(pn,{label:"Interwoven Economy",chains:x.map(({chain_id:j,chain_name:b,pretty_name:v,logo_uri:I})=>({chainId:j,name:v||b,logoUrl:I??""})),value:h,onSelect:f}),n.jsx(pn,{label:"Chains",chains:w.map(({chain_id:j,chain_name:b,pretty_name:v,logo_uri:I})=>({chainId:j,name:v||b,logoUrl:I??""})),value:h,onSelect:f})]}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(Z_,{address:p({initialAddress:u,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:C})},h)]})},$r=({type:e})=>{const t=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Jt(),r=a(t),i=a(s),c=Ge(r),l=St(i,r);return n.jsx(qn,{title:o,content:u=>n.jsx(J_,{type:e,afterSelect:u}),children:n.jsx(sl,{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??""}})})},X_="_skeleton_1l4jn_1",ey={skeleton:X_},gn=({width:e="100%",height:t})=>n.jsx("div",{className:ey.skeleton,style:{width:e,height:t},"aria-hidden":"true"}),ty="_stack_oq1ir_1",ny="_button_oq1ir_6",sy="_isLoading_oq1ir_19",oy="_disabled_oq1ir_19",ay="_checked_oq1ir_23",ry="_header_oq1ir_37",iy="_title_oq1ir_43",cy="_duration_oq1ir_52",ly="_warning_oq1ir_62",uy="_amount_oq1ir_66",dy="_value_oq1ir_67",at={stack:ty,button:ny,isLoading:sy,disabled:oy,checked:ay,header:ry,title:iy,duration:cy,warning:ly,amount:uy,value:dy},my=({children:e})=>n.jsx("div",{className:at.stack,role:"radiogroup","aria-label":"Route options",children:e}),Rs=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Jt(),{dstChainId:l,dstDenom:u}=c(),m=St(u,l),d=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:P(at.button,{[at.isLoading]:i,[at.disabled]:h,[at.checked]:d}),onClick:()=>{i||h||o(s)},role:"radio","aria-checked":d,"aria-disabled":h,children:[n.jsxs("div",{className:at.header,children:[n.jsxs("div",{className:at.title,children:[n.jsx("span",{children:e}),d&&n.jsx(M.IconCheck,{size:14,"aria-hidden":"true"})]}),i?n.jsx(gn,{width:80,height:16}):r?n.jsxs("div",{className:P(at.duration,{[at.warning]:s==="op"}),children:[n.jsx(M.IconClockFilled,{size:12,"aria-hidden":"true"}),n.jsx("span",{children:ss(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:at.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:at.amount,children:i?n.jsx(gn,{width:260,height:40}):r?N.formatAmount(r.amount_out,{decimals:m.decimals}):null}),n.jsx("div",{className:at.value,children:i?n.jsx(gn,{width:120,height:16}):r?r.usd_amount_out?se(r.usd_amount_out):"$-":null})]})]})};Rs.Stack=my;const hy="_description_nuyvt_1",fy="_presets_nuyvt_8",py="_preset_nuyvt_8",gy="_active_nuyvt_29",_y="_custom_nuyvt_40",yy="_wrapper_nuyvt_47",xy="_percent_nuyvt_58",jt={description:hy,presets:fy,preset:py,active:gy,custom:_y,wrapper:yy,percent:xy},Mr=["0.1","0.5","1.0"],wy=({afterConfirm:e})=>{const t=Jt(),s=t.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:c,setValue:l}=$e.useForm({defaultValues:{value:s}}),u=i("value");_.useEffect(()=>{const p=Mr.findIndex(y=>y===s);a(p>=0?p:null)},[s]);const m=(p,y)=>{l("value",p),a(y)},d=()=>{a(null)},h=_.useMemo(()=>Number(u)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(u)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(u)<.1?{type:"warning",text:"Your transaction may fail"}:null,[u]),f=h?.type==="error",g=({value:p})=>{t.setValue("slippagePercent",p),e()};return n.jsxs(xt,{children:[n.jsx("p",{className:jt.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."}),n.jsxs("div",{className:jt.presets,role:"radiogroup","aria-label":"Slippage presets",children:[Mr.map((p,y)=>n.jsxs("button",{type:"button",className:P(jt.preset,{[jt.active]:o===y}),onClick:()=>m(p,y),role:"radio","aria-checked":o===y,children:[p,"%"]},p)),o!==null?n.jsx("button",{type:"button",className:P(jt.preset,jt.custom),onClick:()=>a(null),role:"radio","aria-checked":o===null,children:"Custom"}):n.jsxs("div",{className:jt.wrapper,children:[n.jsx(Xc,{name:"value",control:r,dp:2,onFocus:d,placeholder:"",className:P(jt.preset,jt.active)}),n.jsx("span",{className:jt.percent,children:"%"})]})]}),h&&n.jsx(be,{level:h.type,children:h.text}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},by="_form_1owk5_1",vy="_arrow_1owk5_5",jy="_divider_1owk5_14",Cy="_flip_1owk5_23",Ny="_meta_1owk5_41",ky="_row_1owk5_54",Iy="_title_1owk5_60",Ay="_description_1owk5_64",Sy="_icon_1owk5_71",Ty="_edit_1owk5_76",Ey="_link_1owk5_94",$y="_warning_1owk5_99",Ke={form:by,arrow:vy,divider:jy,flip:Cy,meta:Ny,row:ky,title:Iy,description:Ay,icon:Sy,edit:Ty,link:Ey,warning:$y};function My({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}function Ly({srcChainType:e,chainFeeAssets:t,srcDenom:s}){switch(e){case"initia":case"cosmos":return t.map(({denom:o})=>o);case"evm":return kt.isAddress(s)?[]:[s];default:return[]}}const qy=q(1),Py=()=>{const e=Me(),t=uo(),s=Rn(),[o,a]=_.useState(void 0),[r,i]=_.useState(!1),[c,l]=Qe.useLocalStorage(he.BRIDGE_ROUTE_TYPE,"default"),{watch:u,setValue:m,handleSubmit:d,formState:h}=Jt(),f=u(),{srcChainId:g,srcDenom:p,dstChainId:y,dstDenom:x,quantity:w,sender:C,slippagePercent:j}=f,b=ce(),v=Ge(g),I=xn(v),S=Ge(y),A=xn(S),$=St(p,g),k=St(x,y),{data:T,isError:R}=po(C,g),B=o_(C,g,p),D=T!==void 0,J=B?.amount??(T?"0":void 0),K=!J||q(J).isZero(),[z]=Qe.useDebounceValue(w,300),O=Jc({quantity:z,balance:J,decimals:$?.decimals}),X=g===y,G=X&&g===b.chainId,ue=My({isLayer1Swap:G,isL2Swap:X&&I==="initia"&&!G}),ye=I!=="initia"&&A!=="initia",me=c_(),Ce=oa(z,{disabled:ye,refreshMs:ue}),Se=oa(z,{isOpWithdraw:!0,disabled:!me,refreshMs:ue}),Ne=me&&c==="op",$t=Ne?Se:Ce,ut=Ne?Ce:Se,Pe=Ne?!ye:me,le=$t.error&&Pe?ut:$t,{data:Y,isLoading:Mt,error:en}=le,{data:Lt}=i_(en),bt=z&&Mt&&!r,tn=()=>{m("srcChainId",y),m("srcDenom",x),m("dstChainId",g),m("dstDenom",p),m("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:dt,closeModal:Oe}=ao(),nt=d(async re=>{a(void 0),i(!0);try{const ke=await le.refetch();if(ke.error||!ke.data||!ke.dataUpdatedAt){a(ke.error instanceof Error?ke.error.message:"Failed to refresh route. Please try again.");return}const Ut=ke.data,Un=ke.dataUpdatedAt;if(s("Bridge Simulation Success",{quantity:re.quantity,srcChainId:re.srcChainId,srcDenom:re.srcDenom,dstChainId:re.dstChainId,dstDenom:re.dstDenom}),Ut.warning){const{type:Ul="",message:Ol}=Ut.warning??{};dt({content:n.jsx(Gc,{type:"warning",icon:n.jsx(M.IconWarningFilled,{size:40}),title:Ys.sentenceCase(Ul),primaryButton:{label:"Cancel",onClick:Oe},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:Ut,values:re,quoteVerifiedAt:Un}),Oe()}},children:n.jsx("p",{className:Ke.warning,children:Ol})})});return}e("/bridge/preview",{route:Ut,values:re,quoteVerifiedAt:Un})}finally{i(!1)}}),ee=_.useMemo(()=>Y?.estimated_fees?.filter(({fee_behavior:re})=>re==="FEE_BEHAVIOR_DEDUCTED")??[],[Y]),ve=_.useMemo(()=>Y?.estimated_fees?.filter(({fee_behavior:re})=>re==="FEE_BEHAVIOR_ADDITIONAL")??[],[Y]),Ve=_.useMemo(()=>{if(D)for(const re of ve){const ke=T?.[re.origin_asset.denom]?.amount??"0",Ut=Y?.source_asset_denom===re.origin_asset.denom?Y.amount_in:"0";if(q(ke).lt(q(Ut).plus(re.amount??"0")))return`Insufficient ${re.origin_asset.symbol} for fees`}},[ve,T,D,Y]),mt=!!Y&&ve.length>0&&!D,jo=Y?N.formatAmount(Y.amount_out,{decimals:k.decimals}):"0",bs=_.useMemo(()=>v.fee_assets??[],[v.fee_assets]),Co=_.useCallback((re,ke)=>{const Ut=q(T?.[re]?.amount??"0"),Un=re===(ke?.sourceDenom??p)?q(ke?.amountIn??Y?.amount_in??"0"):q(0);return Ut.minus(Un)},[T,Y?.amount_in,p]),No=_.useMemo(()=>Ly({srcChainType:I,chainFeeAssets:bs,srcDenom:p}),[bs,I,p]),Rl=a_({sourceDenom:p,sourceBalance:J,amountIn:Y?.amount_in,feeTokenDenoms:No,balancesByDenom:T,additionalFees:ve}),Dl=No.some(re=>Co(re).gt(qy)),tr=D&&!!Y&&No.length>0&&!Dl||Rl?"Insufficient balance for fees":void 0,Fl=!!o,nr=_.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!z)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(R)return"Failed to load balance";if(O)return"Insufficient balance";if(!Y)return"Route not found";if(mt)return"Loading balances...";if(Ve)return Ve},[z,Ve,h,mt,R,O,Y,f]),Bl=_.useMemo(()=>r?"Refreshing route...":bt?"Simulating...":!1,[bt,r]),ko=_.useCallback((re,ke)=>re.length?n.jsxs("div",{className:Ke.description,children:[Wa(re),!t&&n.jsx(_s,{label:ke,children:n.jsx("span",{className:Ke.icon,children:n.jsx(M.IconInfoFilled,{size:12,"aria-hidden":"true"})})})]}):null,[t]),vs=q(w).gt(0)&&me&&Ce.data&&Se.data&&Se.data.estimated_route_duration_seconds>Ce.data.estimated_route_duration_seconds,sr=_.useMemo(()=>{if(!Y)return[];const re=el(Y.amount_out,j);return[{condition:!!Y.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[ko(ee,"Fee deducted from the amount you receive"),ko(ve,"Fee charged in addition to the amount you enter")]})},{condition:!vs&&!!ss(Y.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Ke.description,children:ss(Y.estimated_route_duration_seconds)})},{condition:Y.does_swap,title:"Slippage",content:n.jsxs("span",{className:Ke.description,children:[n.jsxs("span",{children:[j,"%"]}),n.jsx(qn,{title:"Slippage tolerance",content:ke=>n.jsx(wy,{afterConfirm:ke}),className:Ke.edit,children:n.jsx(M.IconSettingFilled,{size:12,"aria-hidden":"true"})})]})},{condition:Y.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Ke.description,children:[n.jsx("img",{src:k.logo_uri,alt:k.symbol,width:12,height:12}),N.formatAmount(re,{decimals:k.decimals})," ",k.symbol]})}].filter(ke=>ke.condition)},[ve,ee,k,ko,Y,vs,j]);return n.jsxs("form",{className:Ke.form,onSubmit:nt,"aria-label":"Bridge and swap form",children:[n.jsx(na,{selectButton:n.jsx($r,{type:"src"}),accountButton:I==="cosmos"&&n.jsx(Er,{type:"src"}),quantityInput:n.jsx(ns,{balance:J,decimals:$?.decimals}),balanceButton:n.jsx(Zc,{onClick:()=>m("quantity",N.fromBaseUnit(B?.amount,{decimals:$?.decimals??0}),{shouldValidate:!0}),disabled:K,children:N.formatAmount(J??"0",{decimals:$.decimals})}),value:Y?.usd_amount_in?se(Y.usd_amount_in):"$-"}),n.jsxs("div",{className:Ke.arrow,children:[n.jsx("div",{className:Ke.divider}),n.jsx("button",{type:"button",className:Ke.flip,onClick:()=>tn(),"aria-label":"Swap source and destination",children:n.jsx(M.IconChevronDown,{size:16,"aria-hidden":"true"})})]}),n.jsx(na,{selectButton:n.jsx($r,{type:"dst"}),accountButton:n.jsx(Er,{type:"dst"}),quantityInput:n.jsx(ns.ReadOnly,{children:jo}),value:Y?.usd_amount_out?se(Y.usd_amount_out):"$-",hideNumbers:vs}),n.jsx(ts,{children:vs?n.jsxs(Rs.Stack,{children:[n.jsx(Rs,{label:"Fast",query:Ce,value:"default",onSelect:l,checked:c==="default"}),n.jsx(Rs,{label:"Lossless",query:Se,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(Ae,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(be.Stack,{children:[R&&n.jsx(be,{level:"error",children:"Failed to load balance"}),Fl&&n.jsx(be,{level:"error",children:o}),Y?.extra_infos?.map(re=>n.jsx(be,{level:"info",children:re},re)),Lt&&n.jsx(be,{level:"info",children:Lt}),tr&&n.jsx(be,{level:"warning",children:tr}),Y?.warning&&n.jsx(be,{level:"warning",children:Y.warning.message}),Y?.extra_warnings?.map(re=>n.jsx(be,{level:"warning",children:re},re))]}),n.jsx(ts,{children:sr.length>0&&n.jsx("section",{className:Ke.meta,"aria-label":"Route details",children:sr.map((re,ke)=>n.jsxs("div",{className:Ke.row,children:[n.jsx("span",{className:Ke.title,children:re.title}),re.content]},ke))})})]}),children:n.jsx(fe.White,{loading:Bl,disabled:!!nr||r,children:nr??"Preview route"})})]})},Ry=()=>{Yc();const e=Si(),t=Me(),s=Zt(),o=nh(),a=$e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:u,dstDenom:m,quantity:d,slippagePercent:h,recipient:f}=r();r((T,{name:R})=>{(R==="srcChainId"||R==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Hc(),p=g(c),y=g(l),w=Ka()(f,l);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),_.useEffect(()=>{w||i("recipient",y)},[y,w,i]);const{showNotification:C}=hs(),j=Ge(c),b=Ge(l),v=Hs(c),I=Hs(l),S=v.some(T=>T.denom===u),A=I.some(T=>T.denom===m);_.useEffect(()=>{v.length>0&&!S&&(i("srcDenom",v[0].denom),C({type:"info",title:`Switched to ${v[0].symbol}`,description:`The selected asset is not available on ${j.pretty_name}.`,autoHide:!0}))},[v,S,i,C,j.pretty_name]),_.useEffect(()=>{I.length>0&&!A&&(i("dstDenom",I[0].denom),C({type:"info",title:`Switched to ${I[0].symbol}`,description:`The selected asset is not available on ${b.pretty_name}.`,autoHide:!0}))},[I,A,i,C,b.pretty_name]),_.useEffect(()=>{!S||!A||(localStorage.setItem(he.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(he.BRIDGE_SRC_DENOM,u),localStorage.setItem(he.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(he.BRIDGE_DST_DENOM,m),localStorage.setItem(he.BRIDGE_QUANTITY,d),localStorage.setItem(he.BRIDGE_SLIPPAGE_PERCENT,h))},[c,u,l,m,d,h,S,A]);const $=e[0].path==="/bridge",{reminders:k}=Bn();return n.jsx(Et,{title:"Bridge/Swap",backButton:$?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(fe.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,"aria-label":"Bridge/Swap history",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:[n.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"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(zc,{offset:0,disabled:k.length===0,children:n.jsx(fe.Small,{onClick:()=>t("/op/withdrawals"),disabled:!s,children:n.jsx("span",{children:"Withdrawal status"})})})]}),children:S&&A&&n.jsx($e.FormProvider,{...a,children:n.jsx(xe,{children:n.jsx(Py,{})})})})},Dy="_button_1crvp_1",Fy="_checkbox_1crvp_11",By="_checked_1crvp_25",Es={button:Dy,checkbox:Fy,checked:By},Uy=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:P(Es.button,o),onClick:t,role:"checkbox","aria-checked":e,children:[n.jsx("div",{className:P(Es.checkbox,{[Es.checked]:e}),children:e&&n.jsx(M.IconCheck,{size:12,"aria-hidden":"true"})}),n.jsx("span",{className:Es.label,children:s})]}),Oy="_button_aoxv2_1",Vy={button:Oy},ol=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=Zl.useInView();return _.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:Vy.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})]})};function al(e,t){return e.reduce((s,o)=>{const a=t(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 Ds=({chainId:e,txHash:t})=>`${he.BRIDGE_HISTORY}:${e}:${t}`,Qs=100,Lr=10;function rl(){const[e,t]=Qe.useLocalStorage(he.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(Ds(a),JSON.stringify(r));for(const i of e.slice(Qs-1))localStorage.removeItem(Ds(i));t((i=[])=>[a,...i.slice(0,Qs-1)])},[e,t]),o=_.useCallback(a=>{const r=localStorage.getItem(Ds(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function il(e){return Qe.useLocalStorage(Ds(e),null)}const jn=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function yo(){const{restUrl:e}=ce();return _.useMemo(()=>H.create({prefixUrl:e}),[e])}function Ky(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:jn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:V.INFINITY});return s}const qr=20;function Wy(e){const t=ie();return E.useSuspenseInfiniteQuery({queryKey:jn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:qr,offset:s,order:"desc"},{withdrawals:a}=await H.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=L.last(s)?.sequence;return s.length<qr||!o||o<=1?null:o-1},initialPageParam:0,staleTime:V.SECOND})}function zy(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:jn.latestOutput(e).queryKey,queryFn:()=>t.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:V.SECOND});return s}function Hy({bridge_id:e,output_index:t}){const s=yo(),{data:o}=E.useSuspenseQuery({queryKey:jn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:V.SECOND});return o}function Qy({bridge_id:e,sequence:t}){const o=_e().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=lt()(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}=E.useSuspenseQuery({queryKey:jn.outputResponse(i,t).queryKey,queryFn:()=>H.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:V.SECOND});return c}function cl(e,t){const{bridge_id:s}=e,o=yo(),{data:a}=E.useSuspenseQuery({queryKey:jn.withdrawalClaimed(s,t).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:V.SECOND});return a}function zn(e){return Jl.sha3_256.create().update(e).digest()}function Ko(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function ll(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Ko(t.toString(),8),c=Ko(s.toString(),8),l=Ko(o.amount,8),u=un.concatBytes(i,c,zn(un.utf8ToBytes(a)),zn(un.utf8ToBytes(r)),zn(un.utf8ToBytes(o.denom)),l);return zn(zn(u))}async function Gy(e,t,s){try{return await H.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function Yy(e,t){const s=H.create({prefixUrl:t}),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`)}function Zy({addressList:e,route:t,slippagePercent:s,signedOpHook:o}){return{address_list:e,amount_in:t.amount_in,amount_out:t.amount_out,source_asset_chain_id:t.source_asset_chain_id,source_asset_denom:t.source_asset_denom,dest_asset_chain_id:t.dest_asset_chain_id,dest_asset_denom:t.dest_asset_denom,slippage_tolerance_percent:s,operations:t.operations,signed_op_hook:o}}async function Jy(e,t){const s=Zy(t),{txs:o}=await e.post("v2/fungible/msgs",{json:s}).json();if(!o||o.length===0)throw new Error("No transaction data found");return o}function xo(e,t){if(!e?.length)throw new Error("Invalid transaction data");return e.map(({msg_type_url:s,msg:o})=>{if(!(s&&o))throw new Error("Invalid transaction data");const a=t.converters[s];if(!a)throw new Error(`Unsupported message type: ${s}`);return t.fromAmino({type:a.aminoType,value:JSON.parse(o)})})}function Xy({gas:e,gasPrices:t,gasAdjustment:s=Qt}){return t.reduce((o,{amount:a,denom:r})=>(o[r]=q(e).times(s).times(a).integerValue(q.ROUND_CEIL).toFixed(0),o),{})}function ex({balances:e,requiredFeeByDenom:t,sourceDenom:s,amountIn:o}){const a=Object.keys(t);return a.length===0?!0:a.some(r=>{const i=q(e[r]?.amount??"0"),c=q(r===s?o:0),l=q(t[r]??"0");return i.minus(c).gte(l)})}async function aa(e,t){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=t;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(L.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 wt(){return et()}function tx(e,t){const{customFee:s,onCompleted:o}=t??{},a=Me(),{showNotification:r,updateNotification:i,hideNotification:c}=hs(),{addHistoryItem:l}=rl(),u=Rn(),{route:m,values:d}=wt(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=d,y=Ji(),{requestTxSync:x,submitTxSync:w,waitForTxConfirmation:C}=tt(),{find:j}=go(),b=is(),v=cs(),I=bn(),S=Ge(h),A=xn(S),$=Qc(h),k=E.useQueryClient(),{registryUrl:T}=ae(),R=lt(),B=ce(),{addReminder:D}=Bn(),J=Ue();return E.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const K=xo(e.cosmos_tx.msgs,{converters:v,fromAmino:I.fromAmino.bind(I)});if(A==="initia"){const{srcDenom:ut,quantity:Pe}=d,{decimals:le}=$(ut),Y=s?await w({messages:K,chainId:h,fee:s}):await x({messages:K,chainId:h,internal:1,spendCoins:[{denom:ut,amount:N.toBaseUnit(Pe,{decimals:le})}]}),Mt=C({txHash:Y,chainId:h});return{txHash:Y,wait:Mt}}const z=j(p)?.getProvider();if(!z)throw new Error("Wallet not connected");const O=z.getOfflineSignerOnlyAmino(h),X=await Le.SigningStargateClient.connectWithSigner(S.rpc,O,{registry:b,aminoTypes:I}),G=await X.getAllBalances(f),te=S.fee_assets.find(ut=>G.some(Pe=>Pe.denom===ut.denom&&q(Pe.amount).gt(0)));if(!te){const Pe=["Insufficient balance for fees.",`Available fee assets: ${S.fee_assets.map(le=>$(le.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Pe)}const{denom:ue,gas_price:ye}=te;if(!ye)throw new Error(`Gas price not found for ${ue}`);const me=await X.simulate(f,K,""),Ce=Le.GasPrice.fromString(ye.average+ue),Se=Le.calculateFee(Math.ceil(me*Qt),Ce),Ne=await X.signAndBroadcastSync(f,K,Se),$t=mc({txHash:Ne,client:X});return{txHash:Ne,wait:$t}}if("evm_tx"in e){const{chain_id:K,to:z,value:O,data:X}=e.evm_tx,G=await y(),te=await G.getSigner();await aa(G,S);const ue=await te.sendTransaction({chainId:K,to:z,value:O,data:`0x${X}`}),ye=Xi(ue.wait(),3e4,"Transaction was not confirmed in time. It may still be processing.");return{txHash:ue.hash,wait:ye}}throw new Error("Unlisted chain type")}catch(K){throw K instanceof fn?K:await ct(K)}},onSuccess:async({txHash:K,wait:z})=>{localStorage.removeItem(he.BRIDGE_QUANTITY),k.removeQueries({queryKey:Ie.route._def}),k.removeQueries({queryKey:Ie.routeErrorInfo._def}),o?o({txhash:K,chainId:h,timestamp:Date.now(),success:!0,route:m,values:d}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await z;const O=wo(m)==="OP Bridge withdrawal",X=O?{success:!0,error:null}:await rx(J,K,h);if(!o&&!X.success&&X.error){const me=X.error instanceof Error?X.error.message:String(X.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${me}. The transaction may still be processing.`,autoHide:!0})}const G=X.success,ue=Pr({txHash:K,srcChainId:h,route:m,values:d,recipient:g},G);l(ue.tx,ue.details),o||i(sx(c));const ye=Wo(d,K);if(u("Bridge Transaction Success",ye),O){const me=R(h).metadata?.op_bridge_id;if(me&&!await Gy(B.restUrl,Number(me),m.dest_asset_denom)){const Se=ax(ue.tx,m,g);D(ue.tx,Se)}}}catch(O){const X=O instanceof Error?O.message:String(O);if(O instanceof fn){const te=Pr({txHash:K,srcChainId:h,route:m,values:d},!1);l(te.tx,te.details),o||i(ox(c))}else o?o({success:!1,error:X,route:m,values:d}):i({type:"error",title:"Transaction not confirmed",description:X});u("Bridge Confirmation Failed",{...Wo(d,K),error:X,type:O instanceof fn?"timeout":"error"})}finally{k.invalidateQueries({queryKey:Ie.balances(h,f).queryKey})}},onError:async K=>{const z=A==="initia"?await In(K,R(h),T):K;o?o({success:!1,error:z.message,route:m,values:d}):r({type:"error",title:"Transaction failed",description:z.message});const O=Wo(d);u("Bridge Transaction Failed",{...O,error:z.message})}})}function nx(){const e=Ue(),t=ie(),s=Yi(),{route:o,values:a}=wt(),r=Bt(),i=cs(),c=bn();return E.useMutation({mutationFn:async()=>{try{const{chain_id:l,hook:u}=await e.post("op-hook",{json:{source_address:t,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:N.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Yy(t,r(o.dest_asset_chain_id).rest);const m=xo(u,{converters:i,fromAmino:c.fromAmino.bind(c)}),d=await s(l,t,m,{amount:[],gas:"1"},"",{incrementSequence:l===a.srcChainId?2:0}),h=Ze.Tx.fromPartial({body:Ze.TxBody.decode(d.bodyBytes),authInfo:Ze.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:de.toBase64(Ze.Tx.encode(h).finish())}}catch(l){throw await ct(l)}}})}function sx(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(hn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function ox(e){return{type:"info",title:"Transaction pending",description:_.createElement(_.Fragment,null,"Confirmation is taking longer than expected. Check ",_.createElement(hn,{to:"/bridge/history",onClick:e},"the activity page")," for updates"),autoHide:!0}}function Wo(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function Pr(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=wo(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:t},isOpWithdraw:c}}function ax(e,t,s){return{...e,recipient:N.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function rx(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function ul(e){const{chainId:t,txHash:s,tracked:o}=e,a=Ue();return E.useQuery({queryKey:Ie.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:V.INFINITY,enabled:!o})}function dl(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=Ue();return E.useQuery({queryKey:Ie.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 u=t+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),d=Math.floor((u-m)/1e3);return d<=0?1e3:d<=300?5e3:60*1e3},staleTime:V.INFINITY})}var Yn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Yn||{});function wo(e){const{operations:t,dest_asset_denom:s}=e;return L.has("op_init_transfer",L.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const ix="_success_t4dfk_1",cx="_error_t4dfk_5",Rr={success:ix,error:cx},lx=({tx:e})=>{const[t,s]=il(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=dl(t),a=t.state??ux(o);switch(_.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return n.jsx("div",{className:Rr.error,children:n.jsx(M.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:Rr.success,children:n.jsx(M.IconCheckCircleFilled,{size:14})});default:return n.jsx(At,{size:14})}};function ux(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 dx="_link_104m3_1",mx="_header_104m3_23",hx="_title_104m3_31",fx="_date_104m3_37",px="_explorer_104m3_41",gx="_fees_104m3_57",_x="_label_104m3_65",yx="_content_104m3_69",xx="_route_104m3_75",wx="_row_104m3_80",bx="_asset_104m3_86",vx="_amount_104m3_94",jx="_chain_104m3_99",Cx="_account_104m3_108",Nx="_arrow_104m3_115",Re={link:dx,header:mx,title:hx,date:fx,explorer:px,fees:gx,label:_x,content:yx,route:xx,row:wx,asset:bx,amount:vx,chain:jx,account:Cx,arrow:Nx},kx=({tx:e})=>{const[t,s]=il(e);if(!t)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=t,{data:u}=ul(t),{address:m="",connector:d}=He.useAccount(),{find:h}=go();_.useEffect(()=>{u&&s(D=>{if(!D)throw new Error("Bridge history details not found");return{...D,tracked:!0}})},[s,u]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:y,dest_asset_chain_id:x,dest_asset_denom:w,estimated_fees:C=[]}=r,j=Ge(p),b=Ge(x),v=St(y,p),I=St(w,x),S=(D,J)=>J?n.jsx(oe,{src:J,width:12,height:12}):N.InitiaAddress.equals(D,m)?n.jsx(oe,{src:d?.icon,width:12,height:12}):n.jsx(M.IconWallet,{size:12}),A=(D,{symbol:J,decimals:K,logo_uri:z},{chain_name:O,pretty_name:X,...G},te,ue)=>n.jsxs("div",{className:Re.row,children:[n.jsx(_o,{assetLogoUrl:z,chainLogoUrl:G.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:Re.asset,children:[n.jsx("span",{className:Re.amount,children:N.formatAmount(D,{decimals:K})}),n.jsx("span",{children:J})]}),n.jsxs("div",{className:Re.chain,children:[n.jsxs("span",{children:["on ",X||O]}),n.jsxs("div",{className:Re.account,children:[ue,n.jsx("span",{className:"monospace",children:N.truncate(te)})]})]})]})]}),$=wo(r),k=_.useMemo(()=>{switch($){case Yn.SKIP:return"Skip Explorer";case Yn.OP_WITHDRAW:return"Initia Scan"}},[$]),T=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Re.header,children:[n.jsxs("div",{className:Re.title,children:[l?n.jsx(lx,{tx:e}):n.jsx(At,{size:14}),n.jsx("div",{className:Re.date,children:Xe.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:Re.explorer,children:[n.jsx("span",{children:k}),n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]})]}),n.jsxs("div",{className:Re.route,children:[A(f,v,j,i.sender,S(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:Re.arrow,children:n.jsx(M.IconArrowDown,{size:12,"aria-hidden":"true"})}),A(g,I,b,i.recipient,S(i.recipient))]}),C.length>0&&n.jsxs("div",{className:Re.fees,children:[n.jsx("span",{className:Re.label,children:"Fees"}),n.jsx("span",{className:Re.content,children:Wa(C)})]})]});if($===Yn.OP_WITHDRAW)return n.jsx(ho,{chainId:o,txHash:a,className:Re.link,children:T});const R=new URLSearchParams({tx_hash:a,chain_id:o}),B=new URL(`?${R.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:B.toString(),className:Re.link,target:"_blank",rel:"noopener noreferrer",children:T})},Ix="_history_13u9z_1",Ax="_header_13u9z_5",Sx="_checkbox_13u9z_9",Tx="_groups_13u9z_13",Ex="_dateGroup_13u9z_21",$x="_dateHeader_13u9z_26",Mx="_list_13u9z_32",an={history:Ix,header:Ax,checkbox:Sx,groups:Tx,dateGroup:Ex,dateHeader:$x,list:Mx},Lx=()=>{const{initiaAddress:e,hexAddress:t}=tt(),{history:s,getHistoryDetails:o}=rl(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:y,recipient:x}=p;return[y,x].some(w=>[e,t].includes(w))}),[i,c]=_.useState(1),[l,u]=Qe.useToggle(!r.length),m=l?a:r,d=m.slice(0,i*Lr),h=_.useMemo(()=>al(d,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[d,o]);return n.jsx(Et,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:an.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:an.header,children:n.jsx(Uy,{checked:l,onClick:u,label:"Show all transactions stored in this browser",className:an.checkbox})}),m.length===0?n.jsx(je,{children:"No bridge/swap activity"}):n.jsx("div",{className:an.groups,children:Object.entries(h).map(([f,g])=>n.jsxs("div",{className:an.dateGroup,children:[n.jsx("div",{className:an.dateHeader,children:f}),n.jsx("div",{className:an.list,children:g.map(p=>n.jsx(xe,{children:n.jsx(kx,{tx:p})},p.txHash))})]},f))}),m.length>i*Lr?n.jsx(ol,{onClick:()=>c(f=>f+1)}):s.length>=Qs&&n.jsxs(je,{children:["Only the latest ",Qs," items are stored. Older entries will be removed automatically."]})]})})};function ml({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function qx({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return ml({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function Px({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return ml({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const Rx=1e4;function ra(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(ra).join(",")}]`:`{${Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${ra(s)}`).join(",")}}`}function Dr(e){return ra({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Dx(e,t,s){const o=Me(),a=et(),r=E.useQueryClient(),i=Ue(),[c,l]=_.useState(!1),[u,m]=_.useState(void 0),[d,h]=_.useState(s??0),f=_.useRef(null);return _.useEffect(()=>{h(s??0)},[s]),_.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const p=Math.max(s??0,d);if(Date.now()-p<=Rx)return!1;l(!0),m(void 0);const y=new AbortController;f.current=y;try{const x=await tl(i,r,t,{isOpWithdraw:wo(e)===Yn.OP_WITHDRAW,signal:y.signal});if(y.signal.aborted)return!0;const w=Dr(x)!==Dr(e),C=Date.now();return w?(o(0,qx({currentState:a,route:x,values:t,quoteVerifiedAt:C})),!0):(h(C),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||y.signal.aborted||m((await ct(x)).message),!0}finally{f.current===y&&(f.current=null),y.signal.aborted||l(!1)}},isRefreshing:c,refreshError:u,clearRefreshError:()=>m(void 0)}}function Fx(e,t){return t?"Confirm updated route":e||"Confirm"}function Bx({error:e,warning:t,messageRefreshError:s,refreshError:o,requiresReconfirm:a}){if(e)return{level:"error",text:e};if(s)return{level:"error",text:s};if(o)return{level:"error",text:o};if(t)return{level:"warning",text:t};if(a)return{level:"info",text:"Route updated. Please review and confirm again."}}function Ux({isCheckingApprovals:e,isCheckingFeeBalance:t,isFetchingMessages:s,isEstimatingGas:o,isRouteTransitioning:a}){return a?"Refreshing route...":s?"Fetching messages...":t?"Checking fee balance...":e?"Checking approvals...":o?"Estimating gas...":!1}function Ox({isRefreshing:e,isPending:t,backgroundLoadingText:s}){return e?"Refreshing route...":t?"Signing transaction...":s}const Ha=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a,warning:r,isCheckingApprovals:i,isCheckingFeeBalance:c,messageRefreshError:l,isRouteTransitioning:u,isFetchingMessages:m,isEstimatingGas:d})=>{const h=Me(),f=et(),{route:g,values:p,quoteVerifiedAt:y,requiresReconfirm:x}=wt(),{mutate:w,isPending:C}=tx(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:j,isRefreshing:b,refreshError:v,clearRefreshError:I}=Dx(g,p,y),S=Ux({isCheckingApprovals:i,isCheckingFeeBalance:c,isFetchingMessages:m,isEstimatingGas:d,isRouteTransitioning:u}),A=async()=>{if(!(C||b||S||l)){if(x){h(0,Px({currentState:f,route:g,values:p,quoteVerifiedAt:y??Date.now()}));return}await j()||(I(),w())}},$=Bx({error:a,warning:r,messageRefreshError:l,refreshError:v,requiresReconfirm:x}),k=Ox({isRefreshing:b,isPending:C,backgroundLoadingText:S}),T=C||b||!!S||!!l;return n.jsx(Ae,{extra:$&&n.jsx(be,{level:$.level,children:$.text}),children:n.jsx(fe.White,{onClick:A,loading:k,disabled:!!a||!!r||T,children:Fx(o,!!x)})})};function Vx({approvalError:e,approveTokens:t,exactFeeCheckError:s,isApproving:o,isCheckingApprovals:a,isCheckingFeeBalance:r,isFetchingMessages:i,messageRefreshError:c,requiresApproval:l}){return i||c?{kind:"preview",isFetchingMessages:i,messageRefreshError:c}:r?{kind:"preview",isCheckingFeeBalance:!0}:s?{kind:"preview",error:s}:a?{kind:"preview",isCheckingApprovals:!0}:l&&t?{kind:"approval",approvalError:e,approveTokens:t,isApproving:!!o}:{kind:"preview"}}const Kx="_content_1hzj2_1",Wx="_info_1hzj2_6",zx="_arrow_1hzj2_11",Hx="_divider_1hzj2_19",Qx="_type_1hzj2_27",Gx="_asset_1hzj2_47",Yx="_amount_1hzj2_55",Zx="_lower_1hzj2_60",Jx="_chain_1hzj2_66",Xx="_address_1hzj2_72",ot={content:Kx,info:Wx,arrow:zx,divider:Hx,type:Qx,asset:Gx,amount:Yx,lower:Zx,chain:Jx,address:Xx},hl=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=N.truncate(a),decimals:u=0,logo_uri:m=ya}=e,{chain_name:d,pretty_name:h,...f}=Ge(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:ot.arrow,children:[n.jsx("div",{className:ot.divider}),s?n.jsx(_s,{label:s,children:n.jsx("button",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})})}):n.jsx("span",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})}),n.jsx("div",{className:ot.divider})]}),n.jsxs("div",{className:ot.content,children:[n.jsx(_o,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:ot.info,children:[n.jsxs("div",{className:ot.asset,children:[n.jsx("span",{className:ot.amount,children:N.formatAmount(o,{decimals:u})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:ot.lower,children:[n.jsxs("div",{className:ot.chain,children:["on ",h||d]}),i&&n.jsx(Ws,{value:i,children:({copy:g,copied:p})=>n.jsxs("button",{className:ot.address,onClick:g,children:[c,p?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:N.truncate(i)})]})})]})]})]})]})},Tn=e=>{const t=St(e.denom,e.chainId);return n.jsx(hl,{...e,...t})};Tn.Placeholder=hl;const e1="_root_1hbar_1",t1="_flexEnd_1hbar_6",n1="_toggle_1hbar_11",s1="_route_1hbar_36",o1="_content_1hbar_43",Hn={root:e1,flexEnd:t1,toggle:n1,route:s1,content:o1};function a1(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":Ys.capitalCase(L.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(t).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(t).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 r1=({addressList:e})=>{const{values:t,route:s}=wt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=L.zipObj(s.required_chain_addresses,e),{find:l}=go(),{connector:u,address:m=""}=He.useAccount(),[d,h]=Qe.useToggle(!1),f=i.length>1,g=n.jsx(oe,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:u?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:g},y=b=>N.InitiaAddress.equals(b,m)?g:n.jsx(M.IconWallet,{size:11}),x=b=>{const{label:v,amount_out:I,denom:S,denom_out:A=S,chain_id:$,from_chain_id:k,to_chain_id:T=$??k}=b,R=c[T];return{label:f&&!d?void 0:v,amount:I,denom:A,chainId:T,address:R,walletIcon:y(R)}},w=i.map(a1).map(x),C=w.slice(0,-1),j=w[w.length-1];return n.jsxs(ne.Collapsible.Root,{className:Hn.root,open:d,onOpenChange:h,children:[f&&n.jsx("div",{className:Hn.flexEnd,children:n.jsx(ne.Collapsible.Trigger,{className:Hn.toggle,children:d?n.jsxs(n.Fragment,{children:[n.jsx(M.IconMinus,{size:12}),n.jsx("span",{children:"Hide details"})]}):n.jsxs(n.Fragment,{children:[n.jsx(M.IconList,{size:12}),n.jsx("span",{children:"Show details"})]})})}),n.jsxs("div",{className:Hn.route,children:[n.jsx(Tn,{...p,source:!0}),n.jsx(ne.Collapsible.Content,{className:Hn.content,children:C.map((b,v)=>n.jsx(xe,{suspenseFallback:n.jsx(Tn.Placeholder,{...b}),errorBoundaryProps:{fallback:n.jsx(Tn.Placeholder,{...b})},children:n.jsx(Tn,{...b})},v))}),n.jsx(Tn,{...j})]})]})},fl=({error:e})=>{const t=Me();return n.jsx(Ae,{extra:n.jsx(be,{level:"error",children:e.message}),children:n.jsx(fe.White,{onClick:()=>t("/bridge"),children:"Home"})})},pl=({children:e})=>{const t=wt(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:u,hexAddress:m}=tt(),d=ls(),h=Bt(),f=fs(),g=h(r),p=f(g),y=a.slice(0,-1).some(I=>{const S=h(I);return f(S)==="cosmos"})&&p!=="cosmos",[x,w]=_.useState(void 0),[C,j]=_.useState(!1),[b,v]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!y)return;if(!d)throw new Error("Wallet not connected");j(!0),v(null);const[{pubkey:S}]=await d.getAccounts();w(S)}catch(S){v(await ct(S))}finally{j(!1)}})()},[y,d]),b)return n.jsx(fl,{error:b});if(C)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:C&&"Generating intermediary addresses..."})});if(!y||x){const I=a.map((S,A)=>{if(A===a.length-1){const B=h(i);return f(B)==="initia"?N.InitiaAddress(l).bech32:l}const $=h(S),k=f($),T=h(r),R=f(T);switch(k){case"initia":return u;case"evm":return m;case"cosmos":{if(R==="cosmos")return de.toBech32($.bech32_prefix,de.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return $n.pubkeyToAddress($n.encodeSecp256k1Pubkey(x),$.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(I)}return null};function i1(e){return"evm_tx"in e?JSON.stringify({approvals:e.evm_tx.required_erc20_approvals??[],chainId:e.evm_tx.chain_id,signerAddress:e.evm_tx.signer_address}):"non-evm"}function c1({currentKey:e,isPending:t,nextKey:s}){return!t&&e!==s}function l1(e,t){return typeof e=="function"?e(t):t.isCheckingApprovals?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Checking approvals..."})}):t.requiresApproval&&t.approveTokens?n.jsx(Ae,{extra:n.jsx(be,{level:"error",children:t.approvalError}),children:n.jsx(fe.White,{onClick:t.approveTokens,loading:t.isApproving&&"Approving tokens...",children:"Approve tokens"})}):e}const gl=({tx:e,children:t})=>{const s=Ji(),o=Bt(),a=E.useQueryClient(),r=i1(e),i=_.useRef(r),{data:c,isLoading:l}=E.useQuery({queryKey:["interwovenkit:erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:g,signer_address:p}=e.evm_tx,y=await s();await aa(y,o(g));const x=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async C=>{const{token_contract:j,spender:b}=C,I=await new kt.ethers.Contract(j,x,y).allowance(p,b);return{approval:C,currentAllowance:BigInt(I.toString())}}))).filter(({approval:C,currentAllowance:j})=>j<BigInt(C.amount)).map(({approval:C})=>C)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:u,data:m,isPending:d,error:h,reset:f}=E.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!c||c.length===0)throw new Error("No approvals needed");const{chain_id:g}=e.evm_tx,p=await s(),y=await p.getSigner();await aa(p,o(g));for(const x of c){const{token_contract:w,spender:C,amount:j}=x,b=["function approve(address spender, uint256 amount) external returns (bool)"],I=await new kt.ethers.Contract(w,b,y).approve(C,j);await Xi(I.wait(),3e4,"Approval was not confirmed in time. It may still be processing.")}return!0}catch(g){throw g instanceof fn?(a.invalidateQueries({queryKey:["interwovenkit:erc20-approvals-needed",e]}),g):await ct(g)}}});return _.useEffect(()=>{const g=i.current;c1({currentKey:g,isPending:d,nextKey:r})&&(i.current=r,f())},[r,d,f]),l1(t,{approvalError:h?.message,approveTokens:c&&c.length>0&&!m?()=>u():void 0,isApproving:d,isCheckingApprovals:l,requiresApproval:!!c&&c.length>0&&!m})};function u1({route:e,tx:t,isSrcInitia:s,isDstInitia:o,sender:a,recipient:r}){return!!e&&"cosmos_tx"in t&&!!t.cosmos_tx.msgs?.length&&!e.required_op_hook&&s&&o&&!!a&&!!r}function d1({hasBalances:e,hasChain:t,requiresExactFeeCheck:s}){return s&&e&&t}function m1({balances:e,feeDenoms:t}){return e?[...t].sort().map(s=>`${s}:${e[s]?.amount??"0"}`).join("|"):""}function h1({tx:e,children:t}){const{route:s,values:o}=wt(),{sender:a,recipient:r,srcChainId:i,srcDenom:c,dstChainId:l}=o,u=Ge(i),m=Ge(l),d=xn(u),h=xn(m),{data:f,isLoading:g,error:p}=po(a,i),y=cs(),x=bn(),w=us(),C=u1({route:s,tx:e,isSrcInitia:d==="initia",isDstInitia:h==="initia",sender:a,recipient:r}),{chain:j,error:b,isLoading:v}=uu(i,C),I=j?Array.from(new Set([c,...j.fees.fee_tokens.map(({denom:R})=>R)])):[],S=m1({balances:f,feeDenoms:I}),A=d1({hasBalances:f!==void 0,hasChain:!!j,requiresExactFeeCheck:C}),{data:$,error:k,isLoading:T}=E.useQuery({queryKey:["interwovenkit:bridge-preview-fee-check",e,a,i,c,s.amount_in,S],queryFn:async()=>{try{if(!(C&&j&&"cosmos_tx"in e&&e.cosmos_tx.msgs?.length&&f))throw new Error("Invalid transaction data");const R=xo(e.cosmos_tx.msgs,{converters:y,fromAmino:x.fromAmino.bind(x)}),D=await(await w(i)).simulate(a,R,""),J=await ka(j),K=Xy({gas:D,gasPrices:J});return ex({balances:f,requiredFeeByDenom:K,sourceDenom:c,amountIn:s.amount_in})}catch(R){throw await ct(R)}},enabled:A,retry:!1});return t(C?b?{exactFeeCheckError:b.message,isCheckingFeeBalance:!1}:p?{exactFeeCheckError:p instanceof Error?p.message:"Failed to load balances",isCheckingFeeBalance:!1}:v||g||f===void 0||T?{isCheckingFeeBalance:!0}:k?{exactFeeCheckError:k.message,isCheckingFeeBalance:!1}:$?{isCheckingFeeBalance:!1}:{exactFeeCheckError:"Insufficient balance for fees",isCheckingFeeBalance:!1}:{isCheckingFeeBalance:!1})}function f1({addressList:e,operations:t,signedOpHook:s}){return JSON.stringify({addressList:e,operations:t,signedOpHook:s??null})}function p1({previousQuoteVerifiedAt:e,quoteVerifiedAt:t,hasValue:s,hasMessageRefreshError:o}){return s&&o&&e!==void 0&&t!==void 0&&t!==e}function g1({error:e,loading:t,value:s}){const o=s!==void 0;return{isFetchingMessages:t,messageRefreshError:!t&&o&&e?e.message:void 0,shouldRenderError:!!e&&!o,shouldRenderLoading:!o}}const _l=({addressList:e,signedOpHook:t,children:s})=>{const o=Ue(),{route:a,values:r,quoteVerifiedAt:i}=wt(),[c,l]=_.useState(void 0),[u,m]=_.useState(!1),[d,h]=_.useState(null),[f,g]=_.useState(0),p=_.useRef(i),y=f1({addressList:e,operations:a.operations,signedOpHook:t});_.useEffect(()=>{const w=p.current;p1({previousQuoteVerifiedAt:w,quoteVerifiedAt:i,hasValue:c!==void 0,hasMessageRefreshError:d!==null})&&g(C=>C+1),p.current=i},[i,c,d]),_.useEffect(()=>{let w=!1;return(async()=>{try{if(m(!0),h(null),a.required_op_hook&&!t)throw new Error("Op hook is required");const j=await Jy(o,{addressList:e,route:{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,operations:a.operations},slippagePercent:String(r.slippagePercent),signedOpHook:t});if(w)return;const[b]=j;l(b)}catch(j){if(w)return;h(await ct(j))}finally{w||m(!1)}})(),()=>{w=!0}},[y,f,a.amount_in,a.amount_out,a.source_asset_chain_id,a.source_asset_denom,a.dest_asset_chain_id,a.dest_asset_denom,a.required_op_hook,r.slippagePercent,o]);const x=g1({error:d,loading:u,value:c});return x.shouldRenderError&&d?n.jsx(fl,{error:d}):x.shouldRenderLoading?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Fetching messages..."})}):s(c,{isFetchingMessages:x.isFetchingMessages,messageRefreshError:x.messageRefreshError})},yl=({children:e})=>{const{route:t}=wt(),s=nx();return t.required_op_hook&&!s.data?n.jsx(Ae,{extra:n.jsx(be,{level:"error",children:s.error?.message}),children:n.jsx(fe.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)};function _1({approvalError:e,approveTokens:t,isApproving:s}){return n.jsx(Ae,{extra:e&&n.jsx(be,{level:"error",children:e}),children:n.jsx(fe.White,{onClick:t,loading:s&&"Approving tokens...",children:"Approve tokens"})})}const y1=()=>n.jsx(Et,{title:"Route preview",children:n.jsx(pl,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(r1,{addressList:e}),n.jsx(yl,{children:t=>n.jsx(_l,{addressList:e,signedOpHook:t,children:(s,{isFetchingMessages:o,messageRefreshError:a})=>n.jsx(h1,{tx:s,children:({exactFeeCheckError:r,isCheckingFeeBalance:i})=>n.jsx(gl,{tx:s,children:({approvalError:c,approveTokens:l,isApproving:u,isCheckingApprovals:m,requiresApproval:d})=>{const h=Vx({approvalError:c,approveTokens:l,exactFeeCheckError:r,isApproving:u,isCheckingApprovals:m,isCheckingFeeBalance:i,isFetchingMessages:o,messageRefreshError:a,requiresApproval:d});return h.kind==="approval"?_1({approvalError:h.approvalError,approveTokens:h.approveTokens,isApproving:h.isApproving}):n.jsx(Ha,{tx:s,error:h.error,isCheckingApprovals:h.isCheckingApprovals,isCheckingFeeBalance:h.isCheckingFeeBalance,isFetchingMessages:h.isFetchingMessages,messageRefreshError:h.messageRefreshError})}})})})})]})})}),xl=_.createContext(null);function bo(){return _.useContext(xl)}const x1="_button_17r1o_1",w1="_claimed_17r1o_24",Fr={button:x1,claimed:w1},b1=()=>{const{withdrawalTx:e}=bo(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:u}=e,m=ce(),d=ie(),{requestTxSync:h,waitForTxConfirmation:f}=tt(),g=Qy(e),p=de.toBase64(ll(e)),y=cl(e,p),x=E.useQueryClient(),{mutate:w,isPending:C}=E.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:j}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:d,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(de.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:de.fromBase64(u),storageRoot:de.fromBase64(i),lastBlockHash:de.fromBase64(j)}}],internal:!0})},onSuccess:async j=>{await f({chainId:m.chain_id,txHash:j}),x.invalidateQueries({queryKey:jn.withdrawalClaimed(t,p).queryKey})}});return y?n.jsxs("div",{className:Fr.claimed,children:[n.jsx(M.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:Fr.button,onClick:()=>w(),disabled:C,children:"Claim"})},v1=({children:e})=>{const{withdrawalTx:t}=bo(),s=Ky(t.bridge_id),o=Hy(t),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Xe.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},wl=1e3,j1=60,C1=60,N1=24,ia=wl*j1,ca=ia*C1,Br=ca*N1,k1=({date:e})=>{const t=_.useCallback(()=>{const u=new Date().getTime(),d=e.getTime()-u;if(d<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(d/Br),f=Math.floor(d%Br/ca),g=Math.floor(d%ca/ia),p=Math.floor(d%ia/wl);return{days:h,hours:f,minutes:g,seconds:p}},[e]),[s,o]=_.useState(t());_.useEffect(()=>{const u=window.setInterval(()=>{o(t())},1e3);return()=>window.clearInterval(u)},[t,e]);const a=u=>u.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return n.jsx(_s,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},I1="_container_1lz3w_1",A1="_title_1lz3w_5",Ur={container:I1,title:A1},S1=({date:e})=>n.jsxs("div",{className:Ur.container,children:[n.jsx("div",{className:Ur.title,children:"Claimable in"}),n.jsx(k1,{date:e})]}),T1="_container_1oldz_1",E1="_icon_1oldz_7",Or={container:T1,icon:E1},$1="Withdrawal will begin within an hour",Vr=()=>{const e=uo();return n.jsxs("div",{className:Or.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(_s,{label:$1,children:n.jsx("span",{className:Or.icon,children:n.jsx(M.IconInfoFilled,{size:12})})})]})},M1=({children:e})=>{const{withdrawalTx:t}=bo(),s=zy(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},L1=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=bo(),a=de.toBase64(ll(o)),r=cl(o,a),{setReminder:i,removeReminder:c}=Bn();return _.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:Xe.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},q1=()=>n.jsx(M1,{children:e=>e?n.jsx(Vr,{}):n.jsx(v1,{children:t=>t?n.jsx(L1,{date:t,children:Xe.isFuture(t)?n.jsx(S1,{date:t}):n.jsx(b1,{})}):n.jsx(Vr,{})})}),P1="_asset_6h8u2_1",R1="_info_6h8u2_7",D1="_symbol_6h8u2_11",zo={asset:P1,info:R1,symbol:D1},F1=({amount:e,denom:t})=>{const s=ce(),o=ji(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:zo.asset,children:[n.jsx(oe,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:zo.info,children:[n.jsx("span",{className:"monospace",children:N.formatAmount(e,{decimals:i})}),n.jsx("span",{className:zo.symbol,children:a})]})]})},B1="_item_km5w2_1",U1={item:B1},O1=({chain:e})=>{const t=e.metadata?.executor_uri;if(!t)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=Wy(t),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Bn();return _.useEffect(()=>{const l=i.map(u=>({chainId:e.chainId,txHash:u.tx_hash}));c(l)},[e.chainId,i,c]),i.length?n.jsxs(n.Fragment,{children:[i.map(l=>{const{amount:u}=l;return n.jsxs("div",{className:U1.item,children:[n.jsx(F1,{...u}),n.jsx(xe,{suspenseFallback:null,children:n.jsx(xl.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(q1,{})})})]},l.sequence)}),a&&n.jsx(ol,{onClick:()=>o(),disabled:r})]}):n.jsx(je,{children:"No withdrawals"})},V1="_content_dj1qm_1",K1="_title_dj1qm_5",Kr={content:V1,title:K1},W1=()=>{const{chainId:e}=et(),t=_e(),s=wn(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=lt(),{reminders:i}=Bn(),c=o?r(o):void 0;return n.jsxs(Et,{title:"OP Bridge withdrawals",children:[n.jsx(pn,{chains:t.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(u=>u.chainId===l)}),n.jsx("div",{className:Kr.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Kr.title,children:c.name}),n.jsx(xe,{children:n.jsx(O1,{chain:c})},o)]}):n.jsx(be,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Pn=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),z1="5722e7dffb709492cf5312446ceeff73",H1=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${z1}`,bl=["interwovenkit:walletconnect-wallets"],Q1=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",vl=async e=>{const t=await H.get(H1,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(Q1)},G1=()=>E.useQuery({queryKey:bl,queryFn:({signal:e})=>vl(e),staleTime:V.INFINITY,gcTime:V.INFINITY,retry:2}),Y1="_page_13y8q_1",Z1="_pageTop_13y8q_19",J1="_backButtonFixed_13y8q_63",X1="_listItem_13y8q_64",e0="_socialButton_13y8q_65",t0="_arrowIcon_13y8q_66",n0="_searchInputUnderline_13y8q_67",s0="_header_13y8q_72",o0="_title_13y8q_81",a0="_headerSpacer_13y8q_116",r0="_icon_13y8q_120",i0="_installedText_13y8q_124",c0="_divider_13y8q_131",l0="_dividerText_13y8q_152",u0="_loading_13y8q_193",d0="_socialIcons_13y8q_198",m0="_socialText_13y8q_204",h0="_searchWrapper_13y8q_214",f0="_scrollable_13y8q_248",p0="_list_13y8q_64",g0="_listIconWrapper_13y8q_332",_0="_moreIconSmall_13y8q_342",y0="_externalLinkIcon_13y8q_364",x0="_listName_13y8q_368",w0="_listNameMuted_13y8q_381",b0="_recentBadge_13y8q_394",v0="_learnMoreLink_13y8q_408",U={page:Y1,pageTop:Z1,backButtonFixed:J1,listItem:X1,socialButton:e0,arrowIcon:t0,searchInputUnderline:n0,header:s0,title:o0,headerSpacer:a0,icon:r0,installedText:i0,divider:c0,dividerText:l0,loading:u0,socialIcons:d0,socialText:m0,searchWrapper:h0,scrollable:f0,list:p0,listIconWrapper:g0,moreIconSmall:_0,externalLinkIcon:y0,listName:x0,listNameMuted:w0,recentBadge:b0,learnMoreLink:v0},j0=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},C0=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=_.useState(""),{data:l=[],isError:u,isLoading:m,isFetching:d}=G1(),h=m||d&&l.length===0,f=_.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(y=>y.name.toLowerCase().includes(p))},[e,i]),g=_.useMemo(()=>{const p=new Set(e.map(x=>Pn(x.name))),y=i.toLowerCase();return l.filter(x=>!p.has(Pn(x.name))).filter(x=>!i||x.name.toLowerCase().includes(y)).sort((x,w)=>x.name.localeCompare(w.name))},[l,e,i]);return n.jsxs("div",{className:U.pageTop,children:[n.jsx("button",{type:"button",className:U.backButtonFixed,onClick:r,"aria-label":"Back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"All Wallets"}),n.jsx("div",{className:U.headerSpacer})]}),n.jsx("div",{className:U.searchWrapper,children:n.jsx(ys,{rootClassName:U.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),n.jsx(xt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[f.map(p=>{const{name:y,icon:x,id:w}=p,C=o===w,j=s===w,b="ready"in p?!!p.ready:!0;return n.jsxs("button",{type:"button",className:P(U.listItem,{[U.loading]:j}),onClick:()=>a(p),disabled:t||!b,"aria-busy":j,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(oe,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:y}),j?n.jsx(At,{size:16}):C?n.jsx("span",{className:U.recentBadge,children:"Recent"}):b?n.jsx("span",{className:U.installedText,children:"Installed"}):null]},`connector:${w}`)}),h&&n.jsxs("div",{className:P(U.listItem,U.loading),role:"status","aria-live":"polite",children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(At,{size:16})}),n.jsx("span",{className:U.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const y=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,x=y&&j0(y)?y:void 0;return n.jsxs("button",{type:"button",className:U.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[n.jsx("div",{className:U.listIconWrapper,children:x&&n.jsx(oe,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:p.name})]},`wc:${p.id}`)}),u&&n.jsx(be,{level:"error",children:"Couldn't load additional wallets."})]})})]})},N0=(e,t,s,o)=>{if(e.length<=s)return[...e];const a=o?e.findIndex(d=>d.id===o):-1,r=a>=0?e[a]:void 0,i=a>=0?e.filter((d,h)=>h!==a):e,c=new Set(t.map(d=>d.id)),l=new Set(t.map(d=>Pn(d.name))),u=[],m=[];for(const d of i)c.has(d.id)||l.has(Pn(d.name))?u.push(d):m.push(d);return r?[r,...u,...m].slice(0,s):u.concat(m).slice(0,s)},k0=()=>n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),I0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[n.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),n.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),n.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),n.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),A0=()=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),S0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Wr=[{id:"io.rabby",name:"Rabby",icon:"https://assets.initia.xyz/images/wallets/Rabby.webp",url:"https://rabby.io"},{id:"app.phantom",name:"Phantom",icon:"https://assets.initia.xyz/images/wallets/Phantom.webp",url:"https://phantom.com"},{id:"app.keplr",name:"Keplr",icon:"https://assets.initia.xyz/images/wallets/Keplr.webp",url:"https://keplr.app"},{id:"io.leapwallet",name:"Leap",icon:"https://assets.initia.xyz/images/wallets/Leap.webp",url:"https://leapwallet.io"},{id:"io.metamask",name:"MetaMask",icon:"https://assets.initia.xyz/images/wallets/MetaMask.webp",url:"https://metamask.io"}],zr=5,T0=({walletConnectors:e,privyConnector:t,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),u=N0(l,Wr,zr,a),m=new Set(l.map(g=>g.id)),d=new Set(l.map(g=>Pn(g.name))),h=Math.max(0,zr-u.length),f=Wr.filter(g=>!m.has(g.id)&&!d.has(Pn(g.name))).slice(0,h);return n.jsxs("div",{className:U.page,children:[n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"Sign In"}),n.jsx("div",{className:U.headerSpacer})]}),t&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:P(U.socialButton,{[U.loading]:o===t.id}),onClick:()=>r(t),disabled:s,"aria-busy":o===t.id,children:[n.jsx("span",{className:U.socialText,children:"Email / Socials"}),o===t.id?n.jsx(At,{size:16}):n.jsxs("div",{className:U.socialIcons,children:[n.jsx(I0,{}),n.jsx(S0,{}),n.jsx(A0,{})]})]}),n.jsx("div",{className:U.divider,children:n.jsx("span",{className:U.dividerText,children:"or"})})]}),n.jsx(xt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[u.map(g=>{const{icon:p,id:y,name:x,uid:w}=g,C=o===y,j=a===y;return n.jsxs("button",{type:"button",className:P(U.listItem,{[U.loading]:C}),onClick:()=>r(g),disabled:s,"aria-busy":C,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(oe,{src:p,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:x}),C?n.jsx(At,{size:16}):j?n.jsx("span",{className:U.recentBadge,children:"Recent"}):n.jsx("span",{className:U.installedText,children:"Installed"})]},w)}),f.map(g=>n.jsxs("a",{className:U.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(oe,{src:g.icon,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:g.name}),n.jsx(M.IconExternalLink,{size:10,className:U.externalLinkIcon,"aria-hidden":"true"})]},g.id)),n.jsxs("button",{type:"button",className:U.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx("div",{className:U.moreIconSmall,children:n.jsx(k0,{})})}),n.jsx("span",{className:U.listNameMuted,children:"More wallets"}),n.jsx("span",{className:U.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),n.jsxs("a",{className:U.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Hr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=He.useConnect(),o=Qe.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,c]=_.useState("signin"),l=E.useQueryClient(),u=()=>l.prefetchQuery({queryKey:bl,queryFn:({signal:p})=>vl(p),staleTime:V.INFINITY,gcTime:V.INFINITY}),{mutate:m,isPending:d}=E.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(y){throw await ct(y)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=_.useMemo(()=>[...t].sort((p,y)=>p.id===o?-1:y.id===o?1:p.name.localeCompare(y.name)),[t,o]),f=_.useMemo(()=>h.find(p=>p.id===Jn.id),[h]),g=_.useMemo(()=>h.filter(p=>p.id!==Jn.id),[h]);return i==="all"?n.jsx(C0,{walletConnectors:g,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):n.jsx(T0,{walletConnectors:g,privyConnector:f,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:u})},E0="iUSD",Qr="1",$0="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",M0="0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",L0={[E0]:{externalSourceSymbols:["USDC","AUSD"],extraExternalOptions:[{chainId:Qr,denom:$0},{chainId:Qr,denom:M0}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Gr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function q0(e){return L0[e]}function Yr(e){return e.pretty_name||e.chain_name}function Zr(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const P0={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:""};function R0({chainIds:e,chains:t}){return Object.fromEntries(e.map(s=>[s,t?.[s]?.denoms??{}]))}const D0={deposit:{mode:"deposit",label:"Deposit",local:{denomKey:"dstDenom",chainIdKey:"dstChainId"},external:{denomKey:"srcDenom",chainIdKey:"srcChainId"}},withdraw:{mode:"withdraw",label:"Withdraw",local:{denomKey:"srcDenom",chainIdKey:"srcChainId"},external:{denomKey:"dstDenom",chainIdKey:"dstChainId"}}};function ws(e){return D0[e]}function F0(){const e=Ue(),{data:t,error:s}=E.useQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:o})=>o.filter(({chain_type:a,bech32_prefix:r})=>a==="evm"||a==="cosmos"&&r==="init"),staleTime:V.MINUTE});return{chains:t??[],error:s}}function Qa(){const e=Ue(),t=Fn(),s=ie(),{chains:o,error:a}=F0(),r=_.useMemo(()=>o.map(({chain_id:u})=>u),[o]),{data:i,error:c,isLoading:l}=E.useQuery({queryKey:Ie.allBalances(r,[t,s]).queryKey,queryFn:()=>{const u=Object.fromEntries(o.map(m=>[m.chain_id,{address:m.chain_type==="evm"?t:s,denoms:[]}]));return e.post("v2/info/balances",{json:{chains:u}}).json()},select:({chains:u})=>R0({chainIds:r,chains:u}),enabled:!!s&&r.length>0,staleTime:V.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Ga(){const{localOptions:e=[]}=et(),t=E.useQueryClient(),s=Ue(),{data:o,isLoading:a}=E.useQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:V.MINUTE});return{data:_.useMemo(()=>{if(o){const i=Object.values(o.chain_to_assets_map).flatMap(l=>l?.assets??[]),c=new Map(i.map(l=>[`${l.chain_id}:${l.denom}`,l]));return e.map(({denom:l,chainId:u})=>{const m=c.get(`${u}:${l}`);return{denom:l,chain_id:u,symbol:m?.symbol??"",logo_uri:m?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData(Mn.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Ya(e){const{local:t}=ws(e),s=ps(),{watch:o}=Xt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function B0(e){const{external:t}=ws(e),s=ps(),{watch:o}=Xt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function jl(e){const t=ps(),s=fo(),o=Bt(),a=Va(),{data:r,isLoading:i}=Qa(),{remoteOptions:c=[]}=et(),l=Ya(e);if(!l)return{...P0,isLoading:i};const u=q0(l.symbol),m=u?.externalSourceSymbols??[l.symbol],d=c.length>0,h=u?.extraExternalOptions??[],f=u?.extraInitiaSourceSymbols??[],g=u?.externalChainListSource??"supported-assets",p=new Map(s.map(b=>[b.chain_id,b])),y=t.filter(({symbol:b,denom:v,chain_id:I})=>{if(d)return c.some(R=>Gr(R,I,v));const S=h.some(R=>Gr(R,I,v)),A=p.get(I),$=!!A&&a(A.chain_id)&&f.includes(b),k=S||$;return b===l.symbol||k}).map(b=>{if(b.hidden||b.chain_id===l.chain_id)return null;const v=o(b.chain_id);if(!v||!Zr(v))return null;const I=r?.[v.chain_id]?.[b.denom];return{asset:b,chain:v,balance:I}}).filter(b=>b!==null),x=y.filter(({balance:b})=>e!=="deposit"||!!b&&Number(b.amount)>0),w=new Map;if(g==="extra-options")for(const{chainId:b}of h){const v=p.get(b);v&&Zr(v)&&(a(v.chain_id)||w.set(v.chain_id,v))}else for(const{chain:b}of x)a(b.chain_id)||w.set(b.chain_id,b);const C=Array.from(w.values()).sort((b,v)=>Yr(b).localeCompare(Yr(v))),j=[...new Set(y.filter(({chain:b})=>vg(b,a)).map(({asset:b})=>b.symbol))];return{data:x,isLoading:i,supportedExternalChains:C,appchainSourceSymbols:j,externalSourceSymbols:m,localSymbol:l.symbol}}function Xt(){return $e.useFormContext()}const U0="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",O0="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e";function la(e){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(", ")}, or ${e[e.length-1]}`}function V0(e,t,s){const o=[...new Set(e)],a=[],r=[...s,t];for(const c of r)o.includes(c)&&!a.includes(c)&&a.push(c);const i=o.filter(c=>!a.includes(c)).sort((c,l)=>c.localeCompare(l));return[...a,...i]}function K0(e,t,s){if(!e.length)return"";const o=V0(e,t,s);return o.length===1&&o[0]===t?"from any app":`using ${la(o)} from any app`}function W0({localSymbol:e,externalSourceSymbols:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=la(s),c=[...new Set(t)],l=la(c),u=K0(o,e,c),m=!!u,d=c.length!==1||c[0]!==e;if(r&&m){const h=d?`using ${l} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${h}, or ${u}.`}}return r?d?{title:a,description:`You can deposit ${e} using ${l} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:m?{title:a,description:`You can deposit ${e} ${u}.`}:{title:a,description:"No deposit sources are currently available."}}const z0="_container_pjkfr_1",H0="_title_pjkfr_5",Q0="_close_pjkfr_12",G0="_emptyIcon_pjkfr_24",Y0="_empty_pjkfr_24",Z0="_emptyDescription_pjkfr_39",J0="_list_pjkfr_60",X0="_asset_pjkfr_75",e2="_placeholder_pjkfr_91",t2="_activeAsset_pjkfr_104",n2="_iconContainer_pjkfr_108",s2="_assetIcon_pjkfr_118",o2="_chainIcon_pjkfr_128",a2="_assetPlaceholder_pjkfr_142",r2="_assetName_pjkfr_163",i2="_assetChain_pjkfr_178",c2="_balance_pjkfr_186",l2="_value_pjkfr_195",we={container:z0,title:H0,close:Q0,emptyIcon:G0,empty:Y0,emptyDescription:Z0,list:J0,asset:X0,placeholder:e2,activeAsset:t2,iconContainer:n2,assetIcon:s2,chainIcon:o2,assetPlaceholder:a2,assetName:r2,assetChain:i2,balance:c2,value:l2},u2=({mode:e})=>{const{external:t}=ws(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbols:i,localSymbol:c}=jl(e),{setValue:l,watch:u}=Xt(),m=Ya(e),{data:d}=Ga(),{theme:h}=ae(),f=u(),g=f[t.denomKey],p=f[t.chainIdKey],x=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"";function w(b,v){l(t.denomKey,b),l(t.chainIdKey,v),e==="deposit"&&l("quantity",""),l("page","fields")}const C=_.useEffectEvent(()=>{if(!x)return;const[{asset:b,chain:v}]=s;if(g===b.denom&&p===v.chain_id){l("page","fields");return}w(b.denom,v.chain_id)});_.useEffect(()=>{C()},[x]);function j(){const b=g&&p;return!b&&d.length<=1&&e==="deposit"?null:n.jsx("button",{className:we.close,onClick:()=>{e==="withdraw"||b?l("page","fields"):l("page","select-local")},children:n.jsx(M.IconBack,{size:20})})}if(!m)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const b=a.map(S=>S.pretty_name||S.chain_name).filter(S=>!!S),v=W0({localSymbol:c,externalSourceSymbols:i,externalChainNames:b,appchainSourceSymbols:r}),I=e==="withdraw"?`No supported destinations to withdraw ${m.symbol}.`:v.title;return n.jsxs("div",{className:we.container,children:[j(),n.jsx("h4",{className:we.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?U0:O0,alt:"No assets",className:we.emptyIcon}),n.jsx("p",{className:we.empty,children:I}),e==="deposit"&&n.jsx("p",{className:we.emptyDescription,children:v.description})]})}return n.jsxs("div",{className:we.container,children:[j(),n.jsxs("h4",{className:we.title,children:[e==="withdraw"?"Select destination":`Deposit ${m.symbol}`," "]}),n.jsxs("div",{className:we.list,children:[o&&Array.from({length:5}).map((b,v)=>n.jsxs("div",{className:P(we.asset,we.placeholder),children:[n.jsxs("div",{className:we.iconContainer,children:[n.jsx("div",{className:we.assetIcon}),n.jsx("div",{className:we.chainIcon})]}),n.jsx("div",{className:we.assetPlaceholder})]},v)),!o&&s.sort(({balance:b},{balance:v})=>Number(v?.value_usd??0)-Number(b?.value_usd??0)).map(({asset:b,chain:v,balance:I})=>{const S=g===b.denom&&p===v.chain_id,A=Oa(I?.value_usd,I?.price);return n.jsxs("button",{className:P(we.asset,S&&we.activeAsset),onClick:()=>w(b.denom,v.chain_id),children:[n.jsxs("div",{className:we.iconContainer,children:[n.jsx("img",{src:b.logo_uri,alt:b.symbol,className:we.assetIcon}),n.jsx("img",{src:v.logo_uri||"",alt:v.chain_name,className:we.chainIcon})]}),n.jsxs("p",{className:we.assetName,children:[b.symbol," ",S&&n.jsx("span",{children:n.jsx(M.IconCheck,{size:16})})]}),n.jsxs("p",{className:we.assetChain,children:["on ",v.pretty_name]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:we.balance,children:N.formatAmount(I.amount,{decimals:I.decimals||6})}),n.jsx("p",{className:we.value,children:A})]})]},`${b.chain_id}-${b.denom}`)})]})]})},d2="_title_iequo_1",m2="_list_iequo_7",h2="_asset_iequo_15",f2="_imgPlaceholder_iequo_40",$s={title:d2,list:m2,asset:h2,imgPlaceholder:f2},p2=({mode:e})=>{const{local:t,external:s}=ws(e),{setValue:o}=Xt(),{data:a,isLoading:r}=Ga(),[i,c]=_.useTransition(),l=(m,d)=>{o(t.denomKey,m),o(t.chainIdKey,d),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},u=_.useEffectEvent(()=>{const{denom:m,chain_id:d}=a[0];l(m,d)});return _.useEffect(()=>{!r&&a.length===1&&u()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:$s.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:$s.list,"aria-busy":i,children:a.map(({denom:m,chain_id:d,symbol:h,logo_uri:f})=>n.jsxs("button",{className:$s.asset,onClick:()=>l(m,d),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:$s.imgPlaceholder,"aria-hidden":"true"}),h]},`${m}-${d}`))})]}):n.jsx("div",{children:"No assets found"})},g2="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",_2="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",y2="_container_9k4hs_1",x2="_title_9k4hs_8",w2="_subtitle_9k4hs_14",b2="_linkContainer_9k4hs_30",v2="_link_9k4hs_30",j2="_separator_9k4hs_51",C2="_errorIcon_9k4hs_62",N2="_error_9k4hs_62",De={container:y2,title:x2,subtitle:w2,linkContainer:b2,link:v2,separator:j2,errorIcon:C2,error:N2};function k2(e){if(!e)return"pending";const t=e.state;return t==="STATE_COMPLETED_SUCCESS"?"success":t==="STATE_ABANDONED"||t==="STATE_COMPLETED_ERROR"||t==="STATE_PENDING_ERROR"?"failed":"pending"}function ua({type:e}){const{closeModal:t}=Dn(),{theme:s}=ae(),{watch:o}=Xt(),{result:a}=o(),{openDrawer:r}=Ft();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,u=i?0:a.timestamp??0,{route:m,values:d}=a,{srcDenom:h,srcChainId:f,quantity:g}=d,p=St(h,f),y=e==="deposit"?"Deposit":"Withdraw",{data:x}=ul({chainId:l,txHash:c,tracked:!1}),{data:w}=dl({chainId:l,txHash:c,tracked:!!x,timestamp:u,route:m}),C=k2(w),j=s==="dark"?g2:_2,b=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,v=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return n.jsxs("div",{className:De.container,children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:j,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:a?.error}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]});const I=ss(m.estimated_route_duration_seconds),S=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${S.toString()}`,"https://explorer.skip.build"),$=()=>n.jsxs("div",{className:De.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:De.link,children:"View transaction"}),n.jsx("div",{className:De.separator}),n.jsx("button",{className:De.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:De.container,children:[C==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),n.jsx("video",{src:b,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:De.subtitle,children:["Estimated time: ",n.jsx("span",{children:I})]}),$(),n.jsx("p",{className:De.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," complete"]}),n.jsx("video",{src:v,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:k=>{const T=k.currentTarget;T.duration-T.currentTime<.1&&T.pause()}}),$(),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]}),C==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:j,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:"Your transaction could not be completed"}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const I2=qe.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),A2=({tx:e,children:t})=>{const{values:s}=wt(),{srcChainId:o}=s,a=ie(),r=cs(),i=bn(),c=us(),{data:l,isLoading:u,isFetching:m}=E.useQuery({queryKey:I2.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const f=xo(e.cosmos_tx.msgs,{converters:r,fromAmino:i.fromAmino.bind(i)});return{estimatedGas:await(await c(o)).simulate(a,f,""),messages:f}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if("cosmos_tx"in e&&!l&&u)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})});const d=l?.estimatedGas??null,h="cosmos_tx"in e&&(u||m);return n.jsx(n.Fragment,{children:t(d,{isEstimatingGas:h})})};function S2(e,t){return e?N.InitiaAddress(e).hex:t}function T2({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:S2(e.recipientAddress,o),slippagePercent:"0.1",...a}}}function E2({hasBalancesSnapshot:e,hasBalanceQueryError:t,isBalancesLoading:s}){if(!e){if(s)return"loading";if(t)return"error"}}function $2({hasBalancesSnapshot:e,balance:t}){if(e)return t??"0"}function Jr(e){if(!e)return null;const t=q(e);return!t.isFinite()||t.lt(0)?null:t}function M2({balance:e,requiredAmount:t}){if(t==="0")return!0;const s=Jr(e??"0"),o=Jr(t);return!s||!o?!1:s.gte(o)}function L2({sourceDenom:e,feeDetailsByDenom:t}){const s=t.get(e);if(!s||s.isSufficient)return;for(const[a,r]of t)if(a!==e&&r.isSufficient)return;if(q(s.balance).gte(s.fee))return"Make sure to leave enough for transaction fee"}function q2({feeDenom:e,sourceDenom:t,feeWarning:s,hasSourceBalance:o,isFeeBalanceSufficient:a}){if(!o)return{error:"Insufficient balance"};const r=e===t?s:void 0;return r?{warning:r}:a?{}:{error:"Insufficient balance"}}const P2="_container_11kmm_1",R2="_back_11kmm_6",D2="_title_11kmm_18",F2="_divider_11kmm_26",B2="_label_11kmm_30",U2="_asset_11kmm_37",O2="_assetIcon_11kmm_55",V2="_chainIcon_11kmm_67",K2="_assetName_11kmm_80",W2="_chevron_11kmm_92",z2="_input_11kmm_96",H2="_balanceContainer_11kmm_108",Q2="_value_11kmm_116",G2="_maxButton_11kmm_126",Y2="_detail_11kmm_142",Z2="_detailsContainer_11kmm_153",J2="_detailsButton_11kmm_163",X2="_expandableDetails_11kmm_184",ew="_detailValue_11kmm_192",tw="_detailToken_11kmm_202",nw="_receiveSummary_11kmm_210",Z={container:P2,back:R2,title:D2,divider:F2,label:B2,asset:U2,assetIcon:O2,chainIcon:V2,assetName:K2,chevron:W2,input:z2,balanceContainer:H2,value:Q2,maxButton:G2,detail:Y2,detailsContainer:Z2,detailsButton:J2,expandableDetails:X2,detailValue:ew,detailToken:tw,receiveSummary:nw},Cl=({renderFee:e})=>{const{route:t}=et(),{values:s}=wt(),{dstDenom:o,dstChainId:a}=s,i=ps().find(({denom:g,chain_id:p})=>g===o&&p===a),c=ie(),l=Rc(),[u,m]=Qe.useToggle(!1),d=_.useId(),h=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const f=el(t.amount_out,s.slippagePercent);return n.jsxs("div",{className:Z.detailsContainer,children:[n.jsxs("div",{children:[n.jsxs("button",{type:"button",className:Z.detailsButton,onClick:m,"aria-expanded":u,"aria-controls":d,children:["Transaction details"," ",n.jsx(M.IconChevronDown,{size:12,style:{transform:u?"rotate(180deg)":"rotate(0deg)"},"aria-hidden":"true"})]}),n.jsx(ts,{children:n.jsx("div",{id:d,children:u&&n.jsxs("div",{className:Z.expandableDetails,children:[t.does_swap&&n.jsxs("div",{className:Z.detail,children:[n.jsx("p",{className:Z.detailLabel,children:"Slippage"}),n.jsxs("p",{className:Z.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:Z.detail,children:[n.jsx("p",{className:Z.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:Z.detailValue,children:Wa(t.estimated_fees)})]}),e&&n.jsxs("div",{className:Z.detail,children:[n.jsx("p",{className:Z.detailLabel,children:"Tx fee"}),n.jsx("div",{className:Z.detailValue,children:e()})]}),c&&n.jsxs("div",{className:Z.detail,children:[n.jsx("p",{className:Z.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:Z.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",N.truncate(c)]})]}),t.does_swap&&n.jsxs("div",{className:Z.detail,children:[n.jsx("p",{className:Z.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:Z.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Z.detailToken})," ",N.formatAmount(f,{decimals:i.decimals})," ",i.symbol]})]})]})})})]}),n.jsxs("div",{className:Z.detail,children:[n.jsx("p",{className:Z.detailLabel,children:"Estimated time"}),n.jsx("p",{className:Z.detailValue,style:h?{color:"var(--warning)"}:void 0,children:ss(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:P(Z.detail,Z.receiveSummary),children:[n.jsx("p",{className:Z.detailLabel,children:"Estimated received"}),n.jsxs("p",{className:Z.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Z.detailToken})," ",N.formatAmount(t.amount_out,{decimals:i.decimals})," ",i.symbol]})]})]})},sw="_trigger_1c7d7_1",ow="_item_1c7d7_5",aw="_itemText_1c7d7_13",rw={trigger:sw,item:ow,itemText:aw};function iw(e){return!e.isFetchingMessages&&!e.messageRefreshError}function Nl(e,t,s){return iw(s)?n.jsx(gl,{tx:e,children:t}):t}function cw({feeDetailsByDenom:e,feeOptions:t,lastUsedFeeDenom:s,preferredFeeDenom:o}){if(o&&e.get(o)?.isSufficient)return o;if(s&&e.get(s)?.isSufficient)return s;for(const a of t){const[{denom:r}]=a.amount;if(e.get(r)?.isSufficient)return r}return t[0]?.amount[0].denom}const lw=({tx:e,gas:t,confirmMessage:s,onCompleted:o,messageRefreshError:a,isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c})=>{const{values:l}=wt(),{srcChainId:u,srcDenom:m,quantity:d}=l,f=ps().find(({denom:G,chain_id:te})=>G===m&&te===u),g=yt(u),p=as(g),y=Ia(g),x=Aa(g),w=Tt(g),C=t==null?[]:y.map(({amount:G,denom:te})=>Le.calculateFee(Math.ceil(t*Qt),Le.GasPrice.fromString(G+te))),j=new Map(C.map(G=>{const[{denom:te}]=G.amount;return[te,G]})),b=new Map(p.map(({denom:G,amount:te})=>[G,te])),v=f?q(d||"0").times(q(10).pow(f.decimals)).toFixed(0):"0",I=new Map(C.map(G=>{const[{amount:te,denom:ue}]=G.amount,ye=b.get(ue)??"0",me=f&&m===ue?v:"0",Ce=q(te).plus(me),{symbol:Se,decimals:Ne}=w(ue);return[ue,{symbol:Se,decimals:Ne,spend:q(me).gt(0)?me:null,fee:te,total:Ce.toFixed(),balance:ye,isSufficient:q(ye).gte(Ce)}]})),[S,A]=_.useState(null),$={isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c,messageRefreshError:a},k=cw({feeDetailsByDenom:I,feeOptions:C,lastUsedFeeDenom:x,preferredFeeDenom:S}),T=k?j.get(k):void 0,R=k?I.get(k):null,B=L2({sourceDenom:m,feeDetailsByDenom:I}),D=M2({balance:b.get(m)??"0",requiredAmount:v}),J=q2({feeDenom:k,sourceDenom:m,feeWarning:B,hasSourceBalance:D,isFeeBalanceSufficient:R?.isSufficient??!0}),K=n.jsx(Ha,{tx:e,fee:T,onCompleted:o,confirmMessage:s,error:J.error,warning:J.warning,...$}),z=(G,te)=>{if(N.formatAmount(G,{decimals:te})==="0.000000")return 8},O=G=>{const[{amount:te,denom:ue}]=G.amount;if(q(te).isZero())return"0";const{symbol:ye,decimals:me}=w(ue),Ce=z(te,me);return`${N.formatAmount(te,{decimals:me,dp:Ce})} ${ye}`},X=()=>{if(C.length===0)return null;if(C.length===1)return n.jsx("span",{className:"monospace",children:O(C[0])});if(!T||!k)return null;const G=C.map(Ce=>{const[{denom:Se}]=Ce.amount,{symbol:Ne}=w(Se);return{value:Se,label:O(Ce),triggerLabel:Ne}}),[{amount:te,denom:ue}]=T.amount,{decimals:ye}=w(ue),me=z(te,ye);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:N.formatAmount(te,{decimals:ye,dp:me})}),n.jsx(Ua,{options:G,value:k,onChange:A,classNames:rw})]})};return n.jsxs(n.Fragment,{children:[n.jsx(Cl,{renderFee:C.length>0?X:void 0}),Nl(e,K,$)]})},uw=({tx:e,gas:t,mode:s,messageRefreshError:o,isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i})=>{const{setValue:c}=Xt(),l={isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i,messageRefreshError:o},u=h=>{c("page","completed"),c("result",h)},m=s==="withdraw"?"Withdraw":"Deposit",d=n.jsx(Ha,{tx:e,fee:void 0,onCompleted:u,confirmMessage:m,...l});return"cosmos_tx"in e?n.jsx(lw,{tx:e,gas:t,onCompleted:u,confirmMessage:m,...l}):n.jsxs(n.Fragment,{children:[n.jsx(Cl,{}),Nl(e,d,l)]})};function Xr(e){const t=e.values;return{recipient:t?.recipient,sender:t?.sender}}function dw({currentState:e,nextState:t}){if(e.route!==t.route||e.quoteVerifiedAt!==t.quoteVerifiedAt)return!0;const s=Xr(e),o=Xr(t);return s.sender!==o.sender||s.recipient!==o.recipient}function mw({disabledMessage:e,routeForState:t,routeError:s,isNoRouteError:o,isServerError:a}){return e?"disabled":t?"ready":s?o?"no-route":a?"server-error":"refresh-failed":"loading"}function hw({hasRouteState:e,routeStatus:t}){return e&&(t==="ready"||t==="loading")}function fw({routeStatus:e,disabledMessage:t,isRouteSynced:s}){if(e==="disabled")return t;if(e==="loading"||e==="ready"&&!s)return"Fetching route...";if(e==="no-route")return"No route found";if(e==="server-error")return"Server error";if(e==="refresh-failed")return"Failed to refresh route"}const pw=typeof window>"u"?_.useEffect:_.useLayoutEffect,gw=({mode:e})=>{const t=ws(e),s=Me(),o=et(),{data:a}=Ga(),r=Bt(),{data:i,error:c,chainsError:l,isLoading:u}=Qa(),m=Fn(),{watch:d,setValue:h,getValues:f}=Xt(),g=d(),{srcChainId:p,srcDenom:y,quantity:x=""}=g,{recipientAddress:w,route:C}=o,j=g[t.external.denomKey],b=g[t.external.chainIdKey],v=Ya(e),I=B0(e),{data:S,isLoading:A}=jl(e),$=!A&&S.length===1,k=e==="withdraw"&&!A&&S.length>0&&new Set(S.map(({chain:ee})=>ee.chain_id)).size===1,T=_.useMemo(()=>A||!S.length?null:$?S[0]:k?S.reduce((ee,ve)=>{const Ve=Number(ee.balance?.value_usd??0);return Number(ve.balance?.value_usd??0)>Ve?ve:ee},S[0]):null,[S,$,k,A]),R=T?`${T.chain.chain_id}:${T.asset.denom}`:"",B=b?r(b):null,D=i?.[p]?.[y]?.amount,J=i?.[p]?.[y]?.price,K=q(J??0).times(x||0),[z]=Qe.useDebounceValue(x,300),O=e==="withdraw"?v:I,X=E2({hasBalancesSnapshot:i!==void 0,hasBalanceQueryError:!!(c||l),isBalancesLoading:u}),G=$2({hasBalancesSnapshot:i!==void 0,balance:D}),te=_.useMemo(()=>{if(e==="deposit"&&!I)return"Select asset";const ee=q(x||0);if(!ee.isFinite()||ee.lte(0))return"Enter amount";if(e==="withdraw"&&!I)return"Select destination";if(X==="loading")return"Loading balances...";if(X==="error")return"Failed to load balances";if(G!==void 0){const ve=N.fromBaseUnit(G,{decimals:O?.decimals||6});if(ee.gt(ve))return"Insufficient balance"}},[O,G,X,I,e,x]),ue=_.useMemo(()=>{if(e==="deposit"&&!I)return!0;const ee=q(x||0);if(!ee.isFinite()||ee.lte(0)||e==="withdraw"&&!I||X==="error")return!0;if(G!==void 0){const ve=N.fromBaseUnit(G,{decimals:O?.decimals||6});if(ee.gt(ve))return!0}return!1},[O,G,X,I,e,x]),{data:ye,error:me,dataUpdatedAt:Ce}=oa(z,{disabled:ue}),Se=me instanceof H.HTTPError&&me.response.status===400,Ne=!te&&!Se?ye:void 0,$t=Ne&&Ce>0?Ce:void 0,ut=me instanceof H.HTTPError&&me.response.status===500,Pe=mw({disabledMessage:te,routeForState:Ne,routeError:me,isNoRouteError:Se,isServerError:ut}),le=Pe==="ready"&&o.route===Ne,Y=Pe==="loading"||Pe==="ready"&&!le,Mt=hw({hasRouteState:!!o.route,routeStatus:Pe}),en=fw({routeStatus:Pe,disabledMessage:te,isRouteSynced:le});pw(()=>{const ee=T2({currentState:o,route:Ne,quoteVerifiedAt:$t,hexAddress:m,values:f()});dw({currentState:o,nextState:ee})&&s(0,ee)},[C,f,m,s,$t,w,Ne]);const Lt=_.useEffectEvent(()=>{if(!T||j&&b)return;const{asset:ee,chain:ve}=T;h(t.external.denomKey,ee.denom),h(t.external.chainIdKey,ve.chain_id),e==="deposit"&&h("quantity","")});if(_.useEffect(()=>{Lt()},[R]),!v||e==="deposit"&&!I)return null;const bt=O?.decimals||6,tn=e==="withdraw"?"Select chain":"Select asset",dt=()=>{h("quantity",""),h(t.external.denomKey,""),h(t.external.chainIdKey,""),(e==="withdraw"||$)&&(h(t.local.denomKey,""),h(t.local.chainIdKey,"")),h("page",e==="withdraw"||$?"select-local":"select-external")},Oe=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Z.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:Z.asset,disabled:$,onClick:()=>h("page","select-external"),children:[n.jsx("div",{className:Z.assetIcon,children:I?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol}),n.jsx("img",{src:B?.logo_uri||"",alt:B?.pretty_name,className:Z.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:Z.chainIcon})}),n.jsx("p",{className:Z.assetName,children:I?n.jsxs(n.Fragment,{children:[I.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",B?.pretty_name]})]}):tn}),!$&&n.jsx(M.IconChevronDown,{className:Z.chevron,size:16})]})]}),nt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Z.label,children:"Amount"}),n.jsx(ns,{balance:G,decimals:bt,className:Z.input}),G!==void 0&&n.jsxs("div",{className:Z.balanceContainer,children:[n.jsx("p",{className:Z.value,children:x?Oa(K.toString(),J):"$-"}),n.jsxs("button",{className:Z.maxButton,onClick:()=>{const ee=N.fromBaseUnit(G,{decimals:bt});q(x||0).eq(ee)||h("quantity",ee)},children:[n.jsx(M.IconWallet,{size:16})," ",N.formatAmount(G,{decimals:bt})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("section",{className:Z.container,"aria-label":"Transfer form",children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:Z.back,onClick:dt,children:n.jsx(M.IconBack,{size:20})}),n.jsxs("h3",{className:Z.title,children:[t.label," ",v.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[nt,n.jsx("div",{className:Z.divider}),Oe]}):n.jsxs(n.Fragment,{children:[Oe,n.jsx("div",{className:Z.divider}),nt]}),(l||c)&&n.jsx(je,{error:!0,children:"Failed to load balances"}),Mt?n.jsx(pl,{children:ee=>n.jsx(yl,{children:ve=>n.jsx(_l,{addressList:ee,signedOpHook:ve,children:(Ve,{isFetchingMessages:mt,messageRefreshError:jo})=>n.jsx(A2,{tx:Ve,children:(bs,{isEstimatingGas:Co})=>n.jsx(xe,{suspenseFallback:n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})}),children:n.jsx(uw,{tx:Ve,gas:bs,mode:e,isRouteTransitioning:Y,isFetchingMessages:mt,isEstimatingGas:Co,messageRefreshError:jo})})})})})}):n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:Y&&"Fetching route...",disabled:!0,fullWidth:!0,children:en})})]})},_w="_container_7nl9j_1",yw="_page_7nl9j_5",ei={container:_w,page:yw},kl=({mode:e})=>{const t=$e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Qa(),n.jsx($e.FormProvider,{...t,children:n.jsx(xw,{mode:e})})},xw=({mode:e})=>{const{watch:t}=Xt(),s=t("page"),o=It.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return n.jsx(p2,{mode:e});case"select-external":return n.jsx(u2,{mode:e});case"fields":return n.jsx(gw,{mode:e});case"completed":return n.jsx(ua,{type:e})}};return n.jsx(ts,{children:n.jsx("div",{className:ei.container,children:o((r,i)=>n.jsx(It.animated.div,{style:r,className:ei.page,children:a(i)}))})})},ww=()=>n.jsx(kl,{mode:"deposit"}),bw=()=>n.jsx(kl,{mode:"withdraw"}),vw="_root_1lo0i_1",jw="_address_1lo0i_9",Cw="_copy_1lo0i_19",Nw="_labelWrapper_1lo0i_33",kw="_labelCopy_1lo0i_43",Iw="_labelCopied_1lo0i_47",Aw="_copied_1lo0i_55",Sw="_derived_1lo0i_65",Tw="_derivedLabel_1lo0i_79",Ew="_derivedAddress_1lo0i_83",$w="_hexAddress_1lo0i_89",Mw="_derivedCopy_1lo0i_94",We={root:vw,address:jw,copy:Cw,labelWrapper:Nw,labelCopy:kw,labelCopied:Iw,copied:Aw,derived:Sw,derivedLabel:Tw,derivedAddress:Ew,hexAddress:$w,derivedCopy:Mw},Lw=()=>{const e=_.useRef(null),t=_.useRef(null),{initiaAddress:s,hexAddress:o}=tt(),a=qc("--gray-0");return _.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new Xl({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"}}),t.current.append(e.current)))},[s,a]),n.jsx(Et,{title:"Receive",children:n.jsxs("div",{className:We.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:We.address,children:s}),n.jsx(Ws,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:P(We.copy,{[We.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy address",children:[n.jsx(M.IconCopy,{size:12,"aria-hidden":"true"}),n.jsxs("div",{className:We.labelWrapper,children:[n.jsx("span",{className:We.labelCopy,children:"Copy address"}),n.jsx("span",{className:We.labelCopied,children:"Copied!"})]})]})}),n.jsx(Ws,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:P(We.derived,{[We.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy derived address",children:[n.jsx("span",{className:We.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:We.derivedAddress,children:[n.jsx("span",{className:We.hexAddress,children:N.truncate(o)}),n.jsx(M.IconCopy,{size:12,className:We.derivedCopy,"aria-hidden":"true"}),i&&n.jsx("span",{className:We.copiedText,children:"Copied!"})]})]})})]})})};function qw(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function Pw(){const e=ie(),t=_e();return E.useQueries({queries:t.map(s=>({queryKey:Vs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Js(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=ec(o),r=e?ba(e,s.chainId):null,i=qw(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:V.SECOND,retry:!1}))})}const Rw="_countdown_vfms8_1",Dw={countdown:Rw},Fw=({expiration:e})=>{const t=()=>{const a=new Date,r=Xe.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),u=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${u}s`),m.join(" ")},[s,o]=_.useState(t());return Qe.useInterval(()=>{o(t())},1e3),Xe.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:Dw.countdown,children:s})]})},Bw="_container_1l528_1",Uw="_info_1l528_11",Ow="_header_1l528_17",Vw="_chainName_1l528_23",Kw="_expiration_1l528_29",Ww="_revokeButton_1l528_35",kn={container:Bw,info:Uw,header:Ow,chainName:Vw,expiration:Kw,revokeButton:Ww},zw=({chainId:e,grantee:t,expiration:s})=>{const o=yt(e),{mutate:a,isPending:r}=pc({grantee:t,internal:!0});return n.jsxs("div",{className:kn.container,children:[n.jsxs("div",{className:kn.info,children:[n.jsxs("div",{className:kn.header,children:[n.jsx(oe,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:kn.chainName,children:o.name})]}),n.jsx("div",{className:kn.expiration,children:s?n.jsx(Fw,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:kn.revokeButton,onClick:()=>a(e),disabled:r,"aria-busy":r,children:r?"Revoking...":"Revoke"})]})},Hw=({chainId:e,grants:t})=>{const s=new Map;for(const a of t){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=Na([r.expiration,i])}return[...s.values()].map(a=>_.createElement(zw,{...a,chainId:e,key:a.grantee}))},Qw="_content_q36qs_1",Gw={content:Qw},Yw=()=>{const e=Pw(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(je,{children:"No permissions found"}):n.jsx("div",{className:Gw.content,children:s.map(({chainId:o,grants:a})=>n.jsx(Hw,{chainId:o,grants:a},o))})};return n.jsx(Et,{title:"Manage auto-signing",backButton:"/settings",children:t()})},Zw="_version_1sf5y_1",Jw={version:Zw},Xw=()=>n.jsxs("aside",{className:Jw.version,children:["v","2.9.0"]}),eb="_link_se23z_1",tb="_title_se23z_17",nb="_subtitle_se23z_23",sb="_icon_se23z_30",Ms={link:eb,title:tb,subtitle:nb,icon:sb},Il=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:Ms.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:Ms.title,children:e}),t&&n.jsx("p",{className:Ms.subtitle,children:t})]}),n.jsx("div",{className:Ms.icon,children:s??n.jsx(M.IconChevronRight,{size:16,"aria-hidden":"true"})})]}),ob="https://export.initia.xyz/",ab=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(Il,{title:"Export private key",rightSection:n.jsx(M.IconExternalLink,{size:16}),onClick:()=>window.open(ob,"_blank",e)})},rb="_container_1vxr7_1",ib="_separator_1vxr7_7",ti={container:rb,separator:ib},cb=()=>{const e=Me(),{connector:t}=He.useAccount();return n.jsx(Et,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:ti.container,children:[n.jsx(Il,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ga&&n.jsx(ab,{}),n.jsx(Rt.Separator,{className:ti.separator}),n.jsx(Xw,{})]})})},lb="_trigger_1yjkd_1",ub="_icon_1yjkd_23",db="_full_1yjkd_27",mb="_triggerContent_1yjkd_32",hb="_triggerText_1yjkd_40",fb="_popoverBackdrop_1yjkd_51",pb="_popoverPositioner_1yjkd_70",gb="_popoverPopup_1yjkd_74",_b="_search_1yjkd_99",yb="_viewport_1yjkd_105",xb="_item_1yjkd_111",wb="_highlighted_1yjkd_127",bb="_active_1yjkd_131",vb="_itemContent_1yjkd_136",jb="_extra_1yjkd_142",Cb="_connectedTag_1yjkd_149",Ee={trigger:lb,icon:ub,full:db,triggerContent:mb,triggerText:hb,popoverBackdrop:fb,popoverPositioner:pb,popoverPopup:gb,search:_b,viewport:yb,item:xb,highlighted:wb,active:bb,itemContent:vb,extra:jb,connectedTag:Cb},vo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=ae(),[i,c]=_.useState(""),[l,u]=_.useState(!1),[m,d]=_.useState(0),[h,f]=_.useState(),g=_.useRef([]),p=_.useRef(null),y=_e(),x=s.map(k=>y.find(T=>T.chainId===k)).filter(Boolean),w=k=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:k,height:k,viewBox:"0 0 14 14",children:[n.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"}),n.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),C=_.useMemo(()=>({chainId:"",name:"All",logoUrl:w}),[]),j=_.useMemo(()=>{const k=[C,...x];if(!i)return k;const T=i.toLowerCase();return k.filter(R=>R.name.toLowerCase().includes(T)||R.chainId.toLowerCase().includes(T))},[x,i,C]),b=x.find(k=>k.chainId===e)||C,v=parseInt(qc("--drawer-offset")),I=6,S=()=>{if(c(""),d(-1),p.current){const T=p.current.getBoundingClientRect().bottom+I,R=window.innerHeight-T-2*v;f(R)}u(!0)};_.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=_.useCallback(k=>{switch(k.key){case"ArrowDown":k.preventDefault(),d(T=>(T+1)%j.length);break;case"ArrowUp":k.preventDefault(),d(T=>(T-1+j.length)%j.length);break;case"Enter":k.preventDefault(),j[m]&&(t(j[m].chainId),u(!1));break;case"Escape":k.preventDefault(),u(!1);break}},[j,m,t,u]),$=k=>{t(k),u(!1)};return n.jsxs(Cn.Popover.Root,{open:l,onOpenChange:S,modal:"trap-focus",children:[n.jsx(Cn.Popover.Trigger,{render:n.jsxs("button",{className:P(Ee.trigger,{[Ee.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[n.jsxs("div",{className:Ee.triggerContent,children:[typeof b.logoUrl=="string"?n.jsx(oe,{src:b.logoUrl,width:14,height:14,logo:!0}):b.logoUrl(14),n.jsx("span",{className:Ee.triggerText,children:b.name})]}),n.jsx(M.IconChevronDown,{size:16,className:Ee.icon})]})}),n.jsxs(Cn.Popover.Portal,{container:yn(),children:[n.jsx(Cn.Popover.Backdrop,{className:Ee.popoverBackdrop,onClick:()=>u(!1)}),n.jsx(Cn.Popover.Positioner,{className:Ee.popoverPositioner,align:"end",side:"bottom",sideOffset:I,collisionAvoidance:{side:"none"},children:n.jsxs(Cn.Popover.Popup,{className:P(Ee.popoverPopup,{[Ee.full]:a}),style:{maxHeight:h},children:[n.jsx(ys,{value:i,onChange:k=>{c(k.target.value),d(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search apps",rootClassName:Ee.search,ref:gs()}),n.jsx("div",{className:Ee.viewport,role:"listbox",children:j.length===0?n.jsx(je,{children:"No apps found"}):j.map(({chainId:k,name:T,logoUrl:R},B)=>n.jsxs("div",{className:P(Ee.item,{[Ee.highlighted]:B===m,[Ee.active]:e===k}),onClick:()=>$(k),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),$(k))},onMouseEnter:()=>d(B),role:"option","aria-selected":e===k,tabIndex:-1,ref:D=>{D&&(g.current[B]=D)},children:[n.jsxs("div",{className:Ee.itemContent,children:[typeof R=="string"?n.jsx(oe,{src:R,width:16,height:16,logo:!0}):R(16),n.jsx("span",{className:Ee.name,children:T}),k===r&&n.jsx("span",{className:Ee.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:Ee.extra,children:o(k)})]},k))})]})})]})]})},Nb="_container_1nap1_1",kb="_controls_1nap1_7",Ib="_search_1nap1_13",Za={container:Nb,controls:kb,search:Ib},Ab=({children:e})=>n.jsx("div",{className:Za.container,children:e}),Sb=({children:e})=>n.jsx("div",{className:Za.controls,children:e}),Tb=e=>n.jsx(ys,{...e,rootClassName:Za.search}),gt={Root:Ab,Controls:Sb,SearchInput:Tb},Al=Q.atom(""),Sl=Q.atom(""),Eb=Q.atom(""),$b=Q.atom(""),Mb=Q.atom(""),Lb="_change_1nm9m_1",qb="_positive_1nm9m_8",Pb="_negative_1nm9m_12",Ho={change:Lb,positive:qb,negative:Pb},Tl=({amount:e,asset:t})=>{const{denom:s,symbol:o,decimals:a}=t,r=new q(e).isPositive(),i=new q(e).abs().toString();return n.jsxs("div",{className:P(Ho.change,r?Ho.positive:Ho.negative),children:[r?"+":"-",N.formatAmount(i,{decimals:a})," ",o||s]})},Rb=({changes:e,chain:t})=>{const s=Tt(t);return e.map(({amount:o,denom:a},r)=>n.jsx(Tl,{amount:o,asset:s(a)},r))},Db=({changes:e,chain:t})=>{const s=Tt(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(Oc,{metadata:a,chain:t,children:i=>n.jsx(Tl,{amount:o,asset:s(i)})},r))},Fb=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=tt();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(Db,{changes:Uc(e,o),chain:t}):n.jsx(Rb,{changes:Bc(e,s),chain:t})},Bb="_message_1qc8m_1",Ub="_more_1qc8m_9",ni={message:Bb,more:Ub},Ob=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:ni.message,children:Ys.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:ni.more,children:`+${e.length-3} more`})]}),Vb="_link_1vbb0_1",Kb="_inner_1vbb0_16",Wb="_header_1vbb0_21",zb="_time_1vbb0_30",Hb="_error_1vbb0_36",Qb="_timestamp_1vbb0_40",Gb="_chainInfo_1vbb0_45",Yb="_content_1vbb0_53",Zb="_messages_1vbb0_61",Jb="_changes_1vbb0_67",Ct={link:Vb,inner:Kb,header:Wb,time:zb,error:Hb,timestamp:Qb,chainInfo:Gb,content:Yb,messages:Zb,changes:Jb},Xb=({txItem:e,chain:t})=>n.jsx(ho,{txHash:e.txhash,chainId:t.chainId,className:Ct.link,children:n.jsxs("div",{className:Ct.inner,children:[n.jsxs("div",{className:Ct.header,children:[n.jsxs("div",{className:Ct.time,children:[e.code!==0&&n.jsx(M.IconWarningFilled,{size:14,className:Ct.error}),n.jsx("span",{className:Ct.timestamp,children:Xe.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:Ct.chainInfo,children:[n.jsx(oe,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:Ct.content,children:[n.jsx("div",{className:Ct.messages,children:n.jsx(Ob,{messages:e.tx.body.messages})}),n.jsx("div",{className:Ct.changes,children:n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(Fb,{...e,chain:t})})})]})]})}),ev="_list_1mv55_1",tv="_dateGroup_1mv55_7",nv="_dateHeader_1mv55_12",sv="_more_1mv55_18",Ls={list:ev,dateGroup:tv,dateHeader:nv,more:sv},ov=({list:e,chainId:t})=>{const s=ie(),o=_.useMemo(()=>al(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(je,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Ls.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Ls.dateGroup,children:[n.jsx("div",{className:Ls.dateHeader,children:a}),r.map(i=>n.jsx(xe,{errorBoundaryProps:{fallback:null},children:n.jsx(Xb,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(ho,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},av=()=>{const{activities:e,isLoading:t}=yd(),[s,o]=Q.useAtom(Mb),a=ce(),r=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return t&&e.length===0?n.jsx(je,{children:"Loading activities..."}):!e.length&&!t?n.jsx(je,{children:"No activity yet"}):n.jsxs(gt.Root,{children:[n.jsx(gt.Controls,{children:n.jsx(vo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(ov,{list:i,chainId:s||a.chainId})]})},rv="_thumbnail_1xyqw_1",iv="_placeholder_1xyqw_18",cv="_clickable_1xyqw_24",Qn={thumbnail:rv,placeholder:iv,clickable:cv},lv=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=ae(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:P(Qn.thumbnail,Qn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(oe,{src:l,classNames:{placeholder:Qn.placeholder}})}):n.jsx("div",{className:Qn.thumbnail,style:{width:t,height:t},children:n.jsx(oe,{src:l,classNames:{placeholder:Qn.placeholder}})})},uv="_collectionName_qs5tw_1",dv="_nftName_qs5tw_6",mv="_chainInfo_qs5tw_10",Qo={collectionName:uv,nftName:dv,chainInfo:mv},Ja=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return n.jsxs("div",{className:a?.root,children:[n.jsx(lv,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:P(Qo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:P(Qo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:P(Qo.chainInfo,a?.chainInfo),children:[n.jsx(oe,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Xa=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function hv(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function fv(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const pv=()=>{const e=ie(),t=_e(),s=E.useQueries({queries:t.map(l=>({queryKey:Xa.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Js(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:V.SECOND}))}),o=s.map(L.prop("data")),a=fv(t,o),r=a.reduce((l,{chain:u})=>({...l,[u.chainId]:(l[u.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,u)=>l+u,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function gv(e){const t=si(e);return E.useQuery({queryKey:Xa.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await H.get(t).json();return{...s,image:si(s.image)}}catch{return{}}},staleTime:V.INFINITY})}function si(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const _v=({nftInfo:e,children:t})=>{const{data:s={}}=gv(e.nft.uri),o=hv(e,s);return t(o)},yv="_grid_1wwdn_1",xv="_root_1wwdn_7",wv="_collectionName_1wwdn_15",bv="_nftName_1wwdn_23",vv="_chainInfo_1wwdn_32",oi={grid:yv,root:xv,collectionName:wv,nftName:bv,chainInfo:vv},jv=()=>{const[e,t]=Q.useAtom(Eb),[s,o]=Q.useAtom($b),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=pv(),l=Me(),u=_.useMemo(()=>a.filter(({collection_addr:d,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const y=e.trim().toLowerCase();return d.toLowerCase().includes(y)||h.toLowerCase().includes(y)||f.token_id.toLowerCase().includes(y)||g.toLowerCase().includes(y)}return!0}),[a,s,e]),m=_.useMemo(()=>Array.from(new Set(a.map(({chain:d})=>d.chainId))),[a]);return c&&a.length===0?n.jsx(je,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(je,{children:"No NFTs"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(vo,{value:s,onChange:o,chainIds:m,renderExtra:d=>d?r[d]||0:i})]}),u.length===0?n.jsx(je,{children:"No NFTs found"}):n.jsx("div",{className:oi.grid,children:u.map(d=>{const{collection_addr:h,nft:f}=d;return n.jsx(_v,{nftInfo:d,children:g=>n.jsx(Ja,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:oi})},h+f.token_id)})})]})},El=_.createContext(null);function $l(){return _.useContext(El)}const Cv="_popup_nbecp_1",Nv="_item_nbecp_19",qs={popup:Cv,item:Nv},Ml=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:u}=l,[m,d]=_.useState(!1),h=Me(),f=$l(),{showNotification:g}=hs(),{defaultChainId:p}=ae(),{evm_chain_id:y}=wn(),x=He.useChainId(),{switchChainAsync:w}=He.useSwitchChain(),{watchAssetAsync:C}=He.useWatchAsset(),j=()=>{d(!1),h("/send",{denom:s,chain:l})},b=()=>{d(!1),h("/bridge",{srcChainId:u,srcDenom:s,quantity:""})},v=E.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const I=r;return await w({chainId:Number(y)}),C({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:I}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:I=>{g({type:"error",title:"Asset addition failed",description:I.message})}});return n.jsxs(Rt.Menu.Root,{open:m,onOpenChange:d,modal:!1,children:[n.jsx(Rt.Menu.Trigger,{render:t}),n.jsx(Rt.Menu.Portal,{container:f,children:n.jsx(Rt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(Rt.Menu.Popup,{className:qs.popup,children:[n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:j,children:[n.jsx(M.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:b,disabled:i,children:[n.jsx(M.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),u===p&&y===x&&!!c&&n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:()=>v.mutate(),disabled:v.isPending||v.data,children:[v.data?n.jsx(M.IconCheck,{size:16}):n.jsx(M.IconPlus,{size:16}),n.jsx("span",{children:"Add to Wallet"})]})]})})})]})},kv="_item_38qhm_1",Iv="_info_38qhm_23",Av="_images_38qhm_29",Sv="_name_38qhm_33",Tv="_value_38qhm_39",Ev="_amount_38qhm_47",$v="_usd_38qhm_53",rn={item:kv,info:Iv,images:Av,name:Sv,value:Tv,amount:Ev,usd:$v},Mv=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=N.formatAmount(t,{decimals:e.decimals});return n.jsx(Ml,{asset:e,children:n.jsxs("button",{className:rn.item,children:[n.jsxs("div",{className:rn.info,children:[n.jsx(_o,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:rn.images}),n.jsx("span",{className:rn.name,children:a.name})]}),n.jsxs("div",{className:rn.value,children:[n.jsx("span",{className:rn.amount,children:r}),Number(s)>0&&n.jsx("span",{className:rn.usd,children:se(s)})]})]})})},Lv="_container_ytg3p_1",qv="_assetItem_ytg3p_6",Pv="_expandIcon_ytg3p_22",Rv="_assetInfo_ytg3p_27",Dv="_logo_ytg3p_33",Fv="_details_ytg3p_37",Bv="_symbol_ytg3p_42",Uv="_chainName_ytg3p_53",Ov="_chainInfos_ytg3p_59",Vv="_chainLogos_ytg3p_65",Kv="_chainLogo_ytg3p_65",Wv="_moreChains_ytg3p_76",zv="_expanded_ytg3p_93",Hv="_valueColumn_ytg3p_98",Qv="_amount_ytg3p_108",Gv="_value_ytg3p_98",Yv="_collapsibleContent_ytg3p_121",Zv="_chainsList_ytg3p_151",Te={container:Lv,assetItem:qv,expandIcon:Pv,assetInfo:Rv,logo:Dv,details:Fv,symbol:Bv,chainName:Uv,chainInfos:Ov,chainLogos:Vv,chainLogo:Kv,moreChains:Wv,expanded:zv,valueColumn:Hv,amount:Qv,value:Gv,collapsibleContent:Yv,chainsList:Zv},Jv=Q.atom([]),er=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=Q.useAtom(Jv),c=_.useMemo(()=>Pd(e),[e]),l=_.useMemo(()=>gc(e),[e]),u=r.includes(t),m=()=>{i(h=>u?h.filter(f=>f!==t):[...new Set([...h,t])])},d=()=>n.jsxs("button",{className:Te.assetItem,children:[n.jsxs("div",{className:Te.assetInfo,children:[s&&n.jsx(oe,{src:s,width:32,height:32,className:Te.logo,logo:!0}),n.jsxs("div",{className:Te.details,children:[n.jsx("div",{className:Te.symbol,children:t}),a?n.jsx("div",{className:Te.chainName,children:o[0].chain.name}):n.jsxs("div",{className:Te.chainInfos,children:[n.jsx("div",{className:Te.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(oe,{src:h.logoUrl,width:16,height:16,className:Te.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:Te.moreChains,children:["+",o.length-5]}),n.jsx(M.IconChevronDown,{size:16,className:P(Te.expandIcon,{[Te.expanded]:u})})]})]})]}),n.jsxs("div",{className:Te.valueColumn,children:[n.jsx("div",{className:Te.amount,children:N.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:Te.value,children:se(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:Te.container,children:n.jsx(Ml,{asset:h,children:d()})})}return n.jsx("div",{className:Te.container,children:n.jsxs(ne.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:d()}),n.jsx(ne.Collapsible.Content,{className:Te.collapsibleContent,children:n.jsx("div",{className:Te.chainsList,children:o.map(h=>n.jsx(Mv,{asset:h},h.chain.chainId))})})]})})},Xv="_collapsible_1g7rh_1",ej="_trigger_1g7rh_5",tj="_divider_1g7rh_20",nj="_label_1g7rh_28",sj="_chevron_1g7rh_33",oj="_content_1g7rh_41",aj="_list_1g7rh_45",Wt={collapsible:Xv,trigger:ej,divider:tj,label:nj,chevron:sj,content:oj,list:aj},Ll=({unlistedAssets:e})=>{const[t,s]=_.useState(!1),o=$l(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const d=a.current.scrollHeight;i(d)}},[e]);const c=_.useRef(null),l=d=>{s(d),d&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const x=g.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},u=It.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),m=_.useMemo(()=>e.map(d=>({...d,assets:[d],totalValue:d.value??0,totalAmount:Number(d.quantity)})),[e]);return e.length===0?null:n.jsxs(ne.Collapsible.Root,{open:t,onOpenChange:l,className:Wt.collapsible,children:[n.jsxs(ne.Collapsible.Trigger,{ref:c,className:Wt.trigger,children:[n.jsx("div",{className:Wt.divider}),n.jsxs("span",{className:Wt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(M.IconChevronDown,{className:Wt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Wt.divider})]}),n.jsx(ne.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(It.animated.div,{className:Wt.content,style:u,children:n.jsx("div",{className:Wt.list,ref:a,children:m.map(d=>n.jsx(er,{assetGroup:d},d.assets[0].denom))})})})]})},rj="_container_15xfg_1",ij="_header_15xfg_7",cj="_title_15xfg_13",lj="_totalValue_15xfg_19",uj="_list_15xfg_26",En={container:rj,header:ij,title:cj,totalValue:lj,list:uj},dj=()=>{const[e,t]=Q.useAtom(Al),[s,o]=Q.useAtom(Sl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=Ta(),u=i.map(({chainId:h})=>h),m=_.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:y}=g;return p.toLowerCase().includes(e.toLowerCase())||y.some(({denom:x,address:w})=>x.toLowerCase().includes(e.toLowerCase())||w?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),d=_.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?n.jsx(je,{children:"Loading assets..."}):!m.length&&!d.length&&!e&&!s&&!l?n.jsx(je,{children:"No assets"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(vo,{value:s,onChange:o,chainIds:u,renderExtra:h=>{if(!h)return se(c);const f=i.find(g=>g.chainId===h);return f?se(f.value):null}})]}),n.jsx("div",{children:m.length===0&&d.length===0?n.jsx(je,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:En.list,children:m.map(h=>n.jsx(er,{assetGroup:h},h.symbol))}),n.jsx(Ll,{unlistedAssets:d})]})})]})},mj="_container_11k2x_1",hj={container:mj},Nt=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(gn,{height:e,width:s}):n.jsx("div",{className:hj.container,"aria-hidden":"true",children:o.map(a=>n.jsx(gn,{height:e,width:s},a))})},fj=_.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ms(),l=ce(),{listedGroups:u,unlistedAssets:m}=_.useMemo(()=>th(i,a,r,l.chainId),[i,a,r,l.chainId]),d=_.useMemo(()=>Zm(u,s,o),[u,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=_.useMemo(()=>eh(d,m,e,t),[d,m,e,t]);return n.jsxs("div",{className:En.container,children:[n.jsxs("div",{className:En.header,children:[n.jsx("span",{className:En.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:En.totalValue,children:se(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:En.list,children:h.map(p=>n.jsx(er,{assetGroup:p},p.symbol))}),n.jsx(Ll,{unlistedAssets:g})]}):d.length===0&&c?n.jsx(Nt,{height:56,length:3}):n.jsx(je,{children:"No liquid assets"})]})}),pj="_container_vjtpl_1",gj="_section_vjtpl_7",_j="_sectionHeader_vjtpl_19",yj="_sectionTitle_vjtpl_25",xj="_sectionLabel_vjtpl_31",wj="_sectionTitleLink_vjtpl_49",bj="_sectionValue_vjtpl_63",vj="_tokenList_vjtpl_70",jj="_stakingTokenList_vjtpl_76",Cj="_tokenRow_vjtpl_86",Nj="_tokenMain_vjtpl_92",kj="_tokenTrigger_vjtpl_98",Ij="_tokenChevron_vjtpl_114",Aj="_expanded_vjtpl_125",Sj="_triggerValue_vjtpl_129",Tj="_tokenInfo_vjtpl_136",Ej="_tokenInfoLabel_vjtpl_142",$j="_tokenLogo_vjtpl_148",Mj="_tokenSymbol_vjtpl_152",Lj="_tokenValues_vjtpl_158",qj="_tokenAmount_vjtpl_164",Pj="_tokenValue_vjtpl_158",Rj="_typeBreakdown_vjtpl_178",Dj="_typeRow_vjtpl_186",Fj="_typeLabel_vjtpl_194",Bj="_typeValues_vjtpl_200",Uj="_typeAmount_vjtpl_206",Oj="_typeValue_vjtpl_200",Vj="_perpRow_vjtpl_220",Kj="_perpLeft_vjtpl_227",Wj="_perpLogo_vjtpl_235",zj="_perpInfo_vjtpl_241",Hj="_perpPair_vjtpl_249",Qj="_perpDirectionLong_vjtpl_255",Gj="_perpDirectionShort_vjtpl_261",Yj="_perpRight_vjtpl_267",Zj="_perpValue_vjtpl_275",Jj="_perpPnl_vjtpl_283",Xj="_perpPnlPositive_vjtpl_290",eC="_perpPnlNegative_vjtpl_294",tC="_perpPnlNeutral_vjtpl_298",nC="_collapsibleContent_vjtpl_302",W={container:pj,section:gj,sectionHeader:_j,sectionTitle:yj,sectionLabel:xj,sectionTitleLink:wj,sectionValue:bj,tokenList:vj,stakingTokenList:jj,tokenRow:Cj,tokenMain:Nj,tokenTrigger:kj,tokenChevron:Ij,expanded:Aj,triggerValue:Sj,tokenInfo:Tj,tokenInfoLabel:Ej,tokenLogo:$j,tokenSymbol:Mj,tokenValues:Lj,tokenAmount:qj,tokenValue:Pj,typeBreakdown:Rj,typeRow:Dj,typeLabel:Fj,typeValues:Bj,typeAmount:Uj,typeValue:Oj,perpRow:Vj,perpLeft:Kj,perpLogo:Wj,perpInfo:zj,perpPair:Hj,perpDirectionLong:Qj,perpDirectionShort:Gj,perpRight:Yj,perpValue:Zj,perpPnl:Jj,perpPnlPositive:Xj,perpPnlNegative:eC,perpPnlNeutral:tC,collapsibleContent:nC};function ai(e){return[...e].sort((t,s)=>_t(s.position)-_t(t.position)).map(t=>t.id)}const ql=({protocols:e,denomLogoMap:t,chainName:s,isInitia:o,getClaimableInitByType:a,initPrice:r})=>{const i=e[0]?.manageUrl,c=_.useMemo(()=>{const l=e.flatMap(u=>u.positions);return Um(l)},[e]);return c.size===0?null:n.jsx("div",{className:W.container,children:Array.from(c.entries()).map(([l,u])=>n.jsx(sC,{sectionKey:l,sectionGroup:u,denomLogoMap:t,chainName:s,isInitia:o,manageUrl:i,getClaimableInitByType:a,initPrice:r},l))})},sC=({sectionKey:e,sectionGroup:t,denomLogoMap:s,chainName:o,isInitia:a,manageUrl:r,getClaimableInitByType:i,initPrice:c})=>{const{positions:l,totalValue:u}=t,m=Bm(e,{isInitia:a,chainName:o}),d=e==="staking",h=o?.toLowerCase()===Di,f=d&&!h,g=e==="perp",p=_.useMemo(()=>g?[]:Qm(l),[l,g]),y=_.useMemo(()=>{if(!g)return[];const b=new Map;return l.filter(v=>v.type==="perp-position").map(v=>{const I=`${v.pair}-${v.direction}`,S=b.get(I)??0;return b.set(I,S+1),{id:`${I}-${S}`,position:v}})},[l,g]),x=y.map(b=>b.id).sort().join("|"),[w,C]=_.useState(()=>({signature:x,ids:ai(y)}));w.signature!==x&&C({signature:x,ids:ai(y)});const j=_.useMemo(()=>{const b=new Map(y.map(v=>[v.id,v.position]));return w.ids.map(v=>({id:v,position:b.get(v)})).filter(v=>v.position!=null)},[y,w.ids]);return n.jsxs("section",{className:W.section,"aria-label":m,children:[n.jsxs("div",{className:W.sectionHeader,children:[f&&r?n.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:W.sectionTitleLink,onClick:b=>b.stopPropagation(),children:[n.jsx("span",{className:W.sectionLabel,children:m}),n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]}):n.jsx("div",{className:W.sectionTitle,children:n.jsx("span",{className:W.sectionLabel,children:m})}),n.jsx("span",{className:W.sectionValue,children:se(u)})]}),g?n.jsx("div",{className:W.tokenList,children:j.map(({id:b,position:v})=>n.jsx(aC,{position:v},b))}):n.jsx("div",{className:P(W.tokenList,{[W.stakingTokenList]:f}),children:p.map(b=>n.jsx(rC,{group:b,showTypeBreakdown:f,denomLogoMap:s,getClaimableInitByType:i,initPrice:c},b.denom))})]})};function oC(e){return e==null||!Number.isFinite(e)||e===0?W.perpPnlNeutral:e>0?W.perpPnlPositive:W.perpPnlNegative}const aC=({position:e})=>{const t=e.direction==="long",s=Sc(e),o=Fa(e),a=_t(e),r=Pm(e),i=Rm(s,o),c=i?`${br(s)} ${i}`:br(s),l=t?"Long":"Short",u=Dm(e.leverage),m=u?`${u}X ${l}`:l,d=r?"—":se(a);return n.jsxs("div",{className:W.perpRow,children:[n.jsxs("div",{className:W.perpLeft,children:[e.imageUrl&&n.jsx(oe,{src:e.imageUrl,width:20,height:20,className:W.perpLogo}),n.jsxs("div",{className:W.perpInfo,children:[n.jsx("span",{className:W.perpPair,children:e.pair}),n.jsx("span",{className:t?W.perpDirectionLong:W.perpDirectionShort,children:m})]})]}),n.jsxs("div",{className:W.perpRight,children:[n.jsx("span",{className:W.perpValue,children:d}),n.jsx("span",{className:P(W.perpPnl,oC(s)),children:c})]})]})},rC=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:u}=e,m=s.get(r),[d,h]=_.useState(!1),f=_.useMemo(()=>{if(!t)return null;const g=zm(u);return g.size>0?g:null},[u,t]);return f?n.jsxs(ne.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:W.tokenTrigger,children:[n.jsxs("div",{className:W.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:P(W.tokenChevron,{[W.expanded]:d}),"aria-hidden":"true"}),n.jsxs("div",{className:W.tokenInfoLabel,children:[m?.assetLogo&&n.jsx(oe,{src:m.assetLogo,width:20,height:20,className:W.tokenLogo}),n.jsx("span",{className:W.tokenSymbol,children:i})]})]}),n.jsx("span",{className:W.triggerValue,children:se(l)})]})}),n.jsx(ne.Collapsible.Content,{className:W.collapsibleContent,children:n.jsx(iC,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:W.tokenRow,children:n.jsxs("div",{className:W.tokenMain,children:[n.jsxs("div",{className:W.tokenInfo,children:[m?.assetLogo&&n.jsx(oe,{src:m.assetLogo,width:20,height:20,className:W.tokenLogo}),n.jsx("span",{className:W.tokenSymbol,children:i})]}),n.jsxs("div",{className:W.tokenValues,children:[n.jsx("span",{className:W.tokenAmount,children:N.formatNumber(c,{dp:6})}),n.jsx("span",{className:W.tokenValue,children:se(l)})]})]})})},iC=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([l,u])=>{const m=u.reduce((h,f)=>f.type==="fungible-position"||f.type==="perp-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),d=u.reduce((h,f)=>h+_t(f),0);return{type:l,typeAmount:m,typeValue:d}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:u}of r){const m=o(s,u);l+=Number(m)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:W.typeBreakdown,children:[r.map(({type:l,typeAmount:u,typeValue:m})=>n.jsxs("div",{className:W.typeRow,children:[n.jsx("span",{className:W.typeLabel,children:Wm(l)}),n.jsxs("div",{className:W.typeValues,children:[n.jsxs("span",{className:W.typeAmount,children:[N.formatNumber(u,{dp:6})," ",t]}),n.jsx("span",{className:W.typeValue,children:se(m)})]})]},l)),c&&n.jsxs("div",{className:W.typeRow,children:[n.jsx("span",{className:W.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:W.typeValues,children:[n.jsxs("span",{className:W.typeAmount,children:[N.formatNumber(i,{dp:6})," ",pt]}),n.jsx("span",{className:W.typeValue,children:se(i*(a??0))})]})]})]})},cC="_container_jelqd_1",lC="_trigger_jelqd_6",uC="_expandIcon_jelqd_22",dC="_chainInfo_jelqd_27",mC="_logo_jelqd_33",hC="_chainNameContainer_jelqd_37",fC="_chainName_jelqd_37",pC="_externalIcon_jelqd_53",gC="_chainNameLink_jelqd_58",_C="_valueColumn_jelqd_75",yC="_value_jelqd_75",xC="_expanded_jelqd_92",wC="_collapsibleContent_jelqd_97",bC="_content_jelqd_109",Fe={container:cC,trigger:lC,expandIcon:uC,chainInfo:dC,logo:mC,chainNameContainer:hC,chainName:fC,externalIcon:pC,chainNameLink:gC,valueColumn:_C,value:yC,expanded:xC,collapsibleContent:wC,content:bC},vC=Q.atom([]),jC=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o,protocols:a}=e,r=_e(),i=os(),{denomLogos:c,symbolLogos:l}=_.useMemo(()=>Da(i,r),[i,r]),u=_.useMemo(()=>{const m=new Map;for(const d of a)for(const h of d.positions){if(h.type==="fungible-position"||h.type==="perp-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),y=`${t}:${f}`,x=c.get(y)??l.get(p);x&&m.set(f,{assetLogo:x,chainLogo:o??""})}return m},[a,c,l,t,o]);return n.jsx(ql,{protocols:a,denomLogoMap:u,chainName:s})},CC=({chainGroup:e})=>{const{chainName:t,prettyName:s,chainLogo:o,protocols:a}=e,r=a[0]?.manageUrl,[i,c]=Q.useAtom(vC),l=_.useMemo(()=>a.reduce((g,p)=>g+p.positions.reduce((y,x)=>y+_t(x),0),0),[a]),u=["civitia","yominet"],m=i.includes(t),d=t?.toLowerCase(),h=u.includes(d),f=()=>{c(g=>m?g.filter(p=>p!==t):[...new Set([...g,t])])};return n.jsx("div",{className:Fe.container,children:n.jsxs(ne.Collapsible.Root,{open:m,onOpenChange:f,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Fe.trigger,children:[n.jsxs("div",{className:Fe.chainInfo,children:[o&&n.jsx(oe,{src:o,width:32,height:32,className:Fe.logo,logo:!0}),r?n.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:Fe.chainNameLink,onClick:g=>g.stopPropagation(),children:[n.jsx("span",{className:Fe.chainName,children:s}),n.jsx(M.IconExternalLink,{size:14,className:Fe.externalIcon})]}):n.jsx("div",{className:Fe.chainNameContainer,children:n.jsx("span",{className:Fe.chainName,children:s})})]}),n.jsxs("div",{className:Fe.valueColumn,children:[!h&&n.jsx("span",{className:Fe.value,children:se(l)}),n.jsx(M.IconChevronDown,{size:16,className:P(Fe.expandIcon,{[Fe.expanded]:m})})]})]})}),n.jsx(ne.Collapsible.Content,{className:Fe.collapsibleContent,children:n.jsx("div",{className:Fe.content,children:n.jsx(jC,{chainGroup:e})})})]})})},NC="_container_176wa_1",kC="_section_176wa_6",IC="_sectionHeader_176wa_14",AC="_sectionLabel_176wa_26",SC="_sectionTitleLink_176wa_44",TC="_sectionValue_176wa_58",EC="_tokenList_176wa_65",$C="_tokenTrigger_176wa_77",MC="_tokenChevron_176wa_93",LC="_expanded_176wa_104",qC="_tokenInfo_176wa_108",PC="_tokenInfoLabel_176wa_114",RC="_tokenLogo_176wa_120",DC="_pairedLogos_176wa_124",FC="_coinLogo_176wa_129",BC="_tokenSymbol_176wa_147",UC="_triggerValue_176wa_153",OC="_clammBreakdownContent_176wa_160",VC="_clammPositionRow_176wa_168",KC="_statusDot_176wa_177",WC="_inRange_176wa_184",zC="_outRange_176wa_188",HC="_unknown_176wa_192",QC="_clammStatusValue_176wa_196",GC="_breakdownContent_176wa_206",YC="_breakdownRow_176wa_214",ZC="_breakdownLabel_176wa_222",JC="_breakdownValues_176wa_228",XC="_breakdownAmount_176wa_234",eN="_breakdownValue_176wa_228",tN="_collapsibleContent_176wa_255",F={container:NC,section:kC,sectionHeader:IC,sectionLabel:AC,sectionTitleLink:SC,sectionValue:TC,tokenList:EC,tokenTrigger:$C,tokenChevron:MC,expanded:LC,tokenInfo:qC,tokenInfoLabel:PC,tokenLogo:RC,pairedLogos:DC,coinLogo:FC,tokenSymbol:BC,triggerValue:UC,clammBreakdownContent:OC,clammPositionRow:VC,statusDot:KC,inRange:WC,outRange:zC,unknown:HC,clammStatusValue:QC,breakdownContent:GC,breakdownRow:YC,breakdownLabel:ZC,breakdownValues:JC,breakdownAmount:XC,breakdownValue:eN,collapsibleContent:tN},nN=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:F.container,children:n.jsxs("section",{className:F.section,"aria-label":"Liquidity positions",children:[n.jsxs("div",{className:F.sectionHeader,children:[n.jsxs("a",{href:va,target:"_blank",rel:"noopener noreferrer",className:F.sectionTitleLink,onClick:a=>a.stopPropagation(),children:[n.jsx("span",{className:F.sectionLabel,children:"Liquidity"}),n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]}),n.jsx("span",{className:F.sectionValue,children:se(s)})]}),n.jsx("div",{className:F.tokenList,children:o.map(a=>n.jsx(lN,{row:a,denomLogoMap:t},a.denom))})]})})},sN={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function oN(e){return e===void 0?F.unknown:e?F.inRange:F.outRange}function aN(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function ri(e,t){return e===void 0?"-":`${N.formatNumber(e,{dp:6})} ${t}`}function Pl({isOpen:e,symbol:t,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return n.jsxs("button",{className:F.tokenTrigger,children:[n.jsxs("div",{className:F.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:P(F.tokenChevron,{[F.expanded]:e}),"aria-hidden":"true"}),n.jsxs("div",{className:F.tokenInfoLabel,children:[r?n.jsx("div",{className:F.pairedLogos,children:s.map((i,c)=>n.jsx(oe,{src:i,width:20,height:20,className:F.coinLogo,logo:!0},c))}):o&&n.jsx(oe,{src:o,width:20,height:20,className:F.tokenLogo}),n.jsx("span",{className:F.tokenSymbol,children:t})]})]}),a]})}const rN=({position:e})=>{const t=oN(e.inRange),s=aN(e.inRange);return n.jsxs("div",{className:F.clammPositionRow,children:[n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Position ID"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownAmount,children:e.positionId})})]}),n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Deposit"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownValue,children:se(e.value)})})]}),n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Status"}),n.jsxs("div",{className:F.clammStatusValue,children:[n.jsx("span",{className:P(F.statusDot,t)}),n.jsx("span",{children:s})]})]}),e.isFullRange?n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Range Bounds"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownAmount,children:"Full range"})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Min"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownAmount,children:ri(e.minPrice,e.pricePairLabel)})})]}),n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Max"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownAmount,children:ri(e.maxPrice,e.pricePairLabel)})})]})]}),n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownValue,children:se(e.rewardValue)})})]})]})},iN=({row:e,denomLogoMap:t})=>{const[s,o]=_.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:u}=e,m=t.get(a);if(!u)return null;const d=l||m?.assetLogo;return n.jsxs(ne.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:Pl({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:d,rightContent:n.jsx("span",{className:F.triggerValue,children:se(i)})})}),n.jsx(ne.Collapsible.Content,{className:F.collapsibleContent,children:n.jsxs("div",{className:F.clammBreakdownContent,children:[n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:F.breakdownValues,children:n.jsx("span",{className:F.breakdownValue,children:se(u.totalRewardValue)})})]}),u.positions.map(h=>n.jsx(rN,{position:h},h.tokenAddress))]})})]})},cN=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[u,m]=_.useState(!1),d=t.get(s),h=i||d?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),p=l&&Number(l.total)>0;return n.jsxs(ne.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:Pl({isOpen:u,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:F.triggerValue,children:se(a)})})}),n.jsx(ne.Collapsible.Content,{className:F.collapsibleContent,children:n.jsxs("div",{className:F.breakdownContent,children:[g.map(([y,x])=>{const w=x*f;return n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:sN[y]}),n.jsxs("div",{className:F.breakdownValues,children:[n.jsxs("span",{className:F.breakdownAmount,children:[N.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:F.breakdownValue,children:se(w)})]})]},y)}),p&&n.jsxs("div",{className:F.breakdownRow,children:[n.jsx("span",{className:F.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:F.breakdownValues,children:[n.jsxs("span",{className:F.breakdownAmount,children:[N.formatNumber(Number(l.total),{dp:6})," ",pt]}),n.jsx("span",{className:F.breakdownValue,children:se(l.totalValue)})]})]})]})})]})},lN=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(iN,{row:e,denomLogoMap:t}):n.jsx(cN,{row:e,denomLogoMap:t}),uN="_container_1fdqm_1",dN="_section_1fdqm_6",mN="_sectionHeader_1fdqm_14",hN="_sectionLabel_1fdqm_26",fN="_sectionTitleLink_1fdqm_44",pN="_sectionValue_1fdqm_58",gN="_tokenList_1fdqm_65",_N="_tokenTrigger_1fdqm_77",yN="_tokenChevron_1fdqm_93",xN="_expanded_1fdqm_104",wN="_tokenInfo_1fdqm_108",bN="_tokenInfoLabel_1fdqm_114",vN="_tokenLogo_1fdqm_120",jN="_tokenName_1fdqm_124",CN="_triggerValue_1fdqm_130",NN="_breakdownContent_1fdqm_137",kN="_breakdownRow_1fdqm_145",IN="_breakdownLabel_1fdqm_153",AN="_breakdownValues_1fdqm_159",SN="_breakdownAmount_1fdqm_165",TN="_breakdownValue_1fdqm_159",EN="_collapsibleContent_1fdqm_179",ge={container:uN,section:dN,sectionHeader:mN,sectionLabel:hN,sectionTitleLink:fN,sectionValue:pN,tokenList:gN,tokenTrigger:_N,tokenChevron:yN,expanded:xN,tokenInfo:wN,tokenInfoLabel:bN,tokenLogo:vN,tokenName:jN,triggerValue:CN,breakdownContent:NN,breakdownRow:kN,breakdownLabel:IN,breakdownValues:AN,breakdownAmount:SN,breakdownValue:TN,collapsibleContent:EN},$N=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:ge.container,children:n.jsxs("section",{className:ge.section,"aria-label":"VIP rewards",children:[n.jsxs("div",{className:ge.sectionHeader,children:[n.jsxs("a",{href:Ku,target:"_blank",rel:"noopener noreferrer",className:ge.sectionTitleLink,onClick:o=>o.stopPropagation(),children:[n.jsx("span",{className:ge.sectionLabel,children:"VIP"}),n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]}),n.jsx("span",{className:ge.sectionValue,children:se(t)})]}),n.jsx("div",{className:ge.tokenList,children:s.map(o=>n.jsx(MN,{row:o},`${o.bridgeId}-${o.version}`))})]})})},MN=({row:e})=>{const{name:t,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=_.useState(!1),u=a+i;return n.jsxs(ne.Collapsible.Root,{open:c,onOpenChange:l,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ge.tokenTrigger,children:[n.jsxs("div",{className:ge.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:P(ge.tokenChevron,{[ge.expanded]:c}),"aria-hidden":"true"}),n.jsxs("div",{className:ge.tokenInfoLabel,children:[s&&n.jsx(oe,{src:s,width:20,height:20,className:ge.tokenLogo,logo:!0}),n.jsx("span",{className:ge.tokenName,children:t})]})]}),n.jsx("span",{className:ge.triggerValue,children:se(u)})]})}),n.jsx(ne.Collapsible.Content,{className:ge.collapsibleContent,children:n.jsxs("div",{className:ge.breakdownContent,children:[o>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Locked"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[N.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:se(a)})]})]}),r>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[N.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:se(i)})]})]})]})})]})},LN="_container_jelqd_1",qN="_trigger_jelqd_6",PN="_expandIcon_jelqd_22",RN="_chainInfo_jelqd_27",DN="_logo_jelqd_33",FN="_chainName_jelqd_37",BN="_externalIcon_jelqd_53",UN="_chainNameLink_jelqd_58",ON="_valueColumn_jelqd_75",VN="_value_jelqd_75",KN="_expanded_jelqd_92",WN="_collapsibleContent_jelqd_97",zN="_content_jelqd_109",Ye={container:LN,trigger:qN,expandIcon:PN,chainInfo:RN,logo:DN,chainName:FN,externalIcon:BN,chainNameLink:UN,valueColumn:ON,value:VN,expanded:KN,collapsibleContent:WN,content:zN},HN=Q.atom(!1),QN=()=>{const{totalValue:e}=Ra(),{totalValue:t}=co(),{totalValue:s}=lo(),o=e+t+s;return n.jsx("span",{className:Ye.value,children:se(o)})},GN=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Ra(),{data:i}=Nc(),{data:c}=kc(),l=_.useMemo(()=>{const d=new Map;for(const h of r){if(h.type==="fungible-position"||h.type==="perp-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),y=`${e}:${f}`,x=s.get(y)??o.get(p);x&&d.set(f,{assetLogo:x,chainLogo:t})}return d},[r,s,o,e,t]),u=_.useMemo(()=>(d,h)=>{const f=N.denomToMetadata(d);if(h==="staking"){const g=i?.get(f);return g?N.fromBaseUnit(g.amount,{decimals:it}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?N.fromBaseUnit(g.amount,{decimals:it}):"0"}return"0"},[i,c]),m=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:va,positions:r}],[r]);return m.length===0?null:n.jsx(ql,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:u,initPrice:a})},YN=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=co(),r=_.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:u}=c,m=u.toUpperCase(),d=`${e}:${l}`,h=s.get(d)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx(nN,{data:a,denomLogoMap:r})},ZN=()=>{const e=lo();return e.rows.length===0?null:n.jsx($N,{data:e})},JN=({chainGroup:e})=>{const{chainId:t,prettyName:s,chainLogo:o}=e,[a,r]=Q.useAtom(HN),i=_e(),c=os(),{denomLogos:l,symbolLogos:u}=_.useMemo(()=>Da(c,i),[c,i]),m=ce(),{data:d}=Dt(m),h=_.useMemo(()=>d?.find(g=>g.id===Je)?.price??0,[d]);return n.jsx("div",{className:Ye.container,children:n.jsxs(ne.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(ne.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Ye.trigger,children:[n.jsxs("div",{className:Ye.chainInfo,children:[o&&n.jsx(oe,{src:o,width:32,height:32,className:Ye.logo,logo:!0}),n.jsxs("a",{href:va,target:"_blank",rel:"noopener noreferrer",className:Ye.chainNameLink,onClick:f=>f.stopPropagation(),children:[n.jsx("span",{className:Ye.chainName,children:s}),n.jsx(M.IconExternalLink,{size:14,className:Ye.externalIcon})]})]}),n.jsxs("div",{className:Ye.valueColumn,children:[n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:16,width:60,length:1}),children:n.jsx(QN,{})}),n.jsx(M.IconChevronDown,{size:16,className:P(Ye.expandIcon,{[Ye.expanded]:a})})]})]})}),n.jsx(ne.Collapsible.Content,{className:Ye.collapsibleContent,children:n.jsxs("div",{className:Ye.content,children:[n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:36,length:2}),children:n.jsx(GN,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u,initPrice:h})}),n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:36,length:2}),children:n.jsx(YN,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:36,length:1}),children:n.jsx(ZN,{})})]})})]})})},XN="_totalValue_1v2ca_1",ek={totalValue:XN},tk=({filteredChainGroups:e})=>{const{totalValue:t}=Ra(),{totalValue:s}=co(),{totalValue:o}=lo(),a=t+s+o,r=_.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,u)=>u.isInitia?l:l+u.totalValue,0)+(i?a:0)},[e,a]);return n.jsx("span",{className:ek.totalValue,children:se(r)})},nk="_container_1eubu_1",sk="_header_1eubu_7",ok="_title_1eubu_13",ak="_list_1eubu_19",rk="_skeletonWrapper_1eubu_24",Gn={container:nk,header:sk,title:ok,list:ak,skeletonWrapper:rk},ik=_.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ms(),r=ce(),i=_.useMemo(()=>{const l=[];for(const m of o){if(!Array.isArray(m.positions))continue;const d=s.get(m.chainName.toLowerCase()),h=m.chainName.toLowerCase(),f=(d?.prettyName??m.chainName).toLowerCase();if(t&&d?.chainId!==t||!m.positions.some(w=>w.positions.some(C=>C.type!=="fungible-position")))continue;if(e){const w=e.toLowerCase();if(!h.includes(w)&&!f.includes(w))continue}const p=m.positions.filter(w=>e&&!w.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(w.positions)&&w.positions.length>0),y=r.chainId===d?.chainId,x=p.reduce((w,C)=>w+C.positions.reduce((j,b)=>j+_t(b),0),0);l.push({chainId:d?.chainId??"",chainName:m.chainName,prettyName:d?.prettyName??m.chainName,chainLogo:d?.logoUrl??"",protocols:p,isInitia:y,totalValue:x})}const u=["civitia","yominet"];return L.sortWith([L.descend(m=>m.isInitia??!1),L.ascend(m=>u.includes(m.chainName.toLowerCase())),L.descend(m=>m.totalValue??0),L.ascend(m=>m.prettyName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Gn.container,children:[n.jsxs("div",{className:Gn.header,children:[n.jsx("span",{className:Gn.title,children:"Positions"}),c&&n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:16,width:60,length:1}),children:n.jsx(tk,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Gn.list,children:i.map(l=>l.isInitia?n.jsx(xe,{suspenseFallback:n.jsx("div",{className:Gn.skeletonWrapper,children:n.jsx(Nt,{height:56,length:1})}),children:n.jsx(JN,{chainGroup:l})},l.chainName):n.jsx(CC,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(Nt,{height:56,length:3}):n.jsx(je,{children:"No positions"})]})}),ck="_content_1w1ad_1",lk={content:ck},uk=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=ae(),o=ce(),a=ch(),{totalValue:r}=lo(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=_.useMemo(()=>{const u=new Map;let m=0;for(const h of a)u.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(u.set(o.chainId,(u.get(o.chainId)??0)+r),m+=r),{chainIds:L.sortWith([L.descend(h=>h===s),L.descend(h=>h===o.chainId),L.descend(h=>u.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:u,totalBalance:m}},[a,s,o,r]);return n.jsx(vo,{value:e,onChange:t,chainIds:i,renderExtra:u=>se(u?c.get(u)??0:l)})},dk=()=>{const[e,t]=Q.useAtom(Al),[s,o]=Q.useAtom(Sl),a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Da(r,a),[r,a]),l=_a(),u=_.useMemo(()=>Tc(a,l),[a,l]),m=ih();return n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(xe,{suspenseFallback:n.jsx(gn,{height:44,width:132}),children:n.jsx(uk,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("section",{className:lk.content,"aria-label":"Assets and positions",children:[n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:48,length:5}),children:n.jsx(fj,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Nt,{height:56,length:3}),children:n.jsx(ik,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},mk="_totalValue_5pf7e_1",hk="_totalLabel_5pf7e_7",fk="_totalAmount_5pf7e_13",pk="_loading_5pf7e_18",gk="_skeletonWrapper_5pf7e_23",_k="_nav_5pf7e_28",yk="_item_5pf7e_34",xk="_tabs_5pf7e_59",wk="_tab_5pf7e_59",ze={totalValue:mk,totalLabel:hk,totalAmount:fk,loading:pk,skeletonWrapper:gk,nav:_k,item:yk,tabs:xk,tab:wk},bk=()=>{const{totalValue:e,isLoading:t}=Ta();return n.jsx("div",{className:P(ze.totalAmount,{[ze.loading]:t}),children:se(e)})},vk=()=>{const e=lh(),t=uh(),s=Ac(),o=e+s+t;return n.jsx("div",{className:ze.totalAmount,children:se(o)})},jk=()=>{Yc(),ah();const e=Ba(),t=Me(),s=to(),o=_.useRef(null);return n.jsx(El.Provider,{value:o,children:n.jsxs(xt,{ref:o,children:[n.jsxs("div",{className:ze.totalValue,children:[n.jsx("div",{className:ze.totalLabel,children:"Total value"}),n.jsx(xe,{suspenseFallback:n.jsx("div",{className:ze.skeletonWrapper,children:n.jsx(gn,{height:48,width:120})}),children:e?n.jsx(bk,{}):n.jsx(vk,{})})]}),n.jsxs("nav",{className:ze.nav,"aria-label":"Quick actions",children:[n.jsxs(hn,{to:"/send",className:ze.item,children:[n.jsx(M.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(hn,{to:"/bridge",className:ze.item,children:[n.jsx(M.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(hn,{to:"/receive",className:ze.item,children:[n.jsx(M.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Ot.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Ot.Tabs.List,{className:ze.tabs,children:[n.jsx(Ot.Tabs.Tab,{className:ze.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Ot.Tabs.Tab,{className:ze.tab,value:"/nfts",children:"NFTs"}),n.jsx(Ot.Tabs.Tab,{className:ze.tab,value:"/activity",children:"Activity"})]}),n.jsx(Ot.Tabs.Panel,{value:"/",children:e?n.jsx(dj,{}):n.jsx(dk,{})}),n.jsx(Ot.Tabs.Panel,{value:"/nfts",children:n.jsx(jv,{})}),n.jsx(Ot.Tabs.Panel,{value:"/activity",children:n.jsx(av,{})})]})]})})},Ck="_root_th990_1",Nk="_collectionName_th990_9",kk="_nftName_th990_13",Ik="_chainInfo_th990_17",Ak="_attributes_th990_21",Sk="_title_th990_24",Tk="_count_th990_29",Ek="_item_th990_33",$k="_type_th990_39",Mk="_value_th990_45",cn={root:Ck,collectionName:Nk,nftName:kk,chainInfo:Ik,attributes:Ak,title:Sk,count:Tk,item:Ek,type:$k,value:Mk},Lk=()=>{const e=Me(),t=et(),{attributes:s}=t;return n.jsxs(Et,{title:"NFT details",children:[n.jsx(Ja,{normalizedNft:t,chainIconSize:14,classNames:cn}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:cn.attributes,children:[n.jsxs("header",{className:cn.title,children:["Traits ",n.jsxs("span",{className:cn.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:cn.item,children:[n.jsx("div",{className:cn.type,children:o}),n.jsx("div",{className:cn.value,children:a})]},o))})]})]})};function qk({balances:e,gasPrices:t,gas:s}){return t.map(({denom:o,amount:a})=>{const r=q(a).times(s).toFixed(0,q.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>q(a).gte(o))}function Pk({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(u=>u.denom===e)?.amount??"0",i=qk({balances:t,gasPrices:s,gas:a}),c=i.find(u=>u.denom===o);if(i.length===0)return r;if(e===o&&c){const u=q(r).minus(c.amount);return q.max(u,0).toString()}const l=i.find(u=>u.denom!==e)||i[0];if(!c&&e===l.denom){const u=q(r).minus(l.amount);return q.max(u,0).toString()}return q(r).toString()}const Rk=({chain:e,onSelect:t})=>{const s=_u(e);return n.jsx(xs,{assets:s,onSelect:t})},Dk=({afterSelect:e})=>{const{watch:t,setValue:s}=$e.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=_.useState(r),l=yt(i),u=_e(),m=d=>{if(o===i&&a===d){e();return}s("chainId",i),s("denom",d),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(pn.Stack,{children:n.jsx(pn,{chains:u,value:i,onSelect:c})}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(Rk,{chain:l,onSelect:m})},i)]})},Fk="_fields_brpej_1",Bk="_divider_brpej_11",ii={fields:Fk,divider:Bk},Uk=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Ok=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=tt(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=$e.useFormContext(),{errors:u}=l,{chainId:m,denom:d,recipient:h,quantity:f,memo:g}=r(),p=yt(m),y=as(p),x=Ia(p),w=Aa(p),C=ji(d,p),{data:j}=Dt(p),{decimals:b}=C,v=y.find(O=>O.denom===d)?.amount??"0",I=j?.find(({id:O})=>O===d)?.price,{data:S=0,isLoading:A}=E.useQuery({queryKey:Uk.gas({chainId:m,denom:d,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:lr.MsgSend.fromPartial({fromAddress:t,toAddress:N.InitiaAddress(h).bech32,amount:[{denom:d,amount:"1"}]})}];return s({messages:O,chainId:m})},enabled:N.InitiaAddress.validate(h),staleTime:V.INFINITY}),$=Math.ceil(S*Qt),k=Pk({denom:d,balances:y,gasPrices:x,lastFeeDenom:w,gas:$}),T=q(v).isZero(),B=x.some(({denom:O})=>O===d)&&A,D=T||B,{mutate:J,isPending:K}=E.useMutation({mutationFn:({chainId:O,denom:X,quantity:G,recipient:te,memo:ue})=>{const ye=N.toBaseUnit(G,{decimals:b}),me=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:lr.MsgSend.fromPartial({fromAddress:t,toAddress:N.InitiaAddress(te).bech32,amount:[{denom:X,amount:ye}]})}];return o({messages:me,memo:ue,chainId:O,gas:S,gasAdjustment:Qt,gasPrices:x,spendCoins:[{denom:X,amount:ye}],internal:"/"})}}),z=_.useMemo(()=>{if(!f)return"Enter amount";if(u.quantity)return u.quantity.message;if(!h)return"Enter recipient address";if(u.recipient)return u.recipient.message;if(u.memo)return u.memo.message},[f,h,u.quantity,u.recipient,u.memo]);return n.jsx(Et,{title:"Send",children:n.jsxs("form",{onSubmit:c(O=>J(O)),"aria-label":"Send token form",children:[n.jsxs("div",{className:ii.fields,children:[n.jsx(na,{selectButton:n.jsx(qn,{title:"Select chain and asset",content:O=>n.jsx(Dk,{afterSelect:O}),children:n.jsx(sl,{asset:C,chain:p})}),quantityInput:n.jsx(ns,{balance:v,decimals:b}),balanceButton:n.jsx(Zc,{onClick:()=>i("quantity",N.fromBaseUnit(k,{decimals:b}),{shouldValidate:!0}),disabled:D,children:N.formatAmount(v??"0",{decimals:b})}),value:f?Oa(q(f).times(I??0),I):"$0"}),n.jsx("div",{className:ii.divider}),n.jsx(za,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(be.Stack,{children:!g&&n.jsx(be,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:(A?"Estimating gas...":!1)||K,disabled:!!z,children:z??"Confirm"})})]})})},Vk=()=>{const e=et(),t=wn(),s=Gt(t),{chain:o=t}=e,a=L.head(s);if(!e.denom&&!a)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const r=e.denom??a?.denom,i=$e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return n.jsx($e.FormProvider,{...i,children:n.jsx(Ok,{})})};async function da(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await H.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function Kk(e,t){const s=new kt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await H.create({prefixUrl:t}).post("minievm/evm/v1/call",{json:{sender:N.InitiaAddress("0x1").bech32,contract_addr:N.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function Wk(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await H.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function zk({collection_addr:e},{restUrl:t}){const s=await Kk(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${N.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await da(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${N.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Hk(e,t){const{data:s}=await H.create({prefixUrl:t}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function Qk({object_addr:e,collection_addr:t},{restUrl:s}){const o=await Hk(t,s);return o.startsWith("ibc/")?N.InitiaAddress.equals(N.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await da(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await da(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function Gk(e,t){const s=de.toBase64(un.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await H.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function Yk(e,t){const{collection:s}=await H.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function Zk(e,t){const s=de.toBase64(un.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await H.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function ci(e){const t=/^(.*channel-\d+)\/(.*)$/,s=e.match(t);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function Jk({collection_addr:e},t,s){const o=N.InitiaAddress(e).bech32,a=await Gk(o,t.restUrl),r=t.metadata?.ibc_channels?.find(({chain_id:p,version:y})=>p===s.chain_id&&y.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=de.toBase64(un.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:u}=await H.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=u??o,d=await Zk(c,t.restUrl),h=await Yk(o,t.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:d};if(u&&h!==i.replace("wasm.","")){const[p,y]=ci(u);return{class_id:o,class_trace:{path:p,base_class_id:y},outgoing_proxy:d}}const[f,g]=ci(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:d}}const Xk={minimove:Qk,minievm:zk,miniwasm:Jk};async function eI({nft:e,srcChain:t,intermediaryChain:s}){const o=t.metadata?.is_l1?"minimove":t.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await Xk[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await Wk([e.token_id],a.class_id,t.restUrl)})}const tI="_root_1tyvn_1",nI="_collectionName_1tyvn_10",sI="_nftName_1tyvn_15",oI="_chainInfo_1tyvn_19",aI="_fields_1tyvn_24",rI="_chain_1tyvn_19",Go={root:tI,collectionName:nI,nftName:sI,chainInfo:oI,fields:aI,chain:rI},iI=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),cI=()=>{const e=_e(),t=et(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=ae(),r=bn(),i=ce(),{address:c,initiaAddress:l,requestTxSync:u}=tt(),{watch:m,setValue:d,handleSubmit:h,formState:f}=$e.useFormContext(),{errors:g}=f,p=m(),{recipient:y,dstChainId:x}=p,w=yt(x),C=E.useQuery({queryKey:iI.simulation({collection_addr:o,nft:t,sender:l,recipient:y,srcChain:s,dstChain:w,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const k=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:N.InitiaAddress(y).bech32,to_chain_id:w.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==w.chainId&&await eI({nft:t,srcChain:s,intermediaryChain:i})),{msgs:T}=await H.create({prefixUrl:a}).post("nft",{json:k}).json();return T.map(R=>r.fromAmino(R))},enabled:N.InitiaAddress.validate(y)}),{data:j,isLoading:b,error:v}=C,I=E.useQueryClient(),{mutate:S,isPending:A}=E.useMutation({mutationFn:async()=>{if(!j)throw new Error("Route not found");await u({messages:j,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{I.invalidateQueries({queryKey:Xa.nfts._def})}}),$=_.useMemo(()=>{if(!y)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(v)return"Route not found"},[y,g.recipient,v]);return n.jsxs("form",{onSubmit:h(()=>S()),children:[n.jsx(Ja,{normalizedNft:t,thumbnailSize:80,classNames:Go}),n.jsxs("div",{className:Go.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination app"}),n.jsxs(qn,{title:"Destination app",content:k=>n.jsx(nl,{onSelect:({chainId:T})=>{d("dstChainId",T),k()},list:e,getImage:T=>T.logoUrl,getName:T=>T.name,getKey:T=>T.chainId}),className:P("input",Go.chain),children:[n.jsx(oe,{src:w.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:w.name})]})]}),n.jsx(za,{myAddress:c,ref:gs()})]}),n.jsx(Ae,{children:n.jsx(fe.White,{loading:(b?"Finding route...":!1)||A,disabled:!!$,children:$??"Confirm"})})]})},lI=()=>{const{chain:e}=et(),t=$e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(Et,{title:"Send NFT",children:n.jsx($e.FormProvider,{...t,children:n.jsx(cI,{})})})},ma=()=>{const e=Me(),t=to(),s=Zt(),{closeDrawer:o}=Ft(),{closeModal:a}=ao();_.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=Rn();if(_.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(Hr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(Hr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(jk,{});case"/send":return n.jsx(Vk,{},s);case"/receive":return n.jsx(Lw,{});case"/nft":return n.jsx(Lk,{});case"/nft/send":return n.jsx(lI,{},s);case"/bridge":return n.jsx(Ry,{},s);case"/bridge/preview":return n.jsx(y1,{});case"/bridge/history":return n.jsx(Lx,{});case"/op/withdrawals":return n.jsx(W1,{});case"/tx":return n.jsx(Kc,{});case"/autosign/enable":return n.jsx(gg,{});case"/settings":return n.jsx(cb,{});case"/settings/autosign":return n.jsx(Yw,{});case"/deposit":return n.jsx(ww,{});case"/deposit/completed":return n.jsx(ua,{type:"deposit"});case"/withdraw":return n.jsx(bw,{});case"/withdraw/completed":return n.jsx(ua,{type:"withdraw"})}},uI="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",dI=()=>n.jsxs(n.Fragment,{children:[n.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),n.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),n.jsx("link",{rel:"stylesheet",href:uI}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),mI=()=>(dh(),Fu(),ud(),_e(),rh(),Ac(),os(),null),hI=({children:e,...t})=>(_.useEffect(()=>{qm()},[]),Qe.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(dI,{}),n.jsx(yi.Provider,{value:{..._i,...t},children:n.jsx(Ti,{children:n.jsx(Bp,{children:n.jsx(ne.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(Fp,{children:n.jsxs(Ip,{children:[e,n.jsx(mh,{}),n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(mI,{})}),n.jsx(of,{children:n.jsx(ma,{})}),n.jsx(ef,{children:n.jsx(ma,{})})]})})})})})})]}):null),fI=({bridge:e})=>n.jsx(Ti,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(Dc.Provider,{value:!!e,children:n.jsx(xe,{children:n.jsx(ma,{})})})})}),pI={1:"https://ethereum-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com"};function gI(e){const{id:t="testWallet",name:s="Test Wallet",rpcUrls:o,debug:a=!1,sendTransactionOverrides:r}=e;if("mnemonic"in e&&e.mnemonic==="")throw new Error("mnemonic must not be empty");if(!("mnemonic"in e&&e.mnemonic)&&!("privateKey"in e&&e.privateKey))throw new Error("Either mnemonic or privateKey is required");let i;try{i=e.mnemonic?ur.mnemonicToAccount(e.mnemonic):ur.privateKeyToAccount(e.privateKey)}catch(p){throw new Error(`[${t}] Failed to create account from ${e.mnemonic?"mnemonic":"privateKey"}`,{cause:p})}let c=1;const l={};function u(p,...y){l[p]?.forEach(x=>{x(...y)})}const m={...pI,...o},d={1:eu.mainnet};function h(p){if(m[p])return m[p];const y=d[p];if(y)return y.rpcUrls.default.http[0];throw new Error(`[${t}] No RPC configured for chain ${p}`)}async function f(p,y){const x=h(c),w=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p,params:y??[]})});if(!w.ok)throw new Error(`[${t}] RPC "${p}" failed: HTTP ${w.status} ${w.statusText} (${x})`);let C;try{C=await w.json()}catch(j){throw new Error(`[${t}] RPC "${p}" returned non-JSON response (${x})`,{cause:j})}if(C.error)throw new ft.EIP1193ProviderRpcError(C.error.code,C.error.message);return C.result}const g={request:async({method:p,params:y})=>{switch(a&&console.log(`[${t}] ${p}`,y),p){case"eth_requestAccounts":case"eth_accounts":return[i.address];case"eth_chainId":return`0x${c.toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:x}]=y,w=Number(x);if(!d[w]&&!m[w])throw new ft.EIP1193ProviderRpcError(4902,"Unrecognized chain ID");return!d[w]&&m[w]&&(d[w]={id:w,name:`Chain ${w}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[m[w]]}}}),c=w,u("chainChanged",x),null}case"wallet_addEthereumChain":{const[x]=y,w=x.rpcUrls?.[0];if(!w)throw new Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);const C=Number(x.chainId);return d[C]?a&&console.log(`[${t}] Chain ${C} already registered, skipping`):d[C]={id:C,name:x.chainName??`Chain ${C}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[w]}}},null}case"personal_sign":{const[x]=y;return i.signMessage({message:{raw:x}})}case"eth_signTypedData":case"eth_signTypedData_v4":{const[,x]=y;return i.signMessage({message:{raw:x}})}case"wallet_getPermissions":case"wallet_requestPermissions":return[{parentCapability:"eth_accounts"}];case"eth_sendTransaction":{const[x]=y,w=d[c];if(!w)throw new Error(`[${t}] No chain registered for chain ${c}. Call wallet_switchEthereumChain first.`);return ft.createWalletClient({account:i,chain:w,transport:ft.http(h(c))}).sendTransaction({to:x.to,value:x.value?BigInt(x.value):void 0,data:x.data,chainId:c,...r})}default:return f(p,y)}},on:(p,y)=>{(l[p]??=new Set).add(y)},removeListener:(p,y)=>{l[p]?.delete(y)},removeAllListeners:()=>{for(const p of Object.keys(l))delete l[p]}};return tu.injected({target:()=>({id:t,name:s,provider:g})})}const li={"noble-1":"noble",celestia:"celestia","neutron-1":"neutron","osmosis-1":"osmo"};function _I(e){const{mnemonic:t,name:s="Test Cosmos Wallet",image:o,chains:a,debug:r=!1}=e;if(!t)throw new Error("mnemonic is required");const i=new Map;function c(d){return a?.[d]?a[d].prefix:li[d]?li[d]:d.replace(/-\d+$/,"")}function l(d){const h=c(d),f=i.get(h);if(f)return f;r&&console.log(`[${s}] Creating wallet for chain ${d} (prefix: ${h})`);const g=$n.Secp256k1HdWallet.fromMnemonic(t,{prefix:h});return g.catch(p=>{i.delete(h),console.error(`[${s}] Failed to create wallet for prefix "${h}":`,p)}),i.set(h,g),g}function u(d){return{async getAccounts(){return(await l(d)).getAccounts()},async signAmino(h,f){return(await l(d)).signAmino(h,f)}}}const m={getOfflineSigner(d){return u(d)},getOfflineSignerOnlyAmino(d){return u(d)}};return{name:s,image:o,getProvider:()=>m}}exports.DEFAULT_GAS_ADJUSTMENT=Qt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=gi;exports.InterwovenKit=fI;exports.InterwovenKitProvider=hI;exports.MAINNET=_i;exports.MoveError=rc;exports.PRIVY_APP_ID=ga;exports.TESTNET=su;exports.createTestCosmosWallet=_I;exports.createTestWalletConnector=gI;exports.initiaPrivyWallet=au;exports.initiaPrivyWalletConnector=ou;exports.initiaPrivyWalletOptions=Jn;exports.injectStyles=Th;exports.useAddress=Zt;exports.useHexAddress=Fn;exports.useInitiaAddress=ie;exports.useInterwovenKit=tt;exports.usePortfolio=Ta;exports.useUsernameQuery=_c;